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_GenericObjPointer.hh"
37 #include "SALOME_InteractiveObject.hxx"
39 #include "VTKViewer.h"
41 #include <vtkSmartPointer.h>
42 #include <vtkTimeStamp.h>
48 class vtkActorCollection;
53 //----------------------------------------------------------------------------
57 //----------------------------------------------------------------------------
58 struct TResultObserver: public virtual boost::signalslib::trackable
62 UpdateFromResult(Result_i* theResult) = 0;
66 //----------------------------------------------------------------------------
67 //! Base class for all VTK 3D presentations.
69 It is a root class for a middle level of VISU functionality.
70 Almost all functionality of the the class implemented through redirection
71 external requestes to its VISU_PipeLine.
72 It define an interface and implement the following topics:
73 - provide persistent mechanism;
74 - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors);
75 - implement common 3D functionality like "clipping planes" and offset.
77 class VISU_I_EXPORT Prs3d_i : public virtual POA_VISU::Prs3d,
78 public virtual SALOME::GenericObj_i,
79 public virtual TActorFactory,
80 public virtual PrsObject_i
83 Prs3d_i(const Prs3d_i&);
86 //----------------------------------------------------------------------------
87 typedef PrsObject_i TSuperClass;
88 typedef VISU::Prs3d TInterface;
90 //----------------------------------------------------------------------------
91 //! A constructor to create a fresh instance of the class
94 //! To create a deep copy from another instance of the class
97 SameAs(const Prs3d_i* theOrigin);
102 //----------------------------------------------------------------------------
105 Apply(bool theReInit);
107 //----------------------------------------------------------------------------
109 SetCResult(Result_i* theResult);
116 SetResultObject(VISU::Result_ptr theResult);
122 //----------------------------------------------------------------------------
125 SetMeshName(const char* theMeshName);
132 GetCMeshName() const;
134 //----------------------------------------------------------------------------
135 //! To generate an unique type name for the class (used into persistent functionality)
138 GetComment() const = 0;
140 //! To generate an unique name for the instance of the class
145 //! To save paramters of the instance to std::ostringstream
148 ToStream(std::ostringstream& theStr);
150 //! To restore paramters of the instance from Storable::TRestoringMap
153 Restore(SALOMEDS::SObject_ptr theSObject,
154 const Storable::TRestoringMap& theMap);
156 //----------------------------------------------------------------------------
157 //! Get corresponding SALOMEDS::SObject
159 SALOMEDS::SObject_var
162 //----------------------------------------------------------------------------
163 //! To update is internal state
168 //! To remove the instance from study
173 //----------------------------------------------------------------------------
174 //! Get corresponding VISU_PipeLine
181 //! Get input of the VISU_PipeLine
185 //----------------------------------------------------------------------------
186 //! To define a way to create VTK representation of the instance
191 //! To unregister the pointed actor
194 RemoveActor(VISU_Actor* theActor);
196 //! To unregister all actors of the instance
201 //! To update the pointed actor
204 UpdateActor(VISU_Actor* theActor);
206 //! To update all actors of the instance
211 //----------------------------------------------------------------------------
214 RemoveAllClippingPlanes();
217 AddClippingPlane(vtkPlane* thePlane);
220 GetNumberOfClippingPlanes() const;
223 GetClippingPlane(vtkIdType theID) const;
226 SetPlaneParam(vtkFloatingPointType theDir[3],
227 vtkFloatingPointType theDist,
230 //----------------------------------------------------------------------------
232 GetBounds(vtkFloatingPointType aBounds[6]);
235 GetNumberOfActors ();
237 //! Move the 3D presentation according to the given offset parameters
239 SetOffset(const CORBA::Float* theOffsets);
241 //! Move the 3D presentation according to the given offset parameters
244 SetOffset(CORBA::Float theDx,
248 //! Gets offset parameters for the 3D presentation
250 GetOffset(CORBA::Float* theOffsets);
252 //! Gets offset parameters for the 3D presentation
255 GetOffset(CORBA::Float& theDx,
257 CORBA::Float& theDz);
259 //----------------------------------------------------------------------------
260 //! Gets memory size actually used by the presentation (Mb).
265 //----------------------------------------------------------------------------
266 //! Gets know whether the factory instance can be used for actor management or not
271 //----------------------------------------------------------------------------
272 //! Return modified time of the presentation
277 //----------------------------------------------------------------------------
278 //! Create and return the interactive object
280 Handle(SALOME_InteractiveObject)
283 //! Used in derived classes to initilize the IO for actors
290 Used in Apply method to get know whether it is possible to create presentation
291 with the input parameters or not. The derived classes can use this method
292 to customize Apply behaviour.
296 SetInput(bool theReInit);
298 //! Restore input parameters if Apply function fails
303 //! Used in derived classes to initilize the myPipeLine member
305 SetPipeLine(VISU_PipeLine* thePipeLine);
307 //! Used in derived classes to initilize the myPipeLine member
309 CreateActor(VISU_Actor* theActor);
311 //! Gets or creates VISU_PipeLine instance for actor initilization
316 //! To check dataset validity, throws std::exception if not valid
322 vtkTimeStamp myUpdateTime;
323 vtkTimeStamp myParamsTime;
327 SetResultEntry(const std::string& theResultEntry);
332 typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
334 TResultPtr myPreviousResult;
336 std::string myMeshName;
337 std::string myPreviousMeshName;
339 CORBA::Float myOffset[3];
341 boost::signal0<void> myUpdateActorsSignal;
342 boost::signal0<void> myRemoveActorsFromRendererSignal;
343 vtkSmartPointer<vtkActorCollection> myActorCollection;
345 vtkSmartPointer<VISU_PipeLine> myPipeLine;
347 Handle(SALOME_InteractiveObject) myIO;
350 friend class ColoredPrs3dCache_i;
352 //! Sets activity flag for the factory instance
354 SetActiveState(bool theState);
356 bool myIsActiveSatate;
359 //----------------------------------------------------------------------------