]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/wxradar.hxx
b31842612795ffbf97bd8d1ac6d259f20d6b0e7b
[flightgear.git] / src / Instrumentation / wxradar.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 //
24
25 #ifndef _INST_WXRADAR_HXX
26 #define _INST_WXRADAR_HXX
27
28 #include <osg/ref_ptr>
29 #include <osg/Geode>
30 #include <osg/Texture2D>
31
32 #include <simgear/props/props.hxx>
33 #include <simgear/structure/subsystem_mgr.hxx>
34 #include <simgear/environment/visual_enviro.hxx>
35
36 #include <AIModel/AIBase.hxx>
37 #include <AIModel/AIManager.hxx>
38 #include <vector>
39 #include <string>
40 SG_USING_STD(vector);
41 SG_USING_STD(string);
42
43 class FGAIBase;
44
45 class FGODGauge;
46
47 class wxRadarBg : public SGSubsystem {
48 public:
49
50     wxRadarBg ( SGPropertyNode *node );
51     wxRadarBg ();
52     virtual ~wxRadarBg ();
53
54     virtual void init ();
55     virtual void update (double dt);
56
57 private:
58
59     string _name;
60     int _num;
61
62     string _last_switchKnob;
63     bool _sim_init_done;
64
65     double _user_speed_east_fps;
66     double _user_speed_north_fps;
67
68     float _x_displacement;
69     float _y_displacement;
70     float _x_sym_displacement;
71     float _y_sym_displacement;
72
73     SGPropertyNode_ptr _serviceable_node;
74     SGPropertyNode_ptr _Instrument;
75     SGPropertyNode_ptr _Tacan;
76     SGPropertyNode_ptr _Radar_controls;
77
78     SGPropertyNode_ptr _user_lat_node;
79     SGPropertyNode_ptr _user_lon_node;
80     SGPropertyNode_ptr _user_heading_node;
81     SGPropertyNode_ptr _user_alt_node;
82     SGPropertyNode_ptr _user_speed_east_fps_node;
83     SGPropertyNode_ptr _user_speed_north_fps_node;
84
85     SGPropertyNode_ptr _tacan_serviceable_node;
86     SGPropertyNode_ptr _tacan_distance_node;
87     SGPropertyNode_ptr _tacan_name_node;
88     SGPropertyNode_ptr _tacan_bearing_node;
89     SGPropertyNode_ptr _tacan_in_range_node;
90
91     SGPropertyNode_ptr _radar_weather_node;
92     SGPropertyNode_ptr _radar_position_node;
93     SGPropertyNode_ptr _radar_data_node;
94     SGPropertyNode_ptr _radar_mode_control_node;
95     SGPropertyNode_ptr _radar_centre_node;
96     SGPropertyNode_ptr _radar_coverage_node;
97     SGPropertyNode_ptr _radar_ref_rng_node;
98
99     SGPropertyNode_ptr _ai_enabled_node;
100
101     osg::ref_ptr<osg::Texture2D> resultTexture;
102     osg::ref_ptr<osg::Texture2D> wxEcho;
103     osg::ref_ptr<osg::Geode> radarGeode;
104
105     list_of_SGWxRadarEcho _radarEchoBuffer;
106
107     FGODGauge *_odg;
108     FGAIManager* _ai;
109
110     bool calcRadarHorizon(double user_alt, double alt, double range);
111     bool calcMaxRange(int type, double range);
112
113     void calcRngBrg(double lat, double lon, double lat2, double lon2,
114             double &range, double &bearing) const;
115
116     void updateRadar();
117
118     float calcRelBearing(float bearing, float heading);
119
120     // A list of pointers to AI objects
121     typedef list <SGSharedPtr<FGAIBase> > radar_list_type;
122     typedef radar_list_type::iterator radar_list_iterator;
123     typedef radar_list_type::const_iterator radar_list_const_iterator;
124
125     radar_list_type _radar_list;
126 };
127
128 #endif // _INST_WXRADAR_HXX