]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/modelmgr.hxx
Port over remaining Point3D usage to the more type and unit safe SG* classes.
[flightgear.git] / src / Model / modelmgr.hxx
index 87ee0fe76977b36e4870c96feeae991bed655dba..0b1cf53435248d91511b2181c75682fd5962b229 100644 (file)
 #include <vector>
 
 #include <simgear/compiler.h>  // for SG_USING_STD
+#include <simgear/structure/subsystem_mgr.hxx>
 
-#include <Main/fgfs.hxx>       // for FGSubsystem
-
-SG_USING_STD(vector);
+using std::vector;
 
 // Don't pull in headers, since we don't need them here.
-class ssgSelector;
 class SGPropertyNode;
-class FGModelPlacement;
+class SGModelPlacement;
 
 
 /**
  * Manage a list of user-specified models.
  */
-class FGModelMgr : public FGSubsystem
+class FGModelMgr : public SGSubsystem
 {
 public:
 
@@ -37,24 +35,26 @@ public:
    * The model manager uses the property nodes to update the model's
    * position and orientation; any of the property node pointers may
    * be set to zero to avoid update.  Normally, a caller should
-   * load the model by instantiating FGModelPlacement with the path
+   * load the model by instantiating SGModelPlacement with the path
    * to the model or its XML wrapper, then assign any relevant
    * property node pointers.
    *
-   * @see FGModelPlacement
+   * @see SGModelPlacement
    * @see FGModelMgr#add_instance
    */
   struct Instance
   {
     Instance ();
     virtual ~Instance ();
-    FGModelPlacement * model;
-    SGPropertyNode * lon_deg_node;
-    SGPropertyNode * lat_deg_node;
-    SGPropertyNode * elev_ft_node;
-    SGPropertyNode * roll_deg_node;
-    SGPropertyNode * pitch_deg_node;
-    SGPropertyNode * heading_deg_node;
+    SGModelPlacement * model;
+    SGPropertyNode_ptr node;
+    SGPropertyNode_ptr lon_deg_node;
+    SGPropertyNode_ptr lat_deg_node;
+    SGPropertyNode_ptr elev_ft_node;
+    SGPropertyNode_ptr roll_deg_node;
+    SGPropertyNode_ptr pitch_deg_node;
+    SGPropertyNode_ptr heading_deg_node;
+    bool shadow;
   };
 
   FGModelMgr ();
@@ -65,6 +65,8 @@ public:
   virtual void unbind ();
   virtual void update (double dt);
 
+  virtual void add_model (SGPropertyNode * node);
+
   /**
    * Add an instance of a dynamic model to the manager.
    *
@@ -85,13 +87,26 @@ public:
    */
   virtual void remove_instance (Instance * instance);
 
-  virtual void draw ();
 
 private:
+  /**
+   * Listener class that adds models at runtime.
+   */
+  class Listener : public SGPropertyChangeListener
+  {
+  public:
+    Listener(FGModelMgr *mgr) : _mgr(mgr) {}
+    virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child);
+    virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child);
 
-  vector<Instance *> _instances;
+  private:
+    FGModelMgr * _mgr;
+  };
 
-  ssgSelector * _selector;
+  SGPropertyNode_ptr _models;
+  Listener * _listener;
+
+  vector<Instance *> _instances;
 
 };