1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VISU_MeshAct.cxx
29 #include "VISU_MeshAct.h"
30 #include "SVTK_DeviceActor.h"
32 #include <vtkObjectFactory.h>
33 #include <vtkRenderer.h>
34 #include <vtkTexture.h>
36 #include <vtkFeatureEdges.h>
37 #include <vtkDataSetMapper.h>
38 #include <vtkDataSet.h>
39 #include <vtkMatrix4x4.h>
40 #include <vtkMapperCollection.h>
43 //----------------------------------------------------------------------------
44 vtkStandardNewMacro(VISU_MeshAct);
47 //----------------------------------------------------------------------------
52 m = vtkMatrix4x4::New();
54 mySurfaceActor = SVTK_DeviceActor::New();
55 mySurfaceActor->SetRepresentation(SVTK::Representation::Surface);
56 mySurfaceActor->SetUserMatrix(m);
58 myEdgeActor = SVTK_DeviceActor::New();
59 myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
60 myEdgeActor->SetUserMatrix(m);
62 myNodeActor = SVTK_DeviceActor::New();
63 myNodeActor->SetRepresentation(SVTK::Representation::Points);
64 myNodeActor->SetUserMatrix(m);
67 SetRepresentation(SVTK::Representation::Surface);
73 mySurfaceActor->Delete();
74 myEdgeActor->Delete();
75 myNodeActor->Delete();
79 //----------------------------------------------------------------------------
82 ::SetMapperInput(vtkDataSet* theDataSet)
84 Superclass::SetMapperInput(theDataSet);
86 mySurfaceActor->SetInput(theDataSet);
87 myEdgeActor->SetInput(theDataSet);
88 myNodeActor->SetInput(theDataSet);
92 //----------------------------------------------------------------------------
95 ::SetTransform(VTKViewer_Transform* theTransform)
97 Superclass::SetTransform(theTransform);
99 mySurfaceActor->SetTransform(theTransform);
100 myEdgeActor->SetTransform(theTransform);
101 myNodeActor->SetTransform(theTransform);
105 //----------------------------------------------------------------------------
108 ::SetShrinkable(bool theIsShrinkable)
110 Superclass::SetShrinkable(theIsShrinkable);
112 mySurfaceActor->SetShrinkable(theIsShrinkable);
113 myEdgeActor->SetShrinkable(theIsShrinkable);
118 ::SetShrinkFactor(float theValue)
120 Superclass::SetShrinkFactor(theValue);
122 mySurfaceActor->SetShrinkFactor(theValue);
123 myEdgeActor->SetShrinkFactor(theValue);
127 //----------------------------------------------------------------------------
130 ::GetSurfaceProperty()
132 return mySurfaceActor->GetProperty();
139 return myEdgeActor->GetProperty();
146 return myNodeActor->GetProperty();
149 //----------------------------------------------------------------------------
152 ::SetOpacity(float theValue)
154 GetSurfaceProperty()->SetOpacity(theValue);
161 return GetSurfaceProperty()->GetOpacity();
164 //----------------------------------------------------------------------------
167 ::SetLineWidth(float theLineWidth)
169 GetEdgeProperty()->SetLineWidth(theLineWidth);
173 VISU_MeshAct::GetLineWidth()
175 return GetEdgeProperty()->GetLineWidth();
178 //----------------------------------------------------------------------------
183 if(myRepresentation == VTK_POINTS)
186 Superclass::SetShrink();
188 mySurfaceActor->SetShrink();
189 myEdgeActor->SetShrink();
196 Superclass::UnShrink();
198 mySurfaceActor->UnShrink();
199 myEdgeActor->UnShrink();
203 //----------------------------------------------------------------------------
206 ::SetRepresentation(int theMode)
208 Superclass::SetRepresentation(theMode);
210 if(theMode == SVTK::Representation::Insideframe)
211 myEdgeActor->SetRepresentation(SVTK::Representation::Insideframe);
213 myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
216 //----------------------------------------------------------------------------
219 ::RenderOpaqueGeometry(vtkViewport *ren)
221 GetMatrix(myNodeActor->GetUserMatrix());
222 GetMatrix(myEdgeActor->GetUserMatrix());
223 GetMatrix(mySurfaceActor->GetUserMatrix());
225 using namespace SVTK::Representation;
226 switch(GetRepresentation()){
228 myNodeActor->RenderOpaqueGeometry(ren);
232 myEdgeActor->RenderOpaqueGeometry(ren);
235 mySurfaceActor->RenderOpaqueGeometry(ren);
238 mySurfaceActor->RenderOpaqueGeometry(ren);
239 myEdgeActor->RenderOpaqueGeometry(ren);
247 ::RenderTranslucentGeometry(vtkViewport *ren)
249 GetMatrix(myNodeActor->GetUserMatrix());
250 GetMatrix(myEdgeActor->GetUserMatrix());
251 GetMatrix(mySurfaceActor->GetUserMatrix());
253 using namespace SVTK::Representation;
254 switch(GetRepresentation()){
256 myNodeActor->RenderTranslucentGeometry(ren);
260 myEdgeActor->RenderTranslucentGeometry(ren);
263 mySurfaceActor->RenderTranslucentGeometry(ren);
266 mySurfaceActor->RenderTranslucentGeometry(ren);
267 myEdgeActor->RenderTranslucentGeometry(ren);