1 // Wx Radar background texture
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
7 // Copyright (C) 2005 Harald JOHNSEN - hjohnsen@evc.net
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.
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.
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.
26 #include <osg/ref_ptr>
28 #include <osg/Texture2D>
29 #include <osgText/Text>
31 #include <simgear/props/props.hxx>
32 #include <simgear/structure/subsystem_mgr.hxx>
33 #include <simgear/math/sg_geodesy.hxx>
41 class NavDisplay : public SGSubsystem
45 NavDisplay(SGPropertyNode *node);
46 virtual ~NavDisplay();
49 virtual void update(double dt);
60 SGPropertyNode_ptr _serviceable_node;
61 SGPropertyNode_ptr _Instrument;
62 SGPropertyNode_ptr _radar_mode_control_node;
64 SGPropertyNode_ptr _user_lat_node;
65 SGPropertyNode_ptr _user_lon_node;
66 SGPropertyNode_ptr _user_heading_node;
67 SGPropertyNode_ptr _user_alt_node;
71 // Convenience function for creating a property node with a
73 template<typename DefaultType>
74 SGPropertyNode *getInstrumentNode(const char *name, DefaultType value);
79 typedef enum { ARC, MAP, PLAN, ROSE, BSCAN} DisplayMode;
80 DisplayMode _display_mode;
82 float _scale; // factor to convert nm to display units
85 float _x_offset, _y_offset;
87 double _radar_ref_rng;
92 SGPropertyNode_ptr _Radar_controls;
94 SGPropertyNode_ptr _radar_weather_node;
95 SGPropertyNode_ptr _radar_position_node;
96 SGPropertyNode_ptr _radar_data_node;
97 SGPropertyNode_ptr _radar_symbol_node;
99 SGPropertyNode_ptr _radar_centre_node;
100 SGPropertyNode_ptr _radar_coverage_node;
101 SGPropertyNode_ptr _radar_ref_rng_node;
102 SGPropertyNode_ptr _radar_hdg_marker_node;
103 SGPropertyNode_ptr _radar_rotate_node;
104 SGPropertyNode_ptr _radar_tcas_node;
105 SGPropertyNode_ptr _radar_absalt_node;
107 SGPropertyNode_ptr _font_node;
108 SGPropertyNode_ptr _ai_enabled_node;
110 osg::ref_ptr<osg::Texture2D> _resultTexture;
111 osg::ref_ptr<osg::Texture2D> _symbols;
112 osg::ref_ptr<osg::Geode> _radarGeode;
113 osg::ref_ptr<osg::Geode> _textGeode;
115 osg::Geometry *_geom;
117 osg::DrawArrays* _symbolPrimSet;
118 osg::Vec2Array *_vertices;
119 osg::Vec2Array *_texCoords;
121 osg::Geometry* _lineGeometry;
122 osg::DrawArrays* _linePrimSet;
123 osg::Vec2Array* _lineVertices;
124 osg::Vec3Array* _lineColors;
127 osg::Matrixf _centerTrans;
128 osg::ref_ptr<osgText::Font> _font;
129 osg::Vec4 _font_color;
130 osg::Vec4 _tcas_colors[4];
139 void update_aircraft();
140 bool update_tcas(const SGPropertyNode *model,double range,double user_alt,double alt,
141 double bearing,double radius, bool absMode);
142 void update_data(const SGPropertyNode *ac, double altitude, double heading,
143 double radius, double bearing, bool selected);
146 osg::Matrixf project(const SGGeod& geod) const;
147 void addSymbol(const SGGeod& pos, int symbolIndex, const std::string& data);
150 #endif // _INST_ND_HXX