1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 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 // File : VISU_PrsObject_i.cxx
24 // Author : Alexey PETROV
27 #include "VISU_CutPlanesPL.hxx"
28 #include "VISU_Prs3dUtils.hh"
29 #include "VISU_CutPlanes_i.hh"
31 #include "VISU_Result_i.hh"
32 #include "VISU_Actor.h"
34 #include "SUIT_ResourceMgr.h"
35 #include "SALOME_Event.hxx"
38 static int MYDEBUG = 0;
40 static int MYDEBUG = 0;
44 //----------------------------------------------------------------------------
47 ::IsPossible(Result_i* theResult,
48 const std::string& theMeshName,
49 VISU::Entity theEntity,
50 const std::string& theFieldName,
51 CORBA::Long theTimeStampNumber,
52 bool theIsMemoryCheck)
54 return TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theTimeStampNumber,theIsMemoryCheck);
58 //----------------------------------------------------------------------------
59 int VISU::CutPlanes_i::myNbPresent = 0;
61 //----------------------------------------------------------------------------
66 return VISU::GenerateName("CutPlanes",myNbPresent++);
69 //----------------------------------------------------------------------------
70 const string VISU::CutPlanes_i::myComment = "CUTPLANES";
72 //----------------------------------------------------------------------------
77 return myComment.c_str();
81 //----------------------------------------------------------------------------
87 return "ICON_TREE_CUT_PLANES";
89 return "ICON_TREE_CUT_PLANES_GROUPS";
93 //----------------------------------------------------------------------------
95 ::CutPlanes_i(EPublishInStudyMode thePublishInStudyMode):
96 ColoredPrs3d_i(thePublishInStudyMode),
97 ScalarMap_i(thePublishInStudyMode),
102 //----------------------------------------------------------------------------
105 ::Create(const std::string& theMeshName,
106 VISU::Entity theEntity,
107 const std::string& theFieldName,
108 CORBA::Long theTimeStampNumber)
110 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
114 //----------------------------------------------------------------------------
117 ::Restore(SALOMEDS::SObject_ptr theSObject,
118 const Storable::TRestoringMap& theMap)
120 if(!TSuperClass::Restore(theSObject, theMap))
123 SetNbPlanes(VISU::Storable::FindValue(theMap,"myNbPlanes").toInt());
124 SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement").toDouble());
125 SetOrientation(VISU::CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
126 Storable::FindValue(theMap,"aRot[0]").toDouble(),
127 Storable::FindValue(theMap,"aRot[1]").toDouble());
128 QStringList aPosList = QStringList::split("|",VISU::Storable::FindValue(theMap,"myPlanePosition") );
129 QStringList aCondList = QStringList::split("|",VISU::Storable::FindValue(theMap,"myPlaneCondition") );
130 for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++)
131 if(aCondList[i].toInt() == 0)
132 SetPlanePosition(i,aPosList[i].toDouble());
138 //----------------------------------------------------------------------------
139 void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){
140 TSuperClass::ToStream(theStr);
142 Storable::DataToStream( theStr, "myNbPlanes", int(GetNbPlanes()));
143 Storable::DataToStream( theStr, "myDisplacement", GetDisplacement());
144 Storable::DataToStream( theStr, "myBasePlane", int(GetOrientationType()));
145 Storable::DataToStream( theStr, "aRot[0]", GetRotateX());
146 Storable::DataToStream( theStr, "aRot[1]", GetRotateY());
148 QString aStrPos, aStrCon;
149 for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++){
150 aStrPos.append(QString::number(GetPlanePosition(i)) + "|");
151 aStrCon.append(QString::number(IsDefault(i)) + "|");
153 Storable::DataToStream( theStr, "myPlanePosition", aStrPos.latin1());
154 Storable::DataToStream( theStr, "myPlaneCondition", aStrCon.latin1());
158 //----------------------------------------------------------------------------
162 if(MYDEBUG) MESSAGE("CutPlanes_i::~CutPlanes_i()");
166 //----------------------------------------------------------------------------
169 ::SetOrientation(VISU::CutPlanes::Orientation theOrient,
170 CORBA::Double theXAngle,
171 CORBA::Double theYAngle)
173 struct TEvent: public SALOME_Event
175 VISU_CutPlanesPL* myPipeLine;
176 VISU_CutPlanesPL::PlaneOrientation myOrient;
177 CORBA::Double myXAngle;
178 CORBA::Double myYAngle;
180 TEvent(VISU_CutPlanesPL* thePipeLine,
181 VISU_CutPlanesPL::PlaneOrientation theOrient,
182 CORBA::Double theXAngle,
183 CORBA::Double theYAngle):
184 myPipeLine(thePipeLine),
194 myPipeLine->SetOrientation(myOrient,
200 VISU::TSetModified aModified(this);
202 ProcessVoidEvent(new TEvent(GetSpecificPL(),
203 VISU_CutPlanesPL::PlaneOrientation(theOrient),
208 //----------------------------------------------------------------------------
209 VISU::CutPlanes::Orientation
211 ::GetOrientationType()
213 return VISU::CutPlanes::Orientation(myCutPlanesPL->GetPlaneOrientation());
216 //----------------------------------------------------------------------------
221 return myCutPlanesPL->GetRotateX();
224 //----------------------------------------------------------------------------
229 return myCutPlanesPL->GetRotateY();
233 //----------------------------------------------------------------------------
236 ::SetDisplacement(CORBA::Double theDisp)
238 VISU::TSetModified aModified(this);
240 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutPlanesPL, vtkFloatingPointType, int>
241 (GetSpecificPL(), &VISU_CutPlanesPL::SetDisplacement, theDisp, 0));
244 //----------------------------------------------------------------------------
249 return myCutPlanesPL->GetDisplacement();
253 //----------------------------------------------------------------------------
256 ::SetPlanePosition(CORBA::Long thePlaneNumber,
257 CORBA::Double thePlanePosition)
259 VISU::TSetModified aModified(this);
261 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutPlanesPL, int, vtkFloatingPointType>
262 (GetSpecificPL(), &VISU_CutPlanesPL::SetPartPosition, thePlaneNumber, thePlanePosition));
265 //----------------------------------------------------------------------------
268 ::GetPlanePosition(CORBA::Long thePlaneNumber)
270 return myCutPlanesPL->GetPartPosition(thePlaneNumber);
274 //----------------------------------------------------------------------------
277 ::SetDefault(CORBA::Long thePlaneNumber)
279 VISU::TSetModified aModified(this);
281 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutPlanesPL, int>
282 (GetSpecificPL(), &VISU_CutPlanesPL::SetPartDefault, thePlaneNumber));
285 //----------------------------------------------------------------------------
288 ::IsDefault(CORBA::Long thePlaneNumber)
290 return myCutPlanesPL->IsPartDefault(thePlaneNumber);
294 //----------------------------------------------------------------------------
297 ::SetNbPlanes(CORBA::Long theNb)
299 VISU::TSetModified aModified(this);
301 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutPlanesPL, int>
302 (GetSpecificPL(), &VISU_CutPlanesPL::SetNbParts, theNb));
305 //----------------------------------------------------------------------------
310 return myCutPlanesPL->GetNbParts();
314 //----------------------------------------------------------------------------
317 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
320 myCutPlanesPL = VISU_CutPlanesPL::New();
322 myCutPlanesPL = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine);
324 TSuperClass::CreatePipeLine(myCutPlanesPL);
328 //---------------------------------------------------------------
333 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
336 //----------------------------------------------------------------------------
341 if(VISU_Actor* anActor = TSuperClass::CreateActor()){
342 anActor->SetVTKMapping(true);
343 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
344 int aDispMode = aResourceMgr->integerValue("VISU" , "cut_planes_represent", 1);
345 anActor->SetRepresentation(aDispMode);