2011-06-04 17:41:25 +00:00
|
|
|
// Wx Radar background texture
|
|
|
|
//
|
|
|
|
// Written by Harald JOHNSEN, started May 2005.
|
|
|
|
// With major amendments by Vivian MEAZZA May 2007
|
|
|
|
// Ported to OSG by Tim MOORE Jun 2007
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
#ifndef _INST_ND_HXX
|
|
|
|
#define _INST_ND_HXX
|
|
|
|
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/Geode>
|
|
|
|
#include <osg/Texture2D>
|
|
|
|
#include <osgText/Text>
|
|
|
|
|
|
|
|
#include <simgear/props/props.hxx>
|
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
|
|
|
#include <simgear/math/sg_geodesy.hxx>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2011-11-07 19:40:30 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <Navaids/positioned.hxx>
|
2011-06-04 17:41:25 +00:00
|
|
|
|
|
|
|
class FGODGauge;
|
|
|
|
class FGRouteMgr;
|
2011-06-13 21:34:00 +00:00
|
|
|
class FGNavRecord;
|
2011-07-03 16:56:01 +00:00
|
|
|
|
|
|
|
class SymbolInstance;
|
|
|
|
class SymbolDef;
|
|
|
|
|
|
|
|
namespace flightgear
|
|
|
|
{
|
|
|
|
class Waypt;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef std::set<std::string> string_set;
|
|
|
|
typedef std::vector<SymbolDef*> SymbolDefVector;
|
2011-06-04 17:41:25 +00:00
|
|
|
|
|
|
|
class NavDisplay : public SGSubsystem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NavDisplay(SGPropertyNode *node);
|
|
|
|
virtual ~NavDisplay();
|
|
|
|
|
|
|
|
virtual void init();
|
|
|
|
virtual void update(double dt);
|
|
|
|
|
2011-11-07 19:40:30 +00:00
|
|
|
void invalidatePositionedCache()
|
|
|
|
{
|
|
|
|
_cachedItemsValid = false;
|
|
|
|
}
|
2011-06-04 17:41:25 +00:00
|
|
|
protected:
|
2011-10-17 16:41:59 +00:00
|
|
|
std::string _name;
|
2011-06-04 17:41:25 +00:00
|
|
|
int _num;
|
|
|
|
double _time;
|
2011-06-13 21:34:00 +00:00
|
|
|
double _updateInterval;
|
2011-06-04 17:41:25 +00:00
|
|
|
|
|
|
|
SGPropertyNode_ptr _serviceable_node;
|
|
|
|
SGPropertyNode_ptr _Instrument;
|
|
|
|
SGPropertyNode_ptr _radar_mode_control_node;
|
|
|
|
SGPropertyNode_ptr _user_heading_node;
|
2011-12-22 14:07:06 +00:00
|
|
|
SGPropertyNode_ptr _testModeNode;
|
|
|
|
|
2011-06-04 17:41:25 +00:00
|
|
|
FGODGauge *_odg;
|
|
|
|
|
|
|
|
// Convenience function for creating a property node with a
|
|
|
|
// default value
|
|
|
|
template<typename DefaultType>
|
|
|
|
SGPropertyNode *getInstrumentNode(const char *name, DefaultType value);
|
|
|
|
|
|
|
|
private:
|
2011-07-03 16:56:01 +00:00
|
|
|
void addSymbolsToScene();
|
|
|
|
void addSymbolToScene(SymbolInstance* sym);
|
|
|
|
void limitDisplayedSymbols();
|
|
|
|
|
|
|
|
void findItems();
|
|
|
|
void foundPositionedItem(FGPositioned* pos);
|
|
|
|
void computePositionedPropsAndHeading(FGPositioned* pos, SGPropertyNode* nd, double& heading);
|
|
|
|
void computePositionedState(FGPositioned* pos, string_set& states);
|
|
|
|
void processRoute();
|
|
|
|
void computeWayptPropsAndHeading(flightgear::Waypt* wpt, const SGGeod& pos, SGPropertyNode* nd, double& heading);
|
|
|
|
void processNavRadios();
|
|
|
|
FGNavRecord* processNavRadio(const SGPropertyNode_ptr& radio);
|
|
|
|
void processAI();
|
|
|
|
void computeAIStates(const SGPropertyNode* ai, string_set& states);
|
|
|
|
|
|
|
|
bool anyRuleForType(const std::string& type) const;
|
|
|
|
bool anyRuleMatches(const std::string& type, const string_set& states) const;
|
|
|
|
void findRules(const std::string& type, const string_set& states, SymbolDefVector& rules);
|
|
|
|
|
2012-01-08 17:47:13 +00:00
|
|
|
SymbolInstance* addSymbolInstance(const osg::Vec2& proj, double heading, SymbolDef* def, SGPropertyNode* vars);
|
2011-07-03 16:56:01 +00:00
|
|
|
void addLine(osg::Vec2 a, osg::Vec2 b, const osg::Vec4& color);
|
|
|
|
osg::Vec2 projectBearingRange(double bearingDeg, double rangeNm) const;
|
|
|
|
osg::Vec2 projectGeod(const SGGeod& geod) const;
|
2011-11-07 19:40:30 +00:00
|
|
|
bool isProjectedClipped(const osg::Vec2& projected) const;
|
2011-07-03 16:56:01 +00:00
|
|
|
void updateFont();
|
|
|
|
|
2011-12-22 14:07:06 +00:00
|
|
|
void addTestSymbol(const std::string& type, const std::string& states, const SGGeod& pos, double heading, SGPropertyNode* vars);
|
|
|
|
void addTestSymbols();
|
|
|
|
|
2011-10-17 16:41:59 +00:00
|
|
|
std::string _texture_path;
|
2011-06-04 17:41:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
float _scale; // factor to convert nm to display units
|
|
|
|
float _view_heading;
|
|
|
|
|
|
|
|
SGPropertyNode_ptr _Radar_controls;
|
|
|
|
|
2011-07-03 16:56:01 +00:00
|
|
|
|
2011-06-13 21:34:00 +00:00
|
|
|
|
2011-06-04 17:41:25 +00:00
|
|
|
SGPropertyNode_ptr _font_node;
|
|
|
|
SGPropertyNode_ptr _ai_enabled_node;
|
2011-06-13 21:34:00 +00:00
|
|
|
SGPropertyNode_ptr _navRadio1Node;
|
|
|
|
SGPropertyNode_ptr _navRadio2Node;
|
|
|
|
|
2011-06-04 17:41:25 +00:00
|
|
|
osg::ref_ptr<osg::Texture2D> _resultTexture;
|
2011-07-03 16:56:01 +00:00
|
|
|
osg::ref_ptr<osg::Texture2D> _symbolTexture;
|
2011-06-04 17:41:25 +00:00
|
|
|
osg::ref_ptr<osg::Geode> _radarGeode;
|
|
|
|
osg::ref_ptr<osg::Geode> _textGeode;
|
|
|
|
|
|
|
|
osg::Geometry *_geom;
|
|
|
|
|
|
|
|
osg::DrawArrays* _symbolPrimSet;
|
|
|
|
osg::Vec2Array *_vertices;
|
|
|
|
osg::Vec2Array *_texCoords;
|
2011-07-03 16:56:01 +00:00
|
|
|
osg::Vec4Array* _quadColors;
|
2011-06-13 21:34:00 +00:00
|
|
|
|
2011-06-04 17:41:25 +00:00
|
|
|
osg::Geometry* _lineGeometry;
|
|
|
|
osg::DrawArrays* _linePrimSet;
|
|
|
|
osg::Vec2Array* _lineVertices;
|
2011-07-03 16:56:01 +00:00
|
|
|
osg::Vec4Array* _lineColors;
|
2011-06-04 17:41:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
osg::Matrixf _centerTrans;
|
2011-06-13 21:34:00 +00:00
|
|
|
osg::Matrixf _projectMat;
|
|
|
|
|
2011-06-04 17:41:25 +00:00
|
|
|
osg::ref_ptr<osgText::Font> _font;
|
|
|
|
osg::Vec4 _font_color;
|
|
|
|
float _font_size;
|
|
|
|
float _font_spacing;
|
|
|
|
|
|
|
|
FGRouteMgr* _route;
|
|
|
|
SGGeod _pos;
|
|
|
|
double _rangeNm;
|
2011-11-07 19:40:30 +00:00
|
|
|
SGPropertyNode_ptr _rangeNode;
|
|
|
|
|
2011-07-03 16:56:01 +00:00
|
|
|
SymbolDefVector _rules;
|
|
|
|
FGNavRecord* _nav1Station;
|
|
|
|
FGNavRecord* _nav2Station;
|
|
|
|
std::vector<SymbolInstance*> _symbols;
|
|
|
|
std::set<FGPositioned*> _routeSources;
|
2011-11-07 19:40:30 +00:00
|
|
|
|
|
|
|
bool _cachedItemsValid;
|
|
|
|
SGVec3d _cachedPos;
|
|
|
|
FGPositioned::List _itemsInRange;
|
2011-07-03 16:56:01 +00:00
|
|
|
SGPropertyNode_ptr _excessDataNode;
|
2011-11-07 19:40:30 +00:00
|
|
|
|
|
|
|
class CacheListener;
|
|
|
|
std::auto_ptr<CacheListener> _cacheListener;
|
2011-06-04 17:41:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _INST_ND_HXX
|