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};
159class CmdRadarGrid : public CmdPolarBase { // drain::BasicCommand,
160
161 // future option
162 bool AMZ_TEXT = true;
163 bool DIST_TEXT = true;
164
165public:
166
167 inline
168 CmdRadarGrid() : CmdPolarBase(__FUNCTION__, "Draw polar sectors and rings", GRID) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
169 getParameters().link("radius", radiusMetres.tuple(0.0, 0.0, 0.0), "step:start:end (metres or relative)").fillArray = false;
170 getParameters().link("azimuth", azimuthDegrees.tuple(30.0, 0.0, 360.0), "step:start:end (degrees)").fillArray = false;
171 getParameters().link("MASK", MASK, "add a mask");
172 };
173
174 // Copy constructor
175 inline
176 CmdRadarGrid(const CmdRadarGrid & cmd) : CmdPolarBase(cmd) {
177 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
178 }
179
180 virtual
181 void exec() const override;
182
183};
184
185class CmdRadarSector : public CmdPolarBase { // public drain::BasicCommand,
186
187public:
188
189 CmdRadarSector() : CmdPolarBase(__FUNCTION__, "Draw a sector, annulus or a disc.", SECTOR) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
190 getParameters().link("radius", radiusMetres.range.tuple(0.0, 1.0), "start:end (metres or relative)").fillArray = true;
191 getParameters().link("azimuth", azimuthDegrees.range.tuple(0.0, 0.0), "start:end (degrees)").fillArray = false;
192 getParameters().link("MASK", MASK, "add a mask");
193 };
194
195 // Copy constructor
196 CmdRadarSector(const CmdRadarSector & cmd) : CmdPolarBase(cmd) {
197 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
198 }
199
200 virtual
201 void exec() const override;
202
203};
204
205
206class CmdRadarRay : public CmdPolarBase { // public drain::BasicCommand, public CmdPolarBase {
207
208public:
209
210 CmdRadarRay() : CmdPolarBase(__FUNCTION__, "Draw a sector, annulus or a disc. Styles: GRID,HIGHLIGHT,CmdPolarSector", RAY) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
211 getParameters().link("radius", radiusMetres.range.tuple(0.0, 1.0), "start:end (metres)").fillArray = true;
212 getParameters().link("azimuth", azimuthDegrees.range.min, "(degrees)");
213 getParameters().link("MASK", MASK, "add a mask");
214 };
215
216 // Copy constructor
217 CmdRadarRay(const CmdRadarRay & cmd) : CmdPolarBase(cmd) {
218 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
219 }
220
221 virtual
222 void exec() const override;
223
224};
225
226
227class CmdRadarLabel : public CmdPolarBase { // drain::BasicCommand,
228
229protected:
230
231 // Mutable, to convert escaped chars. \see StringMapper::convertEscaped(
232 // mutable
233 std::string label = "${NOD}\n${PLC}";
234
235public:
236
237 CmdRadarLabel() : CmdPolarBase(__FUNCTION__, "Draw circle describing the radar range.", LABEL) {
238 getParameters().separator = 0;
239 getParameters().link("label", label, "string, supporting variables like ${where:lon}, ${NOD}, ${PLC}"); //.setSeparator(0);
240 //getParameters().link("azimuth", azimuthDegrees.tuple(), "step:start:end (degrees)").fillArray = false;
241 };
242
243 // Copy constructor
244 inline
245 CmdRadarLabel(const CmdRadarLabel & cmd) : CmdPolarBase(cmd) {
246 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
247 }
248
249
250 virtual
251 void exec() const override;
252
253};
254
255}
256
257#endif
258
Simple implementation of Command: adds name , description and parameters .
Definition Command.h:445
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:85
Definition Range.h:170
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:193
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:135
virtual void exec() const override
Definition graphics-overlay.cpp:347
Definition graphics-overlay.h:159
virtual void exec() const override
Definition graphics-overlay.cpp:560
Definition graphics-overlay.h:227
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:404
Definition graphics-overlay.h:206
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:730
Definition graphics-overlay.h:185
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:672
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