1 // Copyright (C) 2007-2011 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 // GEOM OBJECT : interactive object for Geometry entities visualization
24 // File : GEOM_Actor.h
25 // Author : Christophe ATTANASIO
32 #include "GEOM_OBJECT_defs.hxx"
33 #include "GEOM_SmartPtr.h"
35 #include <SALOME_Actor.h>
37 #include <TopoDS_Shape.hxx>
38 #include <vtkSmartPointer.h>
42 class GEOM_VertexSource;
43 typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
45 class GEOM_EdgeSource;
46 typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
48 class GEOM_WireframeFace;
49 typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
51 class GEOM_ShadingFace;
52 typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
56 class vtkAppendPolyData;
57 typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
59 class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
62 vtkTypeMacro(GEOM_Actor,SALOME_Actor);
63 static GEOM_Actor* New();
65 void SetShape(const TopoDS_Shape& theShape,
67 bool theIsVector = false);
69 void SetDeflection(float theDeflection);
70 float GetDeflection() const{ return myDeflection;}
72 void AddToRender(vtkRenderer* theRenderer);
73 void RemoveFromRender(vtkRenderer* theRenderer);
75 enum EDisplayMode{ eWireframe, eShading};
77 /* void SetDisplayMode(EDisplayMode theMode); */
78 /* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */
80 void SetSelected(bool theIsSelected);
81 bool IsSelected() const { return myIsSelected;}
85 void SetHighlightProperty(vtkProperty* Prop);
86 void SetWireframeProperty(vtkProperty* Prop);
87 void SetShadingProperty(vtkProperty* Prop);
89 void setDeflection(double adef);
90 virtual void setDisplayMode(int thenewmode);
93 // This causes the actor to be rendered. It, in turn, will render the actor's
94 // property and then mapper.
95 virtual void Render(vtkRenderer *, vtkMapper *);
97 // Release any graphics resources that are being consumed by this actor.
98 // The parameter window could be used to determine which graphic
99 // resources to release.
100 void ReleaseGraphicsResources(vtkWindow *);
101 const TopoDS_Shape& getTopo();
102 void setInputShape(const TopoDS_Shape& ashape, double adef1,
103 int imode, bool isVector = false);
104 double getDeflection();
112 virtual void highlight(bool theHighlight);
113 virtual bool hasHighlight() { return true; }
115 void ShallowCopy(vtkProp *prop);
118 void SetOpacity(vtkFloatingPointType opa);
119 vtkFloatingPointType GetOpacity();
122 void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
123 void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
125 virtual bool IsInfinitive();
127 // overloaded functions
128 //! To map current selection to VTK representation
131 Highlight(bool theHighlight);
133 //----------------------------------------------------------------------------
134 //! To process prehighlight (called from #SVTK_InteractorStyle)
137 PreHighlight(vtkInteractorStyle* theInteractorStyle,
138 SVTK_SelectionEvent* theSelectionEvent,
139 bool theIsHighlight);
141 //! To process highlight (called from #SVTK_InteractorStyle)
144 Highlight(vtkInteractorStyle* theInteractorStyle,
145 SVTK_SelectionEvent* theSelectionEvent,
146 bool theIsHighlight);
148 //! Visibility management
151 SetVisibility( int );
153 //! IsoLines management
154 // theNb[0] - number of U lines
155 // theNb[1] - number of V lines
158 SetNbIsos(const int theNb[2]);
162 GetNbIsos(int &theNbU,int &theNbV);
164 //! Vector mode management
167 SetVectorMode(const bool theMode);
176 void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
182 TopoDS_Shape myShape;
189 // EDisplayMode myDisplayMode;
193 PDeviceActor myVertexActor;
194 PVertexSource myVertexSource;
196 PDeviceActor myIsolatedEdgeActor;
197 PEdgeSource myIsolatedEdgeSource;
199 PDeviceActor myOneFaceEdgeActor;
200 PEdgeSource myOneFaceEdgeSource;
202 PDeviceActor mySharedEdgeActor;
203 PEdgeSource mySharedEdgeSource;
205 PDeviceActor myWireframeFaceActor;
206 PWFaceSource myWireframeFaceSource;
208 PDeviceActor myShadingFaceActor;
209 PSFaceSource myShadingFaceSource;
211 PDeviceActor myHighlightActor;
212 vtkSmartPointer<vtkProperty> myHighlightProp;
213 vtkSmartPointer<vtkProperty> myPreHighlightProp;
214 vtkSmartPointer<vtkProperty> myShadingFaceProp;
216 PAppendFilter myAppendFilter;
217 PPolyDataMapper myPolyDataMapper;
219 virtual void SetMapper(vtkMapper*);
221 GEOM_Actor(const GEOM_Actor&);
222 void operator=(const GEOM_Actor&);
225 #endif //GEOM_ACTOR_H