Tulip  6.0.0
Large graphs analysis and drawing
TulipViewSettings.h
1 /*
2  *
3  * This file is part of Tulip (https://tulip.labri.fr)
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 #include <map>
31 
32 namespace tlp {
33 
34 class TLP_SCOPE TulipShape {
35 
36 public:
37  enum Values : int {
38  None = -1,
39  Arrow = 50,
40  Billboard = 7,
41  BottomShadowedSphere = 21,
42  Circle = 14,
43  Cone = 3,
44  Cross = 8,
45  Cube = 0,
46  CubeOutlined = 1,
47  CubeOutlinedTransparent = 9,
48  Cylinder = 6,
49  Diamond = 5,
50  GlowSphere = 16,
51  HalfCylinder = 10,
52  Hexagon = 13,
53  LeftBottomShadowedSphere = 22,
54  Pentagon = 12,
55  RightBottomShadowedSphere = 23,
56  Ring = 15,
57  RoundedBox = 18,
58  Sphere = 2,
59  Square = 4,
60  Triangle = 11,
61  Window = 17,
62  Star = 19,
63  Icon = 20
64  };
65 };
66 
67 class TLP_SCOPE NodeShape {
68 
69 public:
70  enum NodeShapes {
71  Billboard = TulipShape::Billboard,
72  BottomShadowedSphere = TulipShape::BottomShadowedSphere,
73  Circle = TulipShape::Circle,
74  Cone = TulipShape::Cone,
75  Cross = TulipShape::Cross,
76  Cube = TulipShape::Cube,
77  CubeOutlined = TulipShape::CubeOutlined,
78  CubeOutlinedTransparent = TulipShape::CubeOutlinedTransparent,
79  Cylinder = TulipShape::Cylinder,
80  Diamond = TulipShape::Diamond,
81  GlowSphere = TulipShape::GlowSphere,
82  HalfCylinder = TulipShape::HalfCylinder,
83  Hexagon = TulipShape::Hexagon,
84  LeftBottomShadowedSphere = TulipShape::LeftBottomShadowedSphere,
85  Pentagon = TulipShape::Pentagon,
86  RightBottomShadowedSphere = TulipShape::RightBottomShadowedSphere,
87  Ring = TulipShape::Ring,
88  RoundedBox = TulipShape::RoundedBox,
89  Sphere = TulipShape::Sphere,
90  Square = TulipShape::Square,
91  Triangle = TulipShape::Triangle,
92  Window = TulipShape::Window,
93  Star = TulipShape::Star,
94  Icon = TulipShape::Icon
95  };
96 
97  static bool checkValue(int v) {
98  return v > -1 && v < 24;
99  }
100 };
101 
102 class TLP_SCOPE EdgeShape {
103 
104 public:
105  enum EdgeShapes { Polyline = 0, BezierCurve = 4, CatmullRomCurve = 8, CubicBSplineCurve = 16 };
106 
107  inline bool static checkValue(int v) {
108  switch (v) {
109  case Polyline:
110  case BezierCurve:
111  case CatmullRomCurve:
112  case CubicBSplineCurve:
113  return true;
114  default:
115  return false;
116  }
117  }
118 };
119 
120 class TLP_SCOPE EdgeExtremityShape {
121 
122 public:
123  enum EdgeExtremityShapes {
124  None = TulipShape::None,
125  Arrow = TulipShape::Arrow,
126  Circle = TulipShape::Circle,
127  Cone = TulipShape::Cone,
128  Cross = TulipShape::Cross,
129  Cube = TulipShape::Cube,
130  CubeOutlinedTransparent = TulipShape::CubeOutlinedTransparent,
131  Cylinder = TulipShape::Cylinder,
132  Diamond = TulipShape::Diamond,
133  GlowSphere = TulipShape::GlowSphere,
134  Hexagon = TulipShape::Hexagon,
135  Pentagon = TulipShape::Pentagon,
136  Ring = TulipShape::Ring,
137  Sphere = TulipShape::Sphere,
138  Square = TulipShape::Square,
139  Star = TulipShape::Star,
140  Icon = TulipShape::Icon
141  };
142 
143  inline bool static checkValue(int v) {
144  switch (v) {
145  case TulipShape::None:
146  case TulipShape::Arrow:
147  case TulipShape::Circle:
148  case TulipShape::Cone:
149  case TulipShape::Cross:
150  case TulipShape::Cube:
151  case TulipShape::CubeOutlinedTransparent:
152  case TulipShape::Cylinder:
153  case TulipShape::Diamond:
154  case TulipShape::GlowSphere:
155  case TulipShape::Hexagon:
156  case TulipShape::Pentagon:
157  case TulipShape::Ring:
158  case TulipShape::Sphere:
159  case TulipShape::Square:
160  case TulipShape::Star:
161  case TulipShape::Icon:
162  return true;
163  default:
164  return false;
165  }
166  }
167 };
168 
169 class TLP_SCOPE LabelPosition {
170 
171 public:
172  enum LabelPositions { Center = 0, Top = 1, Bottom = 2, Left = 3, Right = 4 };
173 
174  inline static bool checkValue(int v) {
175  return v > -1 && v < 4;
176  }
177 };
178 
179 ///@cond DOXYGEN_HIDDEN
180 class TLP_SCOPE TulipViewSettings : public Observable {
181 
182 public:
183  typedef std::map<LabelPosition::LabelPositions, std::string> labelmap;
184 
185  static TulipViewSettings &instance();
186 
187  static labelmap POSITION_LABEL_MAP;
188 
189  static Color defaultColor(ElementType elem);
190  static void setDefaultColor(ElementType elem, const Color &color);
191 
192  static Color defaultBorderColor(ElementType elem);
193  static void setDefaultBorderColor(ElementType elem, const Color &color);
194 
195  static float defaultBorderWidth(ElementType elem);
196  static void setdefaultBorderWidth(ElementType elem, float borderWidth);
197 
198  static Color defaultLabelColor();
199  static void setDefaultLabelColor(const Color &color);
200 
201  static Color defaultLabelBorderColor();
202  static void setDefaultLabelBorderColor(const Color &color);
203 
204  static float defaultLabelBorderWidth();
205  static void setDefaultLabelBorderWidth(float borderWidth);
206 
207  static int defaultLabelPosition();
208  static void setDefaultLabelPosition(int position);
209 
210  static Size defaultSize(ElementType elem);
211  static void setDefaultSize(ElementType elem, const Size &size);
212 
213  static int defaultShape(ElementType elem);
214  static void setDefaultShape(ElementType elem, int shape);
215 
216  static int defaultEdgeExtremitySrcShape();
217  static void setDefaultEdgeExtremitySrcShape(int shape);
218 
219  static int defaultEdgeExtremityTgtShape();
220  static void setDefaultEdgeExtremityTgtShape(int shape);
221 
222  static Size defaultEdgeExtremitySrcSize();
223  static void setDefaultEdgeExtremitySrcSize(const Size &size);
224 
225  static Size defaultEdgeExtremityTgtSize();
226  static void setDefaultEdgeExtremityTgtSize(const Size &size);
227 
228  static std::string defaultFontFile();
229  static void setDefaultFontFile(const std::string &fontFile);
230 
231  static int defaultFontSize();
232  static void setDefaultFontSize(int fontSize);
233 };
234 
235 class TLP_SCOPE ViewSettingsEvent : public tlp::Event {
236 
237 public:
238  enum ViewSettingsEventType {
239  TLP_DEFAULT_COLOR_MODIFIED,
240  TLP_DEFAULT_SHAPE_MODIFIED,
241  TLP_DEFAULT_SIZE_MODIFIED,
242  TLP_DEFAULT_LABEL_COLOR_MODIFIED
243  };
244 
245  ViewSettingsEvent(ElementType elem, const Color &color)
246  : Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
247  _type(TLP_DEFAULT_COLOR_MODIFIED), _elem(elem), _color(color) {}
248 
249  ViewSettingsEvent(ElementType elem, const Size &size)
250  : Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
251  _type(TLP_DEFAULT_SIZE_MODIFIED), _elem(elem), _size(size) {}
252 
253  ViewSettingsEvent(ElementType elem, int shape)
254  : Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
255  _type(TLP_DEFAULT_SHAPE_MODIFIED), _elem(elem), _shape(shape) {}
256 
257  ViewSettingsEvent(const Color &labelColor)
258  : Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
259  _type(TLP_DEFAULT_LABEL_COLOR_MODIFIED), _color(labelColor) {}
260 
261  ViewSettingsEventType getType() const {
262  return _type;
263  }
264 
265  ElementType getElementType() const {
266  return _elem;
267  }
268 
269  Color getColor() const {
270  return _color;
271  }
272 
273  Size getSize() const {
274  return _size;
275  }
276 
277  int getShape() const {
278  return _shape;
279  }
280 
281 private:
282  ViewSettingsEventType _type;
283  ElementType _elem;
284  Color _color;
285  Size _size;
286  int _shape;
287 };
288 ///@endcond
289 } // namespace tlp
290 
291 #endif // TULIPVIEWSETTINGS_H
Event is the base class for all events used in the Observation mechanism.
Definition: Observable.h:52
ElementType
Definition: Graph.h:50