Tulip  4.7.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
TulipViewSettings.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 
20 #ifndef TULIPVIEWSETTINGS_H
21 #define TULIPVIEWSETTINGS_H
22 
23 #include <tulip/tulipconf.h>
24 #include <tulip/Color.h>
25 #include <tulip/Size.h>
26 #include <tulip/Graph.h>
27 #include <tulip/Observable.h>
28 
29 #include <string>
30 
31 namespace tlp {
32 
33 class TLP_SCOPE NodeShape {
34 
35 public:
36 
37  enum NodeShapes {
38  Billboard=7,
39  ChristmasTree=28,
40  Circle=14,
41  Cone=3,
42  Cross=8,
43  Cube=0,
44  CubeOutlined=1,
45  CubeOutlinedTransparent=9,
46  Cylinder=6,
47  Diamond=5,
48  GlowSphere=16,
49  HalfCylinder=10,
50  Hexagon=13,
51  Pentagon=12,
52  Ring=15,
53  RoundedBox=18,
54  Sphere=2 ,
55  Square=4,
56  Triangle=11,
57  Window=17,
58  Star=19,
59  FontAwesomeIcon=20
60  };
61 };
62 
63 class TLP_SCOPE EdgeShape {
64 
65 public:
66 
67  enum EdgeShapes {
68  Polyline=0,
69  BezierCurve=4,
70  CatmullRomCurve=8,
71  CubicBSplineCurve=16
72  };
73 };
74 
75 class TLP_SCOPE EdgeExtremityShape {
76 
77 public:
78 
79  enum EdgeExtremityShapes {
80  None=-1,
81  Arrow=50,
82  Circle=14,
83  Cone=3,
84  Cross=8,
85  Cube=0,
86  CubeOutlinedTransparent=9,
87  Cylinder=6,
88  Diamond=5,
89  GlowSphere=16,
90  Hexagon=13,
91  Pentagon=12,
92  Ring=15,
93  Sphere=2 ,
94  Square=4,
95  Star=19,
96  FontAwesomeIcon=20
97  };
98 };
99 
100 class TLP_SCOPE LabelPosition {
101 
102 public:
103 
104  enum LabelPositions {
105  Center=0,
106  Top,
107  Bottom,
108  Left,
109  Right
110  };
111 };
112 
113 class TLP_SCOPE TulipViewSettings : public Observable {
114 
115 public:
116 
117  static TulipViewSettings &instance();
118 
119  Color defaultColor(ElementType elem) const;
120  void setDefaultColor(ElementType elem, const Color& color);
121 
122  Color defaultBorderColor(ElementType elem) const;
123  void setDefaultBorderColor(ElementType elem, const Color& color);
124 
125  float defaultBorderWidth(ElementType elem) const;
126  void setdefaultBorderWidth(ElementType elem, float borderWidth);
127 
128  Color defaultLabelColor() const;
129  void setDefaultLabelColor(const Color& color);
130 
131  Color defaultLabelBorderColor() const;
132  void setDefaultLabelBorderColor(const Color& color);
133 
134  float defaultLabelBorderWidth() const;
135  void setDefaultLabelBorderWidth(float borderWidth);
136 
137  int defaultLabelPosition() const;
138  void setDefaultLabelPosition(int position);
139 
140  Size defaultSize(ElementType elem) const;
141  void setDefaultSize(ElementType elem, const Size& size);
142 
143  int defaultShape(ElementType elem) const;
144  void setDefaultShape(ElementType elem, int shape);
145 
146  int defaultEdgeExtremitySrcShape() const;
147  void setDefaultEdgeExtremitySrcShape(int shape);
148 
149  int defaultEdgeExtremityTgtShape() const;
150  void setDefaultEdgeExtremityTgtShape(int shape);
151 
152  Size defaultEdgeExtremitySrcSize() const;
153  void setDefaultEdgeExtremitySrcSize(const Size &size);
154 
155  Size defaultEdgeExtremityTgtSize() const;
156  void setDefaultEdgeExtremityTgtSize(const Size &size);
157 
158  std::string defaultFontFile() const;
159  void setDefaultFontFile(const std::string &fontFile);
160 
161  int defaultFontSize() const;
162  void setDefaultFontSize(int fontSize);
163 
164 private:
165 
166  TulipViewSettings();
167 
168  static TulipViewSettings *_instance;
169 
170  Color _defaultNodeColor;
171  Color _defaultEdgeColor;
172  Color _defaultNodeBorderColor;
173  Color _defaultEdgeBorderColor;
174  Color _defaultLabelColor;
175  Color _defaultLabelBorderColor;
176 
177  float _defaultNodeBorderWidth;
178  float _defaultEdgeBorderWidth;
179  float _defaultLabelBorderWidth;
180 
181  int _defaultLabelPosition;
182 
183  Size _defaultNodeSize;
184  Size _defaultEdgeSize;
185 
186  int _defaultNodeShape;
187  int _defaultEdgeShape;
188  int _defaultEdgeExtremitySrcShape;
189  int _defaultEdgeExtremityTgtShape;
190 
191  Size _defaultEdgeExtremitySrcSize;
192  Size _defaultEdgeExtremityTgtSize;
193 
194  std::string _defaultFontFile;
195  int _defaultFontSize;
196 };
197 
198 class TLP_SCOPE ViewSettingsEvent : public tlp::Event {
199 
200 public:
201 
202  enum ViewSettingsEventType {
203  TLP_DEFAULT_COLOR_MODIFIED,
204  TLP_DEFAULT_SHAPE_MODIFIED,
205  TLP_DEFAULT_SIZE_MODIFIED,
206  TLP_DEFAULT_LABEL_COLOR_MODIFIED
207  };
208 
209  ViewSettingsEvent(ElementType elem, const Color &color) :
210  Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
211  _type(TLP_DEFAULT_COLOR_MODIFIED), _elem(elem), _color(color) {}
212 
213  ViewSettingsEvent(ElementType elem, const Size &size) :
214  Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
215  _type(TLP_DEFAULT_SIZE_MODIFIED), _elem(elem), _size(size) {}
216 
217  ViewSettingsEvent(ElementType elem, int shape) :
218  Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
219  _type(TLP_DEFAULT_SHAPE_MODIFIED), _elem(elem), _shape(shape) {}
220 
221  ViewSettingsEvent(const Color &labelColor) :
222  Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
223  _type(TLP_DEFAULT_LABEL_COLOR_MODIFIED), _color(labelColor) {}
224 
225  ViewSettingsEventType getType() const {
226  return _type;
227  }
228 
229  ElementType getElementType() const {
230  return _elem;
231  }
232 
233  Color getColor() const {
234  return _color;
235  }
236 
237  Size getSize() const {
238  return _size;
239  }
240 
241  int getShape() const {
242  return _shape;
243  }
244 
245 private:
246 
247  ViewSettingsEventType _type;
248  ElementType _elem;
249  Color _color;
250  Size _size;
251  int _shape;
252 
253 };
254 
255 }
256 
257 #endif // TULIPVIEWSETTINGS_H
ElementType
Definition: Graph.h:46
Event is the base class for all events used in the Observation mechanism.
Definition: Observable.h:47