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
129 // Here AlignSVG::HorzAlign and AlignSVG::VertAlign unused, as they contain no Topol(ogy).
130 CompleteAlignment<const AlignBase::Axis, AlignBase::Axis::HORZ> alignHorz = {MutualAlign::Topol::INSIDE, AlignBase::Pos::UNDEFINED_POS};
131 CompleteAlignment<const AlignBase::Axis, AlignBase::Axis::VERT> alignVert = {MutualAlign::Topol::INSIDE, AlignBase::Pos::UNDEFINED_POS};
132
133 AlignAnchorSVG::anchor_t anchorHorz;
134 AlignAnchorSVG::anchor_t anchorVert;
135
136 //int svgDebug = 0;
137
138};
139
140
141
142
143// Consider moving ImageKit here?
145public:
146
147
149 ImageContext();
150
152 ImageContext(const ImageContext & ctx);
153
156
158
164
165 // Accessed by CmdSampler
166 ImageSampler imageSampler;
167
168
169 inline
170 void setCurrentImageColor(const Image & src){
171 currentImage = &src;
172 }
173
174 inline
175 void setCurrentImages(const Image & src){
176 currentImage = &src;
177 currentGrayImage = &src;
178 }
179
180 inline
181 void unsetCurrentImages(){
182 currentImage = nullptr;
183 currentGrayImage = nullptr;
184 }
185
186 void getImageStatus(drain::FlexVariableMap & statusMap) const;
187
188
190 const Image *currentImage = nullptr; // = NULL;
191
193 const Image *currentGrayImage = nullptr; // = NULL; // data or grayImage
194
195
196 Image grayImage;
197 Image colorImage;
198
199 std::string paletteKey;
200 int paletteResolution = 0;
201
202 Palette & getPalette();
203
204 Palette & getPalette(const std::string & key);
205
206 void refinePalette(Palette & palette);
207
208
209 // New, returns also the actual key.
210 //PaletteMap::iterator it getPaletteEntry(const std::string & key);
211
213 static
214 void getImageInfo(const Image *ptr, drain::Variable & entry);
215
216
217
218 static
220
221//protected:
222
223 void updateImageStatus(drain::VariableMap & statusMap) const ;
224
225
226};
227
228
229
230
231
232
233
234
235} /* namespace rack */
236
237#endif /* RACKLET_H_ */
238
239// 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
Direction
Direction for "Stacked", horziontally or vertically sequentially aligned layout.
Definition LayoutSVG.h:64
Definition resources-image.h:108
GraphicsContext()
Default constructor.
Definition resources-image.cpp:118
Definition resources-image.h:144
bool imagePhysical
Defines if the next image processing operation uses scaled intentsites instead of raw byte values.
Definition resources-image.h:155
const Image * currentImage
Pointer to the last 2D data (image) processed.
Definition resources-image.h:190
static void getImageInfo(const Image *ptr, drain::Variable &entry)
Given image pointer (null ok), get properties.
Definition resources-image.cpp:270
static std::string outputQuantitySyntax
Definition resources-image.h:219
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:163
const Image * currentGrayImage
Pointer to the last single-channel 2D data (image) processed.
Definition resources-image.h:193
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