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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : VISU_PrsObject_i.cxx
24 // Author : Alexey PETROV
27 #include "VISU_CutPlanesPL.hxx"
28 #include "VISU_Result_i.hh"
29 #include "VISU_CutPlanes_i.hh"
30 #include "VISU_Actor.h"
36 static int MYDEBUG = 0;
38 static int MYDEBUG = 0;
41 int VISU::CutPlanes_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
42 const char* theFieldName, int theIteration, int isMemoryCheck)
44 return VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
48 int VISU::CutPlanes_i::myNbPresent = 0;
49 QString VISU::CutPlanes_i::GenerateName() { return VISU::GenerateName("CutPlanes",myNbPresent++);}
52 const string VISU::CutPlanes_i::myComment = "CUTPLANES";
53 const char* VISU::CutPlanes_i::GetComment() const { return myComment.c_str();}
57 CutPlanes_i(Result_i* theResult,
59 PrsObject_i(theResult->GetStudyDocument()),
60 Prs3d_i(theResult,theAddToStudy),
61 ScalarMap_i(theResult,theAddToStudy),
68 CutPlanes_i(Result_i* theResult,
69 SALOMEDS::SObject_ptr theSObject) :
70 PrsObject_i(theResult->GetStudyDocument()),
71 Prs3d_i(theResult,theSObject),
72 ScalarMap_i(theResult,theSObject),
78 void VISU::CutPlanes_i::SameAs(const CutPlanes_i* theOrigin){
79 VISU::ScalarMap_i::SameAs(theOrigin);
83 VISU::Storable* VISU::CutPlanes_i::Create(const char* theMeshName, VISU::Entity theEntity,
84 const char* theFieldName, int theIteration)
86 return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
90 VISU::Storable* VISU::CutPlanes_i::Restore(const Storable::TRestoringMap& theMap)
93 SetNbPlanes(VISU::Storable::FindValue(theMap,"myNbPlanes").toInt());
94 SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement").toDouble());
95 SetOrientation(VISU::CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
96 Storable::FindValue(theMap,"aRot[0]").toDouble(),
97 Storable::FindValue(theMap,"aRot[1]").toDouble());
98 QStringList aPosList = QStringList::split("|",VISU::Storable::FindValue(theMap,"myPlanePosition") );
99 QStringList aCondList = QStringList::split("|",VISU::Storable::FindValue(theMap,"myPlaneCondition") );
100 for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++)
101 if(aCondList[i].toInt() == 0)
102 SetPlanePosition(i,aPosList[i].toDouble());
104 return ScalarMap_i::Restore(theMap);
108 void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){
109 ScalarMap_i::ToStream(theStr);
111 Storable::DataToStream( theStr, "myNbPlanes", int(GetNbPlanes()));
112 Storable::DataToStream( theStr, "myDisplacement", GetDisplacement());
113 Storable::DataToStream( theStr, "myBasePlane", int(GetOrientationType()));
114 Storable::DataToStream( theStr, "aRot[0]", GetRotateX());
115 Storable::DataToStream( theStr, "aRot[1]", GetRotateY());
117 QString aStrPos, aStrCon;
118 for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++){
119 aStrPos.append(QString::number(GetPlanePosition(i)) + "|");
120 aStrCon.append(QString::number(IsDefault(i)) + "|");
122 Storable::DataToStream( theStr, "myPlanePosition", aStrPos.latin1());
123 Storable::DataToStream( theStr, "myPlaneCondition", aStrCon.latin1());
127 VISU::CutPlanes_i::~CutPlanes_i(){
128 if(MYDEBUG) MESSAGE("CutPlanes_i::~CutPlanes_i()");
132 void VISU::CutPlanes_i::SetOrientation(VISU::CutPlanes::Orientation theOrient,
133 CORBA::Double theXAngle, CORBA::Double theYAngle)
135 myCutPlanesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
136 theXAngle,theYAngle);
139 VISU::CutPlanes::Orientation VISU::CutPlanes_i::GetOrientationType() {
140 return VISU::CutPlanes::Orientation(myCutPlanesPL->GetPlaneOrientation());
142 CORBA::Double VISU::CutPlanes_i::GetRotateX(){
143 return myCutPlanesPL->GetRotateX();
145 CORBA::Double VISU::CutPlanes_i::GetRotateY(){
146 return myCutPlanesPL->GetRotateY();
150 void VISU::CutPlanes_i::SetDisplacement(CORBA::Double theDisp) {
151 myCutPlanesPL->SetDisplacement(theDisp);
153 CORBA::Double VISU::CutPlanes_i::GetDisplacement() {
154 return myCutPlanesPL->GetDisplacement();
158 void VISU::CutPlanes_i::SetPlanePosition(CORBA::Long thePlaneNumber, CORBA::Double thePlanePosition){
159 myCutPlanesPL->SetPartPosition(thePlaneNumber,thePlanePosition);
161 CORBA::Double VISU::CutPlanes_i::GetPlanePosition(CORBA::Long thePlaneNumber){
162 return myCutPlanesPL->GetPartPosition(thePlaneNumber);
166 void VISU::CutPlanes_i::SetDefault(CORBA::Long thePlaneNumber){
167 myCutPlanesPL->SetPartDefault(thePlaneNumber);
169 CORBA::Boolean VISU::CutPlanes_i::IsDefault(CORBA::Long thePlaneNumber){
170 return myCutPlanesPL->IsPartDefault(thePlaneNumber);
174 void VISU::CutPlanes_i::SetNbPlanes(CORBA::Long theNb) {
175 myCutPlanesPL->SetNbParts(theNb);
177 CORBA::Long VISU::CutPlanes_i::GetNbPlanes() {
178 return myCutPlanesPL->GetNbParts();
182 void VISU::CutPlanes_i::DoHook(){
183 if(!myPipeLine) myPipeLine = VISU_CutPlanesPL::New();
184 myCutPlanesPL = dynamic_cast<VISU_CutPlanesPL*>(myPipeLine);
186 ScalarMap_i::DoHook();