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