ATLAS Offline Software
VP1GraphicsItemCollection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // //
7 // Header file for class VP1GraphicsItemCollection //
8 // //
9 // Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10 // //
11 // Initial version: April 2007 //
12 // //
14 
15 #ifndef VP1GRAPHICSITEMCOLLECTION_H
16 #define VP1GRAPHICSITEMCOLLECTION_H
17 
18 //Policy: It is forbidden for systems/channels to install
19 // eventhandlers or to set flags on QGraphicsItems!!!!!
20 //
21 // Each item is marked as either ACTIVE or PASSIVE [+movable]
22 // (internally an ic knows whether it has any active items at all of
23 // course). An IC can be in exactly one of the following modes,
24 // governing how its active items respond (this state is set at
25 // initialisation by the system and is not changeable later - if so,
26 // warn if INACTIVE system has active elements and vice versa?):
27 //
28 // INERT, SINGLEPICKS, SINGLEEVENTS, SELECTIONS (+UNSET)
29 //
30 // It must be set BEFORE a scene is attached for the first time.
31 //
32 // Furthermore, each IC has a temporary ignore state, which makes it
33 // temporarily work (i.e. respond to questions such as "is this item
34 // presently active") just as if it was inert
35 //
36 //
37 // In graphicsview: Any click or event gets passed to the topmost
38 // active item in a non-inert system.
39 //
40 // If there was a previous selection:
41 // If the new item is not in the same IC as the previous selection: clear selection.
42 // Else: If shift was down: Add to selection. Else: Set selection to the new item.
43 //
44 // Future: Special selection tool which lets you draw a path and select anything inside it (needs to know which system it is selecting from)
45 //
46 // Any change of selection or occurrence of picks/events makes the GV ask the appropriate IC to emit a signal.
47 
48 #include <QObject>
49 
50 class VP1GraphicsView;
51 class QGraphicsItem;
52 
53 class VP1GraphicsItemCollection : public QObject {
54 
55  Q_OBJECT
56 
57 public:
58 
59  VP1GraphicsItemCollection( QObject * parent=0 );
61 
63  void setInteractionMode( const INTERACTIONMODE& ); //Can only be called while not attached to a view.
64  //Default is INERT.
66 
67  void addItem( QGraphicsItem*, const bool& active = false, const bool&movable=false );
68  //Beware: All items added will be owned by this class - but if you call removeItem below, you will own them again.
69 
70  //The next methods returns false if the item has not been previously added to the collection:
71  bool setActive(QGraphicsItem*, const bool& active = true);
72  bool setMovable(QGraphicsItem* item, const bool& movable=true);
73  bool removeItem(QGraphicsItem*);//Does not delete item.
74  bool hasItem(QGraphicsItem*) const;
75 
76  void clear(const bool& deleteitems = true);//Removes and possibly deletes all items.
77 
78  //These two can be called from e.g. the systems to avoid updates during intensive work:
79  void detachFromView();//If was not attached, do nothing
80  void reattachToView();//Only does something if it has been previously attached.
81  bool isAttachedToView();
82 
83  //These three gives the same answer irrespective of the temporary ignore state
84  int nItems() const;
85  int nActiveItems() const;
86  int nMovableItems() const;
87  //These two always returns 0 if there is a temporary ignore state:
88  int nPresentlyActiveItems() const;
89  int nPresentlyMovableItems() const;
90 
91  bool itemBelongsAndIsPresentlyActive(QGraphicsItem*) const;
92 
93 signals:
94  void itemPicked(QGraphicsItem*) const;//Emitted for active items when in SINGLEPICK mode.
95  void itemGotEvent(QGraphicsItem*,QEvent*) const;//Emitted for active items when in EVENTS mode.
96  void selectionChanged(QList<QGraphicsItem*>) const;//Emitted for active items when in SELECTIONS mode.
97 
98 private:
101  class Imp;
102  Imp * m_d;
103 private:
104  friend class VP1GraphicsView;
106  void real_detachFromView();
107  void setTemporaryIgnoreInteractions( const bool& );
108  void setTemporaryIgnoreMovable( const bool& );
109  void itemPickedPrivate(QGraphicsItem*) const;
110  void itemGotEventPrivate(QGraphicsItem*,QEvent*) const;
111  void selectionChangedPrivate(QList<QGraphicsItem*>) const;
112 };
113 
114 #endif
VP1GraphicsItemCollection::itemGotEvent
void itemGotEvent(QGraphicsItem *, QEvent *) const
VP1GraphicsItemCollection::isAttachedToView
bool isAttachedToView()
Definition: VP1GraphicsItemCollection.cxx:293
VP1GraphicsItemCollection::m_d
Imp * m_d
Definition: VP1GraphicsItemCollection.h:101
VP1GraphicsItemCollection::setTemporaryIgnoreInteractions
void setTemporaryIgnoreInteractions(const bool &)
Definition: VP1GraphicsItemCollection.cxx:216
VP1GraphicsItemCollection::Imp
Definition: VP1GraphicsItemCollection.cxx:27
VP1GraphicsItemCollection::nMovableItems
int nMovableItems() const
Definition: VP1GraphicsItemCollection.cxx:312
VP1GraphicsItemCollection::setActive
bool setActive(QGraphicsItem *, const bool &active=true)
Definition: VP1GraphicsItemCollection.cxx:161
VP1GraphicsItemCollection::nPresentlyMovableItems
int nPresentlyMovableItems() const
Definition: VP1GraphicsItemCollection.cxx:324
VP1GraphicsItemCollection::nPresentlyActiveItems
int nPresentlyActiveItems() const
Definition: VP1GraphicsItemCollection.cxx:318
VP1GraphicsItemCollection::VP1GraphicsItemCollection
VP1GraphicsItemCollection(const VP1GraphicsItemCollection &)
VP1GraphicsItemCollection::operator=
VP1GraphicsItemCollection & operator=(const VP1GraphicsItemCollection &)
VP1GraphicsItemCollection::INERT
@ INERT
Definition: VP1GraphicsItemCollection.h:62
VP1GraphicsItemCollection::hasItem
bool hasItem(QGraphicsItem *) const
Definition: VP1GraphicsItemCollection.cxx:199
VP1GraphicsItemCollection::setTemporaryIgnoreMovable
void setTemporaryIgnoreMovable(const bool &)
Definition: VP1GraphicsItemCollection.cxx:224
VP1GraphicsItemCollection::selectionChangedPrivate
void selectionChangedPrivate(QList< QGraphicsItem * >) const
Definition: VP1GraphicsItemCollection.cxx:356
VP1GraphicsItemCollection::setMovable
bool setMovable(QGraphicsItem *item, const bool &movable=true)
Definition: VP1GraphicsItemCollection.cxx:140
VP1GraphicsItemCollection::itemBelongsAndIsPresentlyActive
bool itemBelongsAndIsPresentlyActive(QGraphicsItem *) const
Definition: VP1GraphicsItemCollection.cxx:330
VP1GraphicsItemCollection::nActiveItems
int nActiveItems() const
Definition: VP1GraphicsItemCollection.cxx:306
VP1GraphicsItemCollection::EVENTS
@ EVENTS
Definition: VP1GraphicsItemCollection.h:62
VP1GraphicsItemCollection::attachToView
void attachToView(VP1GraphicsView *)
Definition: VP1GraphicsItemCollection.cxx:240
Trk::active
@ active
Definition: Layer.h:48
VP1GraphicsItemCollection::detachFromView
void detachFromView()
Definition: VP1GraphicsItemCollection.cxx:257
VP1GraphicsItemCollection::interactionMode
INTERACTIONMODE interactionMode() const
Definition: VP1GraphicsItemCollection.cxx:88
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1GraphicsItemCollection::clear
void clear(const bool &deleteitems=true)
Definition: VP1GraphicsItemCollection.cxx:175
python.L1.Config.LegacyTopoMergerMap.signals
signals
Definition: LegacyTopoMergerMap.py:13
VP1GraphicsItemCollection::reattachToView
void reattachToView()
Definition: VP1GraphicsItemCollection.cxx:282
VP1GraphicsItemCollection::addItem
void addItem(QGraphicsItem *, const bool &active=false, const bool &movable=false)
Definition: VP1GraphicsItemCollection.cxx:94
VP1GraphicsItemCollection::itemGotEventPrivate
void itemGotEventPrivate(QGraphicsItem *, QEvent *) const
Definition: VP1GraphicsItemCollection.cxx:350
VP1GraphicsItemCollection::removeItem
bool removeItem(QGraphicsItem *)
Definition: VP1GraphicsItemCollection.cxx:115
VP1GraphicsItemCollection::VP1GraphicsItemCollection
VP1GraphicsItemCollection(QObject *parent=0)
Definition: VP1GraphicsItemCollection.cxx:55
item
Definition: ItemListSvc.h:43
VP1GraphicsItemCollection::selectionChanged
void selectionChanged(QList< QGraphicsItem * >) const
VP1GraphicsItemCollection::setInteractionMode
void setInteractionMode(const INTERACTIONMODE &)
Definition: VP1GraphicsItemCollection.cxx:77
VP1GraphicsItemCollection::itemPickedPrivate
void itemPickedPrivate(QGraphicsItem *) const
Definition: VP1GraphicsItemCollection.cxx:344
VP1GraphicsItemCollection::itemPicked
void itemPicked(QGraphicsItem *) const
VP1GraphicsItemCollection::nItems
int nItems() const
Definition: VP1GraphicsItemCollection.cxx:300
VP1GraphicsItemCollection::real_detachFromView
void real_detachFromView()
Definition: VP1GraphicsItemCollection.cxx:267
VP1GraphicsItemCollection::~VP1GraphicsItemCollection
virtual ~VP1GraphicsItemCollection()
Definition: VP1GraphicsItemCollection.cxx:68
VP1GraphicsItemCollection
Definition: VP1GraphicsItemCollection.h:53
VP1GraphicsItemCollection::SINGLEPICKS
@ SINGLEPICKS
Definition: VP1GraphicsItemCollection.h:62
VP1GraphicsView
Definition: VP1GraphicsView.h:22
VP1GraphicsItemCollection::SELECTIONS
@ SELECTIONS
Definition: VP1GraphicsItemCollection.h:62
VP1GraphicsItemCollection::INTERACTIONMODE
INTERACTIONMODE
Definition: VP1GraphicsItemCollection.h:62