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"
32 vtkStandardNewMacro(VISU_ScalarMapPL);
35 VISU_ScalarMapPL::VISU_ScalarMapPL(){
36 myFieldTransform = VISU_FieldTransform::New();
37 //myFieldTransform->DebugOn();
39 myMapperTable = VISU_LookupTable::New();
40 myMapperTable->SetScale(VTK_SCALE_LINEAR);
41 myMapperTable->SetHueRange(0.667,0.0);
43 myBarTable = VISU_LookupTable::New();
44 myBarTable->SetScale(VTK_SCALE_LINEAR);
45 myBarTable->SetHueRange(0.667,0.0);
47 myExtractor = VISU_Extractor::New();
48 //myExtractor->DebugOn();
49 myIsShrinkable = true;
53 VISU_ScalarMapPL::~VISU_ScalarMapPL(){
54 myFieldTransform->UnRegisterAllOutputs();
55 myFieldTransform->Delete();
56 myMapperTable->Delete();;
58 myExtractor->UnRegisterAllOutputs();
59 myExtractor->Delete();
63 void VISU_ScalarMapPL::ShallowCopy(VISU_PipeLine *thePipeLine){
64 VISU_PipeLine::ShallowCopy(thePipeLine);
65 if(VISU_ScalarMapPL *aPipeLine = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine)){
66 SetScalarRange(aPipeLine->GetScalarRange());
67 SetScalarMode(aPipeLine->GetScalarMode());
68 SetNbColors(aPipeLine->GetNbColors());
69 SetScaling(aPipeLine->GetScaling());
75 int VISU_ScalarMapPL::GetScalarMode(){
76 return myExtractor->GetScalarMode();
78 void VISU_ScalarMapPL::SetScalarMode(int theScalarMode){
79 myExtractor->SetScalarMode(theScalarMode);
84 int VISU_ScalarMapPL::GetScaling() {
85 return myBarTable->GetScale();
87 void VISU_ScalarMapPL::SetScaling(int theScaling) {
88 myBarTable->SetScale(theScaling);
89 if(theScaling == VTK_SCALE_LOG10)
90 myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10));
92 myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident));
97 float* VISU_ScalarMapPL::GetScalarRange() {
98 return myFieldTransform->GetScalarRange();
100 void VISU_ScalarMapPL::SetScalarRange(float theRange[2]){
101 myFieldTransform->SetScalarRange(theRange);
102 myBarTable->SetRange(theRange);
105 void VISU_ScalarMapPL::SetScalarMin(float theValue){
106 float aScalarRange[2] = {theValue, GetScalarRange()[1]};
107 SetScalarRange(aScalarRange);
109 void VISU_ScalarMapPL::SetScalarMax(float theValue){
110 float aScalarRange[2] = {GetScalarRange()[0], theValue};
111 SetScalarRange(aScalarRange);
115 void VISU_ScalarMapPL::SetNbColors(int theNbColors) {
116 myMapperTable->SetNumberOfColors(theNbColors);
117 myBarTable->SetNumberOfColors(theNbColors);
120 int VISU_ScalarMapPL::GetNbColors() {
121 return myMapperTable->GetNumberOfColors();
125 VISU_ScalarMapPL::THook* VISU_ScalarMapPL::DoHook(){
126 myMapper->SetColorModeToMapScalars();
127 myMapper->ScalarVisibilityOn();
128 return myFieldTransform->GetUnstructuredGridOutput();
132 void VISU_ScalarMapPL::Init(){
137 void VISU_ScalarMapPL::Build() {
138 myExtractor->SetInput(GetInput2());
139 myFieldTransform->SetInput(myExtractor->GetOutput());
140 myMapper->SetInput(DoHook());
144 void VISU_ScalarMapPL::Update() {
145 float *aRange = myFieldTransform->GetScalarRange();
146 float aScalarRange[2] = {aRange[0], aRange[1]};
147 if(myBarTable->GetScale() == VTK_SCALE_LOG10)
148 VISU_LookupTable::ComputeLogRange(aRange,aScalarRange);
149 myMapperTable->SetRange(aScalarRange);
150 myMapperTable->SetMapScale(1.0);
152 myMapperTable->Build();
155 myMapper->SetLookupTable(myMapperTable);
156 myMapper->SetScalarRange(aScalarRange);
158 VISU_PipeLine::Update();
162 void VISU_ScalarMapPL::SetMapScale(float theMapScale){
163 myMapperTable->SetMapScale(theMapScale);
164 myMapperTable->Build();
166 float VISU_ScalarMapPL::GetMapScale(){
167 return myMapperTable->GetMapScale();
171 void VISU_ScalarMapPL::GetSourceRange(float theRange[2]){
172 myExtractor->Update();
173 myExtractor->GetOutput()->GetScalarRange(theRange);
176 void VISU_ScalarMapPL::SetSourceRange(){
178 GetSourceRange(aRange);
179 SetScalarRange(aRange);