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
41#include "hi5/Hi5.h"
42#include "resources.h" // ctx
43#include "graphics-radar.h" // ctx
44
45
46
47
48namespace rack {
49
50
51
53
54protected:
55
56 drain::SteppedRange<double> radiusMetres = {0.0, 0.0, 0.0};// (50000.0, 0.0, 250000.0);
57 drain::SteppedRange<double> azimuthDegrees = {0.0, 0.0, 0.0}; // (30, 0, 360);
58 bool MASK = false;
59
60public:
61
62 /*
63 enum GRAPHIC {
64 GRID, // overlapping with element class?
65 DOT,
66 LABEL, // External
67 RAY,
68 SECTOR,
69 ANNULUS,
70 CIRCLE,
71 };
72 const drain::ClassXML cssClass;
73 */
74
75
76 inline
77 CmdPolarBase(const std::string & name, const std::string & description, Graphic::GRAPHIC cg = GRID) : Graphic(cg),
78 drain::BasicCommand(name, description + ". CSS classes: GRID," + (const std::string &)cls)
79 {
80 };
81
82 inline
83 CmdPolarBase(const CmdPolarBase & cmd): Graphic(cmd.cls), drain::BasicCommand(cmd) {
84 }
85
86
87 static
88 const std::string DATA_ID; // "data-latest"
89
90
94 static
95 drain::image::TreeSVG & getOverlayGroup(RackContext & ctx, RadarSVG & radarSVG);
96
97 // static
98 drain::image::TreeSVG & getOverlay(drain::image::TreeSVG & overlayGroup, const std::string & label="") const;
99
100 static
101 double ensureMetricRange(double maxRange, double range=1.0);
102
103 // todo also min,max range check
104
106
109 static
110 void resolveDistance(const drain::SteppedRange<double> & ownDist, const drain::SteppedRange<double> & sharedDist, drain::SteppedRange<double> & dist, double maxDistance = 0.0);
111
112 static
113 void resolveAzimuthRange(const drain::SteppedRange<double> & ownAzm, const drain::SteppedRange<double> & sharedAzm, drain::SteppedRange<double> & azm);
114
116
119 static
120 void addGeoData(const drain::image::Image & imageData, drain::image::NodeSVG & node);
121
122
123
124};
125
126
135class CmdRadarDot : public CmdPolarBase { // drain::BasicCommand,
136
137public:
138
139 // Default: 10 kms.
140 CmdRadarDot() : CmdPolarBase(__FUNCTION__, "Mark the radar position with a circle", DOT) {
141 getParameters().link("radius", radiusMetres.range.tuple(10000.0,10000.0), "metres or relative").setFill(true);
142 getParameters().link("MASK", MASK, "add mask");
143 };
144
145 // Copy constructor
146 CmdRadarDot(const CmdRadarDot & cmd) : CmdPolarBase(cmd) {
147 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
148 }
149
150
151 virtual
152 void exec() const override;
153
154};
155
156class CmdRadarDotTest : public CmdPolarBase { // drain::BasicCommand,
157
158public:
159
160 // Default: 10 kms.
161 CmdRadarDotTest() : CmdPolarBase(__FUNCTION__, "Mark the radar position with a circle", DOT) {
162 getParameters().link("radius", radiusMetres.range.tuple(10000.0,10000.0), "metres or relative").setFill(true);
163 getParameters().link("MASK", MASK, "add mask");
164 };
165
166 // Copy constructor
167 CmdRadarDotTest(const CmdRadarDotTest & cmd) : CmdPolarBase(cmd) {
168 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
169 }
170
171
172 virtual
173 void exec() const override;
174
175};
176
177
182class CmdRadarGrid : public CmdPolarBase { // drain::BasicCommand,
183
184 // future option
185 bool AMZ_TEXT = true;
186 bool DIST_TEXT = true;
187
188public:
189
190 inline
191 CmdRadarGrid() : CmdPolarBase(__FUNCTION__, "Draw polar sectors and rings", GRID) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
192 getParameters().link("radius", radiusMetres.tuple(0.0, 0.0, 0.0), "step:start:end (metres or relative)").fillArray = false;
193 getParameters().link("azimuth", azimuthDegrees.tuple(30.0, 0.0, 360.0), "step:start:end (degrees)").fillArray = false;
194 getParameters().link("MASK", MASK, "add a mask");
195 };
196
197 // Copy constructor
198 inline
199 CmdRadarGrid(const CmdRadarGrid & cmd) : CmdPolarBase(cmd) {
200 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
201 }
202
203 virtual
204 void exec() const override;
205
206};
207
208class CmdRadarSector : public CmdPolarBase { // public drain::BasicCommand,
209
210public:
211
212 CmdRadarSector() : CmdPolarBase(__FUNCTION__, "Draw a sector, annulus or a disc.", SECTOR) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
213 getParameters().link("radius", radiusMetres.range.tuple(0.0, 1.0), "start:end (metres or relative)").fillArray = true;
214 getParameters().link("azimuth", azimuthDegrees.range.tuple(0.0, 0.0), "start:end (degrees)").fillArray = false;
215 getParameters().link("MASK", MASK, "add a mask");
216 };
217
218 // Copy constructor
219 CmdRadarSector(const CmdRadarSector & cmd) : CmdPolarBase(cmd) {
220 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
221 }
222
223 virtual
224 void exec() const override;
225
226};
227
228
229class CmdRadarRay : public CmdPolarBase { // public drain::BasicCommand, public CmdPolarBase {
230
231public:
232
233 CmdRadarRay() : CmdPolarBase(__FUNCTION__, "Draw a sector, annulus or a disc. Styles: GRID,HIGHLIGHT,CmdPolarSector", RAY) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
234 getParameters().link("radius", radiusMetres.range.tuple(0.0, 1.0), "start:end (metres)").fillArray = true;
235 getParameters().link("azimuth", azimuthDegrees.range.min, "(degrees)");
236 getParameters().link("MASK", MASK, "add a mask");
237 };
238
239 // Copy constructor
240 CmdRadarRay(const CmdRadarRay & cmd) : CmdPolarBase(cmd) {
241 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
242 }
243
244 virtual
245 void exec() const override;
246
247};
248
249
250class CmdRadarLabel : public CmdPolarBase { // drain::BasicCommand,
251
252protected:
253
254 // Mutable, to convert escaped chars. \see StringMapper::convertEscaped(
255 // mutable
256 std::string label = "${NOD}\n${PLC}";
257
258public:
259
260 CmdRadarLabel() : CmdPolarBase(__FUNCTION__, "Draw circle describing the radar range.", LABEL) {
261 getParameters().separator = 0;
262 getParameters().link("label", label, "string, supporting variables like ${where:lon}, ${NOD}, ${PLC}"); //.setSeparator(0);
263 //getParameters().link("azimuth", azimuthDegrees.tuple(), "step:start:end (degrees)").fillArray = false;
264 };
265
266 // Copy constructor
267 inline
268 CmdRadarLabel(const CmdRadarLabel & cmd) : CmdPolarBase(cmd) {
269 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
270 }
271
272
273 virtual
274 void exec() const override;
275
276};
277
278}
279
280#endif
281
Simple implementation of Command: adds name , description and parameters .
Definition Command.h:443
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:415
char separator
Default character used for splitting input and output. See setValues.
Definition SmartMap.h:81
Definition Range.h:170
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:183
Definition TreeSVG.h:182
Definition graphics-overlay.h:52
static void addGeoData(const drain::image::Image &imageData, drain::image::NodeSVG &node)
Add EPGS, bounding box, encoding, quantity.
Definition graphics-overlay.cpp:320
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:215
static drain::image::TreeSVG & getOverlayGroup(RackContext &ctx, RadarSVG &radarSVG)
Definition graphics-overlay.cpp:89
Definition graphics-overlay.h:156
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:412
Definition graphics-overlay.h:135
virtual void exec() const override
Definition graphics-overlay.cpp:347
Definition graphics-overlay.h:182
virtual void exec() const override
Definition graphics-overlay.cpp:652
Definition graphics-overlay.h:250
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:496
Definition graphics-overlay.h:229
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:822
Definition graphics-overlay.h:208
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:764
Definition graphics-radar.h:49
Resources provided separately for each thread.
Definition resources.h:67
Vector graphics for both composites and single radar data (polar coordinates).
Definition graphics-radar.h:134
Definition DataSelector.cpp:44