]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_IsoSurfaces_i.cc
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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_IsoSurfaces_i.hh"
28 #include "VISU_Prs3dUtils.hh"
29
30 #include "VISU_IsoSurfacesPL.hxx"
31 #include "VISU_Result_i.hh"
32 #include "VISU_Actor.h"
33
34 #include "SUIT_ResourceMgr.h"
35 #include "SALOME_Event.hxx"
36
37 #ifdef _DEBUG_
38 static int MYDEBUG = 0;
39 #else
40 static int MYDEBUG = 0;
41 #endif
42
43 //---------------------------------------------------------------
44 size_t
45 VISU::IsoSurfaces_i
46 ::IsPossible(Result_i* theResult, 
47              const std::string& theMeshName, 
48              VISU::Entity theEntity,
49              const std::string& theFieldName, 
50              CORBA::Long theTimeStampNumber,
51              bool theIsMemoryCheck)
52 {
53   return TSuperClass::IsPossible(theResult,
54                                  theMeshName,
55                                  theEntity,
56                                  theFieldName,
57                                  theTimeStampNumber,
58                                  theIsMemoryCheck);
59 }
60
61 //---------------------------------------------------------------
62 int VISU::IsoSurfaces_i::myNbPresent = 0;
63
64 //---------------------------------------------------------------
65 QString VISU::IsoSurfaces_i::GenerateName()
66
67   return VISU::GenerateName("IsoSurfaces",myNbPresent++);
68 }
69
70 //---------------------------------------------------------------
71 const string VISU::IsoSurfaces_i::myComment = "ISOSURFACES";
72
73 //---------------------------------------------------------------
74 const char* 
75 VISU::IsoSurfaces_i
76 ::GetComment() const
77
78   return myComment.c_str();
79 }
80
81 //---------------------------------------------------------------
82 const char*
83 VISU::IsoSurfaces_i
84 ::GetIconName()
85 {
86   if (!IsGroupsUsed())
87     return "ICON_TREE_ISO_SURFACES";
88   else
89     return "ICON_TREE_ISO_SURFACES_GROUPS";
90 }
91
92 //---------------------------------------------------------------
93 VISU::IsoSurfaces_i
94 ::IsoSurfaces_i(EPublishInStudyMode thePublishInStudyMode) :
95   ColoredPrs3d_i(thePublishInStudyMode),
96   ScalarMap_i(thePublishInStudyMode),
97   myIsoSurfacesPL(NULL)
98 {}
99
100
101 //---------------------------------------------------------------
102 VISU::Storable* 
103 VISU::IsoSurfaces_i
104 ::Create(const std::string& theMeshName, 
105          VISU::Entity theEntity,
106          const std::string& theFieldName, 
107          CORBA::Long theTimeStampNumber)
108 {
109   return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
110 }
111
112
113 //---------------------------------------------------------------
114 VISU::Storable* 
115 VISU::IsoSurfaces_i
116 ::Restore(SALOMEDS::SObject_ptr theSObject,
117           const Storable::TRestoringMap& theMap)
118 {
119   if(!TSuperClass::Restore(theSObject, theMap))
120     return NULL;
121
122   SetNbSurfaces(VISU::Storable::FindValue(theMap,"myNbSurface").toInt());
123   float aMin = VISU::Storable::FindValue(theMap,"myRange[0]").toDouble();
124   float aMax = VISU::Storable::FindValue(theMap,"myRange[1]").toDouble();
125   SetSubRange(aMin,aMax);
126     
127   return this;
128 }
129
130
131 //---------------------------------------------------------------
132 void
133 VISU::IsoSurfaces_i
134 ::ToStream(std::ostringstream& theStr)
135 {
136   TSuperClass::ToStream(theStr);
137
138   Storable::DataToStream( theStr, "myNbSurface", int(GetNbSurfaces()) );
139   Storable::DataToStream( theStr, "myRange[0]", GetSubMin() );
140   Storable::DataToStream( theStr, "myRange[1]", GetSubMax() );
141 }
142
143
144 //---------------------------------------------------------------
145 VISU::IsoSurfaces_i
146 ::~IsoSurfaces_i()
147 {
148   if(MYDEBUG) MESSAGE("IsoSurfaces_i::~IsoSurfaces_i()");
149 }
150
151
152 //---------------------------------------------------------------
153 void 
154 VISU::IsoSurfaces_i
155 ::SetNbSurfaces(CORBA::Long theNb)
156 {
157   VISU::TSetModified aModified(this);
158   
159   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_IsoSurfacesPL, int>
160                    (GetSpecificPL(), &VISU_IsoSurfacesPL::SetNbParts, theNb));
161 }
162
163 //---------------------------------------------------------------
164 CORBA::Long 
165 VISU::IsoSurfaces_i
166 ::GetNbSurfaces()
167 {
168   return myIsoSurfacesPL->GetNbParts();
169 }
170
171
172 //---------------------------------------------------------------
173 void
174 VISU::IsoSurfaces_i
175 ::SetSubRange(CORBA::Double theMin, CORBA::Double theMax)
176
177   VISU::TSetModified aModified(this);
178   
179   vtkFloatingPointType aRange[2] = {theMin, theMax};
180   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_IsoSurfacesPL, vtkFloatingPointType*>
181                    (GetSpecificPL(), &VISU_IsoSurfacesPL::SetRange, aRange));
182 }
183
184 //---------------------------------------------------------------
185 CORBA::Double 
186 VISU::IsoSurfaces_i
187 ::GetSubMin()
188 {
189   return myIsoSurfacesPL->GetMin();
190 }
191
192 //---------------------------------------------------------------
193 CORBA::Double 
194 VISU::IsoSurfaces_i
195 ::GetSubMax()
196 {
197   return myIsoSurfacesPL->GetMax();
198 }
199
200
201 //---------------------------------------------------------------
202 void 
203 VISU::IsoSurfaces_i
204 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
205 {
206   if(!thePipeLine){
207     myIsoSurfacesPL = VISU_IsoSurfacesPL::New();
208   }else
209     myIsoSurfacesPL = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine);
210
211   TSuperClass::CreatePipeLine(myIsoSurfacesPL);
212 }
213
214
215 //----------------------------------------------------------------------------
216 void 
217 VISU::IsoSurfaces_i
218 ::DoSetInput(bool theIsInitilizePipe, bool theReInit)
219 {
220   TSuperClass::DoSetInput(theIsInitilizePipe, theReInit);
221   if(theIsInitilizePipe || (!IsTimeStampFixed() && !IsRangeFixed()) || theReInit)
222     SetSubRange(GetSourceMin(), GetSourceMax());
223 }
224
225 //---------------------------------------------------------------
226 bool
227 VISU::IsoSurfaces_i
228 ::CheckIsPossible() 
229 {
230   return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
231 }
232
233 //---------------------------------------------------------------
234 VISU_Actor* 
235 VISU::IsoSurfaces_i
236 ::CreateActor()
237 {
238   if(VISU_Actor* anActor = TSuperClass::CreateActor()){
239     anActor->SetVTKMapping(true);
240     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
241     int  aDispMode = aResourceMgr->integerValue("VISU" , "iso_surfaces_represent", 2);
242     anActor->SetRepresentation(aDispMode);
243     return anActor;
244   }
245   return NULL;
246 }
247
248
249 //---------------------------------------------------------------
250 void
251 VISU::IsoSurfaces_i
252 ::SetMapScale(double theMapScale)
253 {
254   myIsoSurfacesPL->SetMapScale(theMapScale);
255 }