Version: 9.16.0
GEOM_Actor.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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, or (at your option) any later version.
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
23// GEOM OBJECT : interactive object for Geometry entities visualization
24// File : GEOM_Actor.h
25// Author : Christophe ATTANASIO
26// Module : GEOM
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
39class vtkCamera;
40
43
44class GEOM_EdgeSource;
46
49
52
53class vtkRenderer;
54class vtkTextActor;
55
56class vtkAppendPolyData;
58
60{
61public:
63 static GEOM_Actor* New();
64
65 void SetShape(const TopoDS_Shape& theShape,
66 double theDeflection,
67 bool theIsVector = false);
68
69 void SetDeflection(double theDeflection);
70 double GetDeflection() const{ return myDeflection;}
71
72 void AddToRender(vtkRenderer* theRenderer);
73 void RemoveFromRender(vtkRenderer* theRenderer);
74
75 enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 };
76
77/* void SetDisplayMode(EDisplayMode theMode); */
78/* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */
79
80 void SetSelected(bool theIsSelected);
81 bool IsSelected() const { return myIsSelected;}
82
83 // OLD METHODS
84 // Properties
85 void SetHighlightProperty(vtkProperty* Prop);
86 void SetWireframeProperty(vtkProperty* Prop);
87 void SetShadingProperty(vtkProperty* Prop);
88
89 vtkProperty* GetWireframeProperty();
90 vtkProperty* GetShadingProperty();
91 vtkProperty* GetIsolatedEdgeProperty();
92 vtkProperty* GetVertexProperty();
93 vtkProperty* GetStandaloneVertexProperty();
94 vtkProperty* GetSharedEdgeProperty();
95 vtkProperty* GetFaceEdgeProperty();
96
97 virtual void setDisplayMode(int thenewmode);
98
99 // Description:
100 // This causes the actor to be rendered. It, in turn, will render the actor's
101 // property and then mapper.
102 virtual void Render(vtkRenderer *, vtkMapper *);
103 // Description:
104 // Release any graphics resources that are being consumed by this actor.
105 // The parameter window could be used to determine which graphic
106 // resources to release.
107 void ReleaseGraphicsResources(vtkWindow *);
108 const TopoDS_Shape& getTopo();
109 void setInputShape(const TopoDS_Shape& ashape, double adef1,
110 int imode, bool isVector = false);
111 double isVector();
112
113 // SubShape
114 void SubShapeOn();
115 void SubShapeOff();
116
117 // Highlight
118 virtual void highlight(bool theHighlight);
119 virtual bool hasHighlight() { return true; }
120
121 void ShallowCopy(vtkProp *prop);
122
123 // Opacity
124 void SetOpacity(double opa);
125 double GetOpacity();
126
127 // Color (same to all sub-actors/display modes)
128 void SetColor(double r, double g, double b);
129 void GetColor(double& r, double& g, double& b);
130 // Color of points
131 void SetPointColor(double r, double g, double b);
132 // Color of standalone edges, wires, vectors
133 void SetIsolatedEdgeColor(double r, double g, double b);
134 // Color of shared edges
135 void SetSharedEdgeColor(double r, double g, double b);
136 // Color of free edges
137 void SetFreeEdgeColor(double r, double g, double b);
138 // Color of edges in shading+edges display mode
139 void SetEdgesInShadingColor(double r, double g, double b);
140 // Color of iso-lines
141 void SetIsosColor(double r, double g, double b);
142 // Color of labels
143 void SetLabelColor(double r, double g, double b);
144
145
146 // Material
147 void SetMaterial(std::vector<vtkProperty*> theProps);
148 vtkProperty* GetFrontMaterial();
149 vtkProperty* GetBackMaterial();
150 virtual bool IsInfinitive();
151
152 // overloaded functions
154 virtual
155 void
156 Highlight(bool theHighlight);
157
158 //----------------------------------------------------------------------------
160 virtual
161 bool
162 PreHighlight(vtkInteractorStyle* theInteractorStyle,
163 SVTK_SelectionEvent* theSelectionEvent,
164 bool theIsHighlight);
165
167 virtual
168 bool
169 Highlight(vtkInteractorStyle* theInteractorStyle,
170 SVTK_SelectionEvent* theSelectionEvent,
171 bool theIsHighlight);
172
174 virtual
175 void
176 SetVisibility( int );
177
179 // theNb[0] - number of U lines
180 // theNb[1] - number of V lines
181 virtual
182 void
183 SetNbIsos(const int theNb[2]);
184
185 virtual
186 void
187 GetNbIsos(int &theNbU,int &theNbV);
188
189 virtual
190 void SetIsosWidth(const int width);
191
192 int GetIsosWidth() const;
193
194 virtual void SetWidth(const int width);
195
196 int GetWidth() const;
197
199 virtual
200 void
201 SetVectorMode(const bool theMode);
202
203 virtual
204 bool
205 GetVectorMode();
206
208 virtual
209 void
210 SetVerticesMode(const bool theMode);
211
212 virtual
213 bool
214 GetVerticesMode();
215
217 virtual
218 void
219 SetNameMode(const bool theMode);
220
221 virtual
222 bool
223 GetNameMode();
224
225 virtual
226 void
227 SetTransform(VTKViewer_Transform* theTransform);
228
229
230protected:
231 void SetModified();
232
233 void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
234 void SetShapeName();
235
236 GEOM_Actor();
237 ~GEOM_Actor();
238
239private:
240 TopoDS_Shape myShape;
242
245
246 // EDisplayMode myDisplayMode;
251
254
257
260
263
266
269
272
274
275 vtkTextActor* myTextActor;
276
277 vtkSmartPointer<vtkProperty> myHighlightProp;
278 vtkSmartPointer<vtkProperty> myPreHighlightProp;
279 vtkSmartPointer<vtkProperty> myShadingFaceProp;
280 vtkSmartPointer<vtkProperty> myShadingBackFaceProp;
281
284
285 virtual void SetMapper(vtkMapper*);
286
288 void operator=(const GEOM_Actor&);
289
290 double myEdgesInWireframeColor[3];
291 double myEdgesInShadingColor[3];
292 double myIsolatedEdgeColor[3];
293 double mySharedEdgeColor[3];
294 double myOneFaceEdgeColor[3];
295};
296
297#endif //GEOM_ACTOR_H
298
299
GEOM_SmartPtr< GEOM_EdgeSource > PEdgeSource
Definition: GEOM_Actor.h:45
GEOM_SmartPtr< GEOM_WireframeFace > PWFaceSource
Definition: GEOM_Actor.h:48
GEOM_SmartPtr< vtkAppendPolyData > PAppendFilter
Definition: GEOM_Actor.h:57
GEOM_SmartPtr< GEOM_ShadingFace > PSFaceSource
Definition: GEOM_Actor.h:51
GEOM_SmartPtr< GEOM_VertexSource > PVertexSource
Definition: GEOM_Actor.h:42
#define GEOM_OBJECT_EXPORT
Definition: GEOM_OBJECT_defs.hxx:37
This class allows to display an OpenCASCADE CAD model in a VTK viewer.
Definition: GEOM_Actor.h:60
vtkSmartPointer< vtkProperty > myShadingFaceProp
Definition: GEOM_Actor.h:279
PPolyGeomPainterDataMapper myPolyDataMapper
Definition: GEOM_Actor.h:283
PDeviceActor myHighlightActor
Definition: GEOM_Actor.h:273
vtkSmartPointer< vtkProperty > myHighlightProp
Definition: GEOM_Actor.h:277
PVertexSource myStandaloneVertexSource
Definition: GEOM_Actor.h:256
PDeviceActor myShadingFaceActor
Definition: GEOM_Actor.h:270
PEdgeSource myOneFaceEdgeSource
Definition: GEOM_Actor.h:262
virtual bool hasHighlight()
Definition: GEOM_Actor.h:119
bool myVectorMode
Definition: GEOM_Actor.h:248
PDeviceActor mySharedEdgeActor
Definition: GEOM_Actor.h:264
vtkSmartPointer< vtkProperty > myPreHighlightProp
Definition: GEOM_Actor.h:278
PDeviceActor myOneFaceEdgeActor
Definition: GEOM_Actor.h:261
PSFaceSource myShadingFaceSource
Definition: GEOM_Actor.h:271
vtkSmartPointer< vtkProperty > myShadingBackFaceProp
Definition: GEOM_Actor.h:280
EDisplayMode
Definition: GEOM_Actor.h:75
vtkTypeMacro(GEOM_Actor, SALOME_Actor) static GEOM_Actor *New()
bool myVerticesMode
Definition: GEOM_Actor.h:249
double myDeflection
Definition: GEOM_Actor.h:243
bool myNameMode
Definition: GEOM_Actor.h:250
vtkTextActor * myTextActor
Definition: GEOM_Actor.h:275
void operator=(const GEOM_Actor &)
double GetDeflection() const
Definition: GEOM_Actor.h:70
PWFaceSource myWireframeFaceSource
Definition: GEOM_Actor.h:268
GEOM_Actor(const GEOM_Actor &)
PAppendFilter myAppendFilter
Definition: GEOM_Actor.h:282
PDeviceActor myWireframeFaceActor
Definition: GEOM_Actor.h:267
PDeviceActor myStandaloneVertexActor
Definition: GEOM_Actor.h:255
PEdgeSource mySharedEdgeSource
Definition: GEOM_Actor.h:265
PVertexSource myVertexSource
Definition: GEOM_Actor.h:253
PDeviceActor myIsolatedEdgeActor
Definition: GEOM_Actor.h:258
PEdgeSource myIsolatedEdgeSource
Definition: GEOM_Actor.h:259
bool myIsForced
Definition: GEOM_Actor.h:244
bool myIsSelected
Definition: GEOM_Actor.h:247
PDeviceActor myVertexActor
Definition: GEOM_Actor.h:252
bool IsSelected() const
Definition: GEOM_Actor.h:81
TopoDS_Shape myShape
Definition: GEOM_Actor.h:240
bool isOnlyVertex
Definition: GEOM_Actor.h:241
Definition: GEOM_EdgeSource.h:37
Definition: GEOM_ShadingFace.h:27
Definition: GEOM_VertexSource.h:37
Definition: GEOM_WireframeFace.h:37