1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "VISU_Plot3D_i.hh"
24 #include "VISU_Prs3dUtils.hh"
26 #include "VISU_Result_i.hh"
27 #include "VISU_Plot3DPL.hxx"
28 #include "VISU_Actor.h"
30 #include "SUIT_ResourceMgr.h"
31 #include "SALOME_Event.h"
34 static int MYDEBUG = 0;
36 static int MYDEBUG = 0;
41 //---------------------------------------------------------------
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)
51 return TSuperClass::IsPossible(theResult,
59 //---------------------------------------------------------------
60 int VISU::Plot3D_i::myNbPresent = 0;
62 //---------------------------------------------------------------
67 return VISU::GenerateName("Plot3D",myNbPresent++);
70 //---------------------------------------------------------------
71 const string VISU::Plot3D_i::myComment = "PLOT3D";
73 //---------------------------------------------------------------
78 return myComment.c_str();
81 //---------------------------------------------------------------
87 return "ICON_TREE_PLOT_3D";
89 return "ICON_TREE_PLOT_3D_GROUPS";
92 //---------------------------------------------------------------
94 ::Plot3D_i(EPublishInStudyMode thePublishInStudyMode) :
95 ColoredPrs3d_i(thePublishInStudyMode),
96 ScalarMap_i(thePublishInStudyMode),
101 //---------------------------------------------------------------
104 ::Create(const std::string& theMeshName,
105 VISU::Entity theEntity,
106 const std::string& theFieldName,
107 CORBA::Long theTimeStampNumber)
109 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
113 //---------------------------------------------------------------
116 ::Restore(SALOMEDS::SObject_ptr theSObject,
117 const Storable::TRestoringMap& theMap)
119 if(!TSuperClass::Restore(theSObject, theMap))
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());
135 //---------------------------------------------------------------
138 ::ToStream(std::ostringstream& theStr)
140 TSuperClass::ToStream(theStr);
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()));
153 //---------------------------------------------------------------
157 if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()");
161 //---------------------------------------------------------------
164 ::SetOrientation(VISU::Plot3D::Orientation theOrient,
165 CORBA::Double theXAngle,
166 CORBA::Double theYAngle)
168 struct TEvent: public SALOME_Event
170 VISU_Plot3DPL* myPipeLine;
171 VISU_CutPlanesPL::PlaneOrientation myOrient;
172 CORBA::Double myXAngle;
173 CORBA::Double myYAngle;
175 TEvent(VISU_Plot3DPL* thePipeLine,
176 VISU_CutPlanesPL::PlaneOrientation theOrient,
177 CORBA::Double theXAngle,
178 CORBA::Double theYAngle):
179 myPipeLine(thePipeLine),
189 myPipeLine->SetOrientation(myOrient,
195 VISU::TSetModified aModified(this);
197 ProcessVoidEvent(new TEvent(GetSpecificPL(),
198 VISU_CutPlanesPL::PlaneOrientation(theOrient),
204 //---------------------------------------------------------------
205 VISU::Plot3D::Orientation
207 ::GetOrientationType()
209 return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation());
213 //---------------------------------------------------------------
218 return myPlot3DPL->GetRotateX();
222 //---------------------------------------------------------------
227 return myPlot3DPL->GetRotateY();
231 //---------------------------------------------------------------
234 ::SetPlanePosition(CORBA::Double thePlanePosition,
235 CORBA::Boolean theIsRelative)
237 VISU::TSetModified aModified(this);
239 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_Plot3DPL, double, bool>
240 (GetSpecificPL(), &VISU_Plot3DPL::SetPlanePosition, thePlanePosition, theIsRelative));
244 //---------------------------------------------------------------
249 return myPlot3DPL->GetPlanePosition();
253 //---------------------------------------------------------------
256 ::IsPositionRelative()
258 return myPlot3DPL->IsPositionRelative();
262 //---------------------------------------------------------------
265 ::SetScaleFactor(CORBA::Double theScaleFactor)
267 VISU::TSetModified aModified(this);
269 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, double>
270 (GetSpecificPL(), &VISU_Plot3DPL::SetScaleFactor, theScaleFactor));
274 //---------------------------------------------------------------
279 return myPlot3DPL->GetScaleFactor();
283 //---------------------------------------------------------------
286 ::SetNbOfContours(CORBA::Long theNb)
288 VISU::TSetModified aModified(this);
290 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, int>
291 (GetSpecificPL(), &VISU_Plot3DPL::SetNumberOfContours, theNb));
295 //---------------------------------------------------------------
300 return myPlot3DPL->GetNumberOfContours();
304 //---------------------------------------------------------------
307 ::SetContourPrs(CORBA::Boolean theIsContourPrs)
309 VISU::TSetModified aModified(this);
311 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_Plot3DPL, bool>
312 (GetSpecificPL(), &VISU_Plot3DPL::SetContourPrs, theIsContourPrs));
316 //---------------------------------------------------------------
321 return myPlot3DPL->GetIsContourPrs();
325 //---------------------------------------------------------------
328 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
331 myPlot3DPL = VISU_Plot3DPL::New();
333 myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(thePipeLine);
335 TSuperClass::CreatePipeLine(myPlot3DPL);
339 //---------------------------------------------------------------
344 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
347 //---------------------------------------------------------------
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);
363 //---------------------------------------------------------------
366 ::SetMapScale(double theMapScale)
368 myPlot3DPL->SetMapScale(theMapScale);