Loading...
Searching...
No Matches
resources-image.h
1/*
2
3MIT License
4
5Copyright (c) 2017 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// # pragma once
33#ifndef RACK_RESOURCES_IMG_H
34#define RACK_RESOURCES_IMG_H
35
36#include <string>
37
38#include <drain/RegExp.h>
39#include <drain/image/Image.h>
40#include <drain/image/TreeSVG.h>
41#include <drain/image/TreeUtilsSVG.h>
42#include <drain/imageops/PaletteOp.h>
43#include <drain/imageops/ImageModifierPack.h>
44#include <drain/imageops/PaletteOp.h>
45#include <drain/prog/CommandBankUtils.h>
46#include <drain/util/Rectangle.h>
47
48#include "data/QuantityMap.h"
49#include "data/VariableFormatterODIM.h"
50
51
52namespace rack {
53
54
55//using namespace drain::image;
56
57enum SvgInclude {
58 NONE = 0,
59 PNG = 1, // Main title in SVG image
60 SVG = 2,
61 TXT = 4,
62 SKIP = 16,
63 NEXT = 32,
64 ON = 64,
65 OFF = 128,
66 ALL = ON|(PNG|SVG|TXT),
67 UNKNOWN = 255,
68 // --- unused ? ---
69 // TITLE, // Default title
70};
71
72
73/*
74enum TitleClass {
75 NONE = 0,
76 MAIN = 1, // Main title in SVG image
77 GROUP = 2,
78 IMAGE = 4, // Small title in a corner of radar image (time, location)
79 TIME = 8, // Date and time attributes
80 LOCATION = 16, // Place (coordinates, municipality)
81 GENERAL = 32, // Default type
82};
83*/
84
85
87
89 IncludeFlagger svgIncludes;
90
91 enum ElemClass {
92 NONE = 0,
93 MAIN = 1, // Main title in SVG image
94 GROUP = 2, // Group title
95 IMAGE = 4, // Image title: small text (time, location) in corners of radar images
96 TIME = 8, // Date and time attributes
97 LOCATION = 16, // Place (coordinates, municipality)
98 GENERAL = 32, // Default type
99 ALL = (63),
100 // MAIN,
101 IMAGE_PANEL,
102 IMAGE_BORDER, // RECT surrounding the image
103 SIDE_PANEL,
104 SHARED_METADATA, // Something that should not be repeated in panels.
105 // --- unused ? ---
106 // TITLE, // Default title
107 };
109 TitleFlagger svgImageTitles; // = ElemClass::TIME|ElemClass::LOCATION|ElemClass::GENERAL;
110
111 std::string imageTitle = "TIME,LOCATION,GENERAL";
112
113 enum PathPolicy {
114 ABSOLUTE = 1, // Else is relative, stripped away using inputPrefix?
115 PREFIXED = 2, // file:// is appended
116 };
117
120
121 PathPolicyFlagger pathPolicyFlagger = ABSOLUTE;
122 std::string pathPolicy = "ABSOLUTE";
123 // bool absolutePaths = true;
124
125 std::string mainTitle = "AUTO"; // redesign?
126 std::string groupTitleSyntax = "AUTO"; // redesign?
127 std::string groupTitleFormatted;
128
129
130 /*
131 typedef drain::EnumFlagger<drain::MultiFlagger<ElemClass> > TitleFlagger;
132 TitleFlagger svgImageTitles; // = ElemClass::TIME|ElemClass::LOCATION|ElemClass::GENERAL;
133 */
134
142
148
149 inline // maxPerGroup(10), layout(Alignment::HORZ, LayoutSVG::INCR), legend(LEFT, EMBED),
150 PanelConfSVG() : svgIncludes(SvgInclude::ALL), pathPolicyFlagger(PathPolicy::ABSOLUTE), pathPolicy("ABSOLUTE") { // absolutePaths(true){
151 }
152
153
154};
155
156}
157
158
159namespace drain {
160
161template <>
163DRAIN_ENUM_OSTREAM(rack::SvgInclude);
164
165template <>
167DRAIN_ENUM_OSTREAM(rack::PanelConfSVG::ElemClass);
168
169
170template <>
172DRAIN_ENUM_OSTREAM(rack::PanelConfSVG::PathPolicy);
173
174
175template <> // for T (Tree class)
176template <> // for K (path elem arg)
177bool image::TreeSVG::hasChild(const rack::PanelConfSVG::ElemClass & key) const ;
178
179
181
184template <> // for T (Tree class)
185template <> // for K (path elem arg)
186const image::TreeSVG & image::TreeSVG::operator[](const rack::PanelConfSVG::ElemClass & value) const;
187
188
189template <> // for T (Tree class)
190template <> // for K (path elem arg)
191image::TreeSVG & image::TreeSVG::operator[](const rack::PanelConfSVG::ElemClass & key);
192
193/*
194template <> // for T (Tree class)
195template <> // for K (path elem arg)
196bool image::TreeSVG::hasChild(const rack::PanelConfSVG::ElemClass & key) const;
197
198
199template <> // for T (Tree class)
200template <> // for K (path elem arg)
201image::TreeSVG & image::TreeSVG::operator[](const rack::PanelConfSVG::ElemClass & key);
202
203template <> // for T (Tree class)
204template <> // for K (path elem arg)
205const image::TreeSVG & image::TreeSVG::operator[](const rack::PanelConfSVG::ElemClass & key) const;
206*/
207
208
209}
210
211// using namespace drain::image;
212
213
214namespace rack {
215
216using namespace drain::image;
217
218class GraphicsContext { // : public drain::BasicCommand {
219
220
221public:
222
223
224
227
229 GraphicsContext(const GraphicsContext & ctx);
230
231 TreeSVG svgTrack;
232
233 // SVG output configuration (layout)
234 PanelConfSVG svgPanelConf; // under constr
235
236 AlignBase::Axis mainOrientation = AlignBase::Axis::HORZ;
237 LayoutSVG::Direction mainDirection = LayoutSVG::Direction::INCR;
238
239 // Here AlignSVG::HorzAlign and AlignSVG::VertAlign unused, as they contain no Topol(ogy).
240 CompleteAlignment<const AlignBase::Axis, AlignBase::Axis::HORZ> alignHorz = {AlignSVG::Topol::INSIDE, AlignBase::Pos::UNDEFINED_POS};
241 CompleteAlignment<const AlignBase::Axis, AlignBase::Axis::VERT> alignVert = {AlignSVG::Topol::INSIDE, AlignBase::Pos::UNDEFINED_POS};
242
243 int svgDebug = 0;
244
246
249 // drain::image::TreeSVG & getStyle();
250
252
256 // drain::image::TreeSVG & getMainGroup();
257
258 //drain::image::TreeSVG & getCurrentAlignedGroup();
259
260 // virtual
261 // std::string getFormattedStatus(const std::string & format) const = 0;
262
263 // drain::image::TreeSVG & getCurrentAlignedGroup();
264
265 // drain::image::TreeSVG & getImagePanelGroup(const drain::FilePath & filepath);
266
267 /*
268 typedef drain::EnumFlagger<drain::MultiFlagger<ElemClass> > TitleFlagger;
269 TitleFlagger svgTitles = ElemClass::NONE;
270 */
271 // std::string svgTitles = "";
272
274 // static
275 // void applyAlignment(drain::image::TreeSVG & group);
276
277};
278
279
280
281
282// Consider moving ImageKit here?
284public:
285
286
288 ImageContext();
289
291 ImageContext(const ImageContext & ctx);
292
295
297
303
304 // Accessed by CmdSampler
305 ImageSampler imageSampler;
306
307
308 inline
309 void setCurrentImageColor(const Image & src){
310 currentImage = &src;
311 }
312
313 inline
314 void setCurrentImages(const Image & src){
315 currentImage = &src;
316 currentGrayImage = &src;
317 }
318
319 inline
320 void unsetCurrentImages(){
321 currentImage = nullptr;
322 currentGrayImage = nullptr;
323 }
324
325 void getImageStatus(drain::FlexVariableMap & statusMap) const;
326
327
329 const Image *currentImage = nullptr; // = NULL;
330
332 const Image *currentGrayImage = nullptr; // = NULL; // data or grayImage
333
334
335 Image grayImage;
336 Image colorImage;
337
338 std::string paletteKey;
339
340
341 inline
342 Palette & getPalette(){
343 return PaletteOp::getPalette(paletteKey);
344 }
345
346 Palette & getPalette(const std::string & key);
347
348
350 static
351 void getImageInfo(const Image *ptr, drain::Variable & entry);
352
353
354
355 static std::string outputQuantitySyntax;
356
357//protected:
358
359 void updateImageStatus(drain::VariableMap & statusMap) const ;
360
361
362};
363
364
365
366
367
368
369
370
371} /* namespace rack */
372
373#endif /* RACKLET_H_ */
374
375// Rack
Two-way mapping between strings and objects of template class T.
Definition Dictionary.h:63
Flagger accepting values of enum type E.
Definition EnumFlags.h:190
A map of FlexVariable:s.
Definition VariableMap.h:138
Tuple of N elements of type T.
Definition UniTuple.h:65
A map of Variables.
Definition VariableMap.h:61
Traverses image, returning samples.
Definition ImageModifierPack.h:401
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:184
Definition resources-image.h:218
GraphicsContext()
Default constructor.
Definition resources-image.cpp:162
Definition resources-image.h:283
bool imagePhysical
Defines if the next image processing operation uses scaled intentsites instead of raw byte values.
Definition resources-image.h:294
const Image * currentImage
Pointer to the last 2D data (image) processed.
Definition resources-image.h:329
static void getImageInfo(const Image *ptr, drain::Variable &entry)
Given image pointer (null ok), get properties.
Definition resources-image.cpp:293
static std::string outputQuantitySyntax
Definition resources-image.h:355
ImageContext()
Default constr.
Definition resources-image.cpp:178
ODIMPathElem::group_t qualityGroups
Defines which quality data, if any, is used as input weight.
Definition resources-image.h:302
const Image * currentGrayImage
Pointer to the last single-channel 2D data (image) processed.
Definition resources-image.h:332
unsigned int group_t
In H5, "groups" correspond to directories or folders in file system.
Definition ODIMPath.h:92
Namespace for images and image processing tools.
Definition AccumulationArray.cpp:45
Definition DataSelector.cpp:1277
DRAIN_VARIABLE Variable
Value container supporting dynamic type.
Definition Variable.h:63
Definition DataSelector.cpp:44
Wrapper for unique (static) dictionary of enum values.
Definition EnumFlags.h:66
"Alternative" partial alignment configuration for single object. Partial means that either OBJECT its...
Definition AlignSVG.h:588
Definition resources-image.h:86
drain::EnumFlagger< drain::MultiFlagger< PathPolicy > > PathPolicyFlagger
SVG file may contain several "modules", for example rows or columns of IMAGE:s. This is the name of t...
Definition resources-image.h:119
drain::UniTuple< double, 3 > boxHeights
Definition resources-image.h:147
drain::UniTuple< double, 3 > fontSizes
Definition resources-image.h:141