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();
43 //myFieldTransform->DebugOn();
45 myMapperTable = VISU_LookupTable::New();
46 myMapperTable->SetScale(VTK_SCALE_LINEAR);
47 myMapperTable->SetHueRange(0.667,0.0);
49 myBarTable = VISU_LookupTable::New();
50 myBarTable->SetScale(VTK_SCALE_LINEAR);
51 myBarTable->SetHueRange(0.667,0.0);
53 myExtractor = VISU_Extractor::New();
54 //myExtractor->DebugOn();
58 VISU_ScalarMapPL::~VISU_ScalarMapPL(){
59 myFieldTransform->UnRegisterAllOutputs();
60 myFieldTransform->Delete();
61 myMapperTable->Delete();;
63 myExtractor->UnRegisterAllOutputs();
64 myExtractor->Delete();
68 void VISU_ScalarMapPL::ShallowCopy(VISU_PipeLine *thePipeLine){
69 VISU_PipeLine::ShallowCopy(thePipeLine);
70 if(VISU_ScalarMapPL *aPipeLine = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine)){
71 SetScalarRange(aPipeLine->GetScalarRange());
72 SetScalarMode(aPipeLine->GetScalarMode());
73 SetNbColors(aPipeLine->GetNbColors());
74 SetScaling(aPipeLine->GetScaling());
80 int VISU_ScalarMapPL::GetScalarMode(){
81 return myExtractor->GetScalarMode();
83 void VISU_ScalarMapPL::SetScalarMode(int theScalarMode){
84 myExtractor->SetScalarMode(theScalarMode);
89 int VISU_ScalarMapPL::GetScaling() {
90 return myBarTable->GetScale();
92 void VISU_ScalarMapPL::SetScaling(int theScaling) {
93 myBarTable->SetScale(theScaling);
94 if(theScaling == VTK_SCALE_LOG10)
95 myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10));
97 myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident));
102 float* VISU_ScalarMapPL::GetScalarRange() {
103 return myFieldTransform->GetScalarRange();
105 void VISU_ScalarMapPL::SetScalarRange(float theRange[2]){
106 myFieldTransform->SetScalarRange(theRange);
107 myBarTable->SetRange(theRange);
110 void VISU_ScalarMapPL::SetScalarMin(float theValue){
111 float aScalarRange[2] = {theValue, GetScalarRange()[1]};
112 SetScalarRange(aScalarRange);
114 void VISU_ScalarMapPL::SetScalarMax(float theValue){
115 float aScalarRange[2] = {GetScalarRange()[0], theValue};
116 SetScalarRange(aScalarRange);
120 void VISU_ScalarMapPL::SetNbColors(int theNbColors) {
121 myMapperTable->SetNumberOfColors(theNbColors);
122 myBarTable->SetNumberOfColors(theNbColors);
125 int VISU_ScalarMapPL::GetNbColors() {
126 return myMapperTable->GetNumberOfColors();
130 VISU_ScalarMapPL::THook* VISU_ScalarMapPL::DoHook(){
131 myMapper->SetColorModeToMapScalars();
132 myMapper->ScalarVisibilityOn();
133 return myFieldTransform->GetUnstructuredGridOutput();
137 void VISU_ScalarMapPL::Init(){
142 void VISU_ScalarMapPL::Build() {
143 myExtractor->SetInput(myInput);
144 myFieldTransform->SetInput(myExtractor->GetOutput());
145 myMapper->SetInput(DoHook());
149 void VISU_ScalarMapPL::Update() {
150 float *aRange = myFieldTransform->GetScalarRange();
151 float aScalarRange[2] = {aRange[0], aRange[1]};
152 if(myBarTable->GetScale() == VTK_SCALE_LOG10)
153 VISU_LookupTable::ComputeLogRange(aRange,aScalarRange);
154 myMapperTable->SetRange(aScalarRange);
155 myMapperTable->SetMapScale(1.0);
157 myMapperTable->Build();
160 myMapper->SetLookupTable(myMapperTable);
161 myMapper->SetScalarRange(aScalarRange);
163 VISU_PipeLine::Update();
167 void VISU_ScalarMapPL::SetMapScale(float theMapScale){
168 myMapperTable->SetMapScale(theMapScale);
169 myMapperTable->Build();
171 float VISU_ScalarMapPL::GetMapScale(){
172 return myMapperTable->GetMapScale();
176 void VISU_ScalarMapPL::GetSourceRange(float theRange[2]){
177 myExtractor->Update();
178 myExtractor->GetOutput()->GetScalarRange(theRange);
181 void VISU_ScalarMapPL::SetSourceRange(){
183 GetSourceRange(aRange);
184 SetScalarRange(aRange);