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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: VISU_PipeLine.cxx
24 // Author: Alexey PETROV
28 #include "VISU_VectorsPL.hxx"
29 #include "VISU_PipeLineUtils.hxx"
30 #include "VTKViewer_TransformFilter.h"
31 #include "VTKViewer_Transform.h"
33 #include <vtkGlyph3D.h>
34 #include <vtkConeSource.h>
35 #include <vtkLineSource.h>
36 #include <vtkGlyphSource2D.h>
37 #include <vtkPolyData.h>
39 vtkStandardNewMacro(VISU_VectorsPL);
44 myBaseGlyph = vtkGlyph3D::New();
45 myTransformedGlyph = vtkGlyph3D::New();
47 myGlyphSource = vtkGlyphSource2D::New();
48 myConeSource = vtkConeSource::New();
49 myLineSource = vtkLineSource::New();
51 myCenters = vtkCellCenters::New();
52 myTransformFilter = VTKViewer_TransformFilter::New();
53 myIsShrinkable = false;
59 myBaseGlyph->Delete();
60 myTransformedGlyph->Delete();
64 myGlyphSource->Delete();
66 myConeSource->Delete();
68 myLineSource->Delete();
70 myTransformFilter->Delete();
75 ::ShallowCopy(VISU_PipeLine *thePipeLine)
77 if(VISU_VectorsPL *aPipeLine = dynamic_cast<VISU_VectorsPL*>(thePipeLine)){
78 SetGlyphType(aPipeLine->GetGlyphType());
79 SetGlyphPos(aPipeLine->GetGlyphPos());
81 Superclass::ShallowCopy(thePipeLine);
87 ::SetTransform(VTKViewer_Transform* theTransform)
89 myFieldTransform->SetSpaceTransform(theTransform);
90 myTransformFilter->SetTransform(theTransform);
91 myTransformFilter->Modified();
98 return myFieldTransform->GetSpaceTransform();
104 ::SetScale(vtkFloatingPointType theScale)
106 if(myScaleFactor == theScale)
109 myScaleFactor = theScale;
111 myBaseGlyph->SetScaleFactor(myScaleFactor);
112 myTransformedGlyph->SetScaleFactor(myScaleFactor);
121 return myTransformedGlyph->GetScaleFactor();
140 myBaseGlyph->Update();
141 return myBaseGlyph->GetOutput();
145 VISU_ScalarMapPL::THook*
149 VISU::ToCellCenters(myBaseGlyph,myCenters,GetInput2(),myFieldTransform);
150 myBaseGlyph->SetVectorModeToUseVector();
151 myBaseGlyph->SetScaleModeToScaleByVector();
152 myBaseGlyph->SetColorModeToColorByScalar();
154 VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform);
155 myTransformedGlyph->SetInput(myTransformFilter->GetOutput());
156 myTransformedGlyph->SetVectorModeToUseVector();
157 myTransformedGlyph->SetScaleModeToScaleByVector();
158 myTransformedGlyph->SetColorModeToColorByScalar();
160 return myTransformedGlyph->GetOutput();
168 switch (myTypeGlyph) {
170 myGlyphSource->SetGlyphTypeToArrow();
171 myGlyphSource->SetFilled(0);
172 switch (myPosGlyph) {
174 myGlyphSource->SetCenter(0.5, 0.0, 0.0);
177 myGlyphSource->SetCenter(-0.5, 0.0, 0.0);
180 myGlyphSource->SetCenter(0.0, 0.0, 0.0);
182 myBaseGlyph->SetSource(myGlyphSource->GetOutput());
183 myTransformedGlyph->SetSource(myGlyphSource->GetOutput());
188 if (myTypeGlyph == CONE2)
189 myConeSource->SetResolution(3);
191 myConeSource->SetResolution(7);
192 myConeSource->SetHeight(1.0);
193 myConeSource->SetRadius(.1);
195 switch (myPosGlyph) {
197 myConeSource->SetCenter(0.5, 0.0, 0.0);
200 myConeSource->SetCenter(-0.5, 0.0, 0.0);
203 myConeSource->SetCenter(0.0, 0.0, 0.0);
205 myBaseGlyph->SetSource(myConeSource->GetOutput());
206 myTransformedGlyph->SetSource(myConeSource->GetOutput());
211 myBaseGlyph->SetSource(myLineSource->GetOutput());
212 myTransformedGlyph->SetSource(myLineSource->GetOutput());
216 Superclass::Update();
222 ::SetMapScale(vtkFloatingPointType theMapScale)
224 VISU_ScalarMapPL::SetMapScale(theMapScale);
226 myBaseGlyph->SetScaleFactor(myScaleFactor*theMapScale);
227 myTransformedGlyph->SetScaleFactor(myScaleFactor*theMapScale);