// VISU OBJECT : interactive object for VISU entities implementation
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library 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
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
// File : VISU_PrsObject_i.hxx
#define VISU_Prs3d_i_HeaderFile
#include "VISU_PrsObject_i.hh"
+
+#include "VISU_ActorFactory.h"
+#include "VISU_ConvertorDef.hxx"
+
#include "SALOME_GenericObj_i.hh"
-#include "Handle_SALOME_InteractiveObject.hxx"
-#include "VISU_Convertor.hxx"
+#include "SALOME_InteractiveObject.hxx"
+
+#include <vtkSmartPointer.h>
class VISU_PipeLine;
class VISU_Actor;
-namespace VISU{
+class vtkPlane;
+class vtkActorCollection;
+class vtkUnstructuredGrid;
+
+namespace VISU
+{
class Result_i;
- class Prs3d_i :
+
+ //----------------------------------------------------------------------------
+ //! Base class for all VTK 3D presentations.
+ /*!
+ It is a root class for a middle level of VISU functionality.
+ Almost all functionality of the the class implemented through redirection
+ external requestes to its VISU_PipeLine.
+ It define an interface and implement the following topics:
+ - provide persistent mechanism;
+ - 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
-
+
{
Prs3d_i();
Prs3d_i(const Prs3d_i&);
public:
- Prs3d_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject = SALOMEDS::SObject::_nil());
- virtual void SameAs(const Prs3d_i* theOrigin);
- virtual ~Prs3d_i();
- virtual void RemoveFromStudy() = 0;
+ //----------------------------------------------------------------------------
+ //! A constructor to create a fresh instance of the class
+ explicit
+ Prs3d_i(Result_i* theResult,
+ bool theAddToStudy);
- protected:
- bool myAddToStudy;
- Result_i *myResult;
- VISU_PipeLine *myPipeLine;
- SALOMEDS::SObject_var mySObject;
+ //! A constructor to restore an instance of the class
+ explicit
+ Prs3d_i(Result_i* theResult,
+ SALOMEDS::SObject_ptr theSObject);
- void CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO = NULL);
- virtual VISU_PipeLine* GetPipeLine();
+ //! To create a deep copy from another instance of the class
+ virtual
+ void
+ SameAs(const Prs3d_i* theOrigin);
- public:
- virtual void Update() ;
- VISU_PipeLine* GetPL();
+ virtual
+ ~Prs3d_i();
+
+ //----------------------------------------------------------------------------
+ //! To generate an unique type name for the class (used into persistent functionality)
+ virtual
+ const char*
+ GetComment() const = 0;
+
+ //! To generate an unique name for the instance of the class
+ virtual
+ 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;
+
+ //! Get corresponding SALOMEDS::SObject
+ virtual
+ SALOMEDS::SObject_var
+ GetSObject();
+
+ const std::string&
+ GetMeshName() const;
+
+ //----------------------------------------------------------------------------
+ //! To update is internal state
+ virtual
+ void
+ Update();
- void GetBounds(float aBounds[6]);
+ //! To remove the instance from study
+ virtual
+ void
+ RemoveFromStudy();
- virtual const char* GetComment() const = 0;
- virtual QString GenerateName() = 0;
+ //----------------------------------------------------------------------------
+ //! Get corresponding VISU_PipeLine
+ VISU_PipeLine*
+ GetPL();
- virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+ //! Get input of the VISU_PipeLine
+ vtkUnstructuredGrid*
+ GetInput();
- virtual void ToStream(std::ostringstream& theStr);
+ //----------------------------------------------------------------------------
+ //! To define a way to create VTK representation of the instance
+ virtual
+ VISU_Actor*
+ CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0;
- virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0;
+ //! To unregister the pointed actor
+ virtual
+ void
+ RemoveActor(VISU_Actor* theActor);
- virtual void UpdateActor(VISU_Actor* theActor) ;
+ //! To unregister all actors of the instance
+ virtual
+ void
+ RemoveActors();
+
+ //! To update the pointed actor
+ virtual
+ void
+ UpdateActor(VISU_Actor* theActor);
+
+ //! To update all actors of the instance
+ virtual
+ void
+ UpdateActors();
+
+ //----------------------------------------------------------------------------
+ // Clipping planes
+ void
+ RemoveAllClippingPlanes();
+
+ bool
+ AddClippingPlane(vtkPlane* thePlane);
+
+ vtkIdType
+ GetNumberOfClippingPlanes() const;
+
+ vtkPlane*
+ GetClippingPlane(vtkIdType theID) const;
+
+ void
+ SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
+
+ //----------------------------------------------------------------------------
+ void
+ GetBounds(float aBounds[6]);
+
+ void
+ SetOffset(const float* theOffsets);
+
+ virtual
+ void
+ SetOffset(float theDx, float theDy, float theDz);
+
+ void
+ GetOffset(float* theOffsets);
+
+ virtual
+ void
+ GetOffset(float& theDx, float& theDy, float& theDz);
+
+ //----------------------------------------------------------------------------
+ protected:
+ void
+ CreateActor(VISU_Actor* theActor,
+ const Handle(SALOME_InteractiveObject)& theIO = NULL);
+
+ virtual
+ VISU_PipeLine*
+ GetPipeLine();
+
+ //! To check dataset validity, throws std::exception if not valid
+ virtual
+ void
+ CheckDataSet();
+
+ bool myAddToStudy;
+ float myOffset[3];
+ Result_i *myResult;
+ VISU_PipeLine *myPipeLine;
+ SALOMEDS::SObject_var mySObject;
+ std::string myMeshName;
+
+ boost::signal0<void> myUpdateActorsSignal;
+ boost::signal0<void> myRemoveActorsFromRendererSignal;
+ vtkSmartPointer<vtkActorCollection> myActorCollection;
- Result_i* GetResult() const { return myResult;}
- virtual SALOMEDS::SObject_var GetSObject();
};
- Result_i* GetResult(SALOMEDS::SObject_ptr theSObject);
+
+ //----------------------------------------------------------------------------
+ Result_i*
+ GetResult(SALOMEDS::SObject_ptr theSObject);
+
+ //----------------------------------------------------------------------------
template<class TPrs3d>
- Storable* Restore(SALOMEDS::SObject_ptr theSObject,
- const string& thePrefix, const Storable::TRestoringMap& theMap)
+ Storable*
+ Restore(SALOMEDS::SObject_ptr theSObject,
+ const std::string& thePrefix,
+ const Storable::TRestoringMap& theMap)
{
VISU::Result_i* pResult = GetResult(theSObject);
if(pResult != NULL){
}
return NULL;
}
+ //----------------------------------------------------------------------------
}
#endif