]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
*** empty log message *** before_merge_29-09-08
authorvsv <vsv@opencascade.com>
Fri, 26 Sep 2008 12:04:30 +0000 (12:04 +0000)
committervsv <vsv@opencascade.com>
Fri, 26 Sep 2008 12:04:30 +0000 (12:04 +0000)
src/VISU_I/VISU_ClippingPlaneMgr.cxx
src/VISU_I/VISU_ClippingPlaneMgr.hxx
src/VISU_I/VISU_DumpPython.cc

index bcdf285e26b881a0f0f93cb2e1661c955127041c..f314d4184deed155d2c4b293ec2290e7f7b1c314 100644 (file)
@@ -251,6 +251,24 @@ VISU_CutPlaneFunction* VISU_ClippingPlaneMgr::GetClippingPlane(long id)
     return NULL;
   return (VISU_CutPlaneFunction*) myPlanes->GetItemAsObject(id);
 }
+
+//*************************************************************
+  /* Returns -1 if Plane is not exists */
+int VISU_ClippingPlaneMgr::GetPlaneId(VISU_CutPlaneFunction* thePlane)
+{
+  int aTag = thePlane->getPlaneObject()->Tag();
+  int aRes = -1;
+  VISU_CutPlaneFunction* aPlane;
+  for (int i = 0; i < GetClippingPlanesNb(); i++) {
+    aPlane = GetClippingPlane(i);
+    if (aPlane->getPlaneObject()->Tag() == aTag) {
+      aRes = i;
+      break;
+    }
+  }
+  return aRes;
+}
+
   
 //*************************************************************
   /* Deletes clipping plane by its Id */
index c71e3d98e7c2845c6ddc464a45b69a5bc549785b..78d5cf5a45b15ecb5dffd5ec5b1d5203506efe74 100644 (file)
@@ -97,6 +97,9 @@ public:
   
   /* Returns clipping plane by its Id */
   VISU_CutPlaneFunction* GetClippingPlane(long id);
+
+  /* Returns -1 if Plane is not exists */
+  int GetPlaneId(VISU_CutPlaneFunction* thePlane);
   
   /* Deletes clipping plane by its Id */
   bool DeleteClippingPlane(long id);
index 6b07b81bb6cea09de32dc963523fe34d75fa8090..3fceafc538336382018e1d663ee8a266dbfcedf7 100644 (file)
@@ -178,6 +178,28 @@ namespace VISU
 
 
   //---------------------------------------------------------------------------
+  void SetClippingPlane(Prs3d_i* thePrs, string theName,
+                       std::ostream& theStr,
+                       std::string thePrefix) 
+  {
+    VISU_CutPlaneFunction* aPlane;
+    VISU_Gen_i* aGen = VISU_Gen_i::GetVisuGenImpl();
+    VISU_ClippingPlaneMgr& aMgr = aGen->GetClippingPlaneMgr();
+    int aId;
+    for (int i = 0; i < thePrs->GetNumberOfClippingPlanes(); i++) {
+      aPlane = dynamic_cast<VISU_CutPlaneFunction*>(thePrs->GetClippingPlane(i));
+      if (aPlane) {
+       if (!aPlane->isAuto()) {
+         aId = aMgr.GetPlaneId(aPlane);
+         if (aId > -1) {
+           theStr<<thePrefix<<"aVisu.ApplyClippingPlane("<<theName<<", "<<aId<<")"<<endl;
+         }
+       }
+      }
+    }
+  }
+  
+
   void
   Prs3dToPython(VISU::Prs3d_i* theServant,
                std::ostream& theStr,
@@ -187,6 +209,7 @@ namespace VISU
     float x, y, z;
     theServant->GetOffset(x,y,z);
     theStr<<thePrefix<<theName<<".SetOffset("<<x<<", "<<y<<", "<<z<<")"<<endl;
+    SetClippingPlane(theServant, theName, theStr, thePrefix);
   }
 
   //---------------------------------------------------------------------------
@@ -959,7 +982,7 @@ namespace VISU
     }
   }
 
-  
+
 
   //---------------------------------------------------------------------------
   void
@@ -1855,6 +1878,35 @@ namespace VISU
     theStr<<thePrefix<<endl;
   }
 
+
+  void
+  DumpClippingPlanesToPython(SALOMEDS::Study_ptr theStudy,
+                            CORBA::Boolean theIsPublished,
+                            CORBA::Boolean& theIsValidScript,
+                            SALOMEDS::SObject_ptr theSObject,
+                            std::ostream& theStr,
+                            std::string thePrefix,
+                            VISU_ClippingPlaneMgr& thePlaneMgr)
+  {
+
+    if(!theIsPublished) return;
+
+    VISU_CutPlaneFunction* aPlane;
+    double aOrigin[3], aDir[3];
+    for (int i = 0; i < thePlaneMgr.GetClippingPlanesNb(); i++) {
+      aPlane = thePlaneMgr.GetClippingPlane(i);
+      aPlane->GetOrigin(aOrigin);
+      aPlane->GetNormal(aDir);
+
+      theStr<<thePrefix<<"aVisu.CreateClippingPlane("<<
+       aOrigin[0]<<","<<aOrigin[1]<<","<<aOrigin[2]<<","<<
+       aDir[0]<<","<<aDir[1]<<","<<aDir[2]<<","<<
+       aPlane->isAuto()<<",\""<<aPlane->getName()<<"\")"<<endl;      
+    }
+    theStr<<endl;
+  }  
+
+
   //---------------------------------------------------------------------------
   Engines::TMPFile*
   VISU_Gen_i::
@@ -1895,6 +1947,16 @@ namespace VISU
     aStr<<endl;
 
     SALOMEDS::SComponent_var aComponent = FindOrCreateVisuComponent(aStudy);
+
+    VISU::DumpClippingPlanesToPython(aStudy,
+                                    theIsPublished,
+                                    theIsValidScript,
+                                    aComponent.in(),
+                                    aStr,
+                                    aPrefix, 
+                                    myClippingPlaneMgr);
+
+
     VISU::DumpChildrenToPython(aStudy,
                               theIsPublished,
                               theIsValidScript,
@@ -1932,6 +1994,7 @@ namespace VISU
                                 aStr,
                                 aPrefix);
 
+
     //Output the script that sets up the visul parameters.
     if(theIsPublished) {
       char* script = aStudy->GetDefaultScript("Post-Pro", aPrefix.c_str());