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 <boost/signals/signal0.hpp>
39 #include <vtkSmartPointer.h>
45 class vtkActorCollection;
46 class vtkUnstructuredGrid;
52 //----------------------------------------------------------------------------
53 //! Base class for all VTK 3D presentations.
55 It is a root class for a middle level of VISU functionality.
56 Almost all functionality of the the class implemented through redirection
57 external requestes to its VISU_PipeLine.
58 It define an interface and implement the following topics:
59 - provide persistent mechanism;
60 - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors);
61 - implement common 3D functionality like "clipping planes" and offset.
64 public virtual POA_VISU::Prs3d,
65 public virtual SALOME::GenericObj_i,
66 public virtual TActorFactory,
67 public virtual PrsObject_i
71 Prs3d_i(const Prs3d_i&);
74 //----------------------------------------------------------------------------
75 //! A constructor to create a fresh instance of the class
77 Prs3d_i(Result_i* theResult,
80 //! A constructor to restore an instance of the class
82 Prs3d_i(Result_i* theResult,
83 SALOMEDS::SObject_ptr theSObject);
85 //! To create a deep copy from another instance of the class
88 SameAs(const Prs3d_i* theOrigin);
93 //----------------------------------------------------------------------------
94 //! To generate an unique type name for the class (used into persistent functionality)
97 GetComment() const = 0;
99 //! To generate an unique name for the instance of the class
104 //! To restore paramters of the instance from Storable::TRestoringMap
107 Restore(const Storable::TRestoringMap& theMap);
109 //! To save paramters of the instance to std::ostringstream
112 ToStream(std::ostringstream& theStr);
114 //----------------------------------------------------------------------------
115 //! Get corresponding Result_i
119 //! Get corresponding SALOMEDS::SObject
121 SALOMEDS::SObject_var
127 //----------------------------------------------------------------------------
128 //! To update is internal state
133 //! To remove the instance from study
138 //----------------------------------------------------------------------------
139 //! Get corresponding VISU_PipeLine
143 //! Get input of the VISU_PipeLine
147 //----------------------------------------------------------------------------
148 //! To define a way to create VTK representation of the instance
151 CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0;
153 //! To unregister the pointed actor
156 RemoveActor(VISU_Actor* theActor);
158 //! To unregister all actors of the instance
163 //! To update the pointed actor
166 UpdateActor(VISU_Actor* theActor);
168 //! To update all actors of the instance
173 //----------------------------------------------------------------------------
176 RemoveAllClippingPlanes();
179 AddClippingPlane(vtkPlane* thePlane);
182 GetNumberOfClippingPlanes() const;
185 GetClippingPlane(vtkIdType theID) const;
188 SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
190 //----------------------------------------------------------------------------
192 GetBounds(float aBounds[6]);
195 SetOffset(const float* theOffsets);
199 SetOffset(float theDx, float theDy, float theDz);
202 GetOffset(float* theOffsets);
206 GetOffset(float& theDx, float& theDy, float& theDz);
208 //----------------------------------------------------------------------------
211 CreateActor(VISU_Actor* theActor,
212 const Handle(SALOME_InteractiveObject)& theIO = NULL);
218 //! To check dataset validity, throws std::exception if not valid
226 VISU_PipeLine *myPipeLine;
227 SALOMEDS::SObject_var mySObject;
228 std::string myMeshName;
230 boost::signal0<void> myUpdateActorsSignal;
231 boost::signal0<void> myRemoveActorsFromRendererSignal;
232 vtkSmartPointer<vtkActorCollection> myActorCollection;
236 //----------------------------------------------------------------------------
238 GetResult(SALOMEDS::SObject_ptr theSObject);
240 //----------------------------------------------------------------------------
241 template<class TPrs3d>
243 Restore(SALOMEDS::SObject_ptr theSObject,
244 const std::string& thePrefix,
245 const Storable::TRestoringMap& theMap)
247 VISU::Result_i* pResult = GetResult(theSObject);
249 TPrs3d* pPrs3d = new TPrs3d(pResult,theSObject);
250 return pPrs3d->Restore(theMap);
254 //----------------------------------------------------------------------------