1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // VISU OBJECT : interactive object for VISU entities implementation
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>
49 class vtkActorCollection;
54 //----------------------------------------------------------------------------
58 //----------------------------------------------------------------------------
59 struct TResultObserver: public virtual boost::signalslib::trackable
63 UpdateFromResult(Result_i* theResult) = 0;
67 //----------------------------------------------------------------------------
68 //! Base class for all VTK 3D presentations.
70 It is a root class for a middle level of VISU functionality.
71 Almost all functionality of the the class implemented through redirection
72 external requestes to its VISU_PipeLine.
73 It define an interface and implement the following topics:
74 - provide persistent mechanism;
75 - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors);
76 - implement common 3D functionality like "clipping planes" and offset.
78 class VISU_I_EXPORT Prs3d_i : public virtual POA_VISU::Prs3d,
79 public virtual SALOME::GenericObj_i,
80 public virtual TActorFactory,
81 public virtual PrsObject_i
84 Prs3d_i(const Prs3d_i&);
87 //----------------------------------------------------------------------------
88 typedef PrsObject_i TSuperClass;
89 typedef VISU::Prs3d TInterface;
91 //----------------------------------------------------------------------------
92 //! A constructor to create a fresh instance of the class
95 //! To create a deep copy from another instance of the class
98 SameAs(const Prs3d_i* theOrigin);
103 //----------------------------------------------------------------------------
106 Apply(bool theReInit);
108 //----------------------------------------------------------------------------
110 SetCResult(Result_i* theResult);
117 SetResultObject(VISU::Result_ptr theResult);
123 //----------------------------------------------------------------------------
126 SetMeshName(const char* theMeshName);
133 GetCMeshName() const;
135 //----------------------------------------------------------------------------
136 //! To generate an unique type name for the class (used into persistent functionality)
139 GetComment() const = 0;
141 //! To generate an unique name for the instance of the class
146 //! To save paramters of the instance to std::ostringstream
149 ToStream(std::ostringstream& theStr);
151 //! To restore paramters of the instance from Storable::TRestoringMap
154 Restore(SALOMEDS::SObject_ptr theSObject,
155 const Storable::TRestoringMap& theMap);
157 //----------------------------------------------------------------------------
158 //! Get corresponding SALOMEDS::SObject
160 SALOMEDS::SObject_var
163 //----------------------------------------------------------------------------
164 //! To update is internal state
169 //! To remove the instance from study
174 //----------------------------------------------------------------------------
175 //! Get corresponding VISU_PipeLine
182 //! Get input of the VISU_PipeLine
186 //----------------------------------------------------------------------------
187 //! To define a way to create VTK representation of the instance
192 //! To unregister the pointed actor
195 RemoveActor(VISU_ActorBase* theActor);
197 //! To unregister all actors of the instance
202 //! To update the pointed actor
205 UpdateActor(VISU_ActorBase* theActor);
207 //! To update all actors of the instance
212 //----------------------------------------------------------------------------
215 RemoveAllClippingPlanes();
218 AddClippingPlane(vtkPlane* thePlane);
221 GetNumberOfClippingPlanes() const;
224 GetClippingPlane(vtkIdType theID) const;
226 void RemoveClippingPlane(vtkIdType theID);
229 SetPlaneParam(vtkFloatingPointType theDir[3],
230 vtkFloatingPointType theDist,
233 //----------------------------------------------------------------------------
235 GetBounds(vtkFloatingPointType aBounds[6]);
243 //! Move the 3D presentation according to the given offset parameters
245 SetOffset(const CORBA::Float* theOffsets);
247 //! Move the 3D presentation according to the given offset parameters
250 SetOffset(CORBA::Float theDx,
254 //! Gets offset parameters for the 3D presentation
256 GetOffset(CORBA::Float* theOffsets);
258 //! Gets offset parameters for the 3D presentation
261 GetOffset(CORBA::Float& theDx,
263 CORBA::Float& theDz);
265 //----------------------------------------------------------------------------
266 //! Gets memory size actually used by the presentation (Mb).
271 //----------------------------------------------------------------------------
272 //! Gets know whether the factory instance can be used for actor management or not
277 //----------------------------------------------------------------------------
278 //! Return modified time of the presentation
283 //----------------------------------------------------------------------------
284 //! Create and return the interactive object
286 Handle(SALOME_InteractiveObject)
289 //! Used in derived classes to initilize the IO for actors
294 //----------------------------------------------------------------------------
295 //! Managing "forced hidden" flag
297 IsForcedHidden() const;
300 SetForcedHidden( bool );
304 Used in Apply method to get know whether it is possible to create presentation
305 with the input parameters or not. The derived classes can use this method
306 to customize Apply behaviour.
310 SetInput(bool theReInit);
312 //! Restore input parameters if Apply function fails
317 //! Used in derived classes to initilize the myPipeLine member
319 SetPipeLine(VISU_PipeLine* thePipeLine);
321 //! Used in derived classes to initilize the myPipeLine member
323 CreateActor(VISU_Actor* theActor);
325 //! Gets or creates VISU_PipeLine instance for actor initilization
330 //! To check dataset validity, throws std::exception if not valid
336 vtkTimeStamp myUpdateTime;
337 vtkTimeStamp myParamsTime;
341 SetResultEntry(const std::string& theResultEntry);
346 typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
348 TResultPtr myPreviousResult;
350 std::string myMeshName;
351 std::string myPreviousMeshName;
353 CORBA::Float myOffset[3];
355 boost::signal0<void> myUpdateActorsSignal;
356 boost::signal0<void> myRemoveActorsFromRendererSignal;
357 vtkSmartPointer<vtkActorCollection> myActorCollection;
359 vtkSmartPointer<VISU_PipeLine> myPipeLine;
361 Handle(SALOME_InteractiveObject) myIO;
364 friend class ColoredPrs3dCache_i;
366 //! Sets activity flag for the factory instance
368 SetActiveState(bool theState);
370 bool myIsActiveSatate;
372 bool myIsForcedHidden;
375 //----------------------------------------------------------------------------