Loading...
Searching...
No Matches
LayoutSVG.h
1/*
2
3MIT License
4
5Copyright (c) 2023 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31/*
32 * TreeSVG.h
33 *
34 * Created on: Nov, 2024
35 * Author: mpeura
36 */
37
38#ifndef DRAIN_LAYOUT_SVG
39#define DRAIN_LAYOUT_SVG
40
41#include <drain/util/EnumFlagger.h>
42
43#include "Direction.h"
44
45#include "TreeSVG.h"
46
47namespace drain {
48
49namespace image {
50
51
52
54
57class LayoutSVG {
58
59public:
60
62
66 enum Direction {
67 UNDEFINED_DIRECTION=0,
68 /*
69 RIGHT = 1,
70 LEFT = 2,
71 DOWN = 4,
72 UP = 8,
73 INCR = RIGHT | DOWN,
74 DECR = LEFT | UP,
75 */
76 /*
77 INCR_HORZ = 1,
78 INCR_VERT = 2,
79 INCR = INCR_HORZ | INCR_VERT,
80 DECR_HORZ = 4,
81 DECR_VERT = 8,
82 DECR = DECR_HORZ | DECR_VERT,
83 */
84 INCR = 1,
85 DECR = 2,
86 /*
87 INCR_HORZ = 1+4,
88 DECR_HORZ = 2+4,
89 INCR_VERT = 1+8,
90 DECR_VERT = 2+8,
91 */
92 };
93
94 enum DirectionHorz {
95 //UNDEFINED_DIRECTION=0,
96 RIGHT = INCR,
97 LEFT = DECR,
98 };
99
100 enum DirectionVert {
101 //tDEFINED_DIRECTION=0,
102 DOWN = INCR,
103 UP = DECR,
104 };
105
106
109 STACK_LAYOUT, // Align elements in rows or columns. (Alternate the axis in nesting STACK_LAYOUT levels)
110 ADAPTER, // Translate this group object such that the upper right corner of graphics are in the origin (0,0).
111 ALIGN, // Align this object, with applicable rules and preferences (populate me with align instructions, unless already set)
112 COMPOUND, // Internal elements are already aligned, bypass recursion.
113 FIXED, // Absolute position - do not align.
114 INDEPENDENT, // No anchoring allowed to this element, but collective bounding box is adjusted to include this element
115 NEUTRAL, // The object is not included in updating the collective bounding box but can be used as anchor. \see INDEPENDENT
116 //
117 CROP, // minimize bbox covering all the included objects. \see GroupType::FIXED
118 // Future options
119 // HEADER, // Requests alignment as a title, typically title box combining TEXT (and TSPAN) on a background RECT
120 };
121
122
125
126protected:
127
128 AxisFlagger orientation = AlignBase::HORZ;
129
130 DirectionFlagger direction = INCR;
131
132 inline
133 LayoutSVG(AlignBase::Axis v=AlignBase::HORZ, Direction d=INCR) : orientation(v), direction(d) {
134 }
135
136 inline
137 LayoutSVG(const LayoutSVG & layout) : orientation(layout.orientation), direction(layout.direction){
138 }
139
141
145 template <typename V>
146 inline
147 void setOrientation(const V & axis){
148 orientation.set(Enum<AlignBase::Axis>::getValue(axis));
149 };
150
152
156 template <typename D>
157 inline
158 void setDirection(const D & dir){
159 direction.set(Enum<LayoutSVG::Direction>::getValue(dir));
160 };
161
163
166 template <typename D, typename V>
167 inline
168 void set(const D & d, const V &v){
169 direction.set(Enum<LayoutSVG::Direction>::getValue(d));
170 orientation.set(Enum<AlignBase::Axis>::getValue(v));
171 };
172
173 /*
174 static inline
175 Direction flip(Direction ...){
176 };
177 */
178};
179
180
181} // image::
182
183DRAIN_ENUM_DICT(image::LayoutSVG::Direction);
184DRAIN_ENUM_OSTREAM(image::LayoutSVG::Direction);
185
186DRAIN_ENUM_DICT(image::LayoutSVG::DirectionHorz);
187DRAIN_ENUM_OSTREAM(image::LayoutSVG::DirectionHorz);
188
189DRAIN_ENUM_DICT(image::LayoutSVG::DirectionVert);
190DRAIN_ENUM_OSTREAM(image::LayoutSVG::DirectionVert);
191
192
193DRAIN_ENUM_DICT(image::LayoutSVG::GroupType);
194
195DRAIN_XML_ENUM_KEY(image::TreeSVG, image::LayoutSVG::GroupType);
196
197
198
199} // drain::
200
201
202//DRAIN_ENUM_OSTREAM(drain::image::LayoutSVG::Direction);
203DRAIN_ENUM_OSTREAM(drain::image::LayoutSVG::GroupType);
204
205namespace drain {
206//DRAIN_XML_ENUM_KEY(image::TreeSVG, image::LayoutSVG::GroupType);
207}
208
209#endif // DRAIN_ALIGN_SVG_H_
210
Flagger accepting values of enum type E.
Definition EnumFlagger.h:56
Higher level controller for setting alignments.
Definition LayoutSVG.h:57
void setDirection(const D &dir)
Set direction: coordinates increasing or decreasing.
Definition LayoutSVG.h:158
Direction
Direction for "Stacked", horziontally or vertically sequentially aligned layout.
Definition LayoutSVG.h:66
GroupType
Experimental SVG style classes (requests)
Definition LayoutSVG.h:108
void setOrientation(const V &axis)
Set orientation: horizontal or vertical axis.
Definition LayoutSVG.h:147
void set(const D &d, const V &v)
Set direction and orientation.
Definition LayoutSVG.h:168
Definition DataSelector.cpp:1277
A container for a static dictionary of enumeration values.
Definition Enum.h:51
Definition Direction.h:99