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