1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : VISU_PrsObject_i.hxx
24 // Author : Alexey PETROV
27 #ifndef VISU_Prs3d_i_HeaderFile
28 #define VISU_Prs3d_i_HeaderFile
30 #include "VISU_PrsObject_i.hh"
32 #include "VISU_ActorFactory.h"
33 #include "VISU_ConvertorDef.hxx"
35 #include "SALOME_GenericObj_i.hh"
36 #include "SALOME_InteractiveObject.hxx"
38 #include <vtkSmartPointer.h>
44 class vtkActorCollection;
45 class vtkUnstructuredGrid;
51 //----------------------------------------------------------------------------
52 //! Base class for all VTK 3D presentations.
54 It is a root class for a middle level of VISU functionality.
55 Almost all functionality of the the class implemented through redirection
56 external requestes to its VISU_PipeLine.
57 It define an interface and implement the following topics:
58 - provide persistent mechanism;
59 - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors);
60 - implement common 3D functionality like "clipping planes" and offset.
63 public virtual POA_VISU::Prs3d,
64 public virtual SALOME::GenericObj_i,
65 public virtual TActorFactory,
66 public virtual PrsObject_i
70 Prs3d_i(const Prs3d_i&);
73 //----------------------------------------------------------------------------
74 //! A constructor to create a fresh instance of the class
76 Prs3d_i(Result_i* theResult,
79 //! A constructor to restore an instance of the class
81 Prs3d_i(Result_i* theResult,
82 SALOMEDS::SObject_ptr theSObject);
84 //! To create a deep copy from another instance of the class
87 SameAs(const Prs3d_i* theOrigin);
92 //----------------------------------------------------------------------------
93 //! To generate an unique type name for the class (used into persistent functionality)
96 GetComment() const = 0;
98 //! To generate an unique name for the instance of the class
103 //! To restore paramters of the instance from Storable::TRestoringMap
106 Restore(const Storable::TRestoringMap& theMap);
108 //! To save paramters of the instance to std::ostringstream
111 ToStream(std::ostringstream& theStr);
113 //----------------------------------------------------------------------------
114 //! Get corresponding Result_i
118 //! Get corresponding SALOMEDS::SObject
120 SALOMEDS::SObject_var
126 //----------------------------------------------------------------------------
127 //! To update is internal state
132 //! To remove the instance from study
137 //----------------------------------------------------------------------------
138 //! Get corresponding VISU_PipeLine
142 //! Get input of the VISU_PipeLine
146 //----------------------------------------------------------------------------
147 //! To define a way to create VTK representation of the instance
150 CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0;
152 //! To unregister the pointed actor
155 RemoveActor(VISU_Actor* theActor);
157 //! To unregister all actors of the instance
162 //! To update the pointed actor
165 UpdateActor(VISU_Actor* theActor);
167 //! To update all actors of the instance
172 //----------------------------------------------------------------------------
175 RemoveAllClippingPlanes();
178 AddClippingPlane(vtkPlane* thePlane);
181 GetNumberOfClippingPlanes() const;
184 GetClippingPlane(vtkIdType theID) const;
187 SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
189 //----------------------------------------------------------------------------
191 GetBounds(float aBounds[6]);
194 SetOffset(const float* theOffsets);
198 SetOffset(float theDx, float theDy, float theDz);
201 GetOffset(float* theOffsets);
205 GetOffset(float& theDx, float& theDy, float& theDz);
207 //----------------------------------------------------------------------------
210 CreateActor(VISU_Actor* theActor,
211 const Handle(SALOME_InteractiveObject)& theIO = NULL);
217 //! To check dataset validity, throws std::exception if not valid
225 VISU_PipeLine *myPipeLine;
226 SALOMEDS::SObject_var mySObject;
227 std::string myMeshName;
229 boost::signal0<void> myUpdateActorsSignal;
230 boost::signal0<void> myRemoveActorsFromRendererSignal;
231 vtkSmartPointer<vtkActorCollection> myActorCollection;
235 //----------------------------------------------------------------------------
237 GetResult(SALOMEDS::SObject_ptr theSObject);
239 //----------------------------------------------------------------------------
240 template<class TPrs3d>
242 Restore(SALOMEDS::SObject_ptr theSObject,
243 const std::string& thePrefix,
244 const Storable::TRestoringMap& theMap)
246 VISU::Result_i* pResult = GetResult(theSObject);
248 TPrs3d* pPrs3d = new TPrs3d(pResult,theSObject);
249 return pPrs3d->Restore(theMap);
253 //----------------------------------------------------------------------------