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
56struct ConfSVG {
57
59
60 IncludeFlagger svgIncludes;
61
64
65 PathPolicyFlagger pathPolicyFlagger = FileSVG::ABSOLUTE;
66 std::string pathPolicy = "ABSOLUTE";
67
68 // Could be better here:
69 // bool absolutePaths = true;
70
71 std::string mainTitle = "AUTO"; // redesign?
72 std::string groupIdentifier = ""; // NEW = "AUTO"; // redesign?
73 std::string groupTitle = "AUTO"; // NEW
74 // std::string groupTitleFormatted; dynamic, so better store in data-title attribute
75
76 // On hold...
77 /*
78 typedef drain::EnumFlagger<drain::MultiFlagger<ElemClass> > TitleFlagger;
79 TitleFlagger svgImageTitles; // = ElemClass::TIME|ElemClass::LOCATION|ElemClass::GENERAL;
80 */
81
89
95
96 int debug = 0;
97
98 inline // maxPerGroup(10), layout(Alignment::HORZ, LayoutSVG::INCR), legend(LEFT, EMBED),
99 ConfSVG() : svgIncludes(FileSVG::IncludePolicy::ALL), pathPolicyFlagger(FileSVG::PathPolicy::ABSOLUTE), pathPolicy("ABSOLUTE") { // absolutePaths(true){
100 }
101
102
103};
104
105using namespace drain::image;
106
107class GraphicsContext { // : public drain::BasicCommand {
108
109
110public:
111
112
113
116
118 GraphicsContext(const GraphicsContext & ctx);
119
120 TreeSVG svgTrack;
121
122 // SVG output configuration (layout)
123 ConfSVG svgPanelConf; // under constr
124
125 AlignBase::Axis mainOrientation = AlignBase::Axis::HORZ;
126 LayoutSVG::Direction mainDirection = LayoutSVG::Direction::INCR;
127
128 // Here AlignSVG::HorzAlign and AlignSVG::VertAlign unused, as they contain no Topol(ogy).
129 CompleteAlignment<const AlignBase::Axis, AlignBase::Axis::HORZ> alignHorz = {AlignSVG::Topol::INSIDE, AlignBase::Pos::UNDEFINED_POS};
130 CompleteAlignment<const AlignBase::Axis, AlignBase::Axis::VERT> alignVert = {AlignSVG::Topol::INSIDE, AlignBase::Pos::UNDEFINED_POS};
131
132 AlignAnchorSVG::anchor_t anchorHorz;
133 AlignAnchorSVG::anchor_t anchorVert;
134
135 //int svgDebug = 0;
136
137};
138
139
140
141
142// Consider moving ImageKit here?
144public:
145
146
148 ImageContext();
149
151 ImageContext(const ImageContext & ctx);
152
155
157
163
164 // Accessed by CmdSampler
165 ImageSampler imageSampler;
166
167
168 inline
169 void setCurrentImageColor(const Image & src){
170 currentImage = &src;
171 }
172
173 inline
174 void setCurrentImages(const Image & src){
175 currentImage = &src;
176 currentGrayImage = &src;
177 }
178
179 inline
180 void unsetCurrentImages(){
181 currentImage = nullptr;
182 currentGrayImage = nullptr;
183 }
184
185 void getImageStatus(drain::FlexVariableMap & statusMap) const;
186
187
189 const Image *currentImage = nullptr; // = NULL;
190
192 const Image *currentGrayImage = nullptr; // = NULL; // data or grayImage
193
194
195 Image grayImage;
196 Image colorImage;
197
198 std::string paletteKey;
199
200
201 inline
202 Palette & getPalette(){
203 return PaletteOp::getPalette(paletteKey);
204 }
205
206 Palette & getPalette(const std::string & key);
207
208
210 static
211 void getImageInfo(const Image *ptr, drain::Variable & entry);
212
213
214
215 static std::string outputQuantitySyntax;
216
217//protected:
218
219 void updateImageStatus(drain::VariableMap & statusMap) const ;
220
221
222};
223
224
225
226
227
228
229
230
231} /* namespace rack */
232
233#endif /* RACKLET_H_ */
234
235// Rack
Flagger accepting values of enum type E.
Definition EnumUtils.h:294
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
Definition TreeSVG.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:193
Direction
Direction for "Stacked", horziontally or vertically sequentially aligned layout.
Definition LayoutSVG.h:64
Definition resources-image.h:107
GraphicsContext()
Default constructor.
Definition resources-image.cpp:118
Definition resources-image.h:143
bool imagePhysical
Defines if the next image processing operation uses scaled intentsites instead of raw byte values.
Definition resources-image.h:154
const Image * currentImage
Pointer to the last 2D data (image) processed.
Definition resources-image.h:189
static void getImageInfo(const Image *ptr, drain::Variable &entry)
Given image pointer (null ok), get properties.
Definition resources-image.cpp:249
static std::string outputQuantitySyntax
Definition resources-image.h:215
ImageContext()
Default constr.
Definition resources-image.cpp:134
ODIMPathElem::group_t qualityGroups
Defines which quality data, if any, is used as input weight.
Definition resources-image.h:162
const Image * currentGrayImage
Pointer to the last single-channel 2D data (image) processed.
Definition resources-image.h:192
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
DRAIN_VARIABLE Variable
Value container supporting dynamic type.
Definition Variable.h:63
Definition DataSelector.cpp:44
Definition AlignAnchorSVG.h:76
"Alternative" partial alignment configuration for single object. Partial means that either OBJECT its...
Definition AlignSVG.h:550
Definition resources-image.h:56
drain::UniTuple< double, 3 > boxHeights
Definition resources-image.h:94
drain::UniTuple< double, 3 > fontSizes
Definition resources-image.h:88
drain::EnumFlagger< drain::MultiFlagger< FileSVG::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:63