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"
33 static int MYDEBUG = 1;
35 static int MYDEBUG = 0;
38 vtkStandardNewMacro(VISU_ScalarMapPL);
41 VISU_ScalarMapPL::VISU_ScalarMapPL(){
42 myFieldTransform = VISU_FieldTransform::New();
44 myMapperTable = VISU_LookupTable::New();
45 myMapperTable->SetScale(VTK_SCALE_LINEAR);
46 myMapperTable->SetHueRange(0.667,0.0);
48 myBarTable = VISU_LookupTable::New();
49 myBarTable->SetScale(VTK_SCALE_LINEAR);
50 myBarTable->SetHueRange(0.667,0.0);
52 myExtractor = VISU_Extractor::New();
56 VISU_ScalarMapPL::~VISU_ScalarMapPL(){
57 myFieldTransform->Delete();
58 myMapperTable->Delete();;
60 myExtractor->Delete();
64 void VISU_ScalarMapPL::ShallowCopy(VISU_PipeLine *thePipeLine){
65 VISU_PipeLine::ShallowCopy(thePipeLine);
66 if(VISU_ScalarMapPL *aPipeLine = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine)){
67 SetScalarRange(aPipeLine->GetScalarRange());
68 SetScalarMode(aPipeLine->GetScalarMode());
69 SetNbColors(aPipeLine->GetNbColors());
70 SetScaling(aPipeLine->GetScaling());
76 int VISU_ScalarMapPL::GetScalarMode(){
77 return myExtractor->GetScalarMode();
79 void VISU_ScalarMapPL::SetScalarMode(int theScalarMode){
80 myExtractor->SetScalarMode(theScalarMode);
85 int VISU_ScalarMapPL::GetScaling() {
86 return myBarTable->GetScale();
88 void VISU_ScalarMapPL::SetScaling(int theScaling) {
89 myBarTable->SetScale(theScaling);
90 if(theScaling == VTK_SCALE_LOG10)
91 myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10));
93 myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident));
98 float* VISU_ScalarMapPL::GetScalarRange() {
99 return myFieldTransform->GetScalarRange();
101 void VISU_ScalarMapPL::SetScalarRange(float theRange[2]){
102 myFieldTransform->SetScalarRange(theRange);
103 myBarTable->SetRange(theRange);
106 void VISU_ScalarMapPL::SetScalarMin(float theValue){
107 float aScalarRange[2] = {theValue, GetScalarRange()[1]};
108 SetScalarRange(aScalarRange);
110 void VISU_ScalarMapPL::SetScalarMax(float theValue){
111 float aScalarRange[2] = {GetScalarRange()[0], theValue};
112 SetScalarRange(aScalarRange);
116 void VISU_ScalarMapPL::SetNbColors(int theNbColors) {
117 myMapperTable->SetNumberOfColors(theNbColors);
118 myBarTable->SetNumberOfColors(theNbColors);
121 int VISU_ScalarMapPL::GetNbColors() {
122 return myMapperTable->GetNumberOfColors();
126 VISU_ScalarMapPL::THook* VISU_ScalarMapPL::DoHook(){
127 myMapper->SetColorModeToMapScalars();
128 myMapper->ScalarVisibilityOn();
129 return myFieldTransform->GetUnstructuredGridOutput();
133 void VISU_ScalarMapPL::Init(){
138 void VISU_ScalarMapPL::Build() {
139 myExtractor->SetInput(myInput);
140 myFieldTransform->SetInput(myExtractor->GetOutput());
141 myMapper->SetInput(DoHook());
145 void VISU_ScalarMapPL::Update() {
146 float *aRange = myFieldTransform->GetScalarRange();
147 float aScalarRange[2] = {aRange[0], aRange[1]};
148 if(myBarTable->GetScale() == VTK_SCALE_LOG10)
149 VISU_LookupTable::ComputeLogRange(aRange,aScalarRange);
150 myMapperTable->SetRange(aScalarRange);
151 myMapperTable->SetMapScale(1.0);
153 myMapperTable->Build();
156 myMapper->SetLookupTable(myMapperTable);
157 myMapper->SetScalarRange(aScalarRange);
159 myFieldTransform->Update();
161 VISU_PipeLine::Update();
165 void VISU_ScalarMapPL::SetMapScale(float theMapScale){
166 myMapperTable->SetMapScale(theMapScale);
167 myMapperTable->Build();
169 float VISU_ScalarMapPL::GetMapScale(){
170 return myMapperTable->GetMapScale();
174 void VISU_ScalarMapPL::GetSourceRange(float theRange[2]){
175 myExtractor->Update();
176 myExtractor->GetOutput()->GetScalarRange(theRange);
179 void VISU_ScalarMapPL::SetSourceRange(){
181 GetSourceRange(aRange);
182 SetScalarRange(aRange);