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