X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fwxradar.hxx;h=7aff7771718b2be81c13b5b560f3de7d2b8a3223;hb=0b9adf8854398461333eba43df18fa2f5c8231a1;hp=b31842612795ffbf97bd8d1ac6d259f20d6b0e7b;hpb=143e3f34d43613bd70194eca206cb3e48014f222;p=flightgear.git diff --git a/src/Instrumentation/wxradar.hxx b/src/Instrumentation/wxradar.hxx index b31842612..7aff77717 100644 --- a/src/Instrumentation/wxradar.hxx +++ b/src/Instrumentation/wxradar.hxx @@ -19,8 +19,6 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// -// #ifndef _INST_WXRADAR_HXX #define _INST_WXRADAR_HXX @@ -28,57 +26,85 @@ #include #include #include +#include #include #include -#include -#include -#include #include #include -SG_USING_STD(vector); -SG_USING_STD(string); - -class FGAIBase; class FGODGauge; -class wxRadarBg : public SGSubsystem { +class wxRadarBg : public SGSubsystem, public SGPropertyChangeListener { public: - wxRadarBg ( SGPropertyNode *node ); - wxRadarBg (); - virtual ~wxRadarBg (); + wxRadarBg(SGPropertyNode *node); + wxRadarBg(); + virtual ~wxRadarBg(); - virtual void init (); - virtual void update (double dt); - -private: + virtual void init(); + virtual void update(double dt); + virtual void valueChanged(SGPropertyNode *); - string _name; +protected: + std::string _name; int _num; - - string _last_switchKnob; - bool _sim_init_done; - - double _user_speed_east_fps; - double _user_speed_north_fps; - - float _x_displacement; - float _y_displacement; - float _x_sym_displacement; - float _y_sym_displacement; + double _time; + double _interval; + double _elapsed_time; + double _persistance; SGPropertyNode_ptr _serviceable_node; + SGPropertyNode_ptr _sceneryLoaded; SGPropertyNode_ptr _Instrument; - SGPropertyNode_ptr _Tacan; - SGPropertyNode_ptr _Radar_controls; + SGPropertyNode_ptr _radar_mode_control_node; SGPropertyNode_ptr _user_lat_node; SGPropertyNode_ptr _user_lon_node; SGPropertyNode_ptr _user_heading_node; SGPropertyNode_ptr _user_alt_node; + + FGODGauge *_odg; + + typedef struct { + double bearing; + double range; + double elevation; + double bumpiness; + double elapsed_time; + }ground_echo; + + typedef std::vector ground_echo_vector_type; + typedef ground_echo_vector_type::iterator ground_echo_vector_iterator; + + ground_echo_vector_type ground_echoes; + ground_echo_vector_iterator ground_echoes_iterator; + + // Convenience function for creating a property node with a + // default value + template + SGPropertyNode *getInstrumentNode(const char *name, DefaultType value); + +private: + std::string _texture_path; + + typedef enum { ARC, MAP, PLAN, ROSE, BSCAN} DisplayMode; + DisplayMode _display_mode; + + float _range_nm; + float _scale; // factor to convert nm to display units + float _angle_offset; + float _view_heading; + float _x_offset, _y_offset; + + double _radar_ref_rng; + double _lat, _lon; + double _antenna_ht; + + SGPropertyNode_ptr _Tacan; + SGPropertyNode_ptr _Radar_controls; + SGPropertyNode_ptr _user_speed_east_fps_node; SGPropertyNode_ptr _user_speed_north_fps_node; @@ -91,38 +117,86 @@ private: SGPropertyNode_ptr _radar_weather_node; SGPropertyNode_ptr _radar_position_node; SGPropertyNode_ptr _radar_data_node; - SGPropertyNode_ptr _radar_mode_control_node; + SGPropertyNode_ptr _radar_symbol_node; + SGPropertyNode_ptr _radar_centre_node; SGPropertyNode_ptr _radar_coverage_node; SGPropertyNode_ptr _radar_ref_rng_node; + SGPropertyNode_ptr _radar_hdg_marker_node; + SGPropertyNode_ptr _radar_rotate_node; + SGPropertyNode_ptr _radar_tcas_node; + SGPropertyNode_ptr _radar_absalt_node; + SGPropertyNode_ptr _font_node; SGPropertyNode_ptr _ai_enabled_node; - osg::ref_ptr resultTexture; - osg::ref_ptr wxEcho; - osg::ref_ptr radarGeode; + osg::ref_ptr _resultTexture; + osg::ref_ptr _wxEcho; + osg::ref_ptr _radarGeode; + osg::ref_ptr _textGeode; + osg::Geometry *_geom; + osg::Vec2Array *_vertices; + osg::Vec2Array *_texCoords; + osg::Matrixf _centerTrans; + osg::ref_ptr _font; + osg::Vec4 _font_color; + osg::Vec4 _tcas_colors[4]; + float _font_size; + float _font_spacing; + +// FIXME: implementation of radar echoes missing +// list_of_SGWxRadarEcho _radarEchoBuffer; + + void update_weather(); + void update_aircraft(); + void update_tacan(); + void update_heading_marker(); + void update_data(const SGPropertyNode *ac, double alt, double heading, + double radius, double bearing, bool selected); + bool update_tcas(const SGPropertyNode *model,double range,double user_alt,double alt, + double bearing,double radius, bool absMode); + void center_map(); + void apply_map_offset(); + void updateFont(); + void calcRangeBearing(double lat, double lon, double lat2, double lon2, + double &range, double &bearing) const; + + bool withinRadarHorizon(double user_alt, double alt, double range); + bool inRadarRange(double sigma, double range); - list_of_SGWxRadarEcho _radarEchoBuffer; + float calcRelBearing(float bearing, float heading); + float calcRelBearingDeg(float bearing, float heading); +}; - FGODGauge *_odg; - FGAIManager* _ai; - bool calcRadarHorizon(double user_alt, double alt, double range); - bool calcMaxRange(int type, double range); +template<> inline +SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, bool value) +{ + SGPropertyNode *result = _Instrument->getNode(name, true); + if (!result->hasValue()) + result->setBoolValue(value); + return result; +} - void calcRngBrg(double lat, double lon, double lat2, double lon2, - double &range, double &bearing) const; - void updateRadar(); +template<> inline +SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, double value) +{ + SGPropertyNode *result = _Instrument->getNode(name, true); + if (!result->hasValue()) + result->setDoubleValue(value); + return result; +} - float calcRelBearing(float bearing, float heading); - // A list of pointers to AI objects - typedef list > radar_list_type; - typedef radar_list_type::iterator radar_list_iterator; - typedef radar_list_type::const_iterator radar_list_const_iterator; +template<> inline +SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, const char *value) +{ + SGPropertyNode *result = _Instrument->getNode(name, true); + if (result->hasValue()) + result->setStringValue(value); + return result; +} - radar_list_type _radar_list; -}; #endif // _INST_WXRADAR_HXX