Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/visu.git] / src / VISU_I / VISU_Prs3d_i.hh
index d7bf76280339d94ac7700b9505b319cd272762a0..92df8102554c8d7ceeab6d1e4073634a503e3e38 100644 (file)
 #include "VISU_ConvertorDef.hxx"
 
 #include "SALOME_GenericObj_i.hh"
+#include "SALOME_GenericObjPointer.hh"
 #include "SALOME_InteractiveObject.hxx"
 
 #include "VTKViewer.h"
 
 #include <vtkSmartPointer.h>
+#include <vtkTimeStamp.h>
 
 class VISU_PipeLine;
 class VISU_Actor;
 
 class vtkPlane;
 class vtkActorCollection;
-class vtkUnstructuredGrid;
+class vtkDataSet;
 
 namespace VISU
 {
+  //----------------------------------------------------------------------------
   class Result_i;
 
+
+  //----------------------------------------------------------------------------
+  struct TResultObserver: public virtual boost::signalslib::trackable
+  {
+    virtual
+    void
+    UpdateFromResult(Result_i* theResult) = 0;
+  };
+
+
   //----------------------------------------------------------------------------
   //! Base class for all VTK 3D presentations.
   /*!
@@ -61,27 +74,22 @@ namespace VISU
     - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors);
     - implement common 3D functionality like "clipping planes" and offset.
   */
-  class Prs3d_i :
-    public virtual POA_VISU::Prs3d,
-    public virtual SALOME::GenericObj_i,
-    public virtual TActorFactory,
-    public virtual PrsObject_i
+  class VISU_I_EXPORT Prs3d_i : public virtual POA_VISU::Prs3d,
+                               public virtual SALOME::GenericObj_i,
+                               public virtual TActorFactory,
+                               public virtual PrsObject_i
 
   {
-    Prs3d_i();
     Prs3d_i(const Prs3d_i&);
 
   public:
     //----------------------------------------------------------------------------
-    //! A constructor to create a fresh instance of the class
-    explicit
-    Prs3d_i(Result_i* theResult,
-           bool theAddToStudy);
+    typedef PrsObject_i TSuperClass;
+    typedef VISU::Prs3d TInterface;
 
-    //! A constructor to restore an instance of the class
-    explicit
-    Prs3d_i(Result_i* theResult,
-           SALOMEDS::SObject_ptr theSObject);
+    //----------------------------------------------------------------------------
+    //! A constructor to create a fresh instance of the class
+    Prs3d_i();
 
     //! To create a deep copy from another instance of the class
     virtual
@@ -91,6 +99,38 @@ namespace VISU
     virtual
     ~Prs3d_i();
 
+    //----------------------------------------------------------------------------
+    virtual
+    CORBA::Boolean 
+    Apply(bool theReInit);
+
+    //----------------------------------------------------------------------------
+    void 
+    SetCResult(Result_i* theResult);
+
+    Result_i* 
+    GetCResult() const;
+
+    virtual
+    void 
+    SetResultObject(VISU::Result_ptr theResult);
+
+    virtual
+    VISU::Result_ptr
+    GetResultObject();
+
+    //----------------------------------------------------------------------------
+    virtual
+    void 
+    SetMeshName(const char* theMeshName);
+
+    virtual
+    char*
+    GetMeshName();
+
+    std::string
+    GetCMeshName() const;
+
     //----------------------------------------------------------------------------
     //! To generate an unique type name for the class (used into persistent functionality)
     virtual
@@ -102,29 +142,23 @@ namespace VISU
     QString
     GenerateName() = 0;
 
-    //! To restore paramters of the instance from Storable::TRestoringMap
-    virtual
-    Storable* 
-    Restore(const Storable::TRestoringMap& theMap);
-
     //! To save paramters of the instance to std::ostringstream
     virtual
     void
     ToStream(std::ostringstream& theStr);
 
-    //----------------------------------------------------------------------------
-    //! Get corresponding Result_i
-    Result_i* 
-    GetResult() const;
+    //! To restore paramters of the instance from Storable::TRestoringMap
+    virtual
+    Storable* 
+    Restore(SALOMEDS::SObject_ptr theSObject,
+           const Storable::TRestoringMap& theMap);
 
+    //----------------------------------------------------------------------------
     //! Get corresponding SALOMEDS::SObject
     virtual
     SALOMEDS::SObject_var 
     GetSObject();
 
-    const std::string& 
-    GetMeshName() const;
-
     //----------------------------------------------------------------------------
     //! To update is internal state
     virtual 
@@ -139,17 +173,20 @@ namespace VISU
     //----------------------------------------------------------------------------
     //! Get corresponding VISU_PipeLine
     VISU_PipeLine* 
-    GetPL();
+    GetPipeLine() const;
+
+    bool
+    IsPipeLineExists();
 
     //! Get input of the VISU_PipeLine
-    vtkUnstructuredGrid
+    vtkDataSet
     GetInput();
 
     //----------------------------------------------------------------------------
     //! To define a way to create VTK representation of the instance
     virtual 
     VISU_Actor* 
-    CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0;
+    CreateActor() = 0;
 
     //! To unregister the pointed actor
     virtual 
@@ -194,18 +231,25 @@ namespace VISU
     void
     GetBounds(vtkFloatingPointType aBounds[6]);
 
+    int
+    GetNumberOfActors ();
+
+    //! Move the 3D presentation according to the given offset parameters
     void
     SetOffset(const CORBA::Float* theOffsets);
 
+    //! Move the 3D presentation according to the given offset parameters
     virtual
     void
     SetOffset(CORBA::Float theDx, 
              CORBA::Float theDy, 
              CORBA::Float theDz);
 
+    //! Gets offset parameters for the 3D presentation
     void
     GetOffset(CORBA::Float* theOffsets);
 
+    //! Gets offset parameters for the 3D presentation
     virtual
     void
     GetOffset(CORBA::Float& theDx, 
@@ -213,51 +257,105 @@ namespace VISU
              CORBA::Float& theDz);
 
     //----------------------------------------------------------------------------
+    //! Gets memory size actually used by the presentation (Mb).
+    virtual
+    CORBA::Float
+    GetMemorySize();
+
+    //----------------------------------------------------------------------------
+    //! Gets know whether the factory instance can be used for actor management or not
+    virtual
+    bool 
+    GetActiveState();
+
+    //----------------------------------------------------------------------------
+    //! Return modified time of the presentation
+    virtual
+    unsigned long int 
+    GetMTime();
+
+    //----------------------------------------------------------------------------
+    //! Create and return the interactive object
+    virtual
+    Handle(SALOME_InteractiveObject)
+    GetIO();
+
+    //! Used in derived classes to initilize the IO for actors
+    virtual
+    std::string
+    GetActorEntry();
+
   protected:
+    /*! 
+      Used in Apply method to get know whether it is possible to create presentation
+      with the input parameters or not. The derived classes can use this method 
+      to customize Apply behaviour.
+    */
+    virtual 
+    bool 
+    SetInput(bool theReInit);
+
+    //! Restore input parameters if Apply function fails
+    virtual 
+    void 
+    OnRestoreInput();
+
+    //! Used in derived classes to initilize the myPipeLine member
+    void
+    SetPipeLine(VISU_PipeLine* thePipeLine);
+
+    //! Used in derived classes to initilize the myPipeLine member
     void
-    CreateActor(VISU_Actor* theActor, 
-               const Handle(SALOME_InteractiveObject)& theIO = NULL);
+    CreateActor(VISU_Actor* theActor);
 
+    //! Gets or creates VISU_PipeLine instance for actor initilization
     virtual 
     VISU_PipeLine* 
-    GetPipeLine();
+    GetActorPipeLine();
 
     //! To check dataset validity, throws std::exception if not valid
     virtual
     void
     CheckDataSet();
 
-    bool myAddToStudy;
-    CORBA::Float myOffset[3];
-    Result_i *myResult;
-    VISU_PipeLine *myPipeLine;
-    SALOMEDS::SObject_var mySObject;
+  protected:
+    vtkTimeStamp myUpdateTime;
+    vtkTimeStamp myParamsTime;
+
+  private:
+    void
+    SetResultEntry(const std::string& theResultEntry);
+
+    std::string
+    GetResultEntry();
+
+    typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
+    TResultPtr myResult;
+    TResultPtr myPreviousResult;
+
     std::string myMeshName;
+    std::string myPreviousMeshName;
+
+    CORBA::Float myOffset[3];
 
     boost::signal0<void> myUpdateActorsSignal;
     boost::signal0<void> myRemoveActorsFromRendererSignal;
     vtkSmartPointer<vtkActorCollection> myActorCollection;
 
-  };
+    vtkSmartPointer<VISU_PipeLine> myPipeLine;
 
-  //----------------------------------------------------------------------------
-  Result_i* 
-  GetResult(SALOMEDS::SObject_ptr theSObject);
+    Handle(SALOME_InteractiveObject) myIO;
+
+  private:
+    friend class ColoredPrs3dCache_i;
+
+    //! Sets activity flag for the factory instance
+    void
+    SetActiveState(bool theState);
+    
+    bool myIsActiveSatate;
+  };
 
-  //----------------------------------------------------------------------------
-  template<class TPrs3d>
-  Storable* 
-  Restore(SALOMEDS::SObject_ptr theSObject,
-         const std::string& thePrefix,
-         const Storable::TRestoringMap& theMap)
-  {
-    VISU::Result_i* pResult = GetResult(theSObject);
-    if(pResult != NULL){
-      TPrs3d* pPrs3d = new TPrs3d(pResult,theSObject);
-      return pPrs3d->Restore(theMap);
-    }
-    return NULL;
-  }
   //----------------------------------------------------------------------------
 }