Loading...
Searching...
No Matches
ImageSVG.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_IMAGE_SVG
39#define DRAIN_IMAGE_SVG
40
41#include <string>
42
43#include "Image.h"
44#include "TreeSVG.h"
45#include "TreeUtilsSVG.h" // FloaterSVG::
46
47namespace drain {
48
49namespace image {
50
52
63
64
65public:
66
67
69
72 ImagePanel(drain::image::TreeSVG & imagePanelGroup, const drain::image::Image & src, const drain::FilePath & filePath);
73
74 ImagePanel(drain::image::TreeSVG & imagePanelGroup, const drain::FilePath & filePath, const drain::Frame2D<drain::image::svg::coord_t> & geom = {0,0});
75
77 ImagePanel(drain::image::TreeSVG & imagePanelGroup, const drain::Frame2D<int> & geom = {0,0}); // drain::image::svg::coord_t
78
79 /*
80 IMAGE_PANEL, // Group containing and image and, potentially, title TEXTs.
81 IMAGE_BORDER, // RECT surrounding the image, potentially also a COORD_TRACKER
82 BACKGROUND,
83 OVERLAY, // Standard subgroup name inside IMAGE_PANEL group.
84 */
85
87 static
89
91 static
93
95 static
97
98 // Interactive element illustrating a selection by the user. May also be a GROUP.
99 static
100 const ClassXML SELECTOR;
101
103
106 static
108
110
114 static
116
117
118
119 drain::image::TreeSVG & getImage(const drain::FilePath & filePath = drain::FilePath(), const drain::Frame2D<drain::image::svg::coord_t> & geom = {0,0}) const;
120
122
125 inline
126 drain::image::TreeSVG & getImage(const drain::image::Image & src, const drain::FilePath & filepath) const {
127 return getImage(filepath, src.getGeometry().getAreaGeometry());
128 }
129
130
131 inline
132 drain::image::TreeSVG & getMetadata() const {
133 return getUniqueElem(imagePanelGroup, svg::METADATA);
134 }
135
136 drain::image::TreeSVG& getOverlayGroup() const;
137
138 inline
139 drain::image::TreeSVG& getBackGround() const {
140 drain::image::TreeSVG & overlay = getOverlayGroup();
141 return getUniqueElem(overlay, BACKGROUND, svg::RECT);
142 // return getUniqueElem(imagePanelGroup, RackSVG::ElemClass::BACKGROUND, svg::RECT);
143 };
144
145
146 inline
147 drain::image::TreeSVG & getImageBorder() const {
148 drain::image::TreeSVG & imageBorder = getUniqueElem(imagePanelGroup, IMAGE_BORDER, svg::RECT);
149 imageBorder->addClass(FloaterSVG::FLOATING);
150 return imageBorder;
151 //return getUniqueElem(imagePanelGroup, RackSVG::ElemClass::IMAGE_BORDER, svg::RECT);
152 };
153
154 // Not recommended (yet)
155 // drain::image::TreeSVG & getSourceSpecificGroup(const std::string & source) const;
156
158
161 drain::image::TreeSVG & getVectorOverlayGroup(const std::string & key="", const drain::Frame2D<drain::image::svg::coord_t> & geom = {0,0}) const;
162
163 drain::image::TreeSVG & getMouseListenerElem() const;
164
165 drain::image::TreeSVG & getDataImage(const drain::FilePath & filepath = drain::FilePath(), const drain::Frame2D<drain::image::svg::coord_t> & geom = {0,0}) const;
166
168 inline
169 drain::image::TreeSVG & getDescription(){
170 return imagePanelGroup[svg::IMAGE][svg::DESC](svg::DESC);
171 }
172
174
177 inline
178 drain::image::TreeSVG & getSelectionVisualisation(){
179 drain::image::TreeSVG & select = getOverlayGroup()[SELECTOR]; // (svg::RECT);
180 select->addClass(SELECTOR);
181 return select;
182 }
183
184
185protected:
186
187 drain::image::TreeSVG & imagePanelGroup;
188
189 drain::image::TreeSVG & getUniqueElem(drain::image::TreeSVG & parent, const drain::ClassXML & cls, drain::image::svg::tag_t type = drain::image::svg::GROUP) const;
190
191 drain::image::TreeSVG & getUniqueElem(drain::image::TreeSVG & parent, drain::image::svg::tag_t type = drain::image::svg::GROUP) const;
192
193};
194
195
196} // image::
197
198DRAIN_TYPENAME(image::ImagePanel);
199
200} // drain::
201
202
203
204#endif // DRAIN_IMAGE_SVG
205
A wrapper marking string an CSS effect.
Definition ClassXML.h:57
Extracts and stores directory path, base filename and extension.
Definition FilePath.h:54
Something that has width and height.
Definition Frame.h:53
Creator of SVG image elements located in a SVG group with fixed structure.
Definition ImageSVG.h:62
drain::image::TreeSVG & getSelectionVisualisation()
Return a SELECTOR element or group.
Definition ImageSVG.h:178
static const ClassXML BACKGROUND
RECT, by default invisible, used for aligning other objects, like titles.
Definition ImageSVG.h:92
drain::image::TreeSVG & getImage(const drain::image::Image &src, const drain::FilePath &filepath) const
Recommended version, if image is defined.
Definition ImageSVG.h:126
ImagePanel(drain::image::TreeSVG &imagePanelGroup, const drain::Frame2D< int > &geom={0, 0})
Retrieves the group defined last, or creates...
static const ClassXML IMAGE_BORDER
Topmost layer, optionally with a visible border.
Definition ImageSVG.h:115
static const ClassXML DATA_ARRAY
Optional image serving as a data block.
Definition ImageSVG.h:107
static const ClassXML OVERLAY
Group for vector graphics.
Definition ImageSVG.h:96
static const ClassXML IMAGE_PANEL
Group containing and image and, potentially, title TEXTs.
Definition ImageSVG.h:88
ImagePanel(drain::image::TreeSVG &imagePanelGroup, const drain::image::Image &src, const drain::FilePath &filePath)
Recommended constructor, if Image is defined: stores also METADATA.
drain::image::TreeSVG & getVectorOverlayGroup(const std::string &key="", const drain::Frame2D< drain::image::svg::coord_t > &geom={0, 0}) const
For vector graphics (grids, sectors)
Definition ImageSVG.cpp:372
drain::image::TreeSVG & getDescription()
Return a description element (of the image).
Definition ImageSVG.h:169
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:183
Definition Data.h:1473