1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "VISU_Plot3D_i.hh"
22 #include "VISU_Prs3dUtils.hh"
24 #include "VISU_Result_i.hh"
25 #include "VISU_Plot3DPL.hxx"
26 #include "VISU_Actor.h"
28 #include "SUIT_ResourceMgr.h"
29 #include "SALOME_Event.hxx"
32 static int MYDEBUG = 0;
34 static int MYDEBUG = 0;
38 //---------------------------------------------------------------
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)
48 return TSuperClass::IsPossible(theResult,
56 //---------------------------------------------------------------
57 int VISU::Plot3D_i::myNbPresent = 0;
59 //---------------------------------------------------------------
64 return VISU::GenerateName("Plot3D",myNbPresent++);
67 //---------------------------------------------------------------
68 const string VISU::Plot3D_i::myComment = "PLOT3D";
70 //---------------------------------------------------------------
75 return myComment.c_str();
78 //---------------------------------------------------------------
84 return "ICON_TREE_PLOT_3D";
86 return "ICON_TREE_PLOT_3D_GROUPS";
89 //---------------------------------------------------------------
91 ::Plot3D_i(EPublishInStudyMode thePublishInStudyMode) :
92 ColoredPrs3d_i(thePublishInStudyMode),
93 ScalarMap_i(thePublishInStudyMode),
98 //---------------------------------------------------------------
101 ::Create(const std::string& theMeshName,
102 VISU::Entity theEntity,
103 const std::string& theFieldName,
104 CORBA::Long theTimeStampNumber)
106 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
110 //---------------------------------------------------------------
113 ::Restore(SALOMEDS::SObject_ptr theSObject,
114 const Storable::TRestoringMap& theMap)
116 if(!TSuperClass::Restore(theSObject, theMap))
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());
132 //---------------------------------------------------------------
135 ::ToStream(std::ostringstream& theStr)
137 TSuperClass::ToStream(theStr);
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()));
150 //---------------------------------------------------------------
154 if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()");
158 //---------------------------------------------------------------
161 ::SetOrientation(VISU::Plot3D::Orientation theOrient,
162 CORBA::Double theXAngle,
163 CORBA::Double theYAngle)
165 struct TEvent: public SALOME_Event
167 VISU_Plot3DPL* myPipeLine;
168 VISU_CutPlanesPL::PlaneOrientation myOrient;
169 CORBA::Double myXAngle;
170 CORBA::Double myYAngle;
172 TEvent(VISU_Plot3DPL* thePipeLine,
173 VISU_CutPlanesPL::PlaneOrientation theOrient,
174 CORBA::Double theXAngle,
175 CORBA::Double theYAngle):
176 myPipeLine(thePipeLine),
186 myPipeLine->SetOrientation(myOrient,
192 VISU::TSetModified aModified(this);
194 ProcessVoidEvent(new TEvent(GetSpecificPL(),
195 VISU_CutPlanesPL::PlaneOrientation(theOrient),
201 //---------------------------------------------------------------
202 VISU::Plot3D::Orientation
204 ::GetOrientationType()
206 return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation());
210 //---------------------------------------------------------------
215 return myPlot3DPL->GetRotateX();
219 //---------------------------------------------------------------
224 return myPlot3DPL->GetRotateY();
228 //---------------------------------------------------------------
231 ::SetPlanePosition(CORBA::Double thePlanePosition,
232 CORBA::Boolean theIsRelative)
234 VISU::TSetModified aModified(this);
236 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_Plot3DPL, vtkFloatingPointType, bool>
237 (GetSpecificPL(), &VISU_Plot3DPL::SetPlanePosition, thePlanePosition, theIsRelative));
241 //---------------------------------------------------------------
246 return myPlot3DPL->GetPlanePosition();
250 //---------------------------------------------------------------
253 ::IsPositionRelative()
255 return myPlot3DPL->IsPositionRelative();
259 //---------------------------------------------------------------
262 ::SetScaleFactor(CORBA::Double theScaleFactor)
264 VISU::TSetModified aModified(this);
266 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, vtkFloatingPointType>
267 (GetSpecificPL(), &VISU_Plot3DPL::SetScaleFactor, theScaleFactor));
271 //---------------------------------------------------------------
276 return myPlot3DPL->GetScaleFactor();
280 //---------------------------------------------------------------
283 ::SetNbOfContours(CORBA::Long theNb)
285 VISU::TSetModified aModified(this);
287 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, int>
288 (GetSpecificPL(), &VISU_Plot3DPL::SetNumberOfContours, theNb));
292 //---------------------------------------------------------------
297 return myPlot3DPL->GetNumberOfContours();
301 //---------------------------------------------------------------
304 ::SetContourPrs(CORBA::Boolean theIsContourPrs)
306 VISU::TSetModified aModified(this);
308 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, bool>
309 (GetSpecificPL(), &VISU_Plot3DPL::SetContourPrs, theIsContourPrs));
313 //---------------------------------------------------------------
318 return myPlot3DPL->GetIsContourPrs();
322 //---------------------------------------------------------------
325 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
328 myPlot3DPL = VISU_Plot3DPL::New();
330 myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(thePipeLine);
332 TSuperClass::CreatePipeLine(myPlot3DPL);
336 //---------------------------------------------------------------
341 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
344 //---------------------------------------------------------------
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);
360 //---------------------------------------------------------------
363 ::SetMapScale(double theMapScale)
365 myPlot3DPL->SetMapScale(theMapScale);