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.
25 #ifndef _INST_WXRADAR_HXX
26 #define _INST_WXRADAR_HXX
28 #include <osg/ref_ptr>
30 #include <osg/Texture2D>
32 #include <simgear/props/props.hxx>
33 #include <simgear/structure/subsystem_mgr.hxx>
34 #include <simgear/environment/visual_enviro.hxx>
36 #include <AIModel/AIBase.hxx>
37 #include <AIModel/AIManager.hxx>
47 class wxRadarBg : public SGSubsystem {
50 wxRadarBg ( SGPropertyNode *node );
52 virtual ~wxRadarBg ();
55 virtual void update (double dt);
63 typedef enum { ARC, MAP, PLAN, ROSE } DisplayMode;
64 DisplayMode _display_mode;
66 string _last_switchKnob;
70 float _scale; // factor to convert nm to display units
71 double _radar_ref_rng;
75 float _x_offset, _y_offset;
77 SGPropertyNode_ptr _serviceable_node;
78 SGPropertyNode_ptr _Instrument;
79 SGPropertyNode_ptr _Tacan;
80 SGPropertyNode_ptr _Radar_controls;
82 SGPropertyNode_ptr _user_lat_node;
83 SGPropertyNode_ptr _user_lon_node;
84 SGPropertyNode_ptr _user_heading_node;
85 SGPropertyNode_ptr _user_alt_node;
86 SGPropertyNode_ptr _user_speed_east_fps_node;
87 SGPropertyNode_ptr _user_speed_north_fps_node;
89 SGPropertyNode_ptr _tacan_serviceable_node;
90 SGPropertyNode_ptr _tacan_distance_node;
91 SGPropertyNode_ptr _tacan_name_node;
92 SGPropertyNode_ptr _tacan_bearing_node;
93 SGPropertyNode_ptr _tacan_in_range_node;
95 SGPropertyNode_ptr _radar_weather_node;
96 SGPropertyNode_ptr _radar_position_node;
97 SGPropertyNode_ptr _radar_data_node;
98 SGPropertyNode_ptr _radar_mode_control_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;
104 SGPropertyNode_ptr _ai_enabled_node;
106 osg::ref_ptr<osg::Texture2D> _resultTexture;
107 osg::ref_ptr<osg::Texture2D> _wxEcho;
108 osg::ref_ptr<osg::Geode> _radarGeode;
109 osg::Geometry *_geom;
110 osg::Vec2Array *_vertices;
111 osg::Vec2Array *_texCoords;
112 osg::Matrixf _centerTrans;
114 list_of_SGWxRadarEcho _radarEchoBuffer;
119 void update_weather();
120 void update_aircraft();
122 void update_heading_marker();
125 void apply_map_offset();
126 bool withinRadarHorizon(double user_alt, double alt, double range);
127 bool inRadarRange(int type, double range);
128 float calcRelBearing(float bearing, float heading);
129 void calcRangeBearing(double lat, double lon, double lat2, double lon2,
130 double &range, double &bearing) const;
133 #endif // _INST_WXRADAR_HXX