]> SALOME platform Git repositories - modules/geom.git/blob - src/OBJECT/GEOM_Actor.h
Salome HOME
Bug IPAL21615 Problem in VTK viewer when number of isos = 0
[modules/geom.git] / src / OBJECT / GEOM_Actor.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  GEOM OBJECT : interactive object for Geometry entities visualization
23 //  File   : GEOM_Actor.h
24 //  Author : Christophe ATTANASIO
25 //  Module : GEOM
26 //  $Header$
27 //
28 #ifndef GEOM_ACTOR_H
29 #define GEOM_ACTOR_H
30
31 #include "GEOM_OBJECT_defs.hxx"
32 #include "GEOM_SmartPtr.h"
33
34 #include <SALOME_Actor.h>
35
36 #include <TopoDS_Shape.hxx>
37 #include <vtkSmartPointer.h>
38
39 class vtkCamera;
40
41 class GEOM_VertexSource;
42 typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
43
44 class GEOM_EdgeSource;
45 typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
46
47 class GEOM_WireframeFace;
48 typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
49
50 class GEOM_ShadingFace;
51 typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
52
53 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
54 class vtkRenderer;
55
56 class vtkAppendPolyData;
57 typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
58
59 class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
60 {
61 public:
62   vtkTypeMacro(GEOM_Actor,SALOME_Actor);
63   static GEOM_Actor* New();
64
65   void SetShape(const TopoDS_Shape& theShape,
66                 float theDeflection,
67                 bool theIsRelative,
68                 bool theIsVector = false);
69
70   void SetDeflection(float theDeflection, bool theIsRelative);
71   float GetDeflection() const{ return myDeflection;}
72   bool GetIsRelative() const{ return myIsRelative;}
73
74   void AddToRender(vtkRenderer* theRenderer);
75   void RemoveFromRender(vtkRenderer* theRenderer);
76
77   enum EDisplayMode{ eWireframe, eShading};
78
79 /*   void SetDisplayMode(EDisplayMode theMode);  */
80 /*   EDisplayMode GetDisplayMode() const { return myDisplayMode;}  */
81
82   void SetSelected(bool theIsSelected);
83   bool IsSelected() const { return myIsSelected;}
84
85   // OLD METHODS
86   // Properties
87   void SetHighlightProperty(vtkProperty* Prop);
88   void SetWireframeProperty(vtkProperty* Prop);
89   void SetShadingProperty(vtkProperty* Prop);
90
91   void setDeflection(double adef);
92   virtual void setDisplayMode(int thenewmode);
93
94   // Description:
95   // This causes the actor to be rendered. It, in turn, will render the actor's
96   // property and then mapper.
97   virtual void Render(vtkRenderer *, vtkMapper *);
98   // Description:
99   // Release any graphics resources that are being consumed by this actor.
100   // The parameter window could be used to determine which graphic
101   // resources to release.
102   void ReleaseGraphicsResources(vtkWindow *);
103   const TopoDS_Shape& getTopo();
104   void setInputShape(const TopoDS_Shape& ashape, double adef1,
105                      int imode, bool isVector = false);
106   double getDeflection();
107   double isVector();
108
109   // SubShape
110   void SubShapeOn();
111   void SubShapeOff();
112
113   // Highlight
114   virtual void highlight(bool theHighlight);
115   virtual bool hasHighlight() { return true; }
116
117   void ShallowCopy(vtkProp *prop);
118
119   // Opacity
120   void SetOpacity(vtkFloatingPointType opa);
121   vtkFloatingPointType GetOpacity();
122
123   // Color
124   void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
125   void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
126
127   virtual bool IsInfinitive();
128
129   // overloaded functions
130   //! To map current selection to VTK representation
131   virtual
132   void
133   Highlight(bool theHighlight);
134
135   //----------------------------------------------------------------------------
136   //! To process prehighlight (called from #SVTK_InteractorStyle)
137   virtual
138   bool
139   PreHighlight(vtkInteractorStyle* theInteractorStyle,
140                SVTK_SelectionEvent* theSelectionEvent,
141                bool theIsHighlight);
142
143   //! To process highlight (called from #SVTK_InteractorStyle)
144   virtual
145   bool
146   Highlight(vtkInteractorStyle* theInteractorStyle,
147             SVTK_SelectionEvent* theSelectionEvent,
148             bool theIsHighlight);
149
150   //! Visibility management
151   virtual
152   void
153   SetVisibility( int );
154
155   //! IsoLines management
156   // theNb[0] - number of U lines
157   // theNb[1] - number of V lines
158   virtual
159   void
160   SetNbIsos(const int theNb[2]);
161
162   virtual
163   void
164   GetNbIsos(int &theNbU,int &theNbV);
165   
166   //! Vector mode management
167   virtual
168   void
169   SetVectorMode(const bool theMode);
170
171   virtual
172   bool
173   GetVectorMode();
174
175 protected:
176   void SetShape(const TopoDS_Shape& theShape,
177                 const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
178                 bool theIsVector = false);
179
180   void SetModified();
181
182   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
183
184   GEOM_Actor();
185   ~GEOM_Actor();
186
187 private:
188   TopoDS_Shape myShape;
189   int myNbIsos[2];
190   bool isOnlyVertex;
191
192   float myDeflection;
193   bool myIsRelative;
194   bool myIsForced;
195
196   //  EDisplayMode myDisplayMode;
197   bool myIsSelected;
198   bool myVectorMode;
199
200   PDeviceActor myVertexActor;
201   PVertexSource myVertexSource;
202
203   PDeviceActor myIsolatedEdgeActor;
204   PEdgeSource myIsolatedEdgeSource;
205
206   PDeviceActor myOneFaceEdgeActor;
207   PEdgeSource myOneFaceEdgeSource;
208
209   PDeviceActor mySharedEdgeActor;
210   PEdgeSource mySharedEdgeSource;
211
212   PDeviceActor myWireframeFaceActor;
213   PWFaceSource myWireframeFaceSource;
214
215   PDeviceActor myShadingFaceActor;
216   PSFaceSource myShadingFaceSource;
217
218   PDeviceActor myHighlightActor;
219   vtkSmartPointer<vtkProperty>  myHighlightProp;
220   vtkSmartPointer<vtkProperty>  myPreHighlightProp;
221   vtkSmartPointer<vtkProperty>  myShadingFaceProp;
222
223   PAppendFilter myAppendFilter;
224   PPolyDataMapper myPolyDataMapper;
225
226   virtual void SetMapper(vtkMapper*);
227
228   GEOM_Actor(const GEOM_Actor&);
229   void operator=(const GEOM_Actor&);
230 };
231
232 #endif //GEOM_ACTOR_H