Tulip  5.0.0
Large graphs analysis and drawing
CaptionItem.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 CAPTIONITEM_H
22 #define CAPTIONITEM_H
23 
24 #include <QObject>
25 
26 #include <tulip/Color.h>
27 #include <tulip/Observable.h>
28 
29 class QGradient;
30 
31 namespace tlp {
32 
33 class View;
34 class CaptionGraphicsBackgroundItem;
35 class CaptionGraphicsItem;
36 class Graph;
37 class ColorProperty;
38 class DoubleProperty;
39 class SizeProperty;
40 
41 class CaptionItem : public QObject, public Observable {
42 
43  Q_OBJECT
44 
45 public:
46 
47  enum CaptionType {
48  NodesColorCaption=1,
49  NodesSizeCaption=2,
50  EdgesColorCaption=3,
51  EdgesSizeCaption=4
52  };
53 
54  CaptionItem(View *view);
55  ~CaptionItem();
56 
57  void create(CaptionType captionType);
58 
59  void initCaption();
60 
61  void generateColorCaption(CaptionType captionType);
62 
63  void generateSizeCaption(CaptionType captionType);
64 
65  CaptionGraphicsBackgroundItem *captionGraphicsItem();
66 
67  void treatEvents(const std::vector<Event> &ev);
68 
69 signals :
70 
71  void filtering(bool);
72 
73 public slots :
74 
75  void removeObservation(bool);
76 
77  void applyNewFilter(float begin,float end);
78  void selectedPropertyChanged(std::string propertyName);
79 
80 private :
81 
82  void clearObservers();
83 
84  void generateGradients(const std::vector<std::pair <double,Color> > &metricToColorFiltered, QGradient &activeGradient, QGradient &hideGradient);
85 
86  View *view;
87 
88  CaptionType _captionType;
89  CaptionGraphicsItem *_captionGraphicsItem;
90 
91  Graph *_graph;
92  DoubleProperty *_metricProperty;
93  ColorProperty *_colorProperty;
94  SizeProperty *_sizeProperty;
95  ColorProperty *_backupColorProperty;
96  ColorProperty *_backupBorderColorProperty;
97 };
98 
99 }
100 
101 #endif // CAPTIONITEM_H
102 ///@endcond