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