2005-10-08 11:55:18 +00:00
|
|
|
// Wx Radar background texture
|
|
|
|
//
|
|
|
|
// Written by Harald JOHNSEN, started May 2005.
|
2007-06-24 07:57:45 +00:00
|
|
|
// With major amendments by Vivian MEAZZA May 2007
|
|
|
|
// Ported to OSG by Tim MOORE Jun 2007
|
2005-10-08 11:55:18 +00:00
|
|
|
//
|
|
|
|
// Copyright (C) 2005 Harald JOHNSEN - hjohnsen@evc.net
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-10-08 11:55:18 +00:00
|
|
|
|
|
|
|
#ifndef _INST_WXRADAR_HXX
|
|
|
|
#define _INST_WXRADAR_HXX
|
|
|
|
|
2006-10-29 19:30:21 +00:00
|
|
|
#include <osg/ref_ptr>
|
2007-06-24 07:57:45 +00:00
|
|
|
#include <osg/Geode>
|
2006-10-29 19:30:21 +00:00
|
|
|
#include <osg/Texture2D>
|
2007-09-09 23:22:14 +00:00
|
|
|
#include <osgText/Text>
|
2006-04-17 13:40:20 +00:00
|
|
|
|
2005-10-08 11:55:18 +00:00
|
|
|
#include <simgear/props/props.hxx>
|
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
2005-10-16 17:31:06 +00:00
|
|
|
#include <simgear/environment/visual_enviro.hxx>
|
2005-10-08 11:55:18 +00:00
|
|
|
|
2007-06-24 07:57:45 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2008-07-27 16:25:13 +00:00
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
2007-06-24 07:57:45 +00:00
|
|
|
|
2005-10-08 11:55:18 +00:00
|
|
|
class FGODGauge;
|
|
|
|
|
2007-09-09 23:22:14 +00:00
|
|
|
class wxRadarBg : public SGSubsystem, public SGPropertyChangeListener {
|
2005-10-08 11:55:18 +00:00
|
|
|
public:
|
|
|
|
|
2008-06-02 09:32:37 +00:00
|
|
|
wxRadarBg(SGPropertyNode *node);
|
|
|
|
wxRadarBg();
|
|
|
|
virtual ~wxRadarBg();
|
2005-10-08 11:55:18 +00:00
|
|
|
|
2008-06-02 09:32:37 +00:00
|
|
|
virtual void init();
|
|
|
|
virtual void update(double dt);
|
|
|
|
virtual void valueChanged(SGPropertyNode *);
|
2005-10-08 11:55:18 +00:00
|
|
|
|
2008-06-02 09:32:37 +00:00
|
|
|
protected:
|
|
|
|
string _name;
|
|
|
|
int _num;
|
2007-06-24 22:13:25 +00:00
|
|
|
double _interval;
|
|
|
|
double _time;
|
2008-03-17 08:47:16 +00:00
|
|
|
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;
|
|
|
|
|
2008-03-22 09:19:21 +00:00
|
|
|
// Convenience function for creating a property node with a
|
|
|
|
// default value
|
|
|
|
template<typename DefaultType>
|
2008-06-02 09:32:37 +00:00
|
|
|
SGPropertyNode *getInstrumentNode(const char *name, DefaultType value);
|
2008-03-22 09:19:21 +00:00
|
|
|
|
2008-03-17 08:47:16 +00:00
|
|
|
private:
|
2007-07-03 18:24:45 +00:00
|
|
|
string _texture_path;
|
2005-10-08 11:55:18 +00:00
|
|
|
|
2007-06-29 22:44:41 +00:00
|
|
|
typedef enum { ARC, MAP, PLAN, ROSE } DisplayMode;
|
|
|
|
DisplayMode _display_mode;
|
|
|
|
|
2007-06-24 07:57:45 +00:00
|
|
|
string _last_switchKnob;
|
|
|
|
|
2007-06-29 22:44:41 +00:00
|
|
|
float _range_nm;
|
|
|
|
float _scale; // factor to convert nm to display units
|
|
|
|
float _angle_offset;
|
|
|
|
float _view_heading;
|
|
|
|
float _x_offset, _y_offset;
|
2007-06-24 07:57:45 +00:00
|
|
|
|
2008-03-17 08:47:16 +00:00
|
|
|
double _radar_ref_rng;
|
|
|
|
double _lat, _lon;
|
|
|
|
|
2007-06-24 07:57:45 +00:00
|
|
|
SGPropertyNode_ptr _Tacan;
|
|
|
|
SGPropertyNode_ptr _Radar_controls;
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _user_speed_east_fps_node;
|
|
|
|
SGPropertyNode_ptr _user_speed_north_fps_node;
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _tacan_serviceable_node;
|
|
|
|
SGPropertyNode_ptr _tacan_distance_node;
|
|
|
|
SGPropertyNode_ptr _tacan_name_node;
|
|
|
|
SGPropertyNode_ptr _tacan_bearing_node;
|
|
|
|
SGPropertyNode_ptr _tacan_in_range_node;
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _radar_weather_node;
|
|
|
|
SGPropertyNode_ptr _radar_position_node;
|
|
|
|
SGPropertyNode_ptr _radar_data_node;
|
2007-09-09 23:22:14 +00:00
|
|
|
SGPropertyNode_ptr _radar_symbol_node;
|
2008-06-01 18:08:01 +00:00
|
|
|
|
2007-06-24 07:57:45 +00:00
|
|
|
SGPropertyNode_ptr _radar_centre_node;
|
|
|
|
SGPropertyNode_ptr _radar_coverage_node;
|
|
|
|
SGPropertyNode_ptr _radar_ref_rng_node;
|
2007-06-30 08:53:06 +00:00
|
|
|
SGPropertyNode_ptr _radar_hdg_marker_node;
|
2007-09-09 23:22:14 +00:00
|
|
|
SGPropertyNode_ptr _radar_rotate_node;
|
2007-06-24 07:57:45 +00:00
|
|
|
|
2008-06-01 18:08:01 +00:00
|
|
|
SGPropertyNode_ptr _font_node;
|
2007-06-24 07:57:45 +00:00
|
|
|
SGPropertyNode_ptr _ai_enabled_node;
|
|
|
|
|
2007-06-29 22:44:41 +00:00
|
|
|
osg::ref_ptr<osg::Texture2D> _resultTexture;
|
|
|
|
osg::ref_ptr<osg::Texture2D> _wxEcho;
|
|
|
|
osg::ref_ptr<osg::Geode> _radarGeode;
|
2007-09-09 23:22:14 +00:00
|
|
|
osg::ref_ptr<osg::Geode> _textGeode;
|
2007-06-29 22:44:41 +00:00
|
|
|
osg::Geometry *_geom;
|
|
|
|
osg::Vec2Array *_vertices;
|
|
|
|
osg::Vec2Array *_texCoords;
|
|
|
|
osg::Matrixf _centerTrans;
|
2007-09-09 23:22:14 +00:00
|
|
|
osg::ref_ptr<osgText::Font> _font;
|
2008-06-01 18:08:01 +00:00
|
|
|
osg::Vec4 _font_color;
|
|
|
|
float _font_size;
|
|
|
|
float _font_spacing;
|
2007-06-24 07:57:45 +00:00
|
|
|
|
|
|
|
list_of_SGWxRadarEcho _radarEchoBuffer;
|
|
|
|
|
2007-06-29 22:44:41 +00:00
|
|
|
void update_weather();
|
|
|
|
void update_aircraft();
|
|
|
|
void update_tacan();
|
|
|
|
void update_heading_marker();
|
2009-03-17 22:01:34 +00:00
|
|
|
void update_data(const SGPropertyNode *ac, double alt, double heading,
|
|
|
|
double radius, double bearing, bool selected);
|
2007-06-29 22:44:41 +00:00
|
|
|
void center_map();
|
|
|
|
void apply_map_offset();
|
2008-03-17 08:47:16 +00:00
|
|
|
void updateFont();
|
|
|
|
void calcRangeBearing(double lat, double lon, double lat2, double lon2,
|
|
|
|
double &range, double &bearing) const;
|
|
|
|
|
2007-06-29 22:44:41 +00:00
|
|
|
bool withinRadarHorizon(double user_alt, double alt, double range);
|
2009-03-17 22:01:34 +00:00
|
|
|
bool inRadarRange(double sigma, double range);
|
2008-03-17 08:47:16 +00:00
|
|
|
|
2007-06-24 07:57:45 +00:00
|
|
|
float calcRelBearing(float bearing, float heading);
|
2005-10-08 11:55:18 +00:00
|
|
|
};
|
|
|
|
|
2008-06-01 18:08:01 +00:00
|
|
|
|
2008-03-22 09:19:21 +00:00
|
|
|
template<> inline
|
2008-06-02 09:32:37 +00:00
|
|
|
SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, bool value)
|
2008-03-22 09:19:21 +00:00
|
|
|
{
|
2008-06-02 09:32:37 +00:00
|
|
|
SGPropertyNode *result = _Instrument->getNode(name, true);
|
|
|
|
if (!result->hasValue())
|
2008-03-22 09:19:21 +00:00
|
|
|
result->setBoolValue(value);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-06-01 18:08:01 +00:00
|
|
|
|
2008-03-22 09:19:21 +00:00
|
|
|
template<> inline
|
2008-06-02 09:32:37 +00:00
|
|
|
SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, double value)
|
2008-03-22 09:19:21 +00:00
|
|
|
{
|
2008-06-02 09:32:37 +00:00
|
|
|
SGPropertyNode *result = _Instrument->getNode(name, true);
|
|
|
|
if (!result->hasValue())
|
2008-03-22 09:19:21 +00:00
|
|
|
result->setDoubleValue(value);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-06-01 18:08:01 +00:00
|
|
|
|
2008-03-22 09:19:21 +00:00
|
|
|
template<> inline
|
2008-06-02 09:32:37 +00:00
|
|
|
SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, const char *value)
|
2008-03-22 09:19:21 +00:00
|
|
|
{
|
2008-06-02 09:32:37 +00:00
|
|
|
SGPropertyNode *result = _Instrument->getNode(name, true);
|
|
|
|
if (result->hasValue())
|
2008-03-22 09:19:21 +00:00
|
|
|
result->setStringValue(value);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-08 11:55:18 +00:00
|
|
|
#endif // _INST_WXRADAR_HXX
|