]> git.mxchange.org Git - simgear.git/blob - simgear/canvas/elements/CanvasMap.hxx
Clean up Canvas element creation
[simgear.git] / simgear / canvas / elements / CanvasMap.hxx
1 // A group of 2D Canvas elements which get automatically transformed according
2 // to the map parameters.
3 //
4 // Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Library General Public
8 // License as published by the Free Software Foundation; either
9 // version 2 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Library General Public License for more details.
15 //
16 // You should have received a copy of the GNU Library General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
19
20 #ifndef CANVAS_MAP_HXX_
21 #define CANVAS_MAP_HXX_
22
23 #include "CanvasGroup.hxx"
24
25 #include <boost/shared_ptr.hpp>
26 #include <boost/unordered_map.hpp>
27
28 namespace simgear
29 {
30 namespace canvas
31 {
32   class GeoNodePair;
33   class HorizontalProjection;
34   class Map:
35     public Group
36   {
37     public:
38       Map( const CanvasWeakPtr& canvas,
39            const SGPropertyNode_ptr& node,
40            const Style& parent_style );
41       virtual ~Map();
42
43       virtual void update(double dt);
44
45       virtual void childAdded( SGPropertyNode * parent,
46                                SGPropertyNode * child );
47       virtual void childRemoved( SGPropertyNode * parent,
48                                  SGPropertyNode * child );
49       virtual void valueChanged(SGPropertyNode * child);
50
51     protected:
52
53       virtual void childChanged(SGPropertyNode * child);
54
55       typedef boost::unordered_map< SGPropertyNode*,
56                                     boost::shared_ptr<GeoNodePair>
57                                   > GeoNodes;
58       GeoNodes _geo_nodes;
59       boost::shared_ptr<HorizontalProjection> _projection;
60       bool _projection_dirty;
61
62       struct GeoCoord
63       {
64         GeoCoord():
65           type(INVALID)
66         {}
67         enum
68         {
69           INVALID,
70           LATITUDE,
71           LONGITUDE
72         } type;
73         double value;
74       };
75
76       GeoCoord parseGeoCoord(const std::string& val) const;
77   };
78
79 } // namespace canvas
80 } // namespace simgear
81
82 #endif /* CANVAS_MAP_HXX_ */