resources-base.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 
32 // # pragma once
33 
34 #ifndef RACK_RESOURCES_BASE
35 #define RACK_RESOURCES_BASE
36 
37 #include <string>
38 
39 #include <drain/image/Image.h>
40 #include <drain/image/TreeUtilsSVG.h>
41 #include <drain/imageops/PaletteOp.h>
42 #include <drain/util/Static.h>
43 
44 #include "data/DataSelector.h"
45 #include "data/PolarODIM.h"
46 #include "hi5/Hi5.h"
47 
48 
49 namespace rack {
50 
51 
52 // Consider moving ImageKit here?
53 class ImageContext {
54 public:
55 
57  ImageContext();
58 
60  ImageContext(const ImageContext & ctx);
61 
64 
66 
71  //DataSelector qualitySelector;
72  //ODIMPathElemMatcher qualityGroups;
74 
75  // Accessed by CmdSampler
76  drain::image::ImageSampler imageSampler;
77 
78 
79  inline
80  void setCurrentImageColor(const drain::image::Image & src){
81  currentImage = &src;
82  }
83 
84  inline
85  void setCurrentImages(const drain::image::Image & src){
86  currentImage = &src;
87  currentGrayImage = &src;
88  }
89 
90  inline
91  void unsetCurrentImages(){
92  currentImage = NULL;
93  currentGrayImage = NULL;
94  }
95 
96  void getImageStatus(drain::FlexVariableMap & statusMap) const;
97 
98 
101 
103  const drain::image::Image *currentGrayImage; // = NULL; // data or grayImage
104 
105 
106  drain::image::Image grayImage;
107  drain::image::Image colorImage;
108 
109  std::string paletteKey;
110 
111  // New: SVG
112  drain::image::TreeSVG svgTrack;
113  drain::image::PanelConfSVG svgPanelConf;
114 
115  // New
116  inline
117  drain::image::Palette & getPalette(){
118  return drain::image::PaletteOp::getPalette(paletteKey);
119  }
120 
121  // New
122  inline
123  drain::image::Palette & getPalette(const std::string & key){
124  paletteKey = key;
125  return drain::image::PaletteOp::getPalette(key);
126  }
127 
128  /*
129  struct {
130  drain::Point2D<unsigned short> tilesize = 256;
131  } geotiff;
132  */
134 
136  static
137  void getImageInfo(const drain::image::Image *ptr, drain::Variable & entry);
138 
139 
140 
141  static std::string outputQuantitySyntax;
142 
143 //protected:
144 
145  void updateImageStatus(drain::VariableMap & statusMap) const ;
146 
147 
148 };
149 
150 
151 
152 
154 public:
155 
156  AndreContext() : andreSelect("path=dataset1:3,elangle=0:2.0"), defaultQuality(0.9) {
157  // defaultQuality initialized in respective cmd CmdQuality
158  }
159 
160  AndreContext(const AndreContext & ctx) : andreSelect(ctx.andreSelect), defaultQuality(ctx.defaultQuality) {
161  // defaultQuality initialized in respective cmd CmdQuality
162  }
163 
164  std::string andreSelect;
165 
166  float defaultQuality;
167 };
168 
169 
170 
171 
172 
173 class Hdf5Context {
174 
175 public:
176 
177  Hdf5Context();
178 
179  Hdf5Context(const Hdf5Context &ctx);
180 
181  std::string select;
182  std::string inputSelect;
183 
184 
185 
187  Hi5Tree polarInputHi5;
188 
191 
193  Hi5Tree cartesianHi5;
194 
196  Hi5Tree *currentHi5; // = &inputHi5;
197 
198 
200 
203  Hi5Tree *currentPolarHi5; // = &inputHi5;
204 
206 
207  static const h5_role::ivalue_t CURRENT; //, **< Link also external targets *
208  static const h5_role::ivalue_t INPUT; // , **< No not link, but add entry (void) *
209  // static const h5_role::value_t PRODUCT;
210  static const h5_role::ivalue_t POLAR; // =4, **< No action *
211  static const h5_role::ivalue_t CARTESIAN; // =8, **< Throw exception *
212  static const h5_role::ivalue_t EMPTY; // =16, **< Also accept empty *
213  static const h5_role::ivalue_t PRIVATE; // =32,
214  static const h5_role::ivalue_t SHARED; // =64 **< Try shared first *
215 
216 
218 
222  Hi5Tree & getMyHi5(h5_role::ivalue_t filter=(CARTESIAN|POLAR|INPUT|CURRENT));
223 
224 
226 
232  Hi5Tree & getHi5Defunct(h5_role::ivalue_t filter);
233 
235 
241  /*
242  inline
243  Hi5Tree & getCartesianHi5(h5_role::value_t filter=(PRIVATE|SHARED)){
244  return getHi5(filter | CARTESIAN);
245  }
246 
247  inline
248  Hi5Tree & getCurrentInputHi5(h5_role::value_t filter=(PRIVATE|SHARED)){
249  return getHi5(filter | CURRENT|INPUT);
250  }
251 
252  static inline
253  Hdf5Context & getStaticContext(){
254  return drain::Static::get<Hdf5Context>();
255  }
256  */
257 
258 protected:
259 
260  void updateHdf5Status(drain::VariableMap & statusMap) const; // Not static, because checks
261 
262  static Hi5Tree empty;
263 
264 };
265 
266 
267 } /* namespace rack */
268 
269 #endif /* RACKLET_H_ */
270 
271 // Rack
A map of FlexVariable:s.
Definition: VariableMap.h:138
Flags using a global dictionary.
Definition: GlobalFlags.h:81
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-base.h:153
Definition: resources-base.h:173
Hi5Tree polarInputHi5
The last input file read, typically a volume. May be concatenated ie. read in incrementally.
Definition: resources-base.h:187
Hi5Tree * currentPolarHi5
Pointer to the last HDF5 structure in polar coordinates: input volume or polar product.
Definition: resources-base.h:203
void updateHdf5Status(drain::VariableMap &statusMap) const
Derives the most relevant polar input data and returns it.
Definition: resources-base.cpp:236
Hi5Tree cartesianHi5
A single-radar Cartesian product or a multi-radar composite (mosaic).
Definition: resources-base.h:193
Hi5Tree polarProductHi5
The polar product that has been generated from the volume.
Definition: resources-base.h:190
Hi5Tree & getMyHi5(h5_role::ivalue_t filter=(CARTESIAN|POLAR|INPUT|CURRENT))
Pointer to the last HDF5 structure in Cartesian coordinates: input or Cartesian product.
Definition: resources-base.cpp:124
Hi5Tree * currentHi5
Pointer to the last HDF5 structure read or generated.
Definition: resources-base.h:196
Hi5Tree & getHi5Defunct(h5_role::ivalue_t filter)
Derives the most relevant polar data (input or product) and returns it.
Definition: resources-base.cpp:202
Definition: resources-base.h:53
bool imagePhysical
Defines if the next image processing operation uses scaled intentsites instead of raw byte values.
Definition: resources-base.h:63
static void getImageInfo(const drain::image::Image *ptr, drain::Variable &entry)
Protected:
Definition: resources-base.cpp:73
const drain::image::Image * currentGrayImage
Pointer to the last single-channel 2D data (image) processed.
Definition: resources-base.h:103
static std::string outputQuantitySyntax
Definition: resources-base.h:141
ImageContext()
Default constr.
Definition: resources-base.cpp:45
ODIMPathElem::group_t qualityGroups
Defines which quality data, if any, is used as input weight.
Definition: resources-base.h:73
const drain::image::Image * currentImage
Pointer to the last 2D data (image) processed.
Definition: resources-base.h:100
drain::Flagger::ivalue_t group_t
In H5, "groups" correspond to "directories" or "folders" in Unix and Windows.
Definition: ODIMPath.h:91
DRAIN_VARIABLE Variable
Value container supporting dynamic type.
Definition: Variable.h:63
Definition: DataSelector.cpp:44
Definition: TreeUtilsSVG.h:74