Loading...
Searching...
No Matches
graphics-base.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_GRAPHICS_BASE_SVG
33#define RACK_GRAPHICS_BASE_SVG
34
35
36#include <drain/Enum.h>
37#include <drain/util/ClassXML.h>
38#include <drain/image/TreeSVG.h>
39#include <drain/image/ImageSVG.h>
40
41
42namespace rack {
43
44class ConfSVG;
45
46
48class RackSVG {
49
50
51public:
52
53 //typedef drain::StyleSelectorXML<NodeSVG> Select;
54
55 // Identifier for the anchor background
56 // static const std::string BACKGROUND_RECT; // = "mainRect";
57
61 enum ElemClass {
62 NONE = 0,
63 MAIN_TITLE = 1, // Main title in SVG image
64 GROUP_TITLE = 2, // Group title
65 IMAGE_TITLE = 4, // Image title: small text (time, location) in corners of radar images
66 // Topical
67 TIME = 8, // Date and time attributes
68 LOCATION = 16, // Place (coordinates, municipality)
69 GENERAL = 32, // Default type
70 ALL = (63),
71 // MAIN,
72 SIDE_PANEL,
73 BORDER, // Overall border (RECT) around the SVG document, invisible by default
74 // --
75 // MOUSE, // A group marked for mouse event listeners
76 // MOUSE_TRACKER, // Area inside which mouse events will be tracked.
77 // MONITOR, // Display of interactive operations
78 //SELECTOR, // Interactive element illustrating a selection by the user
79 // DATA_ARRAY, // Image used as data array only, not to be displayed
80 // SHARED_METADATA, // Something that should not be repeated in panels.
81 // --- unused ? ---
82 // TITLE, // Default title
83 };
84
85 static
86 void addStyle(drain::image::TreeSVG & style);
87
89 static
90 const std::string & guessFormat(const std::string & key);
91
92
93
95
98 static
99 drain::image::TreeSVG & addTitleBox(const ConfSVG & conf, drain::image::TreeSVG & object, RackSVG::ElemClass elemClass);
100
101 // TODO: title area "filling order", by group class.
103
104 static
105 drain::image::TreeSVG & appendTitleElements(const ConfSVG &conf, drain::image::TreeSVG &group, const std::string &anchor, RackSVG::ElemClass elemClass);
106
107 static inline
108 drain::image::TreeSVG & appendTitleElements(const ConfSVG &conf, drain::image::TreeSVG &group, const char * anchor, RackSVG::ElemClass elemClass){
109 return appendTitleElements(conf, group, std::string(anchor), elemClass);
110 }
111
112 static inline
113 drain::image::TreeSVG & appendTitleElements(const ConfSVG &conf, drain::image::TreeSVG &group, const drain::ClassXML & anchor, RackSVG::ElemClass elemClass){
114 return appendTitleElements(conf, group, (const std::string &)anchor, elemClass);
115 }
116
117
118 template <class T>
119 static inline
120 drain::image::TreeSVG & appendTitleElements(const ConfSVG &conf, drain::image::TreeSVG &group, const T & anchorId, RackSVG::ElemClass elemClass){
121 //const drain::StringWrapper<T> anchor(anchorId);
122 const drain::EnumWrapper<T> anchor(anchorId);
123 // const std::string & s = anchor;
124 return appendTitleElements(conf, group, (const std::string &)anchor, elemClass);
125 }
126
127 static
128 void addMetaData(const drain::image::Image & src, drain::image::ImagePanel & imagePanel);
129
130};
131
132DRAIN_ENUM_OSTREAM(RackSVG::ElemClass);
133
134} // rack::
135
136
137namespace drain {
138
139DRAIN_ENUM_DICT(rack::RackSVG::ElemClass);
140
141DRAIN_GETKEY_ENUM(image::TreeSVG, rack::RackSVG::ElemClass);
142DRAIN_ENUM_CLASSXML(rack::RackSVG::ElemClass);
143
144}
145
146#endif
147
A wrapper marking string an CSS effect.
Definition ClassXML.h:57
Definition Enum.h:236
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
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1293
SVG support for creating aligned image panels.
Definition graphics-base.h:48
static drain::image::TreeSVG & addTitleBox(const ConfSVG &conf, drain::image::TreeSVG &object, RackSVG::ElemClass elemClass)
Create a title from background rectangle and TEXT elements (MAINTITLE, LOCATION, TIME,...
Definition graphics-panel.cpp:89
static drain::image::TreeSVG & appendTitleElements(const ConfSVG &conf, drain::image::TreeSVG &group, const std::string &anchor, RackSVG::ElemClass elemClass)
Add title elements in given group, to "reserve slots" for actual text content to be added later.
Definition graphics-panel.cpp:133
ElemClass
Definition graphics-base.h:61
static void addStyle(drain::image::TreeSVG &style)
Definition graphics-base.cpp:77
static const std::string & guessFormat(const std::string &key)
returns timeformat
Definition graphics-panel.cpp:65
Definition Data.h:1473
Definition AltitudeOp.cpp:42
Definition resources-svg.h:48