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

Member Function Documentation

◆ clearItemSelection()

void FWSelectionManager::clearItemSelection ( )

Definition at line 72 of file FWSelectionManager.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, mps_monitormerge::items, and m_itemSelection.

Referenced by clearSelection().

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 }
std::set< FWEventItem * > m_itemSelection

◆ clearModelSelectionLeaveItem()

void FWSelectionManager::clearModelSelectionLeaveItem ( )

Definition at line 83 of file FWSelectionManager.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, m_changeManager, and m_selection.

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 }
FWModelChangeManager * m_changeManager
std::set< FWModelId > m_selection

◆ clearSelection()

void FWSelectionManager::clearSelection ( )

◆ finishedAllSelections()

void FWSelectionManager::finishedAllSelections ( )
private

Definition at line 91 of file FWSelectionManager.cc.

References m_newSelection, m_selection, m_wasChanged, and selectionChanged_.

Referenced by FWSelectionManager().

91  {
92  if (m_wasChanged) {
94  selectionChanged_(*this);
95  m_wasChanged = false;
96  }
97 }
std::set< FWModelId > m_newSelection
sigc::signal< void(const FWSelectionManager &)> selectionChanged_
std::set< FWModelId > m_selection

◆ itemChanged()

void FWSelectionManager::itemChanged ( const FWEventItem iItem)
private

Definition at line 129 of file FWSelectionManager.cc.

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

Referenced by select().

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 }
unsigned int id() const
Definition: FWEventItem.cc:433
assert(be >=bs)
std::set< FWModelId > m_newSelection
std::vector< std::pair< int, sigc::connection > > m_itemConnectionCount
std::set< FWModelId > m_selection

◆ operator=()

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

◆ select()

void FWSelectionManager::select ( const FWModelId iId)
private

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

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(std::bind(&FWSelectionManager::itemChanged, this, std::placeholders::_1));
113  }
114  }
115 }
FWItemChangeSignal preItemChanged_
Definition: FWEventItem.h:186
void itemChanged(const FWEventItem *)
unsigned int id() const
Definition: FWEventItem.cc:433
std::set< FWModelId > m_newSelection
const FWEventItem * item() const
Definition: FWModelId.h:39
std::vector< std::pair< int, sigc::connection > > m_itemConnectionCount

◆ selected()

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

◆ selectedItems()

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

Definition at line 170 of file FWSelectionManager.cc.

References m_itemSelection.

Referenced by CmsShowEDI::fillEDIFrame().

170 { return m_itemSelection; }
std::set< FWEventItem * > m_itemSelection

◆ selectItem()

void FWSelectionManager::selectItem ( FWEventItem iItem)
private

Definition at line 157 of file FWSelectionManager.cc.

References itemSelectionChanged_, and m_itemSelection.

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

157  {
158  m_itemSelection.insert(iItem);
159  itemSelectionChanged_(*this);
160 }
sigc::signal< void(const FWSelectionManager &)> itemSelectionChanged_
std::set< FWEventItem * > m_itemSelection

◆ unselect()

void FWSelectionManager::unselect ( const FWModelId iId)
private

Definition at line 117 of file FWSelectionManager.cc.

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

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

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 }
unsigned int id() const
Definition: FWEventItem.cc:433
assert(be >=bs)
std::set< FWModelId > m_newSelection
const FWEventItem * item() const
Definition: FWModelId.h:39
std::vector< std::pair< int, sigc::connection > > m_itemConnectionCount

◆ unselectItem()

void FWSelectionManager::unselectItem ( FWEventItem iItem)
private

Definition at line 161 of file FWSelectionManager.cc.

References itemSelectionChanged_, and m_itemSelection.

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

161  {
162  m_itemSelection.erase(iItem);
163  itemSelectionChanged_(*this);
164 }
sigc::signal< void(const FWSelectionManager &)> itemSelectionChanged_
std::set< FWEventItem * > m_itemSelection

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

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

◆ m_itemSelection

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

Definition at line 74 of file FWSelectionManager.h.

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

◆ m_newSelection

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

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

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

◆ selectionChanged_

sigc::signal<void(const FWSelectionManager&)> FWSelectionManager::selectionChanged_