Loading...
Searching...
No Matches
graphics-overlay.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#ifndef RACK_SVG_OVERLAY
33#define RACK_SVG_OVERLAY
34
35//
36#include <vector>
37
38#include <drain/prog/Command.h>
39#include <drain/util/Base64.h>
40#include <drain/image/MouseEventXML.h>
41#include <drain/image/TextSVG.h>
42
43#include "resources.h" // ctx
44#include "graphics-radar.h" // ctx
45
47
48namespace drain {
49
50DRAIN_GETKEY_ENUM(drain::image::TreeSVG, drain::image::MouseXML::ElemClass);
51DRAIN_GETKEY_ENUM(drain::image::TreeSVG, drain::image::MouseXML::EventClass);
52
53}
54
55
56namespace rack {
57
59
60public:
61
62 static
63 const drain::ClassXML COORD_DISPLAY; // = "COORD_DISPLAY";
64
65 static
66 const drain::ClassXML COORDS_IMG; //
67
68 static
69 const drain::ClassXML COORDS_GEO; //
70
71 CoordBox(TreeSVG & group);
72
73};
74
76
77protected:
78
79 drain::SteppedRange<double> radiusMetres = {0.0, 0.0, 0.0};// (50000.0, 0.0, 250000.0);
80 drain::SteppedRange<double> azimuthDegrees = {0.0, 0.0, 0.0}; // (30, 0, 360);
81 //bool MASK = false;
82 std::string MASK = drain::Enum<MaskerSVG::MaskPosition>::dict.getKey(MaskerSVG::MaskPosition::NONE);
83
84 void linkMask();
85
86 void addCoordView(RackContext & ctx, const ImagePanel & superPanel) const ;
87
88 void adjustCoordBoxPosition(RackContext & ctx, const ImagePanel & superPanel) const ;
89
90public:
91
92 enum CoordUnit {
93 UNDEFINED=0,
94 PIX=1,
95 M=2,
96 DEG=4,
97 GEO=M|DEG,
98 };
99
100 // Coord units
101 std::string coordinateUnits = "DEG:M"; // better to init in gCoords only? But gRect needs also.
102
103
104 inline
105 CmdPolarBase(const std::string & name, const std::string & description, Graphic::GRAPHIC cg = GRID) : Graphic(cg),
106 drain::BasicCommand(name, description + ". CSS classes: GRID," + (const std::string &)cls)
107 {
108 };
109
110 inline
112 }
113
114
115 static
116 const std::string DATA_ID; // "data-latest"
117
121 static
123
124
125
126 // static
127 // drain::image::TreeSVG & getOverlayGroup(RackContext & ctx, RadarSVG & radarSVG);
128
129 // static
130 // drain::image::TreeSVG & getOverlay(drain::image::TreeSVG & overlayGroup, const std::string & label="") const;
131
132 static
133 double ensureMetricRange(double maxRange, double range=1.0);
134
135 // todo also min,max range check
136
138
141 static
143
144 static
146
148
151 static
153
154 // New
155 // static?
159 // TreeSVG & getInteractiveOverlay(RackContext & ctx, RadarSVG & radarSVG, bool fixedAEQD=true) const;
160
161
162};
163
164}
165
166namespace drain {
167
168DRAIN_ENUM_DICT(rack::CmdPolarBase::CoordUnit);
169
170}
171
172namespace rack {
173
182class CmdRadarDot : public CmdPolarBase { // drain::BasicCommand,
183
184public:
185
186 // Default: 10 kms.
187 CmdRadarDot() : CmdPolarBase(__FUNCTION__, "Mark the radar position with a circle", DOT) {
188 getParameters().link("radius", radiusMetres.range.tuple(10000.0,10000.0), "metres or relative").setFill(true);
189 getParameters().link("MASK", MASK, "add mask");
190 };
191
192 // Copy constructor
194 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
195 }
196
197
198 virtual
199 void exec() const override;
200
201};
202
203
204/*
205class CmdRadarDotTest : public CmdPolarBase { // drain::BasicCommand,
206
207public:
208
209 // Default: 10 kms.
210 CmdRadarDotTest() : CmdPolarBase(__FUNCTION__, "Mark the radar position with a circle", DOT) {
211 getParameters().link("radius", radiusMetres.range.tuple(10000.0,10000.0), "metres or relative").setFill(true);
212 getParameters().link("MASK", MASK, "add mask");
213 };
214
215 // Copy constructor
216 CmdRadarDotTest(const CmdRadarDotTest & cmd) : CmdPolarBase(cmd) {
217 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
218 }
219
220
221 virtual
222 void exec() const override;
223
224};
225*/
226
227
232class CmdRadarGrid : public CmdPolarBase { // drain::BasicCommand,
233
234 // future option
235 bool AMZ_TEXT = true;
236 bool DIST_TEXT = true;
237
238public:
239
240 inline
241 CmdRadarGrid() : CmdPolarBase(__FUNCTION__, "Draw polar sectors and rings", GRID) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
242 getParameters().link("radius", radiusMetres.tuple(0.0, 0.0, 0.0), "step:start:end (metres or relative)").fillArray = false;
243 getParameters().link("azimuth", azimuthDegrees.tuple(30.0, 0.0, 360.0), "step:start:end (degrees)").fillArray = false;
244 getParameters().link("MASK", MASK, "add a mask");
245 };
246
247 // Copy constructor
248 inline
250 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
251 }
252
253 virtual
254 void exec() const override;
255
256};
257
258class CmdRadarSector : public CmdPolarBase { // public drain::BasicCommand,
259
260public:
261
262 CmdRadarSector() : CmdPolarBase(__FUNCTION__, "Draw a sector, annulus or a disc.", SECTOR) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
263 getParameters().link("radius", radiusMetres.range.tuple(0.0, 1.0), "start:end (metres or relative)").fillArray = true;
264 getParameters().link("azimuth", azimuthDegrees.range.tuple(0.0, 0.0), "start:end (degrees)").fillArray = false;
265 getParameters().link("MASK", MASK, "add a mask");
266 };
267
268 // Copy constructor
270 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
271 }
272
273 virtual
274 void exec() const override;
275
276};
277
278
279class CmdRadarRay : public CmdPolarBase { // public drain::BasicCommand, public CmdPolarBase {
280
281public:
282
283 CmdRadarRay() : CmdPolarBase(__FUNCTION__, "Draw a sector, annulus or a disc. Styles: GRID,HIGHLIGHT,CmdPolarSector", RAY) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
284 getParameters().link("radius", radiusMetres.range.tuple(0.0, 1.0), "start:end (metres)").fillArray = true;
285 getParameters().link("azimuth", azimuthDegrees.range.min, "(degrees)");
286 getParameters().link("MASK", MASK, drain::sprinter(drain::Enum<MaskerSVG::MaskPosition>::dict.getKeys()).str());
287 // drain::Enum<MaskerSVG::MaskPosition>::dict.getKeys();
288 // drain::Enum<MaskerSVG::MaskPosition>::dict
289 };
290
291 // Copy constructor
293 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
294 }
295
296 virtual
297 void exec() const override;
298
299};
300
301
302class CmdRadarLabel : public CmdPolarBase { // drain::BasicCommand,
303
304protected:
305
306 // Mutable, to convert escaped chars. \see StringMapper::convertEscaped(
307 // mutable
308 std::string label = "${NOD}\n${PLC}";
309
310public:
311
312 CmdRadarLabel() : CmdPolarBase(__FUNCTION__, "Draw circle describing the radar range.", LABEL) {
314 getParameters().link("label", label, "string, supporting variables like ${where:lon}, ${NOD}, ${PLC}"); //.setSeparator(0);
315 //getParameters().link("azimuth", azimuthDegrees.tuple(), "step:start:end (degrees)").fillArray = false;
316 };
317
318 // Copy constructor
319 inline
321 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
322 }
323
324
325 virtual
326 void exec() const override;
327
328};
329
330}
331
332
333#endif
334
Simple implementation of Command: adds name , description and parameters .
Definition Command.h:461
virtual const drain::ReferenceMap & getParameters() const
Returns the command parameters.
Definition Command.h:396
A wrapper marking string an CSS effect.
Definition ClassXML.h:57
void copyStruct(const ReferenceMap &m, const T &src, T &dst, extLinkPolicy policy=RESERVE)
Experimental. Copies references and values of a structure to another.
Definition ReferenceMap.h:412
char separator
Default character used for splitting input and output. See setValues.
Definition SmartMap.h:81
Definition Range.h:170
Creator of SVG image elements located in a SVG group with fixed structure.
Definition ImageSVG.h:62
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:183
Definition MouseEventXML.h:51
ElemClass
Definition MouseXML.h:73
Definition TreeSVG.h:135
Definition TextSVG.h:56
Definition graphics-overlay.h:75
void linkMask()
Definition graphics-overlay.cpp:116
static void updateRadarSVG(RackContext &ctx, RadarSVG &radarSVG)
Definition graphics-overlay.cpp:230
static void addGeoData(const drain::image::Image &imageData, drain::image::NodeSVG &node)
Add EPGS, bounding box, encoding, quantity.
Definition graphics-overlay.cpp:419
static void resolveDistance(const drain::SteppedRange< double > &ownDist, const drain::SteppedRange< double > &sharedDist, drain::SteppedRange< double > &dist, double maxDistance=0.0)
Given a distance or a distance range, ensure metric (if relative) and also validate generally.
Definition graphics-overlay.cpp:309
Definition graphics-overlay.h:182
virtual void exec() const override
Definition graphics-overlay.cpp:449
Definition graphics-overlay.h:232
virtual void exec() const override
Definition graphics-overlay.cpp:822
Definition graphics-overlay.h:302
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:620
Definition graphics-overlay.h:279
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:1017
Definition graphics-overlay.h:258
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:948
Definition graphics-overlay.h:58
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1293
Definition graphics-radar.h:50
Resources provided separately for each thread.
Definition resources.h:70
Vector graphics for both composites and single radar data (polar coordinates).
Definition graphics-radar.h:142
Definition Data.h:1473
Definition AltitudeOp.cpp:42
A container for a static dictionary of enumeration values.
Definition Enum.h:51
static const std::string & getKey(const std::string &s, bool lenient=true)
Convenience for object.set(...) like commands.
Definition Enum.h:144