fileio-svg.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 
32 #ifndef RACK_FILE_IO_SVG
33 #define RACK_FILE_IO_SVG
34 
35 #include <string>
36 
37 #include <drain/prog/CommandBank.h>
38 #include <drain/prog/CommandInstaller.h>
39 
40 #include <drain/util/FileInfo.h>
41 //#include <drain/util/RegExp.h>
42 // #include <drain/util/TreeHTML.h>
43 
44 
45 #include "hi5/Hi5.h"
46 
47 #include "resources.h"
48 
49 namespace rack {
50 
51 
56 
57 public:
58 
59  inline
61  };
62 
63  typedef std::map<std::string, unsigned short> variableStat_t;
64 
65  int visitPrefix(TreeSVG & tree, const TreeSVG::path_t & path);
66 
67  inline
68  int visitPostfix(TreeSVG & tree, const TreeSVG::path_t & path);
69 
70 };
71 
76 
77 public:
78 
79  inline
81  };
82 
83  typedef std::map<std::string, unsigned short> variableStat_t;
84 
85  int visitPrefix(TreeSVG & tree, const TreeSVG::path_t & path);
86 
87  inline
88  int visitPostfix(TreeSVG & tree, const TreeSVG::path_t & path);
89 
90 };
91 
96 
97 public:
98 
99  int mainHeaderHeight;
100 
101  inline
102  TitleCreatorSVG() : mainHeaderHeight(50) {
103  };
104 
105 
106  inline
107  int visitPrefix(TreeSVG & tree, const TreeSVG::path_t & odimPath){
108  return 0;
109  }
110 
111  inline
112  int visitPostfix(TreeSVG & tree, const TreeSVG::path_t & odimPath);
113 
114 };
115 
116 
117 
120 
121 
122 public:
123 
124  // void exec() const;
125 
126  static
127  drain::image::TreeSVG & getMain(RackContext & ctx);
128 
129 
130  static
131  drain::image::TreeSVG & getCurrentGroup(RackContext & ctx);
132 
133 
134  static
135  drain::image::TreeSVG & addImage(RackContext & ctx, const drain::image::Image & src, const drain::FilePath & filepath);
136 
138  static
139  drain::image::TreeSVG & addImage(RackContext & ctx, const drain::image::TreeSVG & svg, const drain::FilePath & filepath);
140 
142  static
143  drain::image::TreeSVG & addImage(RackContext & ctx, const drain::FilePath & filepath, const drain::Frame2D<double> & frame = {640,400});
144 
145 
147 // static
148 // void generateTitles(RackContext & ctx);
149 
150  // Re-align elements etc
151  static
152  void completeSVG(RackContext & ctx, const drain::FilePath & filepath);
153 
155  // static
156  // const std::string & getTextClass(const std::string & key, const std::string & defaultClass = "");
157 
158 protected:
159 
160  // Under construction...
161  // static
162  // void createTitleBox(TreeSVG & tree);
163 
164 };
165 
166 
169 
170 public:
171 
172  inline
173  CmdOutputPanel() : drain::BasicCommand(__FUNCTION__, "Save SVG panel of latest images. See also: --image, --outputRawImages.") {
174  getParameters().link("filename", filename="");
175  getParameters().link("layout", layout, "basic");
176  };
177 
179  getParameters().copyStruct(cmd.getParameters(), cmd, *this);
180  }
181 
182 
183  void exec() const;
184 
185 
186  std::string layout;
187  std::string filename;
188 
189  void appendImage(TreeSVG & group, const std::string & prefix, drain::VariableMap & vmap,
190  const drain::Point2D<double> & location, const drain::image::Image & image, drain::BBox & bbox) const;
191 };
192 
193 
194 
195 } // rack::
196 
197 
198 #endif
199 
Container for geographical extent spanned by lowerLeft(x,y) and upperRight(x,y). Assumes longitude=x ...
Definition: BoundingBox.h:46
Simple implementation of Command: adds name , description and parameters .
Definition: Command.h:417
Extracts and stores directory path, base filename and extension.
Definition: FilePath.h:58
Definition: Frame.h:49
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:399
A map of Variables.
Definition: VariableMap.h:61
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition: Image.h:184
SVG panel utils.
Definition: fileio-svg.h:119
static void completeSVG(RackContext &ctx, const drain::FilePath &filepath)
Traverse groups, collecting info, recognizing common (shared) variables and pruning them recursively.
Definition: fileio-svg.cpp:622
SVG panel.
Definition: fileio-svg.h:168
void exec() const
Definition: fileio-svg.cpp:925
Definition: fileio-svg.h:55
Definition: fileio-svg.h:75
int visitPostfix(TreeSVG &tree, const TreeSVG::path_t &path)
Definition: fileio-svg.cpp:87
Resources provided separately for each thread.
Definition: resources.h:67
Definition: fileio-svg.h:95
Definition: DataSelector.cpp:44
Definition: TreeSVG.h:52