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_PipeLine.cxx
25 // Author: Alexey PETROV
29 #include "VISU_ScalarMapPL.hxx"
30 #include "VISU_PipeLineUtils.hxx"
31 #include "SALOME_ExtractGeometry.h"
34 //============================================================================
35 vtkStandardNewMacro(VISU_ScalarMapPL);
38 //----------------------------------------------------------------------------
42 myMapperTable = VISU_LookupTable::New();
43 myMapperTable->SetScale(VTK_SCALE_LINEAR);
44 myMapperTable->SetHueRange(0.667,0.0);
46 myBarTable = VISU_LookupTable::New();
47 myBarTable->SetScale(VTK_SCALE_LINEAR);
48 myBarTable->SetHueRange(0.667,0.0);
50 myExtractor = VISU_Extractor::New();
51 myExtractor->SetInput(myExtractGeometry->GetOutput());
53 myFieldTransform = VISU_FieldTransform::New();
54 myFieldTransform->SetInput(myExtractor->GetOutput());
56 myIsShrinkable = true;
63 myFieldTransform->Delete();
64 myMapperTable->Delete();
66 myExtractor->Delete();
70 //----------------------------------------------------------------------------
73 ::ShallowCopy(VISU_PipeLine *thePipeLine)
75 if(VISU_ScalarMapPL *aPipeLine = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine)){
76 SetScalarRange(aPipeLine->GetScalarRange());
77 SetScalarMode(aPipeLine->GetScalarMode());
78 SetNbColors(aPipeLine->GetNbColors());
79 SetScaling(aPipeLine->GetScaling());
80 SetMapScale(aPipeLine->GetMapScale());
82 Superclass::ShallowCopy(thePipeLine);
86 //----------------------------------------------------------------------------
91 return myExtractor->GetScalarMode();
96 ::SetScalarMode(int theScalarMode)
98 vtkDataSet *input = GetInput();
100 if(input->GetPointData()->GetNumberOfArrays()){
101 vtkPointData *inData = input->GetPointData();
102 if(!inData->GetAttribute(vtkDataSetAttributes::VECTORS)) {
103 if (theScalarMode==0){
109 vtkCellData *inData = input->GetCellData();
110 if(!inData->GetAttribute(vtkDataSetAttributes::VECTORS)){
111 if (theScalarMode==0){
118 myExtractor->SetScalarMode(theScalarMode);
123 //----------------------------------------------------------------------------
128 return myBarTable->GetScale();
133 ::SetScaling(int theScaling)
135 myBarTable->SetScale(theScaling);
136 if(theScaling == VTK_SCALE_LOG10)
137 myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10));
139 myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident));
144 //----------------------------------------------------------------------------
145 vtkFloatingPointType*
149 return myFieldTransform->GetScalarRange();
154 ::SetScalarRange(vtkFloatingPointType theRange[2])
156 myFieldTransform->SetScalarRange(theRange);
157 myBarTable->SetRange(theRange);
163 ::SetScalarMin(vtkFloatingPointType theValue)
165 vtkFloatingPointType aScalarRange[2] = {theValue, GetScalarRange()[1]};
166 SetScalarRange(aScalarRange);
171 ::SetScalarMax(vtkFloatingPointType theValue)
173 vtkFloatingPointType aScalarRange[2] = {GetScalarRange()[0], theValue};
174 SetScalarRange(aScalarRange);
178 //----------------------------------------------------------------------------
181 ::SetNbColors(int theNbColors)
183 myMapperTable->SetNumberOfColors(theNbColors);
184 myBarTable->SetNumberOfColors(theNbColors);
192 return myMapperTable->GetNumberOfColors();
196 //----------------------------------------------------------------------------
197 VISU_ScalarMapPL::THook*
201 myMapper->SetColorModeToMapScalars();
202 myMapper->ScalarVisibilityOn();
203 return myFieldTransform->GetUnstructuredGridOutput();
219 myMapper->SetInput(DoHook());
227 vtkFloatingPointType *aRange = myFieldTransform->GetScalarRange();
228 vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]};
229 if(myBarTable->GetScale() == VTK_SCALE_LOG10)
230 VISU_LookupTable::ComputeLogRange(aRange,aScalarRange);
231 myMapperTable->SetRange(aScalarRange);
233 myMapperTable->Build();
236 myMapper->SetLookupTable(myMapperTable);
237 myMapper->SetScalarRange(aScalarRange);
239 VISU_PipeLine::Update();
243 //----------------------------------------------------------------------------
248 return myMapperTable;
259 //----------------------------------------------------------------------------
262 ::SetMapScale(vtkFloatingPointType theMapScale)
264 myMapperTable->SetMapScale(theMapScale);
265 myMapperTable->Build();
269 VISU_ScalarMapPL::GetMapScale()
271 return myMapperTable->GetMapScale();
275 //----------------------------------------------------------------------------
278 ::GetSourceRange(vtkFloatingPointType theRange[2])
280 myExtractor->Update();
281 myExtractor->GetOutput()->GetScalarRange(theRange);
288 vtkFloatingPointType aRange[2];
289 GetSourceRange(aRange);
290 SetScalarRange(aRange);