Salome HOME
Update copyright
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ClippingDlg.cxx
index ac190be77b4c17d6a890f56631cf20e4e67b2fd2..4cbbfff65ebcd5aa0eeb5ad69e7f95f31814c4e1 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 // SMESH SMESHGUI : GUI for SMESH component
@@ -113,7 +113,7 @@ SMESH::OrientedPlane::OrientedPlane(SVTK_ViewWindow* theViewWindow):
   myDistance(0.5)
 {
   Init();
-  myViewWindow->AddActor(myActor);
+  myViewWindow->AddActor(myActor, false, false); // don't adjust actors
 }
 
 SMESH::OrientedPlane::OrientedPlane():
@@ -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());