Salome HOME
MPV: Merge V1_2d
[modules/visu.git] / src / VISU_I / VISU_CutPlanes_i.cc
index a4ede3a53df91c63117d74134c7d9402c329f09a..d48d6e0ae621d0fdb593a8e051603cdc4bd3bc4b 100644 (file)
@@ -41,9 +41,9 @@ static int MYDEBUGWITHFILES = 0;
 #endif
 
 int VISU::CutPlanes_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
-                                 const char* theFieldName, int theIteration)
+                                 const char* theFieldName, int theIteration, int isMemoryCheck)
 {
-  return VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration);
+  return VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
 }
 
 
@@ -55,29 +55,18 @@ const string VISU::CutPlanes_i::myComment = "CUTPLANES";
 const char* VISU::CutPlanes_i::GetComment() const { return myComment.c_str();}
 
 
-VISU::CutPlanes_i::CutPlanes_i(Result_i* theResult, bool theAddToStudy) :
+VISU::CutPlanes_i::CutPlanes_i(Result_i* theResult, bool theAddToStudy, SALOMEDS::SObject_ptr theSObject) :
        PrsObject_i(theResult->GetStudyDocument()), 
-       Prs3d_i(theResult),       
-       ScalarMap_i(theResult, theAddToStudy)
+       Prs3d_i(theResult,theSObject),
+       ScalarMap_i(theResult,theAddToStudy,theSObject)
 {
   myCutPlanesPL = NULL;
 }
 
 
-void VISU::CutPlanes_i::Destroy(){
-  ScalarMap_i::Destroy();
-}
-
-
 void VISU::CutPlanes_i::SameAs(const CutPlanes_i* theOrigin){
   CutPlanes_i* aCutPlanes = const_cast<CutPlanes_i*>(theOrigin);
   VISU::ScalarMap_i::SameAs(theOrigin);
-
-  //SetNbPlanes(aCutPlanes->GetNbPlanes());
-  //SetDisplacement(aCutPlanes->GetDisplacement());
-  //SetOrientationType(aCutPlanes->GetOrientationType());
-  //SetRotateX(aCutPlanes->GetRotateX());
-  //SetRotateY(aCutPlanes->GetRotateY());
 }
 
 
@@ -91,39 +80,40 @@ VISU::Storable* VISU::CutPlanes_i::Create(const char* theMeshName, VISU::Entity
 VISU::Storable* VISU::CutPlanes_i::Restore(const Storable::TRestoringMap& theMap)
   throw(std::logic_error&)
 {
-  ScalarMap_i::Restore(theMap);
-
+  DoHook();
   SetNbPlanes(VISU::Storable::FindValue(theMap,"myNbPlanes").toInt());
   SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement").toDouble());
-  SetOrientationType(VISU::CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()));
-  SetRotateX(VISU::Storable::FindValue(theMap,"aRot[0]").toDouble());
-  SetRotateY(VISU::Storable::FindValue(theMap,"aRot[1]").toDouble());
+  SetOrientation(VISU::CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
+                Storable::FindValue(theMap,"aRot[0]").toDouble(),
+                Storable::FindValue(theMap,"aRot[1]").toDouble());
+  QStringList aPosList = QStringList::split("|",VISU::Storable::FindValue(theMap,"myPlanePosition") );
+  QStringList aCondList = QStringList::split("|",VISU::Storable::FindValue(theMap,"myPlaneCondition") );
+  for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++)
+    if(aCondList[i].toInt() == 0)
+      SetPlanePosition(i,aPosList[i].toDouble());
 
-  return Build(true);
+  return ScalarMap_i::Restore(theMap);
 }
 
 
 void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){
   ScalarMap_i::ToStream(theStr);
 
-  Storable::DataToStream( theStr, "myNbPlanes",  int(GetNbPlanes()) );
-  Storable::DataToStream( theStr, "myDisplacement",  GetDisplacement() );
-  Storable::DataToStream( theStr, "myBasePlane", int(GetOrientationType()) );
-  Storable::DataToStream( theStr, "aRot[0]",     GetRotateX() );
-  Storable::DataToStream( theStr, "aRot[1]",     GetRotateY() );
-}
+  int aNbPlanes = GetNbPlanes();
 
+  Storable::DataToStream( theStr, "myNbPlanes", int(GetNbPlanes()));
+  Storable::DataToStream( theStr, "myDisplacement", GetDisplacement());
+  Storable::DataToStream( theStr, "myBasePlane", int(GetOrientationType()));
+  Storable::DataToStream( theStr, "aRot[0]", GetRotateX());
+  Storable::DataToStream( theStr, "aRot[1]", GetRotateY());
 
-VISU::Storable* VISU::CutPlanes_i::Restore(SALOMEDS::SObject_ptr theSObject, 
-                                          const string& thePrefix, const Storable::TRestoringMap& theMap)
-     throw(std::logic_error&)
-{
-  VISU::Result_i* pResult = GetResult(theSObject);
-  if(pResult != NULL){
-    VISU::CutPlanes_i* pResent = new VISU::CutPlanes_i(pResult);
-    return pResent->Restore(theMap);
+  QString aStrPos, aStrCon;
+  for(int i = 0, iEnd = GetNbPlanes(); i < iEnd; i++){
+    aStrPos.append(QString::number(GetPlanePosition(i)) + "|");
+    aStrCon.append(QString::number(IsDefault(i)) + "|");
   }
-  return NULL;
+  Storable::DataToStream( theStr, "myPlanePosition",  aStrPos.latin1());
+  Storable::DataToStream( theStr, "myPlaneCondition", aStrCon.latin1());
 }
 
 
@@ -132,12 +122,22 @@ VISU::CutPlanes_i::~CutPlanes_i(){
 }
 
 
-void VISU::CutPlanes_i::SetOrientationType(VISU::CutPlanes::Orientation theOrient){
-  myCutPlanesPL->SetPlaneOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient));
+void VISU::CutPlanes_i::SetOrientation(VISU::CutPlanes::Orientation theOrient,
+                                      CORBA::Double theXAngle, CORBA::Double theYAngle)
+{
+  myCutPlanesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
+                               theXAngle,theYAngle);
 }
+
 VISU::CutPlanes::Orientation VISU::CutPlanes_i::GetOrientationType() { 
   return VISU::CutPlanes::Orientation(myCutPlanesPL->GetPlaneOrientation());
 }
+CORBA::Double VISU::CutPlanes_i::GetRotateX(){
+  return myCutPlanesPL->GetRotateX();
+}
+CORBA::Double VISU::CutPlanes_i::GetRotateY(){
+  return myCutPlanesPL->GetRotateY();
+}
 
 
 void VISU::CutPlanes_i::SetDisplacement(CORBA::Double theDisp) { 
@@ -172,22 +172,6 @@ CORBA::Long VISU::CutPlanes_i::GetNbPlanes() {
 }
 
 
-void VISU::CutPlanes_i::SetRotateX(CORBA::Double theAngle){
-  myCutPlanesPL->SetRotateX(theAngle);
-}
-CORBA::Double VISU::CutPlanes_i::GetRotateX(){
-  return myCutPlanesPL->GetRotateX();
-}
-
-
-void VISU::CutPlanes_i::SetRotateY(CORBA::Double theAngle){
-  myCutPlanesPL->SetRotateY(theAngle);
-}
-CORBA::Double VISU::CutPlanes_i::GetRotateY(){
-  return myCutPlanesPL->GetRotateY();
-}
-
-
 void VISU::CutPlanes_i::DoHook(){
   if(!myPipeLine) myPipeLine = VISU_CutPlanesPL::New();
   myCutPlanesPL = dynamic_cast<VISU_CutPlanesPL*>(myPipeLine);