Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

graphics.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/basic.h>
35 
36 
37 namespace ogdf {
38 
40 
43 enum class StrokeType : unsigned char {
44  None,
45  Solid,
46  Dash,
47  Dot,
48  Dashdot,
49  Dashdotdot
50 };
51 
53 OGDF_EXPORT ostream &operator<<(ostream &os, const StrokeType &st);
54 
56 
60 
61 
63 
66 enum class StrokeLineCap : unsigned char{
67  Butt,
68  Round,
69  Square
70 };
71 
72 
74 
77 enum class StrokeLineJoin : unsigned char {
78  Miter,
79  Round,
80  Bevel
81 };
82 
83 
85 
88 enum class FillPattern {
89  None,
90  Solid,
91  Dense1,
92  Dense2,
93  Dense3,
94  Dense4,
95  Dense5,
96  Dense6,
97  Dense7,
98  Horizontal,
99  Vertical,
100  Cross,
104 };
105 
107 OGDF_EXPORT ostream &operator<<(ostream &os, const FillPattern &fp);
108 
110 
114 
115 
117 
120 enum class Shape {
121  Rect,
122  RoundedRect,
123  Ellipse,
124  Triangle,
125  Pentagon,
126  Hexagon,
127  Octagon,
128  Rhomb,
129  Trapeze,
130  Parallelogram,
131  InvTriangle,
132  InvTrapeze,
134  Image
135 };
136 
137 
139 
142 enum class EdgeArrow {
143  None,
144  Last,
145  First,
146  Both,
147  Undefined
148 };
149 
151 OGDF_EXPORT ostream &operator<<(ostream &os, const EdgeArrow &ea);
152 
154 
162  uint8_t m_red, m_green, m_blue, m_alpha;
163 
164 public:
166  enum class Name {
167  Aliceblue,
168  Antiquewhite,
169  Aqua,
170  Aquamarine,
171  Azure,
172  Beige,
173  Bisque,
174  Black,
175  Blanchedalmond,
176  Blue,
177  Blueviolet,
178  Brown,
179  Burlywood,
180  Cadetblue,
181  Chartreuse,
182  Chocolate,
183  Coral,
184  Cornflowerblue,
185  Cornsilk,
186  Crimson,
187  Cyan,
188  Darkblue,
189  Darkcyan,
190  Darkgoldenrod,
191  Darkgray,
192  Darkgreen,
193  Darkgrey,
194  Darkkhaki,
195  Darkmagenta,
196  Darkolivegreen,
197  Darkorange,
198  Darkorchid,
199  Darkred,
200  Darksalmon,
201  Darkseagreen,
202  Darkslateblue,
203  Darkslategray,
204  Darkslategrey,
205  Darkturquoise,
206  Darkviolet,
207  Deeppink,
208  Deepskyblue,
209  Dimgray,
210  Dimgrey,
211  Dodgerblue,
212  Firebrick,
213  Floralwhite,
214  Forestgreen,
215  Fuchsia,
216  Gainsboro,
217  Ghostwhite,
218  Gold,
219  Goldenrod,
220  Gray,
221  Green,
222  Greenyellow,
223  Grey,
224  Honeydew,
225  Hotpink,
226  Indianred,
227  Indigo,
228  Ivory,
229  Khaki,
230  Lavender,
231  Lavenderblush,
232  Lawngreen,
233  Lemonchiffon,
234  Lightblue,
235  Lightcoral,
236  Lightcyan,
237  Lightgoldenrodyellow,
238  Lightgray,
239  Lightgreen,
240  Lightgrey,
241  Lightpink,
242  Lightsalmon,
243  Lightseagreen,
244  Lightskyblue,
245  Lightslategray,
246  Lightslategrey,
247  Lightsteelblue,
248  Lightyellow,
249  Lime,
250  Limegreen,
251  Linen,
252  Magenta,
253  Maroon,
254  Mediumaquamarine,
255  Mediumblue,
256  Mediumorchid,
257  Mediumpurple,
258  Mediumseagreen,
259  Mediumslateblue,
260  Mediumspringgreen,
261  Mediumturquoise,
262  Mediumvioletred,
263  Midnightblue,
264  Mintcream,
265  Mistyrose,
266  Moccasin,
267  Navajowhite,
268  Navy,
269  Oldlace,
270  Olive,
271  Olivedrab,
272  Orange,
273  Orangered,
274  Orchid,
275  Palegoldenrod,
276  Palegreen,
277  Paleturquoise,
278  Palevioletred,
279  Papayawhip,
280  Peachpuff,
281  Peru,
282  Pink,
283  Plum,
284  Powderblue,
285  Purple,
286  Red,
287  Rosybrown,
288  Royalblue,
289  Saddlebrown,
290  Salmon,
291  Sandybrown,
292  Seagreen,
293  Seashell,
294  Sienna,
295  Silver,
296  Skyblue,
297  Slateblue,
298  Slategray,
299  Slategrey,
300  Snow,
301  Springgreen,
302  Steelblue,
303  Tan,
304  Teal,
305  Thistle,
306  Tomato,
307  Turquoise,
308  Violet,
309  Wheat,
310  White,
311  Whitesmoke,
312  Yellow,
313  Yellowgreen
314  };
315 
317  Color() : m_red(0), m_green(0), m_blue(0), m_alpha(255) { }
318 
320  Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) : m_red(r), m_green(g), m_blue(b), m_alpha(a) { }
321 
323  Color(int r, int g, int b, int a = 255) : m_red((uint8_t)r), m_green((uint8_t)g), m_blue((uint8_t)b), m_alpha((uint8_t)a) { }
324 
326  Color(Color::Name name);
327 
329  Color(const string &str) { fromString(str); }
330 
332  Color(const char *str) { fromString(string(str)); }
333 
335  uint8_t red() const { return m_red; }
336 
338  uint8_t green() const { return m_green; }
339 
341  uint8_t blue() const { return m_blue; }
342 
344  uint8_t alpha() const { return m_alpha; }
345 
347  void red(uint8_t r) { m_red = r; }
348 
350  void green(uint8_t g) { m_green = g; }
351 
353  void blue(uint8_t b) { m_blue = b; }
354 
356  void alpha(uint8_t a) { m_alpha = a; }
357 
359 
364  string toString() const;
365 
367  bool fromString(const string &str);
368 
370  bool operator==(const Color &c) const {
371  return m_red == c.m_red && m_green == c.m_green && m_blue == c.m_blue && m_alpha == c.m_alpha;
372  }
373 
375  bool operator!=(const Color &c) const {
376  return !operator==(c);
377  }
378 
380  friend ostream &operator<<(ostream &os, const Color &c) {
381  return os << c.toString();
382  }
383 };
384 
385 
387 
392  float m_width;
396 
397  Stroke() : m_color(Color::Name::Black), m_width(1.0f), m_type(StrokeType::Solid), m_cap(StrokeLineCap::Butt), m_join(StrokeLineJoin::Miter) { }
398  Stroke(Color c) : m_color(c), m_width(1.0f), m_type(StrokeType::Solid), m_cap(StrokeLineCap::Butt), m_join(StrokeLineJoin::Miter) { }
399 };
400 
401 
403 
410 
411  Fill() : m_color(Color::Name::White), m_bgColor(Color::Name::Black), m_pattern(FillPattern::Solid) { }
412  Fill(Color c) : m_color(c), m_bgColor(Color::Name::Black), m_pattern(FillPattern::Solid) { }
413  Fill(Color c, FillPattern pattern) : m_color(c), m_bgColor(Color::Name::Black), m_pattern(pattern) { }
414  Fill(Color c, Color bgColor, FillPattern pattern) : m_color(c), m_bgColor(bgColor), m_pattern(pattern) { }
415 };
416 
417 
418 } // end namespace ogdf
inverted parallelogram (slanted to the left)
uint8_t red() const
Returns the red component.
Definition: graphics.h:335
Color(int r, int g, int b, int a=255)
Creates a color from given RGBA-values.
Definition: graphics.h:323
Stroke(Color c)
Definition: graphics.h:398
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
parallelogram (slanted to the right)
trapeze (upper side shorter)
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Creates a color from given RGBA-values.
Definition: graphics.h:320
Fill(Color c)
Definition: graphics.h:412
Color m_color
fill color
Definition: graphics.h:407
StrokeLineCap
Line cap types of strokes.
Definition: graphics.h:66
line style "dash dot dot dash dot dot ..."
StrokeLineJoin
Line join types of strokes.
Definition: graphics.h:77
uint8_t m_red
Definition: graphics.h:162
FillPattern
Fill patterns.
Definition: graphics.h:88
EdgeArrow
Types for edge arrows.
Definition: graphics.h:142
isosceles triangle (base side down)
uint8_t green() const
Returns the green component.
Definition: graphics.h:338
edge arrow at target and source node of the edge
rectangle with rounded corners
ostream & operator<<(ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:764
float m_width
stroke width
Definition: graphics.h:392
Properties of strokes.
Definition: graphics.h:390
string toString() const
Converts the color to a string and returns it.
FillPattern m_pattern
fill pattern
Definition: graphics.h:409
Shape
Types for node shapes.
Definition: graphics.h:120
Fill(Color c, FillPattern pattern)
Definition: graphics.h:413
StrokeLineJoin m_join
line-join of the stroke
Definition: graphics.h:395
uint8_t alpha() const
Returns the alpha channel.
Definition: graphics.h:344
std::string toString(const Attribute &attr)
isosceles triangle (base side up)
bool operator!=(const Color &c) const
Returns true iff c and this color differ in any component.
Definition: graphics.h:375
Colors represented as RGBA values.
Definition: graphics.h:161
bool operator==(const Color &c) const
Returns true iff c and this color are equal in every component.
Definition: graphics.h:370
FillPattern intToFillPattern(int i)
Converts integer i to fill pattern.
edge arrow at target node of the edge
uint8_t m_blue
Definition: graphics.h:162
Color(const string &str)
Crates a color from string str.
Definition: graphics.h:329
line style "dash dot dash dot ..."
uint8_t blue() const
Returns the blue component.
Definition: graphics.h:341
Color(const char *str)
Crates a color from string str.
Definition: graphics.h:332
void blue(uint8_t b)
Sets the blue component to b.
Definition: graphics.h:353
uint8_t m_alpha
Definition: graphics.h:162
StrokeType intToStrokeType(int i)
Converts integer i to stroke type.
Basic declarations, included by all source files.
Name
Named colors (same as SVG color keywords).
Definition: graphics.h:166
StrokeType m_type
stroke type (e.g.
Definition: graphics.h:393
Fill(Color c, Color bgColor, FillPattern pattern)
Definition: graphics.h:414
void green(uint8_t g)
Sets the green component to g.
Definition: graphics.h:350
uint8_t m_green
Definition: graphics.h:162
StrokeType
Line types of strokes.
Definition: graphics.h:43
edge arrow at source node of the edge
The namespace for all OGDF objects.
Color m_color
stroke color
Definition: graphics.h:391
Properties of fills.
Definition: graphics.h:406
void alpha(uint8_t a)
Sets the alpha channel to a.
Definition: graphics.h:356
Color()
Creates an opaque black color.
Definition: graphics.h:317
Color m_bgColor
background color of fill pattern
Definition: graphics.h:408
StrokeLineCap m_cap
line-cap of the stroke
Definition: graphics.h:394
friend ostream & operator<<(ostream &os, const Color &c)
Writes the string representation of color c to output stream os.
Definition: graphics.h:380
bool operator==(const Tuple2< E1, E2 > &t1, const Tuple2< E1, E2 > &t2)
Equality operator for 2-tuples.
Definition: tuples.h:75
rhomb (=diamond)
void red(uint8_t r)
Sets the red component to r.
Definition: graphics.h:347
inverted trapeze (upper side longer)