]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_IsoSurfaces_i.cc
Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/visu.git] / src / VISU_I / VISU_IsoSurfaces_i.cc
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //  File   : VISU_PrsObject_i.cxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #include "VISU_IsoSurfacesPL.hxx"
28 #include "VISU_Result_i.hh"
29 #include "VISU_IsoSurfaces_i.hh"
30 #include "VISU_Actor.h"
31
32 #include "SUIT_ResourceMgr.h"
33
34 using namespace VISU;
35 using namespace std;
36
37 #ifdef _DEBUG_
38 static int MYDEBUG = 0;
39 #else
40 static int MYDEBUG = 0;
41 #endif
42
43 int VISU::IsoSurfaces_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
44                                     const char* theFieldName, int theIteration, int isMemoryCheck)
45 {
46   return VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
47 }
48
49 int VISU::IsoSurfaces_i::myNbPresent = 0;
50 QString VISU::IsoSurfaces_i::GenerateName() { return VISU::GenerateName("IsoSurfaces",myNbPresent++);}
51
52 const string VISU::IsoSurfaces_i::myComment = "ISOSURFACES";
53 const char* VISU::IsoSurfaces_i::GetComment() const { return myComment.c_str();}
54
55
56 VISU::IsoSurfaces_i::
57 IsoSurfaces_i(Result_i* theResult, 
58               bool theAddToStudy) :
59   PrsObject_i(theResult->GetStudyDocument()), 
60   Prs3d_i(theResult,theAddToStudy),
61   ColoredPrs3d_i(theResult,theAddToStudy),
62   ScalarMap_i(theResult,theAddToStudy),
63   myIsoSurfacesPL(NULL)
64 {}
65
66
67 VISU::IsoSurfaces_i::
68 IsoSurfaces_i(Result_i* theResult, 
69               SALOMEDS::SObject_ptr theSObject) :
70   PrsObject_i(theResult->GetStudyDocument()), 
71   Prs3d_i(theResult,theSObject),
72   ColoredPrs3d_i(theResult,theSObject),
73   ScalarMap_i(theResult,theSObject),
74   myIsoSurfacesPL(NULL)
75 {
76 }
77
78
79 VISU::Storable* VISU::IsoSurfaces_i::Create(const char* theMeshName, VISU::Entity theEntity, 
80                                             const char* theFieldName, int theIteration)
81 {
82   return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
83 }
84
85
86 VISU::Storable* VISU::IsoSurfaces_i::Restore(const Storable::TRestoringMap& theMap)
87 {
88   TSuperClass::Restore(theMap);
89
90   SetNbSurfaces(VISU::Storable::FindValue(theMap,"myNbSurface").toInt());
91   float aMin = VISU::Storable::FindValue(theMap,"myRange[0]").toDouble();
92   float aMax = VISU::Storable::FindValue(theMap,"myRange[1]").toDouble();
93   SetSubRange(aMin,aMax);
94     
95   return this;
96 }
97
98 void VISU::IsoSurfaces_i::ToStream(std::ostringstream& theStr){
99   ScalarMap_i::ToStream(theStr);
100
101   Storable::DataToStream( theStr, "myNbSurface", int(GetNbSurfaces()) );
102   Storable::DataToStream( theStr, "myRange[0]", GetSubMin() );
103   Storable::DataToStream( theStr, "myRange[1]", GetSubMax() );
104 }
105
106
107 VISU::IsoSurfaces_i::~IsoSurfaces_i(){
108   if(MYDEBUG) MESSAGE("IsoSurfaces_i::~IsoSurfaces_i()");
109 }
110
111
112 void VISU::IsoSurfaces_i::SetNbSurfaces(CORBA::Long theNb){
113   myIsoSurfacesPL->SetNbParts(theNb);
114 }
115 CORBA::Long VISU::IsoSurfaces_i::GetNbSurfaces(){
116   return myIsoSurfacesPL->GetNbParts();
117 }
118
119
120 void VISU::IsoSurfaces_i::SetSubRange(CORBA::Double theMin, CORBA::Double theMax)
121
122   vtkFloatingPointType aRange[2] = {theMin, theMax};
123   myIsoSurfacesPL->SetRange(aRange);
124 }
125 CORBA::Double VISU::IsoSurfaces_i::GetSubMin(){
126   return myIsoSurfacesPL->GetMin();
127 }
128 CORBA::Double VISU::IsoSurfaces_i::GetSubMax(){
129   return myIsoSurfacesPL->GetMax();
130 }
131
132
133 void VISU::IsoSurfaces_i::DoHook(){
134   if(MYDEBUG) MESSAGE("IsoSurfaces_i::DoHook()- "<<myPipeLine);
135   if(!myPipeLine) myPipeLine = VISU_IsoSurfacesPL::New();
136   myIsoSurfacesPL = dynamic_cast<VISU_IsoSurfacesPL*>(myPipeLine);
137
138   ScalarMap_i::DoHook();
139 }
140
141
142 VISU_Actor* 
143 VISU::IsoSurfaces_i
144 ::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
145 {
146   if(VISU_Actor* anActor = ScalarMap_i::CreateActor(theIO)){
147     anActor->SetVTKMapping(true);
148     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
149     int  aDispMode = aResourceMgr->integerValue("VISU" , "iso_surfaces_represent", 2);
150     anActor->SetRepresentation(aDispMode);
151     return anActor;
152   }
153   return NULL;
154 }
155
156 void VISU::IsoSurfaces_i::SetMapScale(double theMapScale){
157   myIsoSurfacesPL->SetMapScale(theMapScale);
158 }