ATLAS Offline Software
Classes | Public Types | Signals | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
VP1GraphicsItemCollection Class Reference

#include <VP1GraphicsItemCollection.h>

Inheritance diagram for VP1GraphicsItemCollection:
Collaboration diagram for VP1GraphicsItemCollection:

Classes

class  Imp
 

Public Types

enum  INTERACTIONMODE { INERT, SINGLEPICKS, EVENTS, SELECTIONS }
 

Signals

void itemPicked (QGraphicsItem *) const
 
void itemGotEvent (QGraphicsItem *, QEvent *) const
 
void selectionChanged (QList< QGraphicsItem * >) const
 

Public Member Functions

 VP1GraphicsItemCollection (QObject *parent=0)
 
virtual ~VP1GraphicsItemCollection ()
 
void setInteractionMode (const INTERACTIONMODE &)
 
INTERACTIONMODE interactionMode () const
 
void addItem (QGraphicsItem *, const bool &active=false, const bool &movable=false)
 
bool setActive (QGraphicsItem *, const bool &active=true)
 
bool setMovable (QGraphicsItem *item, const bool &movable=true)
 
bool removeItem (QGraphicsItem *)
 
bool hasItem (QGraphicsItem *) const
 
void clear (const bool &deleteitems=true)
 
void detachFromView ()
 
void reattachToView ()
 
bool isAttachedToView ()
 
int nItems () const
 
int nActiveItems () const
 
int nMovableItems () const
 
int nPresentlyActiveItems () const
 
int nPresentlyMovableItems () const
 
bool itemBelongsAndIsPresentlyActive (QGraphicsItem *) const
 

Private Member Functions

 VP1GraphicsItemCollection (const VP1GraphicsItemCollection &)
 
VP1GraphicsItemCollectionoperator= (const VP1GraphicsItemCollection &)
 
void attachToView (VP1GraphicsView *)
 
void real_detachFromView ()
 
void setTemporaryIgnoreInteractions (const bool &)
 
void setTemporaryIgnoreMovable (const bool &)
 
void itemPickedPrivate (QGraphicsItem *) const
 
void itemGotEventPrivate (QGraphicsItem *, QEvent *) const
 
void selectionChangedPrivate (QList< QGraphicsItem * >) const
 

Private Attributes

Impm_d
 

Friends

class VP1GraphicsView
 

Detailed Description

Definition at line 53 of file VP1GraphicsItemCollection.h.

Member Enumeration Documentation

◆ INTERACTIONMODE

Enumerator
INERT 
SINGLEPICKS 
EVENTS 
SELECTIONS 

Definition at line 62 of file VP1GraphicsItemCollection.h.

Constructor & Destructor Documentation

◆ VP1GraphicsItemCollection() [1/2]

VP1GraphicsItemCollection::VP1GraphicsItemCollection ( QObject *  parent = 0)

Definition at line 55 of file VP1GraphicsItemCollection.cxx.

56  : QObject(parent), m_d(new Imp)
57 {
58  m_d->view=0;
59  m_d->lastview=0;
60  m_d->scene=0;
61  m_d->ignoreall_int=false;
62  m_d->ignoreall_move=false;
64  m_d->nactiveitems=0;
65 }

◆ ~VP1GraphicsItemCollection()

VP1GraphicsItemCollection::~VP1GraphicsItemCollection ( )
virtual

Definition at line 68 of file VP1GraphicsItemCollection.cxx.

69 {
70  if (m_d->view)
72  clear();
73  delete m_d;
74 }

◆ VP1GraphicsItemCollection() [2/2]

VP1GraphicsItemCollection::VP1GraphicsItemCollection ( const VP1GraphicsItemCollection )
private

Member Function Documentation

◆ addItem()

void VP1GraphicsItemCollection::addItem ( QGraphicsItem *  item,
const bool &  active = false,
const bool &  movable = false 
)

Definition at line 94 of file VP1GraphicsItemCollection.cxx.

95 {
96  assert(!m_d->items2active.contains(item)&&"Please do not add the same item twice");
97  assert(!item->flags()&&"Please do not add any flags to your items!!");
98 
99  if (m_d->scene) {
100  //The following must postponed if there is no scene:
101  m_d->scene->addItem(item);
102  item->setFlag(QGraphicsItem::ItemIsMovable,(movable&&(!m_d->ignoreall_move)));
103  }
104  assert(!m_d->items2active.contains(item));
105  m_d->items2active.insert(item,active);
106  if (active)
107  ++m_d->nactiveitems;
108  if (movable)
110 }

◆ attachToView()

void VP1GraphicsItemCollection::attachToView ( VP1GraphicsView view)
private

Definition at line 240 of file VP1GraphicsItemCollection.cxx.

241 {
242  assert(!m_d->scene);
243  assert(!m_d->view);
244  m_d->scene=view->scene();
245  // m_d->lastscene=m_d->scene;
246  m_d->view=view;
247  m_d->lastview=m_d->view;
249  for (it=m_d->items2active.begin();it!=itE;++it) {
250  m_d->scene->addItem(it.key());
251  }
252  //Update this, since we didnt do any updates while there was no scene:
254 }

◆ clear()

void VP1GraphicsItemCollection::clear ( const bool &  deleteitems = true)

Definition at line 175 of file VP1GraphicsItemCollection.cxx.

176 {
177  //Clear selections before deleting items in order to only get one selectionchanged signal.
178  if (m_d->view)
180 
182  if (m_d->scene) {
183  //Remove item from scene and possible also remove event filter.
184  for (it=m_d->items2active.begin();it!=itE;++it)
185  m_d->scene->removeItem(it.key());
186  }
187  if (deleteitems) {
188  //Delete the items:
189  for (it=m_d->items2active.begin();it!=itE;++it) {
190  delete it.key();
191  }
192  }
193  m_d->items2active.clear();
194  m_d->movableitems.clear();
195  m_d->nactiveitems=0;
196 }

◆ detachFromView()

void VP1GraphicsItemCollection::detachFromView ( )

Definition at line 257 of file VP1GraphicsItemCollection.cxx.

258 {
259  if (!m_d->view)
260  return;
261  m_d->view->removeItemCollection(this);
262  //NB. The call to removeItemCollection ends up by calling
263  //VP1GraphicsItemCollection::real_detachFromView().
264 }

◆ hasItem()

bool VP1GraphicsItemCollection::hasItem ( QGraphicsItem *  item) const

Definition at line 199 of file VP1GraphicsItemCollection.cxx.

200 {
201  return m_d->items2active.contains(item);
202 }

◆ interactionMode()

VP1GraphicsItemCollection::INTERACTIONMODE VP1GraphicsItemCollection::interactionMode ( ) const

Definition at line 88 of file VP1GraphicsItemCollection.cxx.

89 {
90  return m_d->interactionmode;
91 }

◆ isAttachedToView()

bool VP1GraphicsItemCollection::isAttachedToView ( )

Definition at line 293 of file VP1GraphicsItemCollection.cxx.

294 {
295  return m_d->view;
296 }

◆ itemBelongsAndIsPresentlyActive()

bool VP1GraphicsItemCollection::itemBelongsAndIsPresentlyActive ( QGraphicsItem *  item) const

Definition at line 330 of file VP1GraphicsItemCollection.cxx.

331 {
332  if (!nPresentlyActiveItems())
333  return false;
334  QHash<QGraphicsItem*,bool>::const_iterator it = m_d->items2active.find(item);
335 
336 
337  if (it==m_d->items2active.constEnd())
338  return false;
339  else
340  return it.value();
341 }

◆ itemGotEvent

void VP1GraphicsItemCollection::itemGotEvent ( QGraphicsItem *  ,
QEvent *   
) const
signal

◆ itemGotEventPrivate()

void VP1GraphicsItemCollection::itemGotEventPrivate ( QGraphicsItem *  item,
QEvent *  event 
) const
private

Definition at line 350 of file VP1GraphicsItemCollection.cxx.

351 {
353 }

◆ itemPicked

void VP1GraphicsItemCollection::itemPicked ( QGraphicsItem *  ) const
signal

◆ itemPickedPrivate()

void VP1GraphicsItemCollection::itemPickedPrivate ( QGraphicsItem *  item) const
private

Definition at line 344 of file VP1GraphicsItemCollection.cxx.

345 {
346  itemPicked(item);
347 }

◆ nActiveItems()

int VP1GraphicsItemCollection::nActiveItems ( ) const

Definition at line 306 of file VP1GraphicsItemCollection.cxx.

307 {
308  return m_d->nactiveitems;
309 }

◆ nItems()

int VP1GraphicsItemCollection::nItems ( ) const

Definition at line 300 of file VP1GraphicsItemCollection.cxx.

301 {
302  return m_d->items2active.count();
303 }

◆ nMovableItems()

int VP1GraphicsItemCollection::nMovableItems ( ) const

Definition at line 312 of file VP1GraphicsItemCollection.cxx.

313 {
314  return m_d->movableitems.count();
315 }

◆ nPresentlyActiveItems()

int VP1GraphicsItemCollection::nPresentlyActiveItems ( ) const

Definition at line 318 of file VP1GraphicsItemCollection.cxx.

319 {
320  return m_d->ignoresInteractions() ? 0 : m_d->nactiveitems;
321 }

◆ nPresentlyMovableItems()

int VP1GraphicsItemCollection::nPresentlyMovableItems ( ) const

Definition at line 324 of file VP1GraphicsItemCollection.cxx.

325 {
326  return m_d->ignoresInteractions() ? 0 : m_d->movableitems.count();
327 }

◆ operator=()

VP1GraphicsItemCollection& VP1GraphicsItemCollection::operator= ( const VP1GraphicsItemCollection )
private

◆ real_detachFromView()

void VP1GraphicsItemCollection::real_detachFromView ( )
private

Definition at line 267 of file VP1GraphicsItemCollection.cxx.

268 {
269  //This method is called after the collection has been removed from the the view.
270  if (!m_d->view)
271  return;
272  //Remove item from scene:
274  for (it=m_d->items2active.begin();it!=itE;++it) {
275  m_d->scene->removeItem(it.key());
276  }
277  m_d->view=0;
278  m_d->scene=0;
279 }

◆ reattachToView()

void VP1GraphicsItemCollection::reattachToView ( )

Definition at line 282 of file VP1GraphicsItemCollection.cxx.

283 {
284  if (m_d->view)
285  return;
286  assert(m_d->lastview);
288  //NB. The call to addItemCollection ends up by calling
289  //VP1GraphicsItemCollection::attachToView().
290 }

◆ removeItem()

bool VP1GraphicsItemCollection::removeItem ( QGraphicsItem *  item)

Definition at line 115 of file VP1GraphicsItemCollection.cxx.

116 {
118  if (it==m_d->items2active.end())
119  return false;
120  if (it.value())
121  --m_d->nactiveitems;
122  if (m_d->scene) {
123  m_d->scene->removeItem(item);
124  }
125  m_d->items2active.erase(it);
126  assert(!m_d->items2active.contains(item));
127 
128  if (!m_d->movableitems.empty()) {
130  if (it2!=m_d->movableitems.end()) {
131  assert(m_d->movableitems.contains(item));
132  m_d->movableitems.erase(it2);
133  }
134  }
135  assert(!m_d->movableitems.contains(item));
136  return true;
137 }

◆ selectionChanged

void VP1GraphicsItemCollection::selectionChanged ( QList< QGraphicsItem * >  ) const
signal

◆ selectionChangedPrivate()

void VP1GraphicsItemCollection::selectionChangedPrivate ( QList< QGraphicsItem * >  items) const
private

Definition at line 356 of file VP1GraphicsItemCollection.cxx.

357 {
359 }

◆ setActive()

bool VP1GraphicsItemCollection::setActive ( QGraphicsItem *  item,
const bool &  active = true 
)

Definition at line 161 of file VP1GraphicsItemCollection.cxx.

162 {
164  if (it==m_d->items2active.end())
165  return false;
166  it.value()=active;
167  if (active)
168  ++m_d->nactiveitems;
169  else
170  --m_d->nactiveitems;
171  return true;
172 }

◆ setInteractionMode()

void VP1GraphicsItemCollection::setInteractionMode ( const INTERACTIONMODE im)

Definition at line 77 of file VP1GraphicsItemCollection.cxx.

78 {
79  assert(!m_d->scene&&"VP1GraphicsItemCollection::setInteractionMode can not be called while a scene is attached.");
80  if (m_d->scene) {
81  std::cout<<"VP1GraphicsItemCollection::setInteractionMode can not be called while a scene is attached."<<std::endl;
82  return;
83  }
85 }

◆ setMovable()

bool VP1GraphicsItemCollection::setMovable ( QGraphicsItem *  item,
const bool &  movable = true 
)

Definition at line 140 of file VP1GraphicsItemCollection.cxx.

141 {
143  if (it==m_d->items2active.end())
144  return false;
145  if (movable==m_d->movableitems.contains(item))//Nothing needs to be done:
146  return true;
147  if (movable) {
148  assert(!m_d->movableitems.contains(item));
150  } else {
151  assert(m_d->movableitems.contains(item));
152  m_d->movableitems.remove(item);
153  assert(!m_d->movableitems.contains(item));
154  }
155  if (!m_d->ignoreall_move)
156  item->setFlag(QGraphicsItem::ItemIsMovable,movable);
157  return true;
158 }

◆ setTemporaryIgnoreInteractions()

void VP1GraphicsItemCollection::setTemporaryIgnoreInteractions ( const bool &  b)
private

Definition at line 216 of file VP1GraphicsItemCollection.cxx.

217 {
218  if (m_d->ignoreall_int==b)
219  return;
221 }

◆ setTemporaryIgnoreMovable()

void VP1GraphicsItemCollection::setTemporaryIgnoreMovable ( const bool &  b)
private

Definition at line 224 of file VP1GraphicsItemCollection.cxx.

225 {
226  if (m_d->ignoreall_move==b)
227  return;
229  if (m_d->scene)
231 }

Friends And Related Function Documentation

◆ VP1GraphicsView

friend class VP1GraphicsView
friend

Definition at line 104 of file VP1GraphicsItemCollection.h.

Member Data Documentation

◆ m_d

Imp* VP1GraphicsItemCollection::m_d
private

Definition at line 102 of file VP1GraphicsItemCollection.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
VP1GraphicsItemCollection::Imp::items2active
QHash< QGraphicsItem *, bool > items2active
Definition: VP1GraphicsItemCollection.cxx:41
VP1GraphicsItemCollection::itemGotEvent
void itemGotEvent(QGraphicsItem *, QEvent *) const
VP1GraphicsView::clearSelections
void clearSelections()
Definition: VP1GraphicsView.cxx:673
VP1GraphicsItemCollection::m_d
Imp * m_d
Definition: VP1GraphicsItemCollection.h:101
VP1GraphicsItemCollection::Imp::lastview
VP1GraphicsView * lastview
Definition: VP1GraphicsItemCollection.cxx:31
VP1GraphicsItemCollection::Imp::interactionmode
VP1GraphicsItemCollection::INTERACTIONMODE interactionmode
Definition: VP1GraphicsItemCollection.cxx:49
skel.it
it
Definition: skel.GENtoEVGEN.py:396
VP1GraphicsItemCollection::nPresentlyActiveItems
int nPresentlyActiveItems() const
Definition: VP1GraphicsItemCollection.cxx:318
python.atlas_oh.im
im
Definition: atlas_oh.py:167
VP1GraphicsItemCollection::Imp::ignoreall_move
bool ignoreall_move
Definition: VP1GraphicsItemCollection.cxx:34
VP1GraphicsItemCollection::INERT
@ INERT
Definition: VP1GraphicsItemCollection.h:62
TruthTest.itE
itE
Definition: TruthTest.py:25
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
VP1GraphicsItemCollection::EVENTS
@ EVENTS
Definition: VP1GraphicsItemCollection.h:62
VP1GraphicsItemCollection::Imp::setEnabledMovableItems
void setEnabledMovableItems(const bool &enabled)
Definition: VP1GraphicsItemCollection.cxx:205
Trk::active
@ active
Definition: Layer.h:48
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
VP1GraphicsItemCollection::Imp::ignoresInteractions
bool ignoresInteractions() const
Definition: VP1GraphicsItemCollection.cxx:234
VP1GraphicsView::addItemCollection
void addItemCollection(VP1GraphicsItemCollection *)
Definition: VP1GraphicsView.cxx:380
VP1GraphicsItemCollection::detachFromView
void detachFromView()
Definition: VP1GraphicsItemCollection.cxx:257
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1GraphicsItemCollection::clear
void clear(const bool &deleteitems=true)
Definition: VP1GraphicsItemCollection.cxx:175
VP1GraphicsItemCollection::Imp::movableitems
QSet< QGraphicsItem * > movableitems
Definition: VP1GraphicsItemCollection.cxx:47
VP1GraphicsView::removeItemCollection
void removeItemCollection(VP1GraphicsItemCollection *)
Definition: VP1GraphicsView.cxx:393
VP1GraphicsItemCollection::Imp::view
VP1GraphicsView * view
Definition: VP1GraphicsItemCollection.cxx:32
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
item
Definition: ItemListSvc.h:43
VP1GraphicsItemCollection::selectionChanged
void selectionChanged(QList< QGraphicsItem * >) const
VP1GraphicsItemCollection::Imp::scene
QGraphicsScene * scene
Definition: VP1GraphicsItemCollection.cxx:30
VP1GraphicsItemCollection::Imp::nactiveitems
int nactiveitems
Definition: VP1GraphicsItemCollection.cxx:35
VP1GraphicsItemCollection::itemPicked
void itemPicked(QGraphicsItem *) const
VP1GraphicsItemCollection::Imp::ItemDataMapItr
QHash< QGraphicsItem *, bool >::iterator ItemDataMapItr
Definition: VP1GraphicsItemCollection.cxx:42
VP1GraphicsItemCollection::Imp::ignoreall_int
bool ignoreall_int
Definition: VP1GraphicsItemCollection.cxx:33
VP1GraphicsItemCollection::SINGLEPICKS
@ SINGLEPICKS
Definition: VP1GraphicsItemCollection.h:62
VP1GraphicsItemCollection::SELECTIONS
@ SELECTIONS
Definition: VP1GraphicsItemCollection.h:62
drawFromPickle.view
view
Definition: drawFromPickle.py:294