CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends
FWSelectionManager Class Reference

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

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)

Definition at line 36 of file FWSelectionManager.cc.

References FWModelChangeManager::changeSignalsAreDone_, finishedAllSelections(), and m_changeManager.

36  :
37  m_changeManager(iCM),
38  m_wasChanged(false)
39 {
40  assert(0!=m_changeManager);
42 }
FWModelChangeManager * m_changeManager
sigc::signal< void > changeSignalsAreDone_
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().

83 {
84  //may need this in the future
85  //FWChangeSentry sentry(*m_changeManager);
86  std::set<FWEventItem*> items;
87  items.swap(m_itemSelection);
88  for(std::set<FWEventItem*>::iterator it = items.begin(), itEnd = items.end();
89  it != itEnd;
90  ++it) {
91  //NOTE: this will cause
92  (*it)->unselectItem();
93  }
94 }
std::set< FWEventItem * > m_itemSelection
void FWSelectionManager::clearModelSelectionLeaveItem ( )

Definition at line 97 of file FWSelectionManager.cc.

References m_changeManager, and m_selection.

98 {
100  for(std::set<FWModelId>::iterator it = m_selection.begin(), itEnd = m_selection.end();
101  it != itEnd;
102  ++it) {
103  //NOTE: this will cause
104  it->unselect();
105  }
106 }
FWModelChangeManager * m_changeManager
std::set< FWModelId > m_selection
void FWSelectionManager::clearSelection ( )

Definition at line 69 of file FWSelectionManager.cc.

References clearItemSelection(), m_changeManager, and m_selection.

Referenced by FWCollectionSummaryWidget::infoClicked(), FWCollectionSummaryWidget::labelClicked(), FWTableView::modelSelected(), FWCollectionSummaryWidget::modelSelected(), FWEveViewManager::selectionCleared(), FWCollectionSummaryWidget::stateClicked(), and CmsShowMain::~CmsShowMain().

70 {
72  for(std::set<FWModelId>::iterator it = m_selection.begin(), itEnd = m_selection.end();
73  it != itEnd;
74  ++it) {
75  //NOTE: this will cause
76  it->unselect();
77  }
79 }
FWModelChangeManager * m_changeManager
std::set< FWModelId > m_selection
void FWSelectionManager::finishedAllSelections ( )
private

Definition at line 109 of file FWSelectionManager.cc.

References m_newSelection, m_selection, m_wasChanged, and selectionChanged_.

Referenced by FWSelectionManager().

110 {
111  if(m_wasChanged) {
113  selectionChanged_(*this);
114  m_wasChanged = false;
115  }
116 }
std::set< FWModelId > m_newSelection
sigc::signal< void, const FWSelectionManager & > selectionChanged_
std::set< FWModelId > m_selection
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().

154 {
155  assert(0!=iItem);
156  assert(m_itemConnectionCount.size() > iItem->id());
157  //if this appears in any of our models we need to remove them
158  FWModelId low(iItem,0);
159  FWModelId high(iItem,0x7FFFFFFF); //largest signed 32 bit number
160  bool someoneChanged = false;
161  {
162  std::set<FWModelId>::iterator itL=m_newSelection.lower_bound(low),
163  itH=m_newSelection.upper_bound(high);
164  if(itL!=itH) {
165  m_wasChanged =true;
166  someoneChanged=true;
167  m_newSelection.erase(itL,itH);
168  }
169  }
170  {
171  std::set<FWModelId>::iterator itL=m_selection.lower_bound(low),
172  itH=m_selection.upper_bound(high);
173  if(itL!=itH) {
174  m_wasChanged =true;
175  someoneChanged = true;
176  //Don't need to erase here since will happen in 'finishedAllSelection'
177  }
178  }
179  assert(someoneChanged);
180  m_itemConnectionCount[iItem->id()].second.disconnect();
181  m_itemConnectionCount[iItem->id()].first = 0;
182 }
std::set< FWModelId > m_newSelection
unsigned int id() const
Definition: FWEventItem.cc:495
std::vector< std::pair< int, sigc::connection > > m_itemConnectionCount
std::set< FWModelId > m_selection
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 Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Views.LineDecayView.LineDecayContainer::mousePressEvent(), Vispa.Gui.PortConnection.PointToPointConnection::mousePressEvent(), Vispa.Gui.VispaWidget.VispaWidget::mousePressEvent(), Vispa.Views.AbstractView.AbstractView::restoreSelection(), FWEventItem::select(), and FWEventItem::toggleSelect().

120 {
121  bool changed = m_newSelection.insert(iId).second;
122  m_wasChanged |=changed;
123  if(changed) {
124  //if this is new, we need to connect to the 'item' just incase it changes
125  if(m_itemConnectionCount.size()<= iId.item()->id()) {
126  m_itemConnectionCount.resize(iId.item()->id()+1);
127  }
128  if(1 ==++(m_itemConnectionCount[iId.item()->id()].first) ) {
129  //want to know early about item change so we can send the 'selectionChanged' message
130  // as part of the itemChange message from the ChangeManager
131  // This way if more than one Item has changed, we still only send one 'selectionChanged' message
132  m_itemConnectionCount[iId.item()->id()].second =
133  iId.item()->preItemChanged_.connect(boost::bind(&FWSelectionManager::itemChanged,this,_1));
134  }
135  }
136 }
FWItemChangeSignal preItemChanged_
Definition: FWEventItem.h:204
void itemChanged(const FWEventItem *)
std::set< FWModelId > m_newSelection
unsigned int id() const
Definition: FWEventItem.cc:495
std::vector< std::pair< int, sigc::connection > > m_itemConnectionCount
const FWEventItem * item() const
Definition: FWModelId.h:45
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().

207 {
208  return m_itemSelection;
209 }
std::set< FWEventItem * > m_itemSelection
void FWSelectionManager::selectItem ( FWEventItem iItem)
private

Definition at line 185 of file FWSelectionManager.cc.

References itemSelectionChanged_, and m_itemSelection.

Referenced by FWEventItem::selectItem(), and FWEventItem::toggleSelectItem().

186 {
187  m_itemSelection.insert(iItem);
188  itemSelectionChanged_(*this);
189 }
std::set< FWEventItem * > m_itemSelection
sigc::signal< void, const FWSelectionManager & > itemSelectionChanged_
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().

140 {
141  bool changed = (0 != m_newSelection.erase(iId));
142  m_wasChanged |=changed;
143  if(changed) {
144  assert(m_itemConnectionCount.size() > iId.item()->id());
145  //was this the last model selected for this item?
146  if(0 ==--(m_itemConnectionCount[iId.item()->id()].first)) {
147  m_itemConnectionCount[iId.item()->id()].second.disconnect();
148  }
149  }
150 }
std::set< FWModelId > m_newSelection
unsigned int id() const
Definition: FWEventItem.cc:495
std::vector< std::pair< int, sigc::connection > > m_itemConnectionCount
const FWEventItem * item() const
Definition: FWModelId.h:45
void FWSelectionManager::unselectItem ( FWEventItem iItem)
private

Definition at line 191 of file FWSelectionManager.cc.

References itemSelectionChanged_, and m_itemSelection.

Referenced by FWEventItem::toggleSelectItem(), and FWEventItem::unselectItem().

192 {
193  m_itemSelection.erase(iItem);
194  itemSelectionChanged_(*this);
195 }
std::set< FWEventItem * > m_itemSelection
sigc::signal< void, const FWSelectionManager & > itemSelectionChanged_

Friends And Related Function Documentation

friend class FWEventItem
friend

Definition at line 38 of file FWSelectionManager.h.

Member Data Documentation

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

Definition at line 55 of file FWSelectionManager.h.

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

FWModelChangeManager* FWSelectionManager::m_changeManager
private
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().

std::set<FWEventItem*> FWSelectionManager::m_itemSelection
private

Definition at line 76 of file FWSelectionManager.h.

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

std::set<FWModelId> FWSelectionManager::m_newSelection
private

Definition at line 73 of file FWSelectionManager.h.

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

std::set<FWModelId> FWSelectionManager::m_selection
private
bool FWSelectionManager::m_wasChanged
private

Definition at line 74 of file FWSelectionManager.h.

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

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