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_WIREFRAME_SVG
33#define RACK_WIREFRAME_SVG
34
35// #include <string>
36#include <drain/prog/Command.h>
37
38#include "hi5/Hi5.h"
39#include "resources.h" // ctx
40
41#include "graphics-radar.h" // ctx
42
43
44
45
46namespace rack {
47
48
49
51
52protected:
53
54 drain::SteppedRange<double> radiusMetres = {0.0, 0.0, 0.0};// (50000.0, 0.0, 250000.0);
55 drain::SteppedRange<double> azimuthDegrees = {0.0, 0.0, 0.0}; // (30, 0, 360);
56 bool MASK = false;
57
58public:
59
60 /*
61 enum GRAPHIC {
62 GRID, // overlapping with element class?
63 DOT,
64 LABEL, // External
65 RAY,
66 SECTOR,
67 ANNULUS,
68 CIRCLE,
69 };
70 const drain::ClassXML cssClass;
71 */
72
73
74 inline
75 CmdPolarBase(const std::string & name, const std::string & description, Graphic::GRAPHIC cg = GRID) : Graphic(cg),
76 drain::BasicCommand(name, description + ". CSS classes: GRID," + (const std::string &)cls)
77 {
78 };
79
80 inline
81 CmdPolarBase(const CmdPolarBase & cmd): Graphic(cmd.cls), drain::BasicCommand(cmd) {
82 }
83
84
85 static
86 const std::string DATA_ID; // "data-latest"
87
101 static
102 drain::image::TreeSVG & getOverlayGroup(RackContext & ctx, RadarSVG & radarSVG);
103
104 // static
105 drain::image::TreeSVG & getOverlay(drain::image::TreeSVG & overlayGroup, const std::string & label="") const;
106
107 static
108 double ensureMetricRange(double maxRange, double range=1.0);
109
110 // todo also min,max range check
111
113
116 static
117 void resolveDistance(const drain::SteppedRange<double> & ownDist, const drain::SteppedRange<double> & sharedDist, drain::SteppedRange<double> & dist, double maxDistance = 0.0);
118
119 static
120 void resolveAzimuthRange(const drain::SteppedRange<double> & ownAzm, const drain::SteppedRange<double> & sharedAzm, drain::SteppedRange<double> & azm);
121
122};
123
124
133class CmdRadarDot : public CmdPolarBase { // drain::BasicCommand,
134
135public:
136
137 // Default: 10 kms.
138 CmdRadarDot() : CmdPolarBase(__FUNCTION__, "Mark the radar position with a circle", DOT) {
139 getParameters().link("radius", radiusMetres.range.tuple(10000.0,10000.0), "metres or relative").setFill(true);
140 getParameters().link("MASK", MASK, "add mask");
141 };
142
143 // Copy constructor
144 CmdRadarDot(const CmdRadarDot & cmd) : CmdPolarBase(cmd) {
145 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
146 }
147
148
149 virtual
150 void exec() const override;
151
152};
157class CmdRadarGrid : public CmdPolarBase { // drain::BasicCommand,
158
159 // future option
160 bool AMZ_TEXT = true;
161 bool DIST_TEXT = true;
162
163public:
164
165 inline
166 CmdRadarGrid() : CmdPolarBase(__FUNCTION__, "Draw polar sectors and rings", GRID) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
167 getParameters().link("radius", radiusMetres.tuple(0.0, 0.0, 0.0), "step:start:end (metres or relative)").fillArray = false;
168 getParameters().link("azimuth", azimuthDegrees.tuple(30.0, 0.0, 360.0), "step:start:end (degrees)").fillArray = false;
169 getParameters().link("MASK", MASK, "add a mask");
170 };
171
172 // Copy constructor
173 inline
174 CmdRadarGrid(const CmdRadarGrid & cmd) : CmdPolarBase(cmd) {
175 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
176 }
177
178 virtual
179 void exec() const override;
180
181};
182
183class CmdRadarSector : public CmdPolarBase { // public drain::BasicCommand,
184
185public:
186
187 CmdRadarSector() : CmdPolarBase(__FUNCTION__, "Draw a sector, annulus or a disc.", SECTOR) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
188 getParameters().link("radius", radiusMetres.range.tuple(0.0, 1.0), "start:end (metres or relative)").fillArray = true;
189 getParameters().link("azimuth", azimuthDegrees.range.tuple(0.0, 0.0), "start:end (degrees)").fillArray = false;
190 getParameters().link("MASK", MASK, "add a mask");
191 };
192
193 // Copy constructor
194 CmdRadarSector(const CmdRadarSector & cmd) : CmdPolarBase(cmd) {
195 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
196 }
197
198 virtual
199 void exec() const override;
200
201};
202
203
204class CmdRadarRay : public CmdPolarBase { // public drain::BasicCommand, public CmdPolarBase {
205
206public:
207
208 CmdRadarRay() : CmdPolarBase(__FUNCTION__, "Draw a sector, annulus or a disc. Styles: GRID,HIGHLIGHT,CmdPolarSector", RAY) { // __FUNCTION__, "Adjust font sizes in CSS style section.") {
209 getParameters().link("radius", radiusMetres.range.tuple(0.0, 1.0), "start:end (metres)").fillArray = true;
210 getParameters().link("azimuth", azimuthDegrees.range.min, "(degrees)");
211 getParameters().link("MASK", MASK, "add a mask");
212 };
213
214 // Copy constructor
215 CmdRadarRay(const CmdRadarRay & cmd) : CmdPolarBase(cmd) {
216 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
217 }
218
219 virtual
220 void exec() const override;
221
222};
223
224
225class CmdRadarLabel : public CmdPolarBase { // drain::BasicCommand,
226
227protected:
228
229 // Mutable, to convert escaped chars. \see StringMapper::convertEscaped(
230 // mutable
231 std::string label = "${NOD}\n${PLC}";
232
233public:
234
235 CmdRadarLabel() : CmdPolarBase(__FUNCTION__, "Draw circle describing the radar range.", LABEL) {
236 getParameters().link("label", label, "string, supporting variables like ${where:lon}, ${NOD}, ${PLC}");
237 //getParameters().link("azimuth", azimuthDegrees.tuple(), "step:start:end (degrees)").fillArray = false;
238 };
239
240 // Copy constructor
241 CmdRadarLabel(const CmdRadarLabel & cmd) : CmdPolarBase(cmd) {
242 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
243 }
244
245
246 virtual
247 void exec() const override;
248
249};
250
251
252class CmdCoords : public CmdPolarBase { // drain::BasicCommand,
253
254public:
255
256 CmdCoords() : CmdPolarBase(__FUNCTION__, "SVG test product") {
257 // getParameters().link("name", name, "label");
258 // getParameters().link("panel", panel, "label");
259 // getParameters().link("anchor", myAnchor, drain::sprinter(drain::Enum<drain::image::AnchorElem::Anchor>::dict.getKeys(), "|", "<>").str());
260 }
261
262 CmdCoords(const CmdCoords & cmd) : CmdPolarBase(cmd) {
263 // getParameters().copyStruct(cmd.getParameters(), cmd, *this);
264 }
265
266 void exec() const override ;
267};
268
269
270
271class CmdDot : public CmdPolarBase { // drain::BasicCommand,
272
274 // drain::Range<double> radius;
275 std::string id;
276 std::string style;
277
278public:
279
280 inline
281 CmdDot() : CmdPolarBase(__FUNCTION__, "Draw a marker circle", LABEL) {
282 getParameters().link("lonlat", coords.tuple(25.0, 60.0), "Coordinate (lon,lat) in degrees(decimal) or metres.");
283 getParameters().link("radius", radiusMetres.range.tuple(0,25000), "metres or relative").setFill(true);
284 getParameters().link("id", id, "XML element id");
285 getParameters().link("style", style, "XML element CSS style");
286 }
287
288 inline
289 CmdDot(const CmdDot & cmd) : CmdPolarBase(cmd) {
290 getParameters().copyStruct(cmd.getParameters(), cmd, *this);
291 }
292
293 void exec() const override;
294
295};
296
297} // rack::
298
299
300#endif
301
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
Definition Range.h:170
Definition graphics-overlay.h:252
void exec() const override
Definition graphics-overlay.cpp:819
Definition graphics-overlay.h:271
void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:709
Definition graphics-overlay.h:50
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:213
static drain::image::TreeSVG & getOverlayGroup(RackContext &ctx, RadarSVG &radarSVG)
Definition graphics-overlay.cpp:116
Definition graphics-overlay.h:133
virtual void exec() const override
Definition graphics-overlay.cpp:333
Definition graphics-overlay.h:157
virtual void exec() const override
Definition graphics-overlay.cpp:394
Definition graphics-overlay.h:225
virtual void exec() const override
Definition graphics-overlay.cpp:628
Definition graphics-overlay.h:204
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:564
Definition graphics-overlay.h:183
virtual void exec() const override
Run the command with current parameter values.
Definition graphics-overlay.cpp:506
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:133
Definition DataSelector.cpp:44
Definition Point.h:48