]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/NavDisplay.hxx
Expose departure+arrival airport + runway on route-manager.
[flightgear.git] / src / Instrumentation / NavDisplay.hxx
1 // Wx Radar background texture
2 //
3 // Written by Harald JOHNSEN, started May 2005.
4 // With major amendments by Vivian MEAZZA May 2007
5 // Ported to OSG by Tim MOORE Jun 2007
6 //
7 // Copyright (C) 2005  Harald JOHNSEN - hjohnsen@evc.net
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22
23 #ifndef _INST_ND_HXX
24 #define _INST_ND_HXX
25
26 #include <osg/ref_ptr>
27 #include <osg/Geode>
28 #include <osg/Texture2D>
29 #include <osgText/Text>
30
31 #include <simgear/props/props.hxx>
32 #include <simgear/structure/subsystem_mgr.hxx>
33 #include <simgear/math/sg_geodesy.hxx>
34
35 #include <vector>
36 #include <string>
37
38 class FGODGauge;
39 class FGRouteMgr;
40 class FGNavRecord;
41
42 class NavDisplay : public SGSubsystem
43 {
44 public:
45
46     NavDisplay(SGPropertyNode *node);
47     virtual ~NavDisplay();
48
49     virtual void init();
50     virtual void update(double dt);
51
52 protected:
53     string _name;
54     int _num;
55     double _time;
56     double _updateInterval;
57
58     SGPropertyNode_ptr _serviceable_node;
59     SGPropertyNode_ptr _Instrument;
60     SGPropertyNode_ptr _radar_mode_control_node;
61
62     SGPropertyNode_ptr _user_lat_node;
63     SGPropertyNode_ptr _user_lon_node;
64     SGPropertyNode_ptr _user_heading_node;
65     SGPropertyNode_ptr _user_alt_node;
66
67     FGODGauge *_odg;
68
69     // Convenience function for creating a property node with a
70     // default value
71     template<typename DefaultType>
72     SGPropertyNode *getInstrumentNode(const char *name, DefaultType value);
73
74 private:
75     string _texture_path;
76
77     typedef enum { ARC, MAP, PLAN, ROSE, BSCAN} DisplayMode;
78     DisplayMode _display_mode;
79
80     float _scale;   // factor to convert nm to display units
81     float _view_heading;
82     bool _drawData;
83     
84     SGPropertyNode_ptr _Radar_controls;
85
86     SGPropertyNode_ptr _radar_weather_node;
87     SGPropertyNode_ptr _radar_position_node;
88     SGPropertyNode_ptr _radar_data_node;
89     SGPropertyNode_ptr _radar_symbol_node;
90     SGPropertyNode_ptr _radar_arpt_node;
91     SGPropertyNode_ptr _radar_station_node;
92     
93     SGPropertyNode_ptr _radar_centre_node;
94     SGPropertyNode_ptr _radar_coverage_node;
95     SGPropertyNode_ptr _radar_ref_rng_node;
96     SGPropertyNode_ptr _radar_hdg_marker_node;
97     SGPropertyNode_ptr _radar_rotate_node;
98     SGPropertyNode_ptr _radar_tcas_node;
99     SGPropertyNode_ptr _radar_absalt_node;
100
101     SGPropertyNode_ptr _draw_track_node;
102     SGPropertyNode_ptr _draw_heading_node;
103     SGPropertyNode_ptr _draw_north_node;
104     SGPropertyNode_ptr _draw_fix_node;
105     
106     SGPropertyNode_ptr _font_node;
107     SGPropertyNode_ptr _ai_enabled_node;
108     SGPropertyNode_ptr _navRadio1Node;
109     SGPropertyNode_ptr _navRadio2Node;
110     
111     osg::ref_ptr<osg::Texture2D> _resultTexture;
112     osg::ref_ptr<osg::Texture2D> _symbols;
113     osg::ref_ptr<osg::Geode> _radarGeode;
114     osg::ref_ptr<osg::Geode> _textGeode;
115   
116     osg::Geometry *_geom;
117   
118     osg::DrawArrays* _symbolPrimSet;
119     osg::Vec2Array *_vertices;
120     osg::Vec2Array *_texCoords;
121     osg::Vec3Array* _quadColors;
122     
123     osg::Geometry* _lineGeometry;
124     osg::DrawArrays* _linePrimSet;
125     osg::Vec2Array* _lineVertices;
126     osg::Vec3Array* _lineColors;
127   
128   
129     osg::Matrixf _centerTrans;
130     osg::Matrixf _projectMat;
131     
132     osg::ref_ptr<osgText::Font> _font;
133     osg::Vec4 _font_color;
134     osg::Vec4 _tcas_colors[4];
135     float _font_size;
136     float _font_spacing;
137
138     FGRouteMgr* _route;
139     SGGeod _pos;
140     double _rangeNm;
141     
142     void update_route();
143     void update_aircraft();
144     void update_stations();
145     void update_airports();
146     void update_waypoints();
147     
148     bool update_tcas(const SGPropertyNode *model, const SGGeod& modelPos, 
149                             double user_alt,double alt, bool absMode);
150     void update_data(const SGPropertyNode *ac, double altitude, double heading,
151                                double radius, double bearing, bool selected);
152     void updateFont();
153     
154     osg::Matrixf project(const SGGeod& geod) const;
155     osg::Vec2 projectBearingRange(double bearingDeg, double rangeNm) const;
156     osg::Vec2 projectGeod(const SGGeod& geod) const;
157     
158     void addSymbol(const SGGeod& pos, int symbolIndex, 
159         const std::string& data, const osg::Vec3& color);
160   
161     void addLine(osg::Vec2 a, osg::Vec2 b, const osg::Vec3& color);
162     
163     FGNavRecord* drawTunedNavaid(const SGPropertyNode_ptr& radio );    
164 };
165
166 #endif // _INST_ND_HXX