]> SALOME platform Git repositories - modules/visu.git/blob - src/PIPELINE/VISU_IsoSurfacesPL.cxx
Salome HOME
Add test function : QApplication::postEvent(SALOME_Event)
[modules/visu.git] / src / PIPELINE / VISU_IsoSurfacesPL.cxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 // File:    VISU_PipeLine.cxx
25 // Author:  Alexey PETROV
26 // Module : VISU
27
28
29 #include "VISU_IsoSurfacesPL.hxx"
30 #include "VISU_PipeLineUtils.hxx"
31
32 #include <vtkContourFilter.h>
33
34 vtkStandardNewMacro(VISU_IsoSurfacesPL);
35
36 VISU_IsoSurfacesPL::VISU_IsoSurfacesPL(){
37   myContourFilter = vtkContourFilter::New();
38   myCellDataToPointData = vtkCellDataToPointData::New();
39 }
40
41 VISU_IsoSurfacesPL::~VISU_IsoSurfacesPL(){
42   myContourFilter->UnRegisterAllOutputs();
43   myContourFilter->Delete();
44
45   myCellDataToPointData->UnRegisterAllOutputs();
46   myCellDataToPointData->Delete();
47 }
48
49 void VISU_IsoSurfacesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
50   VISU_ScalarMapPL::ShallowCopy(thePipeLine);
51   if(VISU_IsoSurfacesPL *aPipeLine = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine)){
52     SetNbParts(aPipeLine->GetNbParts());
53     float aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
54     SetRange(aRange);
55   }
56 }
57
58 int VISU_IsoSurfacesPL::GetNbParts() { 
59   return myContourFilter->GetNumberOfContours();
60 }
61 void VISU_IsoSurfacesPL::SetNbParts(int theNb) { 
62   myContourFilter->SetNumberOfContours(theNb);
63   Modified();
64 }
65
66
67 void VISU_IsoSurfacesPL::SetScaling(int theScaling) {
68   VISU_ScalarMapPL::SetScaling(theScaling);
69   SetRange(myRange);
70 }
71 void VISU_IsoSurfacesPL::SetRange(float theRange[2]){ 
72   if(theRange[0] <= theRange[1]){
73     myRange[0] = theRange[0];  myRange[1] = theRange[1];
74     float aRange[2] = {myRange[0], myRange[1]};
75     if(GetScaling() == VTK_SCALE_LOG10)
76       VISU_LookupTable::ComputeLogRange(theRange,aRange);
77     myContourFilter->GenerateValues(GetNbParts(),aRange);
78     Modified();
79   }
80 }
81 float VISU_IsoSurfacesPL::GetMin() {
82   return myRange[0];
83 }
84 float VISU_IsoSurfacesPL::GetMax() {
85   return myRange[1];
86 }
87   
88
89 void VISU_IsoSurfacesPL::Init(){
90   VISU_ScalarMapPL::Init();
91
92   SetNbParts(10);
93   float aScalarRange[2];
94   GetSourceRange(aScalarRange);
95   SetRange(aScalarRange);
96 }
97
98 VISU_ScalarMapPL::THook* VISU_IsoSurfacesPL::DoHook(){
99   return myContourFilter->GetOutput();
100 }
101
102
103 void VISU_IsoSurfacesPL::Update(){
104   VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,myInput,myFieldTransform);
105   SetMapScale();
106
107   VISU_ScalarMapPL::Update();
108 }
109
110 void VISU_IsoSurfacesPL::SetMapScale(float theMapScale){
111   VISU_ScalarMapPL::SetMapScale(theMapScale);
112
113   float aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
114   float aNewRange[2] = {aRange[0], aRange[1]};
115   if(GetScaling() == VTK_SCALE_LOG10)
116     VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
117   myContourFilter->GenerateValues(GetNbParts(),aNewRange);
118   Modified();
119 }