]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Additional fix for issue 0020977: EDF 1520 SMESH: Create a clipping plane on several...
authorouv <ouv@opencascade.com>
Thu, 16 Dec 2010 16:52:14 +0000 (16:52 +0000)
committerouv <ouv@opencascade.com>
Thu, 16 Dec 2010 16:52:14 +0000 (16:52 +0000)
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_ClippingDlg.cxx

index 8d50908bdd3cf9790a4ae9a8f08293addaa22f88..c78fd71d155839f51a1477276c1d20c09d8a9c4f 100644 (file)
@@ -5439,7 +5439,15 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
                     aPlaneInfo.PlaneId = aPlaneId;
                     aPlaneInfo.ActorList.push_back( aSmeshActor );
                     aPlaneInfo.ViewManager = vman;
-                    aPlaneInfoList.push_back( aPlaneInfo );
+
+                    // to make the list sorted by plane id
+                    anIter = aPlaneInfoList.begin();
+                    for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
+                      const TPlaneInfo& aPlaneInfoRef = *anIter;
+                      if( aPlaneInfoRef.PlaneId > aPlaneId )
+                        break;
+                    }
+                    aPlaneInfoList.insert( anIter, aPlaneInfo );
                   }
                 }
               }
@@ -5450,6 +5458,52 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
     } // for names/parameters iterator
   } // for entries iterator
 
+  // take into account planes with empty list of actors referred to them
+  QList<SUIT_ViewManager*> aVMList;
+  getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
+
+  TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
+  for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
+    int aViewId = aPlaneDataIter->first;
+    if( aViewId >= 0 && aViewId < aVMList.count() ) {
+      SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
+
+      const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
+
+      TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
+      TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
+      for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
+        const TPlaneData& aPlaneData = *anIter2;
+        int aPlaneId = aPlaneData.Id;
+
+        bool anIsFound = false;
+        TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
+        for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
+          const TPlaneInfo& aPlaneInfo = *anIter3;
+          if( aPlaneInfo.PlaneId == aPlaneId ) {
+            anIsFound = true;
+            break;
+          }
+        }
+
+        if( !anIsFound ) {
+          TPlaneInfo aPlaneInfo; // ActorList field is empty
+          aPlaneInfo.PlaneId = aPlaneId;
+          aPlaneInfo.ViewManager = aViewManager;
+
+          // to make the list sorted by plane id
+          TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
+          for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
+            const TPlaneInfo& aPlaneInfoRef = *anIter4;
+            if( aPlaneInfoRef.PlaneId > aPlaneId )
+              break;
+          }
+          aPlaneInfoList.insert( anIter4, aPlaneInfo );
+        }
+      }
+    }
+  }
+
   // add clipping planes to actors according to the restored parameters
   // and update the clipping plane map
   TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
index ac190be77b4c17d6a890f56631cf20e4e67b2fd2..486a859ac52559c0bd19c903fe3d9967cdcf5cc7 100644 (file)
@@ -194,7 +194,8 @@ private:
 struct TSetVisibility {
   TSetVisibility(int theIsVisible): myIsVisible(theIsVisible){}
   void operator()(SMESH::TPlaneData& thePlaneData){
-    thePlaneData.Plane.GetPointer()->myActor->SetVisibility(myIsVisible);
+    bool anIsEmpty = thePlaneData.ActorList.empty();
+    thePlaneData.Plane.GetPointer()->myActor->SetVisibility(myIsVisible && !anIsEmpty);
   }
   int myIsVisible;
 };
@@ -261,11 +262,22 @@ SMESH::OrientedPlane* SMESHGUI_ClippingDlg::AddPlane (SMESH::TActorList
 
   vtkFloatingPointType aBounds[6];
   vtkFloatingPointType anOrigin[3];
-  bool anIsOk = SMESH::ComputeClippingPlaneParameters( theActorList,
-                                                       aNormal,
-                                                       theDistance,
-                                                       aBounds,
-                                                       anOrigin );
+
+  bool anIsOk = false;
+  if( theActorList.empty() ) {
+    // to support planes with empty actor list we should create
+    // a nullified plane that will be initialized later 
+    anOrigin[0] = anOrigin[1] = anOrigin[2] = 0;
+    aBounds[0] = aBounds[2] = aBounds[4] = 0;
+    aBounds[1] = aBounds[3] = aBounds[5] = 0;
+    anIsOk = true;
+  }
+  else
+    anIsOk = SMESH::ComputeClippingPlaneParameters( theActorList,
+                                                    aNormal,
+                                                    theDistance,
+                                                    aBounds,
+                                                    anOrigin );
   if( !anIsOk )
     return NULL;
 
@@ -545,8 +557,10 @@ void SMESHGUI_ClippingDlg::ClickOnApply()
       SMESH::TPlaneData aPlaneData = *anIter2;
       SMESH::TPlane aPlane = aPlaneData.Plane;
       SMESH::TActorList anActorList = aPlaneData.ActorList;
-      if( anActorList.empty() )
-        continue;
+
+      // the check is disabled to support planes with empty actor list
+      //if( anActorList.empty() )
+      //  continue;
 
       SMESH::OrientedPlane* anOrientedPlane = SMESH::OrientedPlane::New(myViewWindow);
       anOrientedPlane->ShallowCopy(aPlane.GetPointer());