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/LayoutSVG.h>
41#include <drain/image/TreeSVG.h>
42#include <drain/image/TreeUtilsSVG.h>
43#include <drain/imageops/PaletteOp.h>
44#include <drain/imageops/ImageModifierPack.h>
45#include <drain/imageops/PaletteOp.h>
46#include <drain/prog/CommandBankUtils.h>
47#include <drain/util/Rectangle.h>
48
49#include "data/QuantityMap.h"
50#include "data/VariableFormatterODIM.h"
51
52
53namespace rack {
54
55
56
57struct ConfSVG {
58
60
61 IncludeFlagger svgIncludes;
62
65
66 PathPolicyFlagger pathPolicyFlagger = FileSVG::ABSOLUTE;
67 std::string pathPolicy = "ABSOLUTE";
68
69 // Could be better here:
70 // bool absolutePaths = true;
71
72 std::string mainTitle = "AUTO"; // redesign?
73 std::string groupIdentifier = ""; // NEW = "AUTO"; // redesign?
74 std::string groupTitle = "AUTO"; // NEW
75 // std::string groupTitleFormatted; dynamic, so better store in data-title attribute
76
77 // On hold...
78 /*
79 typedef drain::EnumFlagger<drain::MultiFlagger<ElemClass> > TitleFlagger;
80 TitleFlagger svgImageTitles; // = ElemClass::TIME|ElemClass::LOCATION|ElemClass::GENERAL;
81 */
82
90
96
97 int debug = 0;
98
99 inline // maxPerGroup(10), layout(Alignment::HORZ, LayoutSVG::INCR), legend(LEFT, EMBED),
100 ConfSVG() : svgIncludes(FileSVG::IncludePolicy::ALL), pathPolicyFlagger(FileSVG::PathPolicy::ABSOLUTE), pathPolicy("ABSOLUTE") { // absolutePaths(true){
101 }
102
103
104};
105
106using namespace drain::image;
107
108class GraphicsContext { // : public drain::BasicCommand {
109
110
111public:
112
113
114
117
119 GraphicsContext(const GraphicsContext & ctx);
120
121 TreeSVG svgTrack;
122
123 // SVG output configuration (layout)
124 ConfSVG svgPanelConf; // under constr
125
126 AlignBase::Axis mainOrientation = AlignBase::Axis::HORZ;
127 //LayoutSVG::Direction mainDirection = LayoutSVG::Direction::INCR;
128 LayoutSVG::DirectionHorz mainDirectionHorz = LayoutSVG::DirectionHorz::RIGHT;
129 LayoutSVG::DirectionVert mainDirectionVert = LayoutSVG::DirectionVert::DOWN;
130
131 // Here AlignSVG::HorzAlign and AlignSVG::VertAlign unused, as they contain no Topol(ogy).
132 CompleteAlignment<const AlignBase::Axis, AlignBase::Axis::HORZ> alignHorz = {MutualAlign::Topol::INSIDE, AlignBase::Pos::UNDEFINED_POS};
133 CompleteAlignment<const AlignBase::Axis, AlignBase::Axis::VERT> alignVert = {MutualAlign::Topol::INSIDE, AlignBase::Pos::UNDEFINED_POS};
134
135 AlignAnchorSVG::anchor_t anchorHorz;
136 AlignAnchorSVG::anchor_t anchorVert;
137
138 //int svgDebug = 0;
139
140};
141
142
143
144
145// Consider moving ImageKit here?
147public:
148
149
151 ImageContext();
152
154 ImageContext(const ImageContext & ctx);
155
158
160
166
167 // Accessed by CmdSampler
168 ImageSampler imageSampler;
169
170
171 inline
172 void setCurrentImageColor(const Image & src){
173 currentImage = &src;
174 }
175
176 inline
177 void setCurrentImages(const Image & src){
178 currentImage = &src;
179 currentGrayImage = &src;
180 }
181
182 inline
183 void unsetCurrentImages(){
184 currentImage = nullptr;
185 currentGrayImage = nullptr;
186 }
187
188 void getImageStatus(drain::FlexVariableMap & statusMap) const;
189
190
192 const Image *currentImage = nullptr; // = NULL;
193
195 const Image *currentGrayImage = nullptr; // = NULL; // data or grayImage
196
197
198 Image grayImage;
199 Image colorImage;
200
201 std::string paletteKey;
202 int paletteResolution = 0;
203
204 Palette & getPalette();
205
206 Palette & getPalette(const std::string & key);
207
208 void refinePalette(Palette & palette);
209
210
211 // New, returns also the actual key.
212 //PaletteMap::iterator it getPaletteEntry(const std::string & key);
213
215 static
216 void getImageInfo(const Image *ptr, drain::Variable & entry);
217
218
219
220 static
222
223//protected:
224
225 void updateImageStatus(drain::VariableMap & statusMap) const ;
226
227
228};
229
230
231
232
233
234
235
236
237} /* namespace rack */
238
239#endif /* RACKLET_H_ */
240
241// Rack
Flagger accepting values of enum type E.
Definition EnumFlagger.h:56
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:400
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:183
Definition resources-image.h:108
GraphicsContext()
Default constructor.
Definition resources-image.cpp:68
Definition resources-image.h:146
bool imagePhysical
Defines if the next image processing operation uses scaled intentsites instead of raw byte values.
Definition resources-image.h:157
const Image * currentImage
Pointer to the last 2D data (image) processed.
Definition resources-image.h:192
static void getImageInfo(const Image *ptr, drain::Variable &entry)
Given image pointer (null ok), get properties.
Definition resources-image.cpp:216
static std::string outputQuantitySyntax
Definition resources-image.h:221
ImageContext()
Default constr.
Definition resources-image.cpp:84
ODIMPathElem::group_t qualityGroups
Defines which quality data, if any, is used as input weight.
Definition resources-image.h:165
const Image * currentGrayImage
Pointer to the last single-channel 2D data (image) processed.
Definition resources-image.h:195
unsigned int group_t
In H5, "groups" correspond to directories or folders in file system.
Definition ODIMPath.h:91
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:77
"Alternative" partial alignment configuration for single object. Partial means that either OBJECT its...
Definition AlignSVG.h:256
Definition resources-image.h:57
drain::UniTuple< double, 3 > boxHeights
Definition resources-image.h:95
drain::UniTuple< double, 3 > fontSizes
Definition resources-image.h:89
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:64