]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/NavDisplay.hxx
Merge branch 'next' of gitorious.org:fg/flightgear into next
[flightgear.git] / src / Instrumentation / NavDisplay.hxx
index 7f4b0f283eabad4731a91cf2bdd73e3ec5191cca..d91cf2ab58cb930993ad847c3ab184a2f053afb6 100644 (file)
 
 #include <vector>
 #include <string>
+#include <memory>
+
+#include <Navaids/positioned.hxx>
 
 class FGODGauge;
 class FGRouteMgr;
 class FGNavRecord;
-class FGPositioned;
 
 class SymbolInstance;
 class SymbolDef;
+class SymbolRule;
 
 namespace flightgear
 {
@@ -49,6 +52,7 @@ namespace flightgear
 }
 
 typedef std::set<std::string> string_set;
+typedef std::vector<SymbolRule*> SymbolRuleVector;
 typedef std::vector<SymbolDef*> SymbolDefVector;
 
 class NavDisplay : public SGSubsystem
@@ -61,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:
     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
@@ -84,11 +99,17 @@ protected:
     SGPropertyNode *getInstrumentNode(const char *name, DefaultType value);
 
 private:
+    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);
@@ -99,19 +120,22 @@ private:
     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);
+    void findRules(const std::string& type, const string_set& states, SymbolRuleVector& rules);
     
-    void addSymbolInstance(const osg::Vec2& proj, double heading, SymbolDef* def, SGPropertyNode* vars);
+    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;
@@ -124,8 +148,9 @@ private:
     SGPropertyNode_ptr _ai_enabled_node;
     SGPropertyNode_ptr _navRadio1Node;
     SGPropertyNode_ptr _navRadio2Node;
-    
-    osg::ref_ptr<osg::Texture2D> _resultTexture;
+    SGPropertyNode_ptr _xCenterNode, _yCenterNode;
+    SGPropertyNode_ptr _viewHeadingNode;
+  
     osg::ref_ptr<osg::Texture2D> _symbolTexture;
     osg::ref_ptr<osg::Geode> _radarGeode;
     osg::ref_ptr<osg::Geode> _textGeode;
@@ -154,13 +179,26 @@ private:
     FGRouteMgr* _route;
     SGGeod _pos;
     double _rangeNm;
-
-    SymbolDefVector _rules;
+    SGPropertyNode_ptr _rangeNode;
+    
+    SymbolDefVector _definitions;
+    SymbolRuleVector _rules;
     FGNavRecord* _nav1Station;
     FGNavRecord* _nav2Station;
     std::vector<SymbolInstance*> _symbols;
     std::set<FGPositioned*> _routeSources;
+    
+    bool _cachedItemsValid;
+    SGVec3d _cachedPos;
+    FGPositioned::List _itemsInRange;
     SGPropertyNode_ptr _excessDataNode;
+    int _maxSymbols;
+  
+    class CacheListener;
+    std::auto_ptr<CacheListener> _cacheListener;
+    
+    class ForceUpdateListener;
+    std::auto_ptr<ForceUpdateListener> _forceUpdateListener;
 };
 
 #endif // _INST_ND_HXX