X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2FNavDisplay.hxx;h=d91cf2ab58cb930993ad847c3ab184a2f053afb6;hb=9fa790bcac7e535bb06cd228ae15178f1b10b26f;hp=8d72bb80a3d93a5b4f0c2750d13e676efc6cca45;hpb=af6ed2ff3a0e8b04b42e1992e5d79c3156b7b358;p=flightgear.git diff --git a/src/Instrumentation/NavDisplay.hxx b/src/Instrumentation/NavDisplay.hxx index 8d72bb80a..d91cf2ab5 100644 --- a/src/Instrumentation/NavDisplay.hxx +++ b/src/Instrumentation/NavDisplay.hxx @@ -34,11 +34,27 @@ #include #include +#include + +#include class FGODGauge; class FGRouteMgr; class FGNavRecord; +class SymbolInstance; +class SymbolDef; +class SymbolRule; + +namespace flightgear +{ + class Waypt; +} + +typedef std::set string_set; +typedef std::vector SymbolRuleVector; +typedef std::vector SymbolDefVector; + class NavDisplay : public SGSubsystem { public: @@ -49,21 +65,32 @@ public: virtual void init(); virtual void update(double dt); + void invalidatePositionedCache() + { + _cachedItemsValid = false; + } + + double textureSize() const + { return _textureSize; } + + void forceUpdate() + { _forceUpdate = true; } + + bool anyRuleForType(const std::string& type) const; + bool isPositionedShown(FGPositioned* pos); protected: - string _name; + std::string _name; int _num; double _time; double _updateInterval; - + bool _forceUpdate; + 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; - + SGPropertyNode_ptr _testModeNode; + FGODGauge *_odg; // Convenience function for creating a property node with a @@ -72,44 +99,59 @@ protected: SGPropertyNode *getInstrumentNode(const char *name, DefaultType value); private: - string _texture_path; - - typedef enum { ARC, MAP, PLAN, ROSE, BSCAN} DisplayMode; - DisplayMode _display_mode; + friend class SymbolRule; + friend class SymbolDef; + + void addRule(SymbolRule*); + + void addSymbolsToScene(); + void addSymbolToScene(SymbolInstance* sym); + void limitDisplayedSymbols(); + + void findItems(); + void isPositionedShownInner(FGPositioned* pos, SymbolRuleVector& rules); + 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 anyRuleMatches(const std::string& type, const string_set& states) const; + void findRules(const std::string& type, const string_set& states, SymbolRuleVector& rules); + + SymbolInstance* addSymbolInstance(const osg::Vec2& proj, double heading, SymbolDef* def, SGPropertyNode* vars); + 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; + bool isProjectedClipped(const osg::Vec2& projected) const; + void updateFont(); + + void addTestSymbol(const std::string& type, const std::string& states, const SGGeod& pos, double heading, SGPropertyNode* vars); + void addTestSymbols(); + + std::string _texture_path; + unsigned int _textureSize; float _scale; // factor to convert nm to display units float _view_heading; - bool _drawData; SGPropertyNode_ptr _Radar_controls; - SGPropertyNode_ptr _radar_weather_node; - SGPropertyNode_ptr _radar_position_node; - SGPropertyNode_ptr _radar_data_node; - SGPropertyNode_ptr _radar_symbol_node; - SGPropertyNode_ptr _radar_arpt_node; - SGPropertyNode_ptr _radar_station_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 _draw_track_node; - SGPropertyNode_ptr _draw_heading_node; - SGPropertyNode_ptr _draw_north_node; - SGPropertyNode_ptr _draw_fix_node; + SGPropertyNode_ptr _font_node; SGPropertyNode_ptr _ai_enabled_node; SGPropertyNode_ptr _navRadio1Node; SGPropertyNode_ptr _navRadio2Node; - - osg::ref_ptr _resultTexture; - osg::ref_ptr _symbols; + SGPropertyNode_ptr _xCenterNode, _yCenterNode; + SGPropertyNode_ptr _viewHeadingNode; + + osg::ref_ptr _symbolTexture; osg::ref_ptr _radarGeode; osg::ref_ptr _textGeode; @@ -118,12 +160,12 @@ private: osg::DrawArrays* _symbolPrimSet; osg::Vec2Array *_vertices; osg::Vec2Array *_texCoords; - osg::Vec3Array* _quadColors; + osg::Vec4Array* _quadColors; osg::Geometry* _lineGeometry; osg::DrawArrays* _linePrimSet; osg::Vec2Array* _lineVertices; - osg::Vec3Array* _lineColors; + osg::Vec4Array* _lineColors; osg::Matrixf _centerTrans; @@ -131,36 +173,32 @@ private: osg::ref_ptr _font; osg::Vec4 _font_color; - osg::Vec4 _tcas_colors[4]; float _font_size; float _font_spacing; FGRouteMgr* _route; SGGeod _pos; double _rangeNm; + SGPropertyNode_ptr _rangeNode; - void update_route(); - void update_aircraft(); - void update_stations(); - void update_airports(); - void update_waypoints(); - - bool update_tcas(const SGPropertyNode *model, const SGGeod& modelPos, - double user_alt,double alt, bool absMode); - void update_data(const SGPropertyNode *ac, double altitude, double heading, - double radius, double bearing, bool selected); - void updateFont(); - - osg::Matrixf project(const SGGeod& geod) const; - osg::Vec2 projectBearingRange(double bearingDeg, double rangeNm) const; - osg::Vec2 projectGeod(const SGGeod& geod) const; + SymbolDefVector _definitions; + SymbolRuleVector _rules; + FGNavRecord* _nav1Station; + FGNavRecord* _nav2Station; + std::vector _symbols; + std::set _routeSources; - void addSymbol(const SGGeod& pos, int symbolIndex, - const std::string& data, const osg::Vec3& color); + bool _cachedItemsValid; + SGVec3d _cachedPos; + FGPositioned::List _itemsInRange; + SGPropertyNode_ptr _excessDataNode; + int _maxSymbols; - void addLine(osg::Vec2 a, osg::Vec2 b, const osg::Vec3& color); + class CacheListener; + std::auto_ptr _cacheListener; - FGNavRecord* drawTunedNavaid(const SGPropertyNode_ptr& radio ); + class ForceUpdateListener; + std::auto_ptr _forceUpdateListener; }; #endif // _INST_ND_HXX