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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 "VTKViewer.h"
40 #include <vtkSmartPointer.h>
46 class vtkActorCollection;
47 class vtkUnstructuredGrid;
53 //----------------------------------------------------------------------------
54 //! Base class for all VTK 3D presentations.
56 It is a root class for a middle level of VISU functionality.
57 Almost all functionality of the the class implemented through redirection
58 external requestes to its VISU_PipeLine.
59 It define an interface and implement the following topics:
60 - provide persistent mechanism;
61 - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors);
62 - implement common 3D functionality like "clipping planes" and offset.
65 public virtual POA_VISU::Prs3d,
66 public virtual SALOME::GenericObj_i,
67 public virtual TActorFactory,
68 public virtual PrsObject_i
72 Prs3d_i(const Prs3d_i&);
75 //----------------------------------------------------------------------------
76 //! A constructor to create a fresh instance of the class
78 Prs3d_i(Result_i* theResult,
81 //! A constructor to restore an instance of the class
83 Prs3d_i(Result_i* theResult,
84 SALOMEDS::SObject_ptr theSObject);
86 //! To create a deep copy from another instance of the class
89 SameAs(const Prs3d_i* theOrigin);
94 //----------------------------------------------------------------------------
95 //! To generate an unique type name for the class (used into persistent functionality)
98 GetComment() const = 0;
100 //! To generate an unique name for the instance of the class
105 //! To restore paramters of the instance from Storable::TRestoringMap
108 Restore(const Storable::TRestoringMap& theMap);
110 //! To save paramters of the instance to std::ostringstream
113 ToStream(std::ostringstream& theStr);
115 //----------------------------------------------------------------------------
116 //! Get corresponding Result_i
120 //! Get corresponding SALOMEDS::SObject
122 SALOMEDS::SObject_var
128 //----------------------------------------------------------------------------
129 //! To update is internal state
134 //! To remove the instance from study
139 //----------------------------------------------------------------------------
140 //! Get corresponding VISU_PipeLine
144 //! Get input of the VISU_PipeLine
148 //----------------------------------------------------------------------------
149 //! To define a way to create VTK representation of the instance
152 CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0;
154 //! To unregister the pointed actor
157 RemoveActor(VISU_Actor* theActor);
159 //! To unregister all actors of the instance
164 //! To update the pointed actor
167 UpdateActor(VISU_Actor* theActor);
169 //! To update all actors of the instance
174 //----------------------------------------------------------------------------
177 RemoveAllClippingPlanes();
180 AddClippingPlane(vtkPlane* thePlane);
183 GetNumberOfClippingPlanes() const;
186 GetClippingPlane(vtkIdType theID) const;
189 SetPlaneParam(vtkFloatingPointType theDir[3],
190 vtkFloatingPointType theDist,
193 //----------------------------------------------------------------------------
195 GetBounds(vtkFloatingPointType aBounds[6]);
198 SetOffset(const CORBA::Float* theOffsets);
202 SetOffset(CORBA::Float theDx,
207 GetOffset(CORBA::Float* theOffsets);
211 GetOffset(CORBA::Float& theDx,
213 CORBA::Float& theDz);
215 //----------------------------------------------------------------------------
218 CreateActor(VISU_Actor* theActor,
219 const Handle(SALOME_InteractiveObject)& theIO = NULL);
225 //! To check dataset validity, throws std::exception if not valid
231 CORBA::Float myOffset[3];
233 VISU_PipeLine *myPipeLine;
234 SALOMEDS::SObject_var mySObject;
235 std::string myMeshName;
237 boost::signal0<void> myUpdateActorsSignal;
238 boost::signal0<void> myRemoveActorsFromRendererSignal;
239 vtkSmartPointer<vtkActorCollection> myActorCollection;
243 //----------------------------------------------------------------------------
245 GetResult(SALOMEDS::SObject_ptr theSObject);
247 //----------------------------------------------------------------------------
248 template<class TPrs3d>
250 Restore(SALOMEDS::SObject_ptr theSObject,
251 const std::string& thePrefix,
252 const Storable::TRestoringMap& theMap)
254 VISU::Result_i* pResult = GetResult(theSObject);
256 TPrs3d* pPrs3d = new TPrs3d(pResult,theSObject);
257 return pPrs3d->Restore(theMap);
261 //----------------------------------------------------------------------------