X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fwxradar.hxx;h=533a4587254db7db5677d47852dc66034ab09a2a;hb=5cad5aa7da2476ca8323a61f81dea59676dca085;hp=f42e8d21b54c2cc11a3ad72c8722ba060fbd355f;hpb=7ad0813990173698af00678e29215bf88233e606;p=flightgear.git diff --git a/src/Instrumentation/wxradar.hxx b/src/Instrumentation/wxradar.hxx index f42e8d21b..533a45872 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 @@ -34,58 +32,67 @@ #include #include -#include -#include #include #include -SG_USING_STD(vector); -SG_USING_STD(string); - -class FGAIBase; +using std::vector; +using std::string; class FGODGauge; 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); - virtual void valueChanged(SGPropertyNode*); + virtual void init(); + virtual void update(double dt); + virtual void valueChanged(SGPropertyNode *); -private: +protected: string _name; int _num; double _interval; double _time; + bool _sim_init_done; + + SGPropertyNode_ptr _serviceable_node; + SGPropertyNode_ptr _Instrument; + 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; + + // Convenience function for creating a property node with a + // default value + template + SGPropertyNode *getInstrumentNode(const char *name, DefaultType value); + +private: string _texture_path; typedef enum { ARC, MAP, PLAN, ROSE } DisplayMode; DisplayMode _display_mode; string _last_switchKnob; - bool _sim_init_done; float _range_nm; float _scale; // factor to convert nm to display units - double _radar_ref_rng; float _angle_offset; float _view_heading; - double _lat, _lon; float _x_offset, _y_offset; - SGPropertyNode_ptr _serviceable_node; - SGPropertyNode_ptr _Instrument; + double _radar_ref_rng; + double _lat, _lon; + SGPropertyNode_ptr _Tacan; SGPropertyNode_ptr _Radar_controls; - SGPropertyNode_ptr _user_lat_node; - SGPropertyNode_ptr _user_lon_node; - SGPropertyNode_ptr _user_heading_node; - SGPropertyNode_ptr _user_alt_node; SGPropertyNode_ptr _user_speed_east_fps_node; SGPropertyNode_ptr _user_speed_north_fps_node; @@ -99,14 +106,14 @@ private: SGPropertyNode_ptr _radar_position_node; SGPropertyNode_ptr _radar_data_node; SGPropertyNode_ptr _radar_symbol_node; - SGPropertyNode_ptr _radar_mode_control_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_font_node; + SGPropertyNode_ptr _font_node; SGPropertyNode_ptr _ai_enabled_node; osg::ref_ptr _resultTexture; @@ -118,26 +125,59 @@ private: osg::Vec2Array *_texCoords; osg::Matrixf _centerTrans; osg::ref_ptr _font; + osg::Vec4 _font_color; + float _font_size; + float _font_spacing; list_of_SGWxRadarEcho _radarEchoBuffer; - FGODGauge *_odg; - FGAIManager* _ai; - void update_weather(); void update_aircraft(); void update_tacan(); void update_heading_marker(); - void update_data(FGAIBase* ac, double radius, double bearing, bool selected); - + void update_data(const SGPropertyNode *ac, double alt, double heading, + double radius, double bearing, bool selected); void center_map(); void apply_map_offset(); - bool withinRadarHorizon(double user_alt, double alt, double range); - bool inRadarRange(int type, double range); - float calcRelBearing(float bearing, float heading); + void updateFont(); void calcRangeBearing(double lat, double lon, double lat2, double lon2, double &range, double &bearing) const; - void updateFont(); + + bool withinRadarHorizon(double user_alt, double alt, double range); + bool inRadarRange(double sigma, double range); + + float calcRelBearing(float bearing, float heading); }; + +template<> inline +SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, bool value) +{ + SGPropertyNode *result = _Instrument->getNode(name, true); + if (!result->hasValue()) + result->setBoolValue(value); + return result; +} + + +template<> inline +SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, double value) +{ + SGPropertyNode *result = _Instrument->getNode(name, true); + if (!result->hasValue()) + result->setDoubleValue(value); + return result; +} + + +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; +} + + #endif // _INST_WXRADAR_HXX