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 34 of file FWSelectionManager.h.

Constructor & Destructor Documentation

FWSelectionManager::FWSelectionManager ( FWModelChangeManager iCM)

Definition at line 35 of file FWSelectionManager.cc.

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

35  :
36  m_changeManager(iCM),
37  m_wasChanged(false)
38 {
41 }
assert(m_qm.get())
FWModelChangeManager * m_changeManager
sigc::signal< void > changeSignalsAreDone_
FWSelectionManager::FWSelectionManager ( const FWSelectionManager )
private

Member Function Documentation

void FWSelectionManager::clearItemSelection ( )

Definition at line 81 of file FWSelectionManager.cc.

References mps_monitormerge::items, and m_itemSelection.

Referenced by clearSelection().

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

Definition at line 96 of file FWSelectionManager.cc.

References m_changeManager, and m_selection.

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

Definition at line 68 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().

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

Definition at line 108 of file FWSelectionManager.cc.

References m_newSelection, m_selection, m_wasChanged, and selectionChanged_.

Referenced by FWSelectionManager().

109 {
110  if(m_wasChanged) {
112  selectionChanged_(*this);
113  m_wasChanged = false;
114  }
115 }
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 152 of file FWSelectionManager.cc.

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

Referenced by select().

153 {
154  assert(0!=iItem);
155  assert(m_itemConnectionCount.size() > iItem->id());
156  //if this appears in any of our models we need to remove them
157  FWModelId low(iItem,0);
158  FWModelId high(iItem,0x7FFFFFFF); //largest signed 32 bit number
159  bool someoneChanged = false;
160  {
161  std::set<FWModelId>::iterator itL=m_newSelection.lower_bound(low),
162  itH=m_newSelection.upper_bound(high);
163  if(itL!=itH) {
164  m_wasChanged =true;
165  someoneChanged=true;
166  m_newSelection.erase(itL,itH);
167  }
168  }
169  {
170  std::set<FWModelId>::iterator itL=m_selection.lower_bound(low),
171  itH=m_selection.upper_bound(high);
172  if(itL!=itH) {
173  m_wasChanged =true;
174  someoneChanged = true;
175  //Don't need to erase here since will happen in 'finishedAllSelection'
176  }
177  }
178  assert(someoneChanged);
179  m_itemConnectionCount[iItem->id()].second.disconnect();
180  m_itemConnectionCount[iItem->id()].first = 0;
181 }
assert(m_qm.get())
std::set< FWModelId > m_newSelection
unsigned int id() const
Definition: FWEventItem.cc:496
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 118 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().

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

Definition at line 205 of file FWSelectionManager.cc.

References m_itemSelection.

Referenced by CmsShowEDI::fillEDIFrame().

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

Definition at line 184 of file FWSelectionManager.cc.

References itemSelectionChanged_, and m_itemSelection.

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

185 {
186  m_itemSelection.insert(iItem);
187  itemSelectionChanged_(*this);
188 }
std::set< FWEventItem * > m_itemSelection
sigc::signal< void, const FWSelectionManager & > itemSelectionChanged_
void FWSelectionManager::unselect ( const FWModelId iId)
private

Definition at line 138 of file FWSelectionManager.cc.

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

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

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

Definition at line 190 of file FWSelectionManager.cc.

References itemSelectionChanged_, and m_itemSelection.

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

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

Friends And Related Function Documentation

friend class FWEventItem
friend

Definition at line 37 of file FWSelectionManager.h.

Member Data Documentation

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

Definition at line 54 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 74 of file FWSelectionManager.h.

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

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

Definition at line 75 of file FWSelectionManager.h.

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

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

Definition at line 72 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 73 of file FWSelectionManager.h.

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

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