]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_Plot3D_i.cc
Salome HOME
a8de05e67d153a7b2ae860a23d5d6b43e13b1ed1
[modules/visu.git] / src / VISU_I / VISU_Plot3D_i.cc
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20
21 #include "VISU_Plot3D_i.hh"
22 #include "VISU_Prs3dUtils.hh"
23
24 #include "VISU_Result_i.hh"
25 #include "VISU_Plot3DPL.hxx"
26 #include "VISU_Actor.h"
27
28 #include "SUIT_ResourceMgr.h"
29 #include "SALOME_Event.hxx"
30
31 #ifdef _DEBUG_
32 static int MYDEBUG = 0;
33 #else
34 static int MYDEBUG = 0;
35 #endif
36
37
38 //---------------------------------------------------------------
39 size_t 
40 VISU::Plot3D_i
41 ::IsPossible(Result_i* theResult, 
42              const std::string& theMeshName, 
43              VISU::Entity theEntity,
44              const std::string& theFieldName, 
45              CORBA::Long theTimeStampNumber,
46              bool theIsMemoryCheck)
47 {
48   return TSuperClass::IsPossible(theResult,
49                                  theMeshName,
50                                  theEntity,
51                                  theFieldName,
52                                  theTimeStampNumber,
53                                  theIsMemoryCheck);
54 }
55
56 //---------------------------------------------------------------
57 int VISU::Plot3D_i::myNbPresent = 0;
58
59 //---------------------------------------------------------------
60 QString 
61 VISU::Plot3D_i
62 ::GenerateName() 
63
64   return VISU::GenerateName("Plot3D",myNbPresent++); 
65 }
66
67 //---------------------------------------------------------------
68 const string VISU::Plot3D_i::myComment = "PLOT3D";
69
70 //---------------------------------------------------------------
71 const char* 
72 VISU::Plot3D_i
73 ::GetComment() const 
74
75   return myComment.c_str(); 
76 }
77
78 //---------------------------------------------------------------
79 const char*
80 VISU::Plot3D_i
81 ::GetIconName()
82 {
83   if (!IsGroupsUsed())
84     return "ICON_TREE_PLOT_3D";
85   else
86     return "ICON_TREE_PLOT_3D_GROUPS";
87 }
88
89 //---------------------------------------------------------------
90 VISU::Plot3D_i
91 ::Plot3D_i(EPublishInStudyMode thePublishInStudyMode) :
92   ColoredPrs3d_i(thePublishInStudyMode),
93   ScalarMap_i(thePublishInStudyMode),
94   myPlot3DPL(NULL)
95 {}
96
97
98 //---------------------------------------------------------------
99 VISU::Storable* 
100 VISU::Plot3D_i
101 ::Create(const std::string& theMeshName, 
102          VISU::Entity theEntity,
103          const std::string& theFieldName, 
104          CORBA::Long theTimeStampNumber)
105 {
106   return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
107 }
108
109
110 //---------------------------------------------------------------
111 VISU::Storable* 
112 VISU::Plot3D_i
113 ::Restore(SALOMEDS::SObject_ptr theSObject,
114           const Storable::TRestoringMap& theMap)
115 {
116   if(!TSuperClass::Restore(theSObject, theMap))
117     return NULL;
118
119   SetOrientation(VISU::Plot3D::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
120                  Storable::FindValue(theMap,"aRot[0]").toDouble(),
121                  Storable::FindValue(theMap,"aRot[1]").toDouble());
122   SetPlanePosition(VISU::Storable::FindValue(theMap,"myPlanePosition").toDouble(),
123                    VISU::Storable::FindValue(theMap,"myPlaneCondition").toInt());
124   SetScaleFactor(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
125   SetContourPrs(VISU::Storable::FindValue(theMap,"myContourPrs").toInt());
126   SetNbOfContours(VISU::Storable::FindValue(theMap,"myNbOfContours").toInt());
127
128   return this;
129 }
130
131
132 //---------------------------------------------------------------
133 void
134 VISU::Plot3D_i
135 ::ToStream(std::ostringstream& theStr)
136 {
137   TSuperClass::ToStream(theStr);
138
139   Storable::DataToStream(theStr, "myBasePlane", int(GetOrientationType()));
140   Storable::DataToStream(theStr, "aRot[0]", GetRotateX());
141   Storable::DataToStream(theStr, "aRot[1]", GetRotateY());
142   Storable::DataToStream(theStr, "myPlanePosition", GetPlanePosition());
143   Storable::DataToStream(theStr, "myPlaneCondition", int(IsPositionRelative()));
144   Storable::DataToStream(theStr, "myScaleFactor", GetScaleFactor());
145   Storable::DataToStream(theStr, "myContourPrs", int(GetIsContourPrs()));
146   Storable::DataToStream(theStr, "myNbOfContours", int(GetNbOfContours()));
147 }
148
149
150 //---------------------------------------------------------------
151 VISU::Plot3D_i
152 ::~Plot3D_i()
153 {
154   if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()");
155 }
156
157
158 //---------------------------------------------------------------
159 void
160 VISU::Plot3D_i
161 ::SetOrientation(VISU::Plot3D::Orientation theOrient,
162                  CORBA::Double theXAngle, 
163                  CORBA::Double theYAngle)
164 {
165   struct TEvent: public SALOME_Event 
166   {
167     VISU_Plot3DPL* myPipeLine;
168     VISU_CutPlanesPL::PlaneOrientation myOrient;
169     CORBA::Double myXAngle;
170     CORBA::Double myYAngle;
171
172     TEvent(VISU_Plot3DPL* thePipeLine,
173            VISU_CutPlanesPL::PlaneOrientation theOrient,
174            CORBA::Double theXAngle, 
175            CORBA::Double theYAngle):
176       myPipeLine(thePipeLine),
177       myOrient(theOrient),
178       myXAngle(theXAngle),
179       myYAngle(theYAngle)
180     {}
181
182     virtual
183     void
184     Execute()
185     {
186       myPipeLine->SetOrientation(myOrient,
187                                  myXAngle,
188                                  myYAngle);
189     }
190   };
191
192   VISU::TSetModified aModified(this);
193   
194   ProcessVoidEvent(new TEvent(GetSpecificPL(),
195                               VISU_CutPlanesPL::PlaneOrientation(theOrient),
196                               theXAngle,
197                               theYAngle));
198 }
199
200
201 //---------------------------------------------------------------
202 VISU::Plot3D::Orientation
203 VISU::Plot3D_i
204 ::GetOrientationType()
205 {
206   return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation());
207 }
208
209
210 //---------------------------------------------------------------
211 CORBA::Double
212 VISU::Plot3D_i
213 ::GetRotateX()
214 {
215   return myPlot3DPL->GetRotateX();
216 }
217
218
219 //---------------------------------------------------------------
220 CORBA::Double 
221 VISU::Plot3D_i
222 ::GetRotateY()
223 {
224   return myPlot3DPL->GetRotateY();
225 }
226
227
228 //---------------------------------------------------------------
229 void
230 VISU::Plot3D_i
231 ::SetPlanePosition(CORBA::Double  thePlanePosition,
232                    CORBA::Boolean theIsRelative)
233 {
234   VISU::TSetModified aModified(this);
235   
236   ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_Plot3DPL, vtkFloatingPointType, bool>
237                    (GetSpecificPL(), &VISU_Plot3DPL::SetPlanePosition, thePlanePosition, theIsRelative));
238 }
239
240
241 //---------------------------------------------------------------
242 CORBA::Double
243 VISU::Plot3D_i
244 ::GetPlanePosition()
245 {
246   return myPlot3DPL->GetPlanePosition();
247 }
248
249
250 //---------------------------------------------------------------
251 CORBA::Boolean
252 VISU::Plot3D_i
253 ::IsPositionRelative()
254 {
255   return myPlot3DPL->IsPositionRelative();
256 }
257
258
259 //---------------------------------------------------------------
260 void
261 VISU::Plot3D_i
262 ::SetScaleFactor(CORBA::Double theScaleFactor)
263 {
264   VISU::TSetModified aModified(this);
265   
266   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, vtkFloatingPointType>
267                    (GetSpecificPL(), &VISU_Plot3DPL::SetScaleFactor, theScaleFactor));
268 }
269
270
271 //---------------------------------------------------------------
272 CORBA::Double
273 VISU::Plot3D_i
274 ::GetScaleFactor()
275 {
276   return myPlot3DPL->GetScaleFactor();
277 }
278
279
280 //---------------------------------------------------------------
281 void
282 VISU::Plot3D_i
283 ::SetNbOfContours(CORBA::Long theNb)
284 {
285   VISU::TSetModified aModified(this);
286   
287   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, int>
288                    (GetSpecificPL(), &VISU_Plot3DPL::SetNumberOfContours, theNb));
289 }
290
291
292 //---------------------------------------------------------------
293 CORBA::Long
294 VISU::Plot3D_i
295 ::GetNbOfContours()
296 {
297   return myPlot3DPL->GetNumberOfContours();
298 }
299
300
301 //---------------------------------------------------------------
302 void
303 VISU::Plot3D_i
304 ::SetContourPrs(CORBA::Boolean theIsContourPrs)
305 {
306   VISU::TSetModified aModified(this);
307   
308   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, bool>
309                    (GetSpecificPL(), &VISU_Plot3DPL::SetContourPrs, theIsContourPrs));
310 }
311
312
313 //---------------------------------------------------------------
314 CORBA::Boolean
315 VISU::Plot3D_i
316 ::GetIsContourPrs()
317 {
318   return myPlot3DPL->GetIsContourPrs();
319 }
320
321
322 //---------------------------------------------------------------
323 void
324 VISU::Plot3D_i
325 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
326 {
327   if(!thePipeLine){
328     myPlot3DPL = VISU_Plot3DPL::New();
329   }else
330     myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(thePipeLine);
331
332   TSuperClass::CreatePipeLine(myPlot3DPL);
333 }
334
335
336 //---------------------------------------------------------------
337 bool
338 VISU::Plot3D_i
339 ::CheckIsPossible() 
340 {
341   return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
342 }
343
344 //---------------------------------------------------------------
345 VISU_Actor* 
346 VISU::Plot3D_i
347 ::CreateActor()
348 {
349   if(VISU_Actor* anActor = TSuperClass::CreateActor()){
350     anActor->SetVTKMapping(true);
351     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
352     int aDispMode = aResourceMgr->integerValue("VISU", "plot3d_represent", 2);
353     anActor->SetRepresentation(aDispMode);
354     return anActor;
355   }
356   return NULL;
357 }
358
359
360 //---------------------------------------------------------------
361 void
362 VISU::Plot3D_i
363 ::SetMapScale(double theMapScale)
364 {
365   myPlot3DPL->SetMapScale(theMapScale);
366 }