graph_analysis
FilterItem.hpp
Go to the documentation of this file.
1 #ifndef FILTERITEM_HPP
2 #define FILTERITEM_HPP
3 
4 #include <string>
5 #include <QPen>
6 #include <QObject>
7 #include <QGraphicsItem>
8 #include <QGraphicsItemGroup>
9 
10 namespace graph_analysis {
11 namespace gui {
12 
13 namespace items {
14  class Label;
15 } // end namespace items
16 
17 class FilterManager;
18 
26 class FilterItem : public QGraphicsItemGroup
27 {
28  friend class FilterManager;
29 
30 public:
32  typedef unsigned int filter_size_t;
34  typedef unsigned int filter_index_t;
35 
37  static const filter_size_t sHeight;
39  static const qreal sDisplacementWeight;
41  static const qreal sDisplacementThreshold;
43  FilterItem(FilterManager *manager, filter_index_t index, const std::string& filter = std::string());
46 
48  QRectF boundingRect() const;
50  QPainterPath shape() const;
52  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget*);
53 
55  void setIndex(filter_index_t index) { mIndex = index; }
57  filter_index_t getIndex(void) { return mIndex; }
58 
60  void updatePos(void);
61 
63  QString getLabel(void) const;
65  void setLabel(QString label);
67  void syncToolTips(void);
69  bool isActivated() const { return mIsActivated; }
70 
71  QString getRegexp() const { return getLabel(); }
72 
73 protected:
75  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
77  void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
79  void mousePressEvent(QGraphicsSceneMouseEvent* event);
81  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
82 
84  void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
86  void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
88  QVariant itemChange(GraphicsItemChange change, const QVariant &value);
89 
90  void setActivation(bool activation) { mIsActivated = activation; }
91 
92 private:
94  FilterManager* mpFilterManager;
96  filter_index_t mIndex;
98  items::Label* mLabel;
100  QPen mPen;
102  QPen mPenDefault;
104  bool mIsActivated;
105 };
106 
107 } // end namespace gui
108 } // end namespace graph_analysis
109 #endif // FILTERITEM_HPP
bool isActivated() const
check if filter is activated
Definition: FilterItem.hpp:69
widget to manage all graphical custom regexp filter items in a common scene under behavioral restrict...
Definition: FilterManager.hpp:21
QString getRegexp() const
Definition: FilterItem.hpp:71
void setActivation(bool activation)
Definition: FilterItem.hpp:90
static const qreal sDisplacementThreshold
constant displacement threshold (relative distance up to which overlapping items are away from each o...
Definition: FilterItem.hpp:41
static const filter_size_t sHeight
constant height (in points) of a graphical filter item
Definition: FilterItem.hpp:37
graphical node text label and Cluster label implementation
Definition: Label.hpp:27
~FilterItem()
destructor
Definition: FilterItem.hpp:45
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
static const qreal sDisplacementWeight
constant displacement procentage (degree up to which two filter items need to overlap in the scene su...
Definition: FilterItem.hpp:39
void setIndex(filter_index_t index)
setter method for the filter index
Definition: FilterItem.hpp:55
unsigned int filter_size_t
datatype for denoting the height (in points) of a graphical filter item
Definition: FilterItem.hpp:32
graphical custom regexp filter representation class; specific to FilterManager widget in the layers t...
Definition: FilterItem.hpp:26
unsigned int filter_index_t
datatype for the filters index counter
Definition: FilterItem.hpp:34
filter_index_t getIndex(void)
getter method for the filter index
Definition: FilterItem.hpp:57