Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / OBJECT / VISU_VectorsAct.cxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VISU_VectorsAct.cxx
25 //  Author : Laurent CORNABE with help of Nicolas REJNERI
26 //  Module : VISU
27 //  $Header$
28
29 #include "VISU_VectorsAct.h"
30 #include "VISU_VectorsPL.hxx"
31 #include "VTKViewer_PassThroughFilter.h"
32  
33 // VTK Includes
34 #include <vtkObjectFactory.h>
35 #include <vtkDataSetMapper.h>
36 #include <vtkPolyDataMapper.h>
37 #include <vtkPolyData.h>
38
39
40 //----------------------------------------------------------------------------
41 vtkStandardNewMacro(VISU_VectorsAct);
42
43
44 //----------------------------------------------------------------------------
45 VISU_VectorsAct
46 ::VISU_VectorsAct():
47   myVectorsPL(NULL)
48 {}
49
50
51 //----------------------------------------------------------------------------
52 VISU_VectorsAct
53 ::~VISU_VectorsAct()
54 {}
55
56
57 //----------------------------------------------------------------------------
58 void 
59 VISU_VectorsAct
60 ::SetPipeLine(VISU_PipeLine* thePipeLine) 
61 {
62   myVectorsPL = dynamic_cast<VISU_VectorsPL*>(thePipeLine);
63   VISU_Actor::SetPipeLine(myVectorsPL);
64   myVectorsPL->Delete();
65 }
66
67
68 //----------------------------------------------------------------------------
69 vtkDataSet* 
70 VISU_VectorsAct
71 ::GetInput()
72 {
73   return GetCurrentPL()->GetOutput();
74 }
75
76
77 //----------------------------------------------------------------------------
78 void
79 VISU_VectorsAct
80 ::SetTransform(VTKViewer_Transform* theTransform)
81 {
82   Superclass::SetTransform(theTransform);
83   myVectorsPL->SetTransform(theTransform);
84 }
85
86
87 //----------------------------------------------------------------------------
88 void
89 VISU_VectorsAct
90 ::SetMapper(vtkMapper* theMapper)
91 {
92   if(theMapper){
93     myPassFilter[0]->SetInput(theMapper->GetInput());
94     
95     myPassFilter[1]->SetInput(myPassFilter[0]->GetPolyDataOutput());
96
97     myPassFilter[2]->SetInput(myPassFilter[1]->GetPolyDataOutput());
98
99     myPassFilter[3]->SetInput(myPassFilter[2]->GetPolyDataOutput());
100
101     if(vtkDataSetMapper* aMapper = dynamic_cast<vtkDataSetMapper*>(theMapper))
102       aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput());
103     else if(vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>(theMapper))
104       aMapper->SetInput(myPassFilter[3]->GetPolyDataOutput());
105   }
106   vtkLODActor::SetMapper(theMapper);
107 }