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