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/image/AlignAnchorSVG.h>
42#include <drain/util/EnumFlagger.h>
43
44#include "TreeSVG.h"
45
46namespace drain {
47
48namespace image {
49
50
51
53
56class LayoutSVG {
57
58public:
59
61
65 enum Direction {
66 UNDEFINED_DIRECTION=0,
67 INCR = 1,
68 DECR = 2,
69 };
70
72 enum GroupType {
73 STACK_LAYOUT, // Align elements in rows or columns. (Alternate the axis in nesting STACK_LAYOUT levels)
74 ADAPTER, // Translate this group object such that the upper right corner of graphics are in the origin (0,0).
75 ALIGN, // Align this object, with applicable rules and preferences (populate me with align instructions, unless already set)
76 COMPOUND, // Internal elements are already aligned, bypass recursion.
77 FIXED, // Absolute position - do not align.
78 INDEPENDENT, // No anchoring allowed to this element, but collective bounding box is adjusted to include this element
79 NEUTRAL, // The object is not included in updating the collective bounding box but can be used as anchor. \see INDEPENDENT
80 //
81 CROP, // minimize bbox covering all the included objects. \see GroupType::FIXED
82 // Future options
83 // HEADER, // Requests alignment as a title, typically title box combining TEXT (and TSPAN) on a background RECT
84 };
85
86
87protected:
88
90 AxisFlagger orientation = AlignBase::HORZ;
91
93 DirectionFlagger direction = INCR;
94
95 inline
96 LayoutSVG(AlignBase::Axis v=AlignBase::HORZ, Direction d=INCR) : orientation(v), direction(d) {
97 }
98
99 inline
100 LayoutSVG(const LayoutSVG & layout) : orientation(layout.orientation), direction(layout.direction){
101 }
102
104
108 template <typename V>
109 inline
110 void setOrientation(const V & axis){
111 orientation.set(Enum<AlignBase::Axis>::getValue(axis));
112 };
113
115
119 template <typename D>
120 inline
121 void setDirection(const D & dir){
122 direction.set(Enum<LayoutSVG::Direction>::getValue(dir));
123 };
124
126
129 template <typename D, typename V>
130 inline
131 void set(const D & d, const V &v){
132 direction.set(Enum<LayoutSVG::Direction>::getValue(d));
133 orientation.set(Enum<AlignBase::Axis>::getValue(v));
134 };
135
136 /*
137 static inline
138 Direction flip(Direction ...){
139 };
140 */
141};
142
143
144} // image::
145
146DRAIN_ENUM_DICT(image::LayoutSVG::Direction);
147DRAIN_ENUM_DICT(image::LayoutSVG::GroupType);
148
149DRAIN_XML_ENUM_KEY(image::TreeSVG, image::LayoutSVG::GroupType);
150
151} // drain::
152
153
154DRAIN_ENUM_OSTREAM(drain::image::LayoutSVG::Direction);
155DRAIN_ENUM_OSTREAM(drain::image::LayoutSVG::GroupType);
156
157namespace drain {
158//DRAIN_XML_ENUM_KEY(image::TreeSVG, image::LayoutSVG::GroupType);
159}
160
161#endif // DRAIN_ALIGN_SVG_H_
162
Flagger accepting values of enum type E.
Definition EnumFlagger.h:56
Higher level controller for setting alignments.
Definition LayoutSVG.h:56
void setDirection(const D &dir)
Set direction: coordinates increasing or decreasing.
Definition LayoutSVG.h:121
Direction
Direction for "Stacked", horziontally or vertically sequentially aligned layout.
Definition LayoutSVG.h:65
GroupType
Experimental SVG style classes (requests)
Definition LayoutSVG.h:72
void setOrientation(const V &axis)
Set orientation: horizontal or vertical axis.
Definition LayoutSVG.h:110
void set(const D &d, const V &v)
Set direction and orientation.
Definition LayoutSVG.h:131
Definition DataSelector.cpp:1277
A container for a static dictionary of enumeration values.
Definition Enum.h:51
Definition Direction.h:99