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