Tulip  5.0.0
Large graphs analysis and drawing
CaptionGraphicsSubItems.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef CAPTIONGRAPHICSSUBITEMS_H
22 #define CAPTIONGRAPHICSSUBITEMS_H
23 
24 #include <QGraphicsPixmapItem>
25 #include <QObject>
26 
27 class QGradient;
28 
29 namespace tlp {
30 
31 class ConfigurationIconItem : public QObject, public QGraphicsPixmapItem {
32 
33  Q_OBJECT
34 
35 public :
36 
37  ConfigurationIconItem() {
38 
39  }
40 
41 signals :
42 
43  void configurationIconPressed();
44 
45 protected :
46 
47  void mousePressEvent( QGraphicsSceneMouseEvent *) {
48  emit configurationIconPressed();
49  }
50 };
51 
52 class SelectionArrowItem : public QObject, public QGraphicsPathItem {
53 
54  Q_OBJECT
55 
56 public :
57 
58  SelectionArrowItem(float initRangePos,const QPoint &initPos);
59 
60  bool sceneEvent ( QEvent * event );
61 
62 signals :
63 
64  void circleMoved();
65 
66 protected :
67 
68  int yPos;
69  QPoint initPos;
70 };
71 
72 class SelectionTextItem : public QGraphicsTextItem {
73 
74 public :
75 
76  SelectionTextItem();
77 
78 protected :
79 
80  bool sceneEvent ( QEvent * event ) {
81  return ((SelectionArrowItem*)parentItem())->sceneEvent(event);
82  }
83 
84 };
85 
86 class MovableRectItem : public QObject, public QGraphicsRectItem {
87 
88  Q_OBJECT
89 
90 public :
91 
92  MovableRectItem(const QRectF &rect,const QRectF &size,SelectionArrowItem *topCircle, SelectionArrowItem *bottomCircle);
93 
94  void setInternalRect(const QRectF &rect);
95 
96 signals :
97 
98  // begin and end in 0,1 range
99  void moved(float begin, float end);
100 
101 protected :
102 
103  bool sceneEvent ( QEvent * event );
104 
105  QRectF _currentRect;
106  QPoint _initPos;
107  SelectionArrowItem *_topCircle;
108  SelectionArrowItem *_bottomCircle;
109 };
110 
111 class MovablePathItem : public QObject, public QGraphicsPathItem {
112 
113  Q_OBJECT
114 
115 public :
116 
117  MovablePathItem(const QRectF &rect, QGraphicsPathItem *topPathItem, QGraphicsPathItem *bottomPathItem,SelectionArrowItem *topCircle, SelectionArrowItem *bottomCircle);
118 
119  void setDataToPath(const std::vector< std::pair< double,float > > &metricToSizeFilteredList, double minMetric, double maxMetric);
120 
121  void setRect(const QRectF &rect);
122 
123 signals :
124 
125  // begin and end in 0,1 range
126  void moved(float begin, float end);
127 
128 protected :
129 
130  void updatePath();
131 
132  bool sceneEvent ( QEvent * event );
133 
134  std::vector<std::pair <double, float> > _metricToSizeFilteredList;
135  double _minMetric;
136  double _maxMetric;
137 
138  QRectF _currentRect;
139  QGraphicsPathItem *_topPathItem;
140  QGraphicsPathItem *_bottomPathItem;
141  SelectionArrowItem *_topCircle;
142  SelectionArrowItem *_bottomCircle;
143 };
144 
145 class CaptionGraphicsBackgroundItem : public QObject, public QGraphicsRectItem {
146 
147  Q_OBJECT
148 
149 public :
150 
151  CaptionGraphicsBackgroundItem(const QRect &rect);
152 
153  void generateColorCaption(const QGradient &activeGradient, const QGradient &hideGradient, const std::string &propertyName, double minValue, double maxValue);
154 
155  void generateSizeCaption(const std::vector< std::pair< double,float > > &metricToSizeFilteredList, const std::string &propertyName, double minValue, double maxValue);
156 
157 public slots :
158 
159  void updateCaption();
160  // begin and end in 0,1 range
161  void updateCaption(float begin, float end);
162  void configurationIconPressedSlot();
163 
164  void activateInteractions();
165  void removeInteractions();
166 
167 signals :
168 
169  void filterChanged(float begin, float end);
170  void configurationIconPressed();
171 
172  void interactionsActivated();
173  void interactionsRemoved();
174 
175 protected :
176 
177  void activateInteractions(bool);
178 
179  bool sceneEvent ( QEvent * event );
180  void updateSelectionText(float begin, float end);
181 
182  bool _interactionsActivated;
183  float _beginBackup;
184  float _endBackup;
185  QPoint _captionContentPos;
186 
187  double _minValue;
188  double _maxValue;
189 
190  // Global Items
191  QGraphicsTextItem *_minTextItem;
192  QGraphicsTextItem *_maxTextItem;
193  QGraphicsTextItem *_min2TextItem;
194  QGraphicsTextItem *_max2TextItem;
195  QGraphicsLineItem *_min2LineItem;
196  QGraphicsLineItem *_max2LineItem;
197  QGraphicsRectItem *_captionRectBorder;
198  SelectionArrowItem *_rangeSelector1Item;
199  SelectionArrowItem *_rangeSelector2Item;
200  SelectionTextItem *_rangeSelector1TextItem;
201  SelectionTextItem *_rangeSelector2TextItem;
202 
203  // Color caption Items
204  QGraphicsRectItem *_topCaptionRectItem;
205  MovableRectItem *_middleCaptionRectItem;
206  QGraphicsRectItem *_bottomCaptionRectItem;
207 
208  // Size caption Items
209  //MovableRectItem *_selectionSizeRectItem;
210  MovablePathItem *_sizeCaptionPathItem;
211  QGraphicsPathItem *_topSizeCaptionPathItem;
212  QGraphicsPathItem *_bottomSizeCaptionPathItem;
213 
214 
215 };
216 
217 }
218 
219 #endif // CAPTIONGRAPHICSSUB_H
220 ///@endcond