Salome HOME
Port to use Qt 5.11.x (native on Debian 10).
[modules/geom.git] / src / OBJECT / GEOM_DeviceActor.cxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "GEOM_DeviceActor.h" 
21
22 #include <vtkObjectFactory.h> 
23  
24 #include <vtkPoints.h> 
25 #include <vtkPolyData.h> 
26 #include <vtkStripper.h>  
27 #include <vtkPolyDataMapper.h>  
28 #include <vtkPolyDataNormals.h>  
29 #include <vtkActor.h>
30 #include <vtkRenderer.h> 
31
32 #include <VTKViewer_Actor.h>
33 #include <VTKViewer_Transform.h>
34 #include <VTKViewer_TransformFilter.h>
35
36  
37 vtkStandardNewMacro(GEOM_DeviceActor);
38  
39 GEOM_DeviceActor::GEOM_DeviceActor() :
40   myStripper(vtkStripper::New(), true),
41   myPolyDataMapper(vtkPolyDataMapper::New(), true),
42   myPolyDataNormals(vtkPolyDataNormals::New(), true),
43   myActor(VTKViewer_Actor::New(), true),
44   myTransformFilter(VTKViewer_TransformFilter::New())
45
46   myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort());
47   myTransformFilter->SetInputConnection(myStripper->GetOutputPort());
48   myPolyDataMapper->SetInputConnection(myTransformFilter->GetOutputPort());
49  
50   myActor->SetMapper(myPolyDataMapper.Get()); 
51   myActor->PickableOff(); 
52
53  
54 GEOM_DeviceActor::~GEOM_DeviceActor() 
55
56
57  
58 void 
59 GEOM_DeviceActor:: 
60 SetInput(vtkAlgorithmOutput* thePolyData, bool theUseStripper)
61
62   if(theUseStripper)
63   {
64     myPolyDataNormals->SetInputConnection(thePolyData); 
65     myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort());
66     myTransformFilter->SetInputConnection(myStripper->GetOutputPort());
67     myPolyDataMapper->SetInputConnection(myTransformFilter->GetOutputPort());
68   }
69   else
70     myTransformFilter->SetInputConnection(thePolyData);
71     myPolyDataMapper->SetInputConnection(myTransformFilter->GetOutputPort());
72 }
73  
74 void 
75 GEOM_DeviceActor:: 
76 SetProperty(vtkProperty* theProperty)
77 {
78   myActor->SetProperty(theProperty);
79 }
80  
81 vtkProperty* 
82 GEOM_DeviceActor:: 
83 GetProperty()
84 {
85   return myActor->GetProperty();
86 }
87  
88 void
89 GEOM_DeviceActor::
90 SetBackfaceProperty(vtkProperty* theProperty)
91 {
92   myActor->SetBackfaceProperty(theProperty);
93 }
94  
95 vtkProperty*
96 GEOM_DeviceActor::
97 GetBackfaceProperty()
98 {
99   return myActor->GetBackfaceProperty();
100 }
101  
102 void 
103 GEOM_DeviceActor:: 
104 SetVisibility(int theVisibility)
105 {
106   myActor->SetVisibility(theVisibility);
107 }
108  
109 int 
110 GEOM_DeviceActor:: 
111 GetVisibility()
112 {
113   return myActor->GetVisibility();
114 }
115  
116 void 
117 GEOM_DeviceActor:: 
118 AddToRender(vtkRenderer* theRenderer)
119 {
120   theRenderer->AddActor(myActor.GetPointer());
121 }
122
123 void 
124 GEOM_DeviceActor:: 
125 RemoveFromRender(vtkRenderer* theRenderer)
126 {
127   theRenderer->RemoveActor(myActor.GetPointer());
128 }
129
130 void
131 GEOM_DeviceActor
132 ::SetTransform(VTKViewer_Transform* theTransform)
133 {
134   myTransformFilter->SetTransform(theTransform);
135 }