Salome HOME
0022123: EDF 2558 SMESH: Group creation crashs with the filter "Free faces":
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ClippingDlg.cxx
index 93410883f140e5c749f714b6ded4de2a26622ffe..c359f18a69c14ec2db046b66f3118c2320507803 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
@@ -370,7 +370,7 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( SMESHGUI* theModule, SVTK_ViewWindow
 
   ActorList = new QListWidget(GroupPlanes);
   ActorList->setSelectionMode(QAbstractItemView::SingleSelection);
-
+  
   SelectAllCheckBox = new QCheckBox(tr("SELECT_ALL"), GroupPlanes);
 
   GroupPlanesLayout->addWidget(ComboBoxPlanes,    0, 0);
@@ -477,14 +477,14 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( SMESHGUI* theModule, SVTK_ViewWindow
   connect(SpinBoxRot1, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam()));
   connect(SpinBoxRot2, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam()));
   connect(PreviewCheckBox, SIGNAL(toggled(bool)), this, SLOT(OnPreviewToggle(bool)));
-  connect(AutoApplyCheckBox, SIGNAL(toggled(bool)), this, SLOT(ClickOnApply()));
+  connect(AutoApplyCheckBox, SIGNAL(toggled(bool)), this, SLOT(onAutoApply(bool)));
   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
-  connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
+  connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
   connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
-  connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
+  connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(reject()));
   /* to close dialog if study frame change */
-  connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), this, SLOT(ClickOnCancel()));
+  connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), this, SLOT(reject()));
 
   this->show();
 }
@@ -589,16 +589,17 @@ void SMESHGUI_ClippingDlg::ClickOnApply()
 void SMESHGUI_ClippingDlg::ClickOnOk()
 {
   ClickOnApply();
-  ClickOnCancel();
+  reject();
 }
 
 //=======================================================================
-// function : ClickOnCancel()
+// function : reject()
 // purpose  :
 //=======================================================================
-void SMESHGUI_ClippingDlg::ClickOnCancel()
+void SMESHGUI_ClippingDlg::reject()
 {
-  close();
+  //here we can insert actions to do at close.
+  QDialog::reject();
 }
 
 //=================================================================================
@@ -742,14 +743,8 @@ void SMESHGUI_ClippingDlg::updateActorItem( QListWidgetItem* theItem,
         if( anItem->checkState() == Qt::Checked )
           aNbChecked++;
 
-    Qt::CheckState aCheckState = Qt::Unchecked;
-    if( aNbChecked == aNbItems )
-      aCheckState = Qt::Checked;
-    else if( aNbChecked > 0 )
-      aCheckState = Qt::PartiallyChecked;
-
     bool anIsBlocked = SelectAllCheckBox->blockSignals( true );
-    SelectAllCheckBox->setCheckState( aCheckState );
+    SelectAllCheckBox->setCheckState( aNbChecked == aNbItems ? Qt::Checked : Qt::Unchecked);
     SelectAllCheckBox->blockSignals( anIsBlocked );
   }
 
@@ -1063,7 +1058,9 @@ void SMESHGUI_ClippingDlg::initializePlaneData()
     SMESHGUI_ClippingPlaneInfoList::const_iterator anIter2 = aClippingPlaneInfoList.begin();
     for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
       const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
-      SMESH::TPlane aTPlane( aClippingPlaneInfo.Plane );
+      SMESH::OrientedPlane* anOrientedPlane = SMESH::OrientedPlane::New(myViewWindow);
+      anOrientedPlane->ShallowCopy(aClippingPlaneInfo.Plane);
+      SMESH::TPlane aTPlane( anOrientedPlane );
       SMESH::TPlaneData aPlaneData( aTPlane, aClippingPlaneInfo.ActorList );
       myPlanes.push_back( aPlaneData );
     }
@@ -1170,3 +1167,8 @@ void SMESHGUI_ClippingDlg::dumpPlaneData() const
   }
   printf( "----------------------------------\n" );
 }
+
+void SMESHGUI_ClippingDlg::onAutoApply(bool toggled)
+{
+  if ( toggled ) ClickOnApply();
+}