Tulip  5.4.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 
159 class TLP_SCOPE ViewSettingsEvent : public tlp::Event {
160 
161 public:
162  enum ViewSettingsEventType {
163  TLP_DEFAULT_COLOR_MODIFIED,
164  TLP_DEFAULT_SHAPE_MODIFIED,
165  TLP_DEFAULT_SIZE_MODIFIED,
166  TLP_DEFAULT_LABEL_COLOR_MODIFIED
167  };
168 
169  ViewSettingsEvent(ElementType elem, const Color &color)
170  : Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
171  _type(TLP_DEFAULT_COLOR_MODIFIED), _elem(elem), _color(color) {}
172 
173  ViewSettingsEvent(ElementType elem, const Size &size)
174  : Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
175  _type(TLP_DEFAULT_SIZE_MODIFIED), _elem(elem), _size(size) {}
176 
177  ViewSettingsEvent(ElementType elem, int shape)
178  : Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
179  _type(TLP_DEFAULT_SHAPE_MODIFIED), _elem(elem), _shape(shape) {}
180 
181  ViewSettingsEvent(const Color &labelColor)
182  : Event(TulipViewSettings::instance(), Event::TLP_MODIFICATION),
183  _type(TLP_DEFAULT_LABEL_COLOR_MODIFIED), _color(labelColor) {}
184 
185  ViewSettingsEventType getType() const {
186  return _type;
187  }
188 
189  ElementType getElementType() const {
190  return _elem;
191  }
192 
193  Color getColor() const {
194  return _color;
195  }
196 
197  Size getSize() const {
198  return _size;
199  }
200 
201  int getShape() const {
202  return _shape;
203  }
204 
205 private:
206  ViewSettingsEventType _type;
207  ElementType _elem;
208  Color _color;
209  Size _size;
210  int _shape;
211 };
212 } // namespace tlp
213 
214 #endif // TULIPVIEWSETTINGS_H
ElementType
Definition: Graph.h:50
Event is the base class for all events used in the Observation mechanism.
Definition: Observable.h:52