]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_Plot3D_i.cc
Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / VISU_I / VISU_Plot3D_i.cc
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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 #include "VISU_Plot3D_i.hh"
24 #include "VISU_Prs3dUtils.hh"
25
26 #include "VISU_Result_i.hh"
27 #include "VISU_Plot3DPL.hxx"
28 #include "VISU_Actor.h"
29
30 #include "SUIT_ResourceMgr.h"
31 #include "SALOME_Event.h"
32
33 #ifdef _DEBUG_
34 static int MYDEBUG = 0;
35 #else
36 static int MYDEBUG = 0;
37 #endif
38
39 using namespace std;
40
41 //---------------------------------------------------------------
42 size_t 
43 VISU::Plot3D_i
44 ::IsPossible(Result_i* theResult, 
45              const std::string& theMeshName, 
46              VISU::Entity theEntity,
47              const std::string& theFieldName, 
48              CORBA::Long theTimeStampNumber,
49              bool theIsMemoryCheck)
50 {
51   return TSuperClass::IsPossible(theResult,
52                                  theMeshName,
53                                  theEntity,
54                                  theFieldName,
55                                  theTimeStampNumber,
56                                  theIsMemoryCheck);
57 }
58
59 //---------------------------------------------------------------
60 int VISU::Plot3D_i::myNbPresent = 0;
61
62 //---------------------------------------------------------------
63 QString 
64 VISU::Plot3D_i
65 ::GenerateName() 
66
67   return VISU::GenerateName("Plot3D",myNbPresent++); 
68 }
69
70 //---------------------------------------------------------------
71 const string VISU::Plot3D_i::myComment = "PLOT3D";
72
73 //---------------------------------------------------------------
74 const char* 
75 VISU::Plot3D_i
76 ::GetComment() const 
77
78   return myComment.c_str(); 
79 }
80
81 //---------------------------------------------------------------
82 const char*
83 VISU::Plot3D_i
84 ::GetIconName()
85 {
86   if (!IsGroupsUsed())
87     return "ICON_TREE_PLOT_3D";
88   else
89     return "ICON_TREE_PLOT_3D_GROUPS";
90 }
91
92 //---------------------------------------------------------------
93 VISU::Plot3D_i
94 ::Plot3D_i(EPublishInStudyMode thePublishInStudyMode) :
95   ColoredPrs3d_i(thePublishInStudyMode),
96   ScalarMap_i(thePublishInStudyMode),
97   myPlot3DPL(NULL)
98 {}
99
100
101 //---------------------------------------------------------------
102 VISU::Storable* 
103 VISU::Plot3D_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::Plot3D_i
116 ::Restore(SALOMEDS::SObject_ptr theSObject,
117           const Storable::TRestoringMap& theMap)
118 {
119   if(!TSuperClass::Restore(theSObject, theMap))
120     return NULL;
121
122   SetOrientation(VISU::Plot3D::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
123                  Storable::FindValue(theMap,"aRot[0]").toDouble(),
124                  Storable::FindValue(theMap,"aRot[1]").toDouble());
125   SetPlanePosition(VISU::Storable::FindValue(theMap,"myPlanePosition").toDouble(),
126                    VISU::Storable::FindValue(theMap,"myPlaneCondition").toInt());
127   SetScaleFactor(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
128   SetContourPrs(VISU::Storable::FindValue(theMap,"myContourPrs").toInt());
129   SetNbOfContours(VISU::Storable::FindValue(theMap,"myNbOfContours").toInt());
130
131   return this;
132 }
133
134
135 //---------------------------------------------------------------
136 void
137 VISU::Plot3D_i
138 ::ToStream(std::ostringstream& theStr)
139 {
140   TSuperClass::ToStream(theStr);
141
142   Storable::DataToStream(theStr, "myBasePlane", int(GetOrientationType()));
143   Storable::DataToStream(theStr, "aRot[0]", GetRotateX());
144   Storable::DataToStream(theStr, "aRot[1]", GetRotateY());
145   Storable::DataToStream(theStr, "myPlanePosition", GetPlanePosition());
146   Storable::DataToStream(theStr, "myPlaneCondition", int(IsPositionRelative()));
147   Storable::DataToStream(theStr, "myScaleFactor", GetScaleFactor());
148   Storable::DataToStream(theStr, "myContourPrs", int(GetIsContourPrs()));
149   Storable::DataToStream(theStr, "myNbOfContours", int(GetNbOfContours()));
150 }
151
152
153 //---------------------------------------------------------------
154 VISU::Plot3D_i
155 ::~Plot3D_i()
156 {
157   if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()");
158 }
159
160
161 //---------------------------------------------------------------
162 void
163 VISU::Plot3D_i
164 ::SetOrientation(VISU::Plot3D::Orientation theOrient,
165                  CORBA::Double theXAngle, 
166                  CORBA::Double theYAngle)
167 {
168   struct TEvent: public SALOME_Event 
169   {
170     VISU_Plot3DPL* myPipeLine;
171     VISU_CutPlanesPL::PlaneOrientation myOrient;
172     CORBA::Double myXAngle;
173     CORBA::Double myYAngle;
174
175     TEvent(VISU_Plot3DPL* thePipeLine,
176            VISU_CutPlanesPL::PlaneOrientation theOrient,
177            CORBA::Double theXAngle, 
178            CORBA::Double theYAngle):
179       myPipeLine(thePipeLine),
180       myOrient(theOrient),
181       myXAngle(theXAngle),
182       myYAngle(theYAngle)
183     {}
184
185     virtual
186     void
187     Execute()
188     {
189       myPipeLine->SetOrientation(myOrient,
190                                  myXAngle,
191                                  myYAngle);
192     }
193   };
194
195   VISU::TSetModified aModified(this);
196   
197   ProcessVoidEvent(new TEvent(GetSpecificPL(),
198                               VISU_CutPlanesPL::PlaneOrientation(theOrient),
199                               theXAngle,
200                               theYAngle));
201 }
202
203
204 //---------------------------------------------------------------
205 VISU::Plot3D::Orientation
206 VISU::Plot3D_i
207 ::GetOrientationType()
208 {
209   return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation());
210 }
211
212
213 //---------------------------------------------------------------
214 CORBA::Double
215 VISU::Plot3D_i
216 ::GetRotateX()
217 {
218   return myPlot3DPL->GetRotateX();
219 }
220
221
222 //---------------------------------------------------------------
223 CORBA::Double 
224 VISU::Plot3D_i
225 ::GetRotateY()
226 {
227   return myPlot3DPL->GetRotateY();
228 }
229
230
231 //---------------------------------------------------------------
232 void
233 VISU::Plot3D_i
234 ::SetPlanePosition(CORBA::Double  thePlanePosition,
235                    CORBA::Boolean theIsRelative)
236 {
237   VISU::TSetModified aModified(this);
238   
239   ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_Plot3DPL, vtkFloatingPointType, bool>
240                    (GetSpecificPL(), &VISU_Plot3DPL::SetPlanePosition, thePlanePosition, theIsRelative));
241 }
242
243
244 //---------------------------------------------------------------
245 CORBA::Double
246 VISU::Plot3D_i
247 ::GetPlanePosition()
248 {
249   return myPlot3DPL->GetPlanePosition();
250 }
251
252
253 //---------------------------------------------------------------
254 CORBA::Boolean
255 VISU::Plot3D_i
256 ::IsPositionRelative()
257 {
258   return myPlot3DPL->IsPositionRelative();
259 }
260
261
262 //---------------------------------------------------------------
263 void
264 VISU::Plot3D_i
265 ::SetScaleFactor(CORBA::Double theScaleFactor)
266 {
267   VISU::TSetModified aModified(this);
268   
269   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, vtkFloatingPointType>
270                    (GetSpecificPL(), &VISU_Plot3DPL::SetScaleFactor, theScaleFactor));
271 }
272
273
274 //---------------------------------------------------------------
275 CORBA::Double
276 VISU::Plot3D_i
277 ::GetScaleFactor()
278 {
279   return myPlot3DPL->GetScaleFactor();
280 }
281
282
283 //---------------------------------------------------------------
284 void
285 VISU::Plot3D_i
286 ::SetNbOfContours(CORBA::Long theNb)
287 {
288   VISU::TSetModified aModified(this);
289   
290   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, int>
291                    (GetSpecificPL(), &VISU_Plot3DPL::SetNumberOfContours, theNb));
292 }
293
294
295 //---------------------------------------------------------------
296 CORBA::Long
297 VISU::Plot3D_i
298 ::GetNbOfContours()
299 {
300   return myPlot3DPL->GetNumberOfContours();
301 }
302
303
304 //---------------------------------------------------------------
305 void
306 VISU::Plot3D_i
307 ::SetContourPrs(CORBA::Boolean theIsContourPrs)
308 {
309   VISU::TSetModified aModified(this);
310   
311   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, bool>
312                    (GetSpecificPL(), &VISU_Plot3DPL::SetContourPrs, theIsContourPrs));
313 }
314
315
316 //---------------------------------------------------------------
317 CORBA::Boolean
318 VISU::Plot3D_i
319 ::GetIsContourPrs()
320 {
321   return myPlot3DPL->GetIsContourPrs();
322 }
323
324
325 //---------------------------------------------------------------
326 void
327 VISU::Plot3D_i
328 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
329 {
330   if(!thePipeLine){
331     myPlot3DPL = VISU_Plot3DPL::New();
332   }else
333     myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(thePipeLine);
334
335   TSuperClass::CreatePipeLine(myPlot3DPL);
336 }
337
338
339 //---------------------------------------------------------------
340 bool
341 VISU::Plot3D_i
342 ::CheckIsPossible() 
343 {
344   return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
345 }
346
347 //---------------------------------------------------------------
348 VISU_Actor* 
349 VISU::Plot3D_i
350 ::CreateActor()
351 {
352   if(VISU_Actor* anActor = TSuperClass::CreateActor()){
353     anActor->SetVTKMapping(true);
354     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
355     int aDispMode = aResourceMgr->integerValue("VISU", "plot3d_represent", 2);
356     anActor->SetRepresentation(aDispMode);
357     return anActor;
358   }
359   return NULL;
360 }
361
362
363 //---------------------------------------------------------------
364 void
365 VISU::Plot3D_i
366 ::SetMapScale(double theMapScale)
367 {
368   myPlot3DPL->SetMapScale(theMapScale);
369 }