1 // Copyright (C) 2007-2012 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
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_PrsObject_i.hxx
25 // Author : Alexey PETROV
28 #ifndef VISU_Prs3d_i_HeaderFile
29 #define VISU_Prs3d_i_HeaderFile
31 #include "VISU_PrsObject_i.hh"
33 #include "VISU_ActorFactory.h"
34 #include "VISU_ConvertorDef.hxx"
36 #include "SALOME_GenericObj_i.hh"
37 #include "SALOME_GenericObjPointer.hh"
38 #include "SALOME_InteractiveObject.hxx"
40 #include "VTKViewer.h"
42 #include <vtkSmartPointer.h>
43 #include <vtkTimeStamp.h>
50 class vtkActorCollection;
55 //----------------------------------------------------------------------------
59 //----------------------------------------------------------------------------
60 struct TResultObserver: public virtual boost::signalslib::trackable
64 UpdateFromResult(Result_i* theResult) = 0;
68 //----------------------------------------------------------------------------
69 //! Base class for all VTK 3D presentations.
71 It is a root class for a middle level of VISU functionality.
72 Almost all functionality of the the class implemented through redirection
73 external requestes to its VISU_PipeLine.
74 It define an interface and implement the following topics:
75 - provide persistent mechanism;
76 - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors);
77 - implement common 3D functionality like "clipping planes" and offset.
79 class VISU_I_EXPORT Prs3d_i : public virtual POA_VISU::Prs3d,
80 public virtual SALOME::GenericObj_i,
81 public virtual TActorFactory,
82 public virtual PrsObject_i
85 Prs3d_i(const Prs3d_i&);
88 //----------------------------------------------------------------------------
89 typedef PrsObject_i TSuperClass;
90 typedef VISU::Prs3d TInterface;
92 //----------------------------------------------------------------------------
93 //! A constructor to create a fresh instance of the class
96 //! To create a deep copy from another instance of the class
99 SameAs(const Prs3d_i* theOrigin);
104 //----------------------------------------------------------------------------
107 Apply(bool theReInit);
109 //----------------------------------------------------------------------------
111 SetCResult(Result_i* theResult);
118 SetResultObject(VISU::Result_ptr theResult);
124 //----------------------------------------------------------------------------
127 SetMeshName(const char* theMeshName);
134 GetCMeshName() const;
136 //----------------------------------------------------------------------------
137 //! To generate an unique type name for the class (used into persistent functionality)
140 GetComment() const = 0;
142 //! To generate an unique name for the instance of the class
147 //! To save paramters of the instance to std::ostringstream
150 ToStream(std::ostringstream& theStr);
152 //! To restore paramters of the instance from Storable::TRestoringMap
155 Restore(SALOMEDS::SObject_ptr theSObject,
156 const Storable::TRestoringMap& theMap);
158 //----------------------------------------------------------------------------
159 //! Get corresponding SALOMEDS::SObject
161 SALOMEDS::SObject_var
164 //----------------------------------------------------------------------------
165 //! To update is internal state
170 //! To remove the instance from study
175 //----------------------------------------------------------------------------
176 //! Get corresponding VISU_PipeLine
183 //! Get input of the VISU_PipeLine
187 //----------------------------------------------------------------------------
188 //! To define a way to create VTK representation of the instance
193 //! To unregister the pointed actor
196 RemoveActor(VISU_ActorBase* theActor);
198 //! To unregister all actors of the instance
203 //! To update the pointed actor
206 UpdateActor(VISU_ActorBase* theActor);
208 //! To update all actors of the instance
213 //----------------------------------------------------------------------------
216 RemoveAllClippingPlanes();
219 AddClippingPlane(vtkPlane* thePlane);
222 GetNumberOfClippingPlanes() const;
225 GetClippingPlane(vtkIdType theID) const;
227 void RemoveClippingPlane(vtkIdType theID);
230 SetPlaneParam(vtkFloatingPointType theDir[3],
231 vtkFloatingPointType theDist,
234 //----------------------------------------------------------------------------
236 GetBounds(vtkFloatingPointType aBounds[6]);
244 //! Move the 3D presentation according to the given offset parameters
246 SetOffset(const CORBA::Float* theOffsets);
248 //! Move the 3D presentation according to the given offset parameters
251 SetOffset(CORBA::Float theDx,
255 //! Gets offset parameters for the 3D presentation
257 GetOffset(CORBA::Float* theOffsets);
259 //! Gets offset parameters for the 3D presentation
262 GetOffset(CORBA::Float& theDx,
264 CORBA::Float& theDz);
266 //----------------------------------------------------------------------------
267 //! Set standard point marker for the object
270 SetMarkerStd(VISU::MarkerType theMarkerType, VISU::MarkerScale theMarkerScale);
272 //! Set custom point marker
275 SetMarkerTexture(CORBA::Long theTextureId);
277 //! Get type of the point marker
282 //! Get scale of the point marker
287 //! Get texture identifier of the point marker
292 //----------------------------------------------------------------------------
293 //! Gets memory size actually used by the presentation (Mb).
298 //----------------------------------------------------------------------------
299 //! Gets know whether the factory instance can be used for actor management or not
304 //----------------------------------------------------------------------------
305 //! Return modified time of the presentation
310 //----------------------------------------------------------------------------
311 //! Create and return the interactive object
313 Handle(SALOME_InteractiveObject)
316 //! Used in derived classes to initilize the IO for actors
321 //----------------------------------------------------------------------------
322 //! Managing "forced hidden" flag
324 IsForcedHidden() const;
327 SetForcedHidden( bool );
331 Used in Apply method to get know whether it is possible to create presentation
332 with the input parameters or not. The derived classes can use this method
333 to customize Apply behaviour.
337 SetInput(bool theReInit);
339 //! Restore input parameters if Apply function fails
344 //! Used in derived classes to initilize the myPipeLine member
346 SetPipeLine(VISU_PipeLine* thePipeLine);
348 //! Used in derived classes to initilize the myPipeLine member
350 CreateActor(VISU_Actor* theActor);
352 //! Gets or creates VISU_PipeLine instance for actor initilization
357 //! To check dataset validity, throws std::exception if not valid
363 LoadMarkerTexture(int theMarkerId, VTK::MarkerTexture& theMarkerTexture);
366 vtkTimeStamp myUpdateTime;
367 vtkTimeStamp myParamsTime;
371 SetResultEntry(const std::string& theResultEntry);
376 typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
378 TResultPtr myPreviousResult;
380 std::string myMeshName;
381 std::string myPreviousMeshName;
383 CORBA::Float myOffset[3];
385 VISU::MarkerType myMarkerType;
386 VISU::MarkerScale myMarkerScale;
389 boost::signal0<void> myUpdateActorsSignal;
390 boost::signal0<void> myRemoveActorsFromRendererSignal;
391 vtkSmartPointer<vtkActorCollection> myActorCollection;
393 vtkSmartPointer<VISU_PipeLine> myPipeLine;
395 Handle(SALOME_InteractiveObject) myIO;
398 friend class ColoredPrs3dCache_i;
400 //! Sets activity flag for the factory instance
402 SetActiveState(bool theState);
404 bool myIsActiveSatate;
406 bool myIsForcedHidden;
409 //----------------------------------------------------------------------------