Loading...
Searching...
No Matches
CoordsSVG.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_COORDS_SVG
39#define DRAIN_COORDS_SVG
40
41#include <string>
42
43// #include "drain/Enum.h"
44// #include "drain/util/XML.h"
45// #include "drain/util/Frame.h"
46#include "Alignment.h"
47#include "TreeSVG.h"
48#include "AlignSVG.h"
49
50
51namespace drain {
52
53namespace image {
54
55
57
61
62public:
63
64 // Starting coordinate (x or y).
65 svg::coord_t pos = 0; // BBoxSVG::undefined;
66
67 // Width or height
68 svg::coord_t span = 0; // BBoxSVG::undefined;
69
70 inline
71 CoordSpanBase(svg::coord_t pos = 0, svg::coord_t span = 0) : pos(pos), span(span) {
72 }
73
74 inline
75 CoordSpanBase(const CoordSpanBase & cspan) : pos(cspan.pos), span(cspan.span) {
76 }
77
78 inline
79 bool isDefined() const {
80 return ! (std::isnan(pos) || std::isnan(span));
81 }
82
83 bool getPosition(AlignBase::Pos alignLoc, svg::coord_t & coord) const;
84
85};
86
87
88// template <>
89// const drain::Enum<AlignSVG_FOO>::dict_t drain::Enum<AlignSVG_FOO>::dict;
90
91template <AlignBase::Axis AX>
92struct CoordSpan : public CoordSpanBase {
93
94 inline
95 CoordSpan(svg::coord_t pos = 0, svg::coord_t span = 0) : CoordSpanBase(pos, span) {
96 }
97
98 inline
99 CoordSpan(const CoordSpan & cspan) : CoordSpanBase(cspan.pos, cspan.span) {
100 }
101
102
103 // ? void getTranslatedCoordSpan(const BBoxSVG & bbox);
104 void copyFrom(const NodeSVG & node);
105
106 void copyFrom(const BBoxSVG & bbox);
107
108};
109
110
111
112template <AlignBase::Axis AX>
113std::ostream & operator<<(std::ostream & ostr, const CoordSpan<AX> &span){
114 ostr << "span" << AX << "=" << span.pos << "(+" << span.span << ')';
115 return ostr;
116}
117
118} // image::
119
120} // drain::
121
122// template <drain::image::AlignBase::Axis AX>
123// std::ostream & operator<<(std::ostream & ostr, const drain::image::CoordSpan<AX> &span);
124
125
126
127#endif // DRAIN_COORDS_SVG
128
Definition SVG.h:91
SVG classes marking requests of relative horizontal and vertical alignment.
Definition CoordsSVG.h:60
Definition TreeSVG.h:135
Definition Data.h:1473
Pos
Reference position at Axis (HORZ or VERT)
Definition Alignment.h:55
Definition CoordsSVG.h:92