CMS 3D CMS Logo

Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends

FWSelectionManager Class Reference

#include <Fireworks/Core/interface/FWSelectionManager.h>

List of all members.

Public Member Functions

void clearItemSelection ()
void clearModelSelectionLeaveItem ()
void clearSelection ()
 FWSelectionManager (FWModelChangeManager *iCM)
const std::set< FWModelId > & selected () const
const std::set< FWEventItem * > & selectedItems () const

Public Attributes

sigc::signal< void, const
FWSelectionManager & > 
itemSelectionChanged_
sigc::signal< void, const
FWSelectionManager & > 
selectionChanged_

Private Member Functions

void finishedAllSelections ()
 FWSelectionManager (const FWSelectionManager &)
void itemChanged (const FWEventItem *)
const FWSelectionManageroperator= (const FWSelectionManager &)
void select (const FWModelId &iId)
void selectItem (FWEventItem *)
void unselect (const FWModelId &iId)
void unselectItem (FWEventItem *)

Private Attributes

FWModelChangeManagerm_changeManager
std::vector< std::pair< int,
sigc::connection > > 
m_itemConnectionCount
std::set< FWEventItem * > m_itemSelection
std::set< FWModelIdm_newSelection
std::set< FWModelIdm_selection
bool m_wasChanged

Friends

class FWEventItem

Detailed Description

Description: Manages the list of selected Model items

Usage: <usage>

Definition at line 35 of file FWSelectionManager.h.


Constructor & Destructor Documentation

FWSelectionManager::FWSelectionManager ( FWModelChangeManager iCM)
FWSelectionManager::FWSelectionManager ( const FWSelectionManager ) [private]

Member Function Documentation

void FWSelectionManager::clearItemSelection ( )

Definition at line 82 of file FWSelectionManager.cc.

References m_itemSelection.

Referenced by clearSelection().

{
   //may need this in the future 
   //FWChangeSentry sentry(*m_changeManager);
   std::set<FWEventItem*> items;
   items.swap(m_itemSelection);
   for(std::set<FWEventItem*>::iterator it = items.begin(), itEnd = items.end();
       it != itEnd;
       ++it) {
      //NOTE: this will cause
      (*it)->unselectItem();
   }
}
void FWSelectionManager::clearModelSelectionLeaveItem ( )

Definition at line 97 of file FWSelectionManager.cc.

References m_changeManager, and m_selection.

{
   FWChangeSentry sentry(*m_changeManager);
   for(std::set<FWModelId>::iterator it = m_selection.begin(), itEnd = m_selection.end();
       it != itEnd;
       ++it) {
      //NOTE: this will cause
      it->unselect();
   }
}
void FWSelectionManager::clearSelection ( )
void FWSelectionManager::finishedAllSelections ( ) [private]
void FWSelectionManager::itemChanged ( const FWEventItem iItem) [private]

Definition at line 153 of file FWSelectionManager.cc.

References FWEventItem::id(), m_itemConnectionCount, m_newSelection, m_selection, and m_wasChanged.

Referenced by select().

{
   assert(0!=iItem);
   assert(m_itemConnectionCount.size() > iItem->id());
   //if this appears in any of our models we need to remove them
   FWModelId low(iItem,0);
   FWModelId high(iItem,0x7FFFFFFF); //largest signed 32 bit number
   bool someoneChanged = false;
   {
      std::set<FWModelId>::iterator itL=m_newSelection.lower_bound(low),
                                    itH=m_newSelection.upper_bound(high);
      if(itL!=itH) {
         m_wasChanged =true;
         someoneChanged=true;
         m_newSelection.erase(itL,itH);
      }
   }
   {
      std::set<FWModelId>::iterator itL=m_selection.lower_bound(low),
                                    itH=m_selection.upper_bound(high);
      if(itL!=itH) {
         m_wasChanged =true;
         someoneChanged = true;
         //Don't need to erase here since will happen in 'finishedAllSelection'
      }
   }
   assert(someoneChanged);
   m_itemConnectionCount[iItem->id()].second.disconnect();
   m_itemConnectionCount[iItem->id()].first = 0;
}
const FWSelectionManager& FWSelectionManager::operator= ( const FWSelectionManager ) [private]
void FWSelectionManager::select ( const FWModelId iId) [private]

Definition at line 119 of file FWSelectionManager.cc.

References FWEventItem::id(), FWModelId::item(), itemChanged(), m_itemConnectionCount, m_newSelection, m_wasChanged, and FWEventItem::preItemChanged_.

Referenced by FWEventItem::select(), and FWEventItem::toggleSelect().

{
   bool changed = m_newSelection.insert(iId).second;
   m_wasChanged |=changed;
   if(changed) {
      //if this is new, we need to connect to the 'item' just incase it changes
      if(m_itemConnectionCount.size()<= iId.item()->id()) {
         m_itemConnectionCount.resize(iId.item()->id()+1);
      }
      if(1 ==++(m_itemConnectionCount[iId.item()->id()].first) ) {
         //want to know early about item change so we can send the 'selectionChanged' message
         // as part of the itemChange message from the ChangeManager
         // This way if more than one Item has changed, we still only send one 'selectionChanged' message
         m_itemConnectionCount[iId.item()->id()].second =
            iId.item()->preItemChanged_.connect(boost::bind(&FWSelectionManager::itemChanged,this,_1));
      }
   }
}
const std::set< FWModelId > & FWSelectionManager::selected ( ) const
const std::set< FWEventItem * > & FWSelectionManager::selectedItems ( ) const

Definition at line 206 of file FWSelectionManager.cc.

References m_itemSelection.

Referenced by CmsShowEDI::fillEDIFrame().

{
   return m_itemSelection;
}
void FWSelectionManager::selectItem ( FWEventItem iItem) [private]
void FWSelectionManager::unselect ( const FWModelId iId) [private]

Definition at line 139 of file FWSelectionManager.cc.

References FWEventItem::id(), FWModelId::item(), m_itemConnectionCount, m_newSelection, and m_wasChanged.

Referenced by FWEventItem::destroy(), FWEventItem::toggleSelect(), and FWEventItem::unselect().

{
   bool changed = (0 != m_newSelection.erase(iId));
   m_wasChanged |=changed;
   if(changed) {
      assert(m_itemConnectionCount.size() > iId.item()->id());
      //was this the last model selected for this item?
      if(0 ==--(m_itemConnectionCount[iId.item()->id()].first)) {
         m_itemConnectionCount[iId.item()->id()].second.disconnect();
      }
   }
}
void FWSelectionManager::unselectItem ( FWEventItem iItem) [private]

Friends And Related Function Documentation

friend class FWEventItem [friend]

Definition at line 38 of file FWSelectionManager.h.


Member Data Documentation

Definition at line 55 of file FWSelectionManager.h.

Referenced by CmsShowEDI::CmsShowEDI(), selectItem(), and unselectItem().

std::vector<std::pair<int,sigc::connection> > FWSelectionManager::m_itemConnectionCount [private]

Definition at line 75 of file FWSelectionManager.h.

Referenced by itemChanged(), select(), and unselect().

Definition at line 76 of file FWSelectionManager.h.

Referenced by clearItemSelection(), selectedItems(), selectItem(), and unselectItem().

Definition at line 73 of file FWSelectionManager.h.

Referenced by finishedAllSelections(), itemChanged(), select(), and unselect().

Definition at line 74 of file FWSelectionManager.h.

Referenced by finishedAllSelections(), itemChanged(), select(), and unselect().