CMS 3D CMS Logo

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 &)=delete
 
void itemChanged (const FWEventItem *)
 
const FWSelectionManageroperator= (const FWSelectionManager &)=delete
 
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() [1/2]

FWSelectionManager::FWSelectionManager ( FWModelChangeManager iCM)

◆ FWSelectionManager() [2/2]

FWSelectionManager::FWSelectionManager ( const FWSelectionManager )
privatedelete

Member Function Documentation

◆ clearItemSelection()

void FWSelectionManager::clearItemSelection ( )

Definition at line 72 of file FWSelectionManager.cc.

72  {
73  //may need this in the future
74  //FWChangeSentry sentry(*m_changeManager);
75  std::set<FWEventItem*> items;
76  items.swap(m_itemSelection);
77  for (std::set<FWEventItem*>::iterator it = items.begin(), itEnd = items.end(); it != itEnd; ++it) {
78  //NOTE: this will cause
79  (*it)->unselectItem();
80  }
81 }

References mps_monitormerge::items, and m_itemSelection.

Referenced by clearSelection().

◆ clearModelSelectionLeaveItem()

void FWSelectionManager::clearModelSelectionLeaveItem ( )

Definition at line 83 of file FWSelectionManager.cc.

83  {
85  for (std::set<FWModelId>::iterator it = m_selection.begin(), itEnd = m_selection.end(); it != itEnd; ++it) {
86  //NOTE: this will cause
87  it->unselect();
88  }
89 }

References m_changeManager, and m_selection.

◆ clearSelection()

void FWSelectionManager::clearSelection ( )

Definition at line 63 of file FWSelectionManager.cc.

63  {
65  for (std::set<FWModelId>::iterator it = m_selection.begin(), itEnd = m_selection.end(); it != itEnd; ++it) {
66  //NOTE: this will cause
67  it->unselect();
68  }
70 }

References clearItemSelection(), m_changeManager, and m_selection.

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

◆ finishedAllSelections()

void FWSelectionManager::finishedAllSelections ( )
private

Definition at line 91 of file FWSelectionManager.cc.

91  {
92  if (m_wasChanged) {
94  selectionChanged_(*this);
95  m_wasChanged = false;
96  }
97 }

References m_newSelection, m_selection, m_wasChanged, and selectionChanged_.

Referenced by FWSelectionManager().

◆ itemChanged()

void FWSelectionManager::itemChanged ( const FWEventItem iItem)
private

Definition at line 129 of file FWSelectionManager.cc.

129  {
130  assert(nullptr != iItem);
131  assert(m_itemConnectionCount.size() > iItem->id());
132  //if this appears in any of our models we need to remove them
133  FWModelId low(iItem, 0);
134  FWModelId high(iItem, 0x7FFFFFFF); //largest signed 32 bit number
135  bool someoneChanged = false;
136  {
137  std::set<FWModelId>::iterator itL = m_newSelection.lower_bound(low), itH = m_newSelection.upper_bound(high);
138  if (itL != itH) {
139  m_wasChanged = true;
140  someoneChanged = true;
141  m_newSelection.erase(itL, itH);
142  }
143  }
144  {
145  std::set<FWModelId>::iterator itL = m_selection.lower_bound(low), itH = m_selection.upper_bound(high);
146  if (itL != itH) {
147  m_wasChanged = true;
148  someoneChanged = true;
149  //Don't need to erase here since will happen in 'finishedAllSelection'
150  }
151  }
152  assert(someoneChanged);
153  m_itemConnectionCount[iItem->id()].second.disconnect();
154  m_itemConnectionCount[iItem->id()].first = 0;
155 }

References cms::cuda::assert(), LaserClient_cfi::high, FWEventItem::id(), LaserClient_cfi::low, m_itemConnectionCount, m_newSelection, m_selection, and m_wasChanged.

Referenced by select().

◆ operator=()

const FWSelectionManager& FWSelectionManager::operator= ( const FWSelectionManager )
privatedelete

◆ select()

void FWSelectionManager::select ( const FWModelId iId)
private

Definition at line 99 of file FWSelectionManager.cc.

99  {
100  bool changed = m_newSelection.insert(iId).second;
101  m_wasChanged |= changed;
102  if (changed) {
103  //if this is new, we need to connect to the 'item' just incase it changes
104  if (m_itemConnectionCount.size() <= iId.item()->id()) {
105  m_itemConnectionCount.resize(iId.item()->id() + 1);
106  }
107  if (1 == ++(m_itemConnectionCount[iId.item()->id()].first)) {
108  //want to know early about item change so we can send the 'selectionChanged' message
109  // as part of the itemChange message from the ChangeManager
110  // This way if more than one Item has changed, we still only send one 'selectionChanged' message
111  m_itemConnectionCount[iId.item()->id()].second =
112  iId.item()->preItemChanged_.connect(boost::bind(&FWSelectionManager::itemChanged, this, _1));
113  }
114  }
115 }

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

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

◆ selected()

const std::set< FWModelId > & FWSelectionManager::selected ( ) const

◆ selectedItems()

const std::set< FWEventItem * > & FWSelectionManager::selectedItems ( ) const

Definition at line 170 of file FWSelectionManager.cc.

170 { return m_itemSelection; }

References m_itemSelection.

Referenced by CmsShowEDI::fillEDIFrame().

◆ selectItem()

void FWSelectionManager::selectItem ( FWEventItem iItem)
private

Definition at line 157 of file FWSelectionManager.cc.

157  {
158  m_itemSelection.insert(iItem);
159  itemSelectionChanged_(*this);
160 }

References itemSelectionChanged_, and m_itemSelection.

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

◆ unselect()

void FWSelectionManager::unselect ( const FWModelId iId)
private

Definition at line 117 of file FWSelectionManager.cc.

117  {
118  bool changed = (0 != m_newSelection.erase(iId));
119  m_wasChanged |= changed;
120  if (changed) {
121  assert(m_itemConnectionCount.size() > iId.item()->id());
122  //was this the last model selected for this item?
123  if (0 == --(m_itemConnectionCount[iId.item()->id()].first)) {
124  m_itemConnectionCount[iId.item()->id()].second.disconnect();
125  }
126  }
127 }

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

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

◆ unselectItem()

void FWSelectionManager::unselectItem ( FWEventItem iItem)
private

Definition at line 161 of file FWSelectionManager.cc.

161  {
162  m_itemSelection.erase(iItem);
163  itemSelectionChanged_(*this);
164 }

References itemSelectionChanged_, and m_itemSelection.

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

Friends And Related Function Documentation

◆ FWEventItem

friend class FWEventItem
friend

Definition at line 36 of file FWSelectionManager.h.

Member Data Documentation

◆ itemSelectionChanged_

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

Definition at line 54 of file FWSelectionManager.h.

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

◆ m_changeManager

FWModelChangeManager* FWSelectionManager::m_changeManager
private

◆ m_itemConnectionCount

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().

◆ m_itemSelection

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

Definition at line 75 of file FWSelectionManager.h.

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

◆ m_newSelection

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

Definition at line 72 of file FWSelectionManager.h.

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

◆ m_selection

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

◆ m_wasChanged

bool FWSelectionManager::m_wasChanged
private

Definition at line 73 of file FWSelectionManager.h.

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

◆ selectionChanged_

sigc::signal<void, const FWSelectionManager&> FWSelectionManager::selectionChanged_
FWSelectionManager::finishedAllSelections
void finishedAllSelections()
Definition: FWSelectionManager.cc:91
FWEventItem::preItemChanged_
FWItemChangeSignal preItemChanged_
Definition: FWEventItem.h:186
FWSelectionManager::m_changeManager
FWModelChangeManager * m_changeManager
Definition: FWSelectionManager.h:70
FWModelId
Definition: FWModelId.h:28
cms::cuda::assert
assert(be >=bs)
FWEventItem::id
unsigned int id() const
Definition: FWEventItem.cc:433
FWModelId::item
const FWEventItem * item() const
Definition: FWModelId.h:39
FWModelChangeManager::changeSignalsAreDone_
sigc::signal< void > changeSignalsAreDone_
Definition: FWModelChangeManager.h:50
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
FWSelectionManager::itemChanged
void itemChanged(const FWEventItem *)
Definition: FWSelectionManager.cc:129
FWSelectionManager::itemSelectionChanged_
sigc::signal< void, const FWSelectionManager & > itemSelectionChanged_
Definition: FWSelectionManager.h:54
FWSelectionManager::selectionChanged_
sigc::signal< void, const FWSelectionManager & > selectionChanged_
Definition: FWSelectionManager.h:53
FWChangeSentry
Definition: FWModelChangeManager.h:68
FWSelectionManager::m_wasChanged
bool m_wasChanged
Definition: FWSelectionManager.h:73
FWSelectionManager::clearItemSelection
void clearItemSelection()
Definition: FWSelectionManager.cc:72
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
FWSelectionManager::m_itemConnectionCount
std::vector< std::pair< int, sigc::connection > > m_itemConnectionCount
Definition: FWSelectionManager.h:74
FWSelectionManager::m_itemSelection
std::set< FWEventItem * > m_itemSelection
Definition: FWSelectionManager.h:75
FWSelectionManager::m_newSelection
std::set< FWModelId > m_newSelection
Definition: FWSelectionManager.h:72
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
FWSelectionManager::m_selection
std::set< FWModelId > m_selection
Definition: FWSelectionManager.h:71