1 // Copyright (C) 2007-2008 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
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_PrsObject_i.cxx
24 // Author : Alexey PETROV
27 #include "VISU_CutPlanesPL.hxx"
28 #include "VISU_Convertor.hxx"
29 #include "VISU_Prs3dUtils.hh"
30 #include "VISU_CutPlanes_i.hh"
32 #include "VISU_Result_i.hh"
33 #include "VISU_Actor.h"
35 #include "SUIT_ResourceMgr.h"
36 #include "SALOME_Event.h"
39 static int MYDEBUG = 0;
41 static int MYDEBUG = 0;
46 //----------------------------------------------------------------------------
49 ::IsPossible(Result_i* theResult,
50 const std::string& theMeshName,
51 VISU::Entity theEntity,
52 const std::string& theFieldName,
53 CORBA::Long theTimeStampNumber,
54 bool theIsMemoryCheck)
56 return TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theTimeStampNumber,theIsMemoryCheck);
60 //----------------------------------------------------------------------------
61 int VISU::CutPlanes_i::myNbPresent = 0;
63 //----------------------------------------------------------------------------
68 return VISU::GenerateName("CutPlanes",myNbPresent++);
71 //----------------------------------------------------------------------------
72 const string VISU::CutPlanes_i::myComment = "CUTPLANES";
74 //----------------------------------------------------------------------------
79 return myComment.c_str();
83 //----------------------------------------------------------------------------
89 return "ICON_TREE_CUT_PLANES";
91 return "ICON_TREE_CUT_PLANES_GROUPS";
95 //----------------------------------------------------------------------------
97 ::CutPlanes_i(EPublishInStudyMode thePublishInStudyMode):
98 ColoredPrs3d_i(thePublishInStudyMode),
99 ScalarMap_i(thePublishInStudyMode),
102 OptionalDeformation_i(this)
104 if(MYDEBUG) MESSAGE("CutPlanes_i::CutPlanes_i()");
108 //----------------------------------------------------------------------------
111 ::Create(const std::string& theMeshName,
112 VISU::Entity theEntity,
113 const std::string& theFieldName,
114 CORBA::Long theTimeStampNumber)
116 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
120 //----------------------------------------------------------------------------
123 ::Restore(SALOMEDS::SObject_ptr theSObject,
124 const Storable::TRestoringMap& theMap)
126 if(!TSuperClass::Restore(theSObject, theMap))
129 SetNbPlanes(VISU::Storable::FindValue(theMap,"myNbPlanes").toInt());
130 SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement").toDouble());
131 SetOrientation(VISU::CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
132 Storable::FindValue(theMap,"aRot[0]").toDouble(),
133 Storable::FindValue(theMap,"aRot[1]").toDouble());
134 QStringList aPosList = VISU::Storable::FindValue(theMap,"myPlanePosition").split("|", QString::SkipEmptyParts );
135 QStringList aCondList = VISU::Storable::FindValue(theMap,"myPlaneCondition").split("|", QString::SkipEmptyParts );
136 for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++)
137 if(aCondList[i].toInt() == 0)
138 SetPlanePosition(i,aPosList[i].toDouble());
140 OptionalDeformation_i::RestoreDeformation(theSObject,theMap);
146 //----------------------------------------------------------------------------
147 void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){
148 TSuperClass::ToStream(theStr);
150 Storable::DataToStream( theStr, "myNbPlanes", int(GetNbPlanes()));
151 Storable::DataToStream( theStr, "myDisplacement", GetDisplacement());
152 Storable::DataToStream( theStr, "myBasePlane", int(GetOrientationType()));
153 Storable::DataToStream( theStr, "aRot[0]", GetRotateX());
154 Storable::DataToStream( theStr, "aRot[1]", GetRotateY());
156 QString aStrPos, aStrCon;
157 for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++){
158 aStrPos.append(QString::number(GetPlanePosition(i)) + "|");
159 aStrCon.append(QString::number(IsDefault(i)) + "|");
161 Storable::DataToStream( theStr, "myPlanePosition", (const char*)aStrPos.toLatin1());
162 Storable::DataToStream( theStr, "myPlaneCondition", (const char*)aStrCon.toLatin1());
163 OptionalDeformation_i::DeformationToStream(theStr);
167 //----------------------------------------------------------------------------
171 if(MYDEBUG) MESSAGE("CutPlanes_i::~CutPlanes_i()");
175 //----------------------------------------------------------------------------
178 ::SetOrientation(VISU::CutPlanes::Orientation theOrient,
179 CORBA::Double theXAngle,
180 CORBA::Double theYAngle)
182 struct TEvent: public SALOME_Event
184 VISU_CutPlanesPL* myPipeLine;
185 VISU_CutPlanesPL::PlaneOrientation myOrient;
186 CORBA::Double myXAngle;
187 CORBA::Double myYAngle;
189 TEvent(VISU_CutPlanesPL* thePipeLine,
190 VISU_CutPlanesPL::PlaneOrientation theOrient,
191 CORBA::Double theXAngle,
192 CORBA::Double theYAngle):
193 myPipeLine(thePipeLine),
203 myPipeLine->SetOrientation(myOrient,
209 VISU::TSetModified aModified(this);
211 ProcessVoidEvent(new TEvent(GetSpecificPL(),
212 VISU_CutPlanesPL::PlaneOrientation(theOrient),
217 //----------------------------------------------------------------------------
218 VISU::CutPlanes::Orientation
220 ::GetOrientationType()
222 return VISU::CutPlanes::Orientation(myCutPlanesPL->GetPlaneOrientation());
225 //----------------------------------------------------------------------------
230 return myCutPlanesPL->GetRotateX();
233 //----------------------------------------------------------------------------
238 return myCutPlanesPL->GetRotateY();
242 //----------------------------------------------------------------------------
245 ::SetDisplacement(CORBA::Double theDisp)
247 VISU::TSetModified aModified(this);
249 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutPlanesPL, vtkFloatingPointType, int>
250 (GetSpecificPL(), &VISU_CutPlanesPL::SetDisplacement, theDisp, 0));
253 //----------------------------------------------------------------------------
258 return myCutPlanesPL->GetDisplacement();
262 //----------------------------------------------------------------------------
265 ::SetPlanePosition(CORBA::Long thePlaneNumber,
266 CORBA::Double thePlanePosition)
268 VISU::TSetModified aModified(this);
270 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutPlanesPL, int, vtkFloatingPointType>
271 (GetSpecificPL(), &VISU_CutPlanesPL::SetPartPosition, thePlaneNumber, thePlanePosition));
274 //----------------------------------------------------------------------------
277 ::GetPlanePosition(CORBA::Long thePlaneNumber)
279 return myCutPlanesPL->GetPartPosition(thePlaneNumber);
283 //----------------------------------------------------------------------------
286 ::SetDefault(CORBA::Long thePlaneNumber)
288 VISU::TSetModified aModified(this);
290 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutPlanesPL, int>
291 (GetSpecificPL(), &VISU_CutPlanesPL::SetPartDefault, thePlaneNumber));
294 //----------------------------------------------------------------------------
297 ::IsDefault(CORBA::Long thePlaneNumber)
299 return myCutPlanesPL->IsPartDefault(thePlaneNumber);
303 //----------------------------------------------------------------------------
306 ::SetNbPlanes(CORBA::Long theNb)
308 VISU::TSetModified aModified(this);
310 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutPlanesPL, int>
311 (GetSpecificPL(), &VISU_CutPlanesPL::SetNbParts, theNb));
314 //----------------------------------------------------------------------------
319 return myCutPlanesPL->GetNbParts();
323 //----------------------------------------------------------------------------
326 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
329 myCutPlanesPL = VISU_CutPlanesPL::New();
331 myCutPlanesPL = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine);
333 InitDeformedPipeLine(myCutPlanesPL);
334 TSuperClass::CreatePipeLine(myCutPlanesPL);
338 //---------------------------------------------------------------
343 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
346 //----------------------------------------------------------------------------
351 if(VISU_Actor* anActor = TSuperClass::CreateActor()){
352 anActor->SetVTKMapping(true);
353 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
354 int aDispMode = aResourceMgr->integerValue("VISU" , "cut_planes_represent", 1);
355 anActor->SetRepresentation(aDispMode);
363 SameAs(const Prs3d_i* theOrigin){
364 if(MYDEBUG) MESSAGE("CutPlanes_i::SameAs()");
365 TSuperClass::SameAs(theOrigin);
366 OptionalDeformation_i::SameAsDeformation(dynamic_cast<const Deformation_i*>(theOrigin));