1 // Copyright (C) 2007-2010 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 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_PrsObject_i.cxx
25 // Author : Alexey PETROV
28 #include "VISU_CutPlanesPL.hxx"
29 #include "VISU_Convertor.hxx"
30 #include "VISU_Prs3dUtils.hh"
31 #include "VISU_CutPlanes_i.hh"
33 #include "VISU_Result_i.hh"
34 #include "VISU_Actor.h"
36 #include "SUIT_ResourceMgr.h"
37 #include "SALOME_Event.h"
40 static int MYDEBUG = 0;
42 static int MYDEBUG = 0;
47 //----------------------------------------------------------------------------
50 ::IsPossible(Result_i* theResult,
51 const std::string& theMeshName,
52 VISU::Entity theEntity,
53 const std::string& theFieldName,
54 CORBA::Long theTimeStampNumber,
55 bool theIsMemoryCheck)
57 return TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theTimeStampNumber,theIsMemoryCheck);
61 //----------------------------------------------------------------------------
62 int VISU::CutPlanes_i::myNbPresent = 0;
64 //----------------------------------------------------------------------------
69 return VISU::GenerateName("CutPlanes",myNbPresent++);
72 //----------------------------------------------------------------------------
73 const string VISU::CutPlanes_i::myComment = "CUTPLANES";
75 //----------------------------------------------------------------------------
80 return myComment.c_str();
84 //----------------------------------------------------------------------------
90 return "ICON_TREE_CUT_PLANES";
92 return "ICON_TREE_CUT_PLANES_GROUPS";
96 //----------------------------------------------------------------------------
98 ::CutPlanes_i(EPublishInStudyMode thePublishInStudyMode):
99 ColoredPrs3d_i(thePublishInStudyMode),
100 ScalarMap_i(thePublishInStudyMode),
103 OptionalDeformation_i(this)
105 if(MYDEBUG) MESSAGE("CutPlanes_i::CutPlanes_i()");
109 //----------------------------------------------------------------------------
112 ::Create(const std::string& theMeshName,
113 VISU::Entity theEntity,
114 const std::string& theFieldName,
115 CORBA::Long theTimeStampNumber)
117 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
121 //----------------------------------------------------------------------------
124 ::Restore(SALOMEDS::SObject_ptr theSObject,
125 const Storable::TRestoringMap& theMap)
127 if(!TSuperClass::Restore(theSObject, theMap))
130 SetNbPlanes(VISU::Storable::FindValue(theMap,"myNbPlanes").toInt());
131 SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement").toDouble());
132 SetOrientation(VISU::CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
133 Storable::FindValue(theMap,"aRot[0]").toDouble(),
134 Storable::FindValue(theMap,"aRot[1]").toDouble());
135 QStringList aPosList = VISU::Storable::FindValue(theMap,"myPlanePosition").split("|", QString::SkipEmptyParts );
136 QStringList aCondList = VISU::Storable::FindValue(theMap,"myPlaneCondition").split("|", QString::SkipEmptyParts );
137 for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++)
138 if(aCondList[i].toInt() == 0)
139 SetPlanePosition(i,aPosList[i].toDouble());
141 OptionalDeformation_i::RestoreDeformation(theSObject,theMap);
147 //----------------------------------------------------------------------------
148 void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){
149 TSuperClass::ToStream(theStr);
151 Storable::DataToStream( theStr, "myNbPlanes", int(GetNbPlanes()));
152 Storable::DataToStream( theStr, "myDisplacement", GetDisplacement());
153 Storable::DataToStream( theStr, "myBasePlane", int(GetOrientationType()));
154 Storable::DataToStream( theStr, "aRot[0]", GetRotateX());
155 Storable::DataToStream( theStr, "aRot[1]", GetRotateY());
157 QString aStrPos, aStrCon;
158 for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++){
159 aStrPos.append(QString::number(GetPlanePosition(i)) + "|");
160 aStrCon.append(QString::number(IsDefault(i)) + "|");
162 Storable::DataToStream( theStr, "myPlanePosition", (const char*)aStrPos.toLatin1());
163 Storable::DataToStream( theStr, "myPlaneCondition", (const char*)aStrCon.toLatin1());
164 OptionalDeformation_i::DeformationToStream(theStr);
168 //----------------------------------------------------------------------------
172 if(MYDEBUG) MESSAGE("CutPlanes_i::~CutPlanes_i()");
176 //----------------------------------------------------------------------------
179 ::SetOrientation(VISU::CutPlanes::Orientation theOrient,
180 CORBA::Double theXAngle,
181 CORBA::Double theYAngle)
183 struct TEvent: public SALOME_Event
185 VISU_CutPlanesPL* myPipeLine;
186 VISU_CutPlanesPL::PlaneOrientation myOrient;
187 CORBA::Double myXAngle;
188 CORBA::Double myYAngle;
190 TEvent(VISU_CutPlanesPL* thePipeLine,
191 VISU_CutPlanesPL::PlaneOrientation theOrient,
192 CORBA::Double theXAngle,
193 CORBA::Double theYAngle):
194 myPipeLine(thePipeLine),
204 myPipeLine->SetOrientation(myOrient,
210 VISU::TSetModified aModified(this);
212 ProcessVoidEvent(new TEvent(GetSpecificPL(),
213 VISU_CutPlanesPL::PlaneOrientation(theOrient),
218 //----------------------------------------------------------------------------
219 VISU::CutPlanes::Orientation
221 ::GetOrientationType()
223 return VISU::CutPlanes::Orientation(myCutPlanesPL->GetPlaneOrientation());
226 //----------------------------------------------------------------------------
231 return myCutPlanesPL->GetRotateX();
234 //----------------------------------------------------------------------------
239 return myCutPlanesPL->GetRotateY();
243 //----------------------------------------------------------------------------
246 ::SetDisplacement(CORBA::Double theDisp)
248 VISU::TSetModified aModified(this);
250 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutPlanesPL, vtkFloatingPointType, int>
251 (GetSpecificPL(), &VISU_CutPlanesPL::SetDisplacement, theDisp, 0));
254 //----------------------------------------------------------------------------
259 return myCutPlanesPL->GetDisplacement();
263 //----------------------------------------------------------------------------
266 ::SetPlanePosition(CORBA::Long thePlaneNumber,
267 CORBA::Double thePlanePosition)
269 VISU::TSetModified aModified(this);
271 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutPlanesPL, int, vtkFloatingPointType>
272 (GetSpecificPL(), &VISU_CutPlanesPL::SetPartPosition, thePlaneNumber, thePlanePosition));
275 //----------------------------------------------------------------------------
278 ::GetPlanePosition(CORBA::Long thePlaneNumber)
280 return myCutPlanesPL->GetPartPosition(thePlaneNumber);
284 //----------------------------------------------------------------------------
287 ::SetDefault(CORBA::Long thePlaneNumber)
289 VISU::TSetModified aModified(this);
291 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutPlanesPL, int>
292 (GetSpecificPL(), &VISU_CutPlanesPL::SetPartDefault, thePlaneNumber));
295 //----------------------------------------------------------------------------
298 ::IsDefault(CORBA::Long thePlaneNumber)
300 return myCutPlanesPL->IsPartDefault(thePlaneNumber);
304 //----------------------------------------------------------------------------
307 ::SetNbPlanes(CORBA::Long theNb)
309 VISU::TSetModified aModified(this);
311 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutPlanesPL, int>
312 (GetSpecificPL(), &VISU_CutPlanesPL::SetNbParts, theNb));
315 //----------------------------------------------------------------------------
320 return myCutPlanesPL->GetNbParts();
324 //----------------------------------------------------------------------------
327 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
330 myCutPlanesPL = VISU_CutPlanesPL::New();
332 myCutPlanesPL = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine);
334 InitDeformedPipeLine(myCutPlanesPL);
335 TSuperClass::CreatePipeLine(myCutPlanesPL);
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" , "cut_planes_represent", 1);
356 anActor->SetRepresentation(aDispMode);
364 SameAs(const Prs3d_i* theOrigin){
365 if(MYDEBUG) MESSAGE("CutPlanes_i::SameAs()");
366 TSuperClass::SameAs(theOrigin);
367 OptionalDeformation_i::SameAsDeformation(dynamic_cast<const Deformation_i*>(theOrigin));