Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
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 1 and Inria Bordeaux - Sud Ouest
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 
25 #include <QtGui/QGraphicsItemGroup>
26 #include <QtGui/QComboBox>
27 #include <QtOpenGL/QGLFramebufferObject>
28 #include <tulip/View.h>
29 #include <tulip/Color.h>
30 
31 
32 #include <QtGui/QGraphicsSceneMouseEvent>
33 
34 namespace tlp {
35 
36 class ConfigurationIconItem : public QObject, public QGraphicsPixmapItem {
37 
38  Q_OBJECT
39 
40 public :
41 
42  ConfigurationIconItem() {
43 
44  }
45 
46 signals :
47 
48  void configurationIconPressed();
49 
50 protected :
51 
52  void mousePressEvent( QGraphicsSceneMouseEvent *) {
53  emit configurationIconPressed();
54  }
55 };
56 
57 class SelectionArrowItem : public QObject, public QGraphicsPathItem {
58 
59  Q_OBJECT
60 
61 public :
62 
63  SelectionArrowItem(float initRangePos,const QPoint &initPos);
64 
65  bool sceneEvent ( QEvent * event );
66 
67 signals :
68 
69  void circleMoved();
70 
71 protected :
72 
73  int yPos;
74  QPoint initPos;
75 };
76 
77 class SelectionTextItem : public QGraphicsTextItem {
78 
79 public :
80 
81  SelectionTextItem() {
82  QFont f=font();
83  f.setBold(true);
84  setFont(f);
85  }
86 
87 protected :
88 
89  bool sceneEvent ( QEvent * event ) {
90  return ((SelectionArrowItem*)parentItem())->sceneEvent(event);
91  }
92 
93 };
94 
95 class MovableRectItem : public QObject, public QGraphicsRectItem {
96 
97  Q_OBJECT
98 
99 public :
100 
101  MovableRectItem(const QRectF &rect,const QRectF &size,SelectionArrowItem *topCircle, SelectionArrowItem *bottomCircle);
102 
103  void setInternalRect(const QRectF &rect);
104 
105 signals :
106 
107  // begin and end in 0,1 range
108  void moved(float begin, float end);
109 
110 protected :
111 
112  bool sceneEvent ( QEvent * event );
113 
114  QRectF _currentRect;
115  QPoint _initPos;
116  SelectionArrowItem *_topCircle;
117  SelectionArrowItem *_bottomCircle;
118 };
119 
120 class MovablePathItem : public QObject, public QGraphicsPathItem {
121 
122  Q_OBJECT
123 
124 public :
125 
126  MovablePathItem(const QRectF &rect, QGraphicsPathItem *topPathItem, QGraphicsPathItem *bottomPathItem,SelectionArrowItem *topCircle, SelectionArrowItem *bottomCircle);
127 
128  void setDataToPath(const std::vector< std::pair< double,float > > &metricToSizeFilteredList, double minMetric, double maxMetric);
129 
130  void setRect(const QRectF &rect);
131 
132 signals :
133 
134  // begin and end in 0,1 range
135  void moved(float begin, float end);
136 
137 protected :
138 
139  void updatePath();
140 
141  bool sceneEvent ( QEvent * event );
142 
143  std::vector<std::pair <double, float> > _metricToSizeFilteredList;
144  double _minMetric;
145  double _maxMetric;
146 
147  QRectF _currentRect;
148  QGraphicsPathItem *_topPathItem;
149  QGraphicsPathItem *_bottomPathItem;
150  SelectionArrowItem *_topCircle;
151  SelectionArrowItem *_bottomCircle;
152 };
153 
154 class CaptionGraphicsBackgroundItem : public QObject, public QGraphicsRectItem {
155 
156  Q_OBJECT
157 
158 public :
159 
160  CaptionGraphicsBackgroundItem(const QRect &rect);
161 
162  void generateColorCaption(const QGradient &activeGradient, const QGradient &hideGradient, const std::string &propertyName, double minValue, double maxValue);
163 
164  void generateSizeCaption(const std::vector< std::pair< double,float > > &metricToSizeFilteredList, const std::string &propertyName, double minValue, double maxValue);
165 
166 public slots :
167 
168  void updateCaption();
169  // begin and end in 0,1 range
170  void updateCaption(float begin, float end);
171  void configurationIconPressedSlot();
172 
173  void activateInteractions();
174  void removeInteractions();
175 
176 signals :
177 
178  void filterChanged(float begin, float end);
179  void configurationIconPressed();
180 
181  void interactionsActivated();
182  void interactionsRemoved();
183 
184 protected :
185 
186  void activateInteractions(bool);
187 
188  bool sceneEvent ( QEvent * event );
189  void updateSelectionText(float begin, float end);
190 
191  bool _interactionsActivated;
192  float _beginBackup;
193  float _endBackup;
194  QPoint _captionContentPos;
195 
196  double _minValue;
197  double _maxValue;
198 
199  // Global Items
200  QGraphicsTextItem *_minTextItem;
201  QGraphicsTextItem *_maxTextItem;
202  QGraphicsTextItem *_min2TextItem;
203  QGraphicsTextItem *_max2TextItem;
204  QGraphicsLineItem *_min2LineItem;
205  QGraphicsLineItem *_max2LineItem;
206  QGraphicsRectItem *_captionRectBorder;
207  SelectionArrowItem *_rangeSelector1Item;
208  SelectionArrowItem *_rangeSelector2Item;
209  SelectionTextItem *_rangeSelector1TextItem;
210  SelectionTextItem *_rangeSelector2TextItem;
211 
212  // Color caption Items
213  QGraphicsRectItem *_topCaptionRectItem;
214  MovableRectItem *_middleCaptionRectItem;
215  QGraphicsRectItem *_bottomCaptionRectItem;
216 
217  // Size caption Items
218  //MovableRectItem *_selectionSizeRectItem;
219  MovablePathItem *_sizeCaptionPathItem;
220  QGraphicsPathItem *_topSizeCaptionPathItem;
221  QGraphicsPathItem *_bottomSizeCaptionPathItem;
222 
223 
224 };
225 
226 }
227 
228 #endif // CAPTIONGRAPHICSSUB_H
229 ///@endcond