Salome HOME
INT PAL 0053060: Preview in clipping
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ClippingDlg.cxx
index e9bf24bc05584deec7bcd6abc85ec8d85ba75c56..c02181beeebf45fa5f5456f3593bc51fe92672ad 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  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
@@ -601,12 +601,12 @@ SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg()
   if (myViewWindow)
     SMESH::RenderViewWindow(myViewWindow);
 
-  for( int i=0; i< myPlanes.size(); i++ ) {
+  for ( size_t i = 0; i < myPlanes.size(); i++ ) {
     SMESH::TPlaneData aPlaneData = myPlanes[i];
     aPlaneData.Plane->Delete();
   }
 
-  if (myPreviewWidget) {
+  if ( myPreviewWidget ) {
     myPreviewWidget->Off();
     myPreviewWidget->Delete();
   }
@@ -629,7 +629,7 @@ double SMESHGUI_ClippingDlg::getDistance() const
 */
 void SMESHGUI_ClippingDlg::setDistance( const double theDistance )
 {
-  SpinSliderDistance->setValue( theDistance*100 );
+  SpinSliderDistance->setValue( theDistance );
 }
 
 /*!
@@ -1133,9 +1133,14 @@ void SMESHGUI_ClippingDlg::updateActorItem( QListWidgetItem* theItem,
         else if( theItem->checkState() == Qt::Unchecked && anIsPushed )
           anActorList.remove( anActor );
 
-        SMESH::ComputeBounds( anActorList, myBounds );
-        myPreviewWidget->PlaceWidget( myBounds[0], myBounds[1], myBounds[2],
-                                      myBounds[3], myBounds[4], myBounds[5] );
+        if( SMESH::ComputeBounds( anActorList, myBounds ) ) {
+          myPreviewWidget->PlaceWidget( myBounds[0], myBounds[1], myBounds[2],
+                                        myBounds[3], myBounds[4], myBounds[5] );
+          if( PreviewCheckBox->isChecked() )
+            myPreviewWidget->On();
+        }
+        else
+          myPreviewWidget->Off();
       }
     }
   }
@@ -1244,9 +1249,15 @@ void SMESHGUI_ClippingDlg::ClickOnNew()
 
     bool anIsBlocked = ActorList->blockSignals( true );
 
-    SMESH::ComputeBounds( anActorList, myBounds );
-    myPreviewWidget->PlaceWidget( myBounds[0],myBounds[1],myBounds[2],
-                                  myBounds[3],myBounds[4],myBounds[5] );
+    if( SMESH::ComputeBounds( anActorList, myBounds ) ) {
+      myPreviewWidget->PlaceWidget( myBounds[0], myBounds[1], myBounds[2],
+                                    myBounds[3], myBounds[4], myBounds[5] );
+      if( PreviewCheckBox->isChecked() )
+        myPreviewWidget->On();
+    }
+    else
+      myPreviewWidget->Off();
+
     synchronize();
     SetCurrentPlaneParam();
 
@@ -1331,9 +1342,16 @@ void SMESHGUI_ClippingDlg::onSelectPlane ( int theIndex )
     }
   }
   myIsSelectPlane = false;
-  SMESH::ComputeBounds( aPlaneData.ActorList, myBounds );
-  myPreviewWidget->PlaceWidget( myBounds[0], myBounds[1], myBounds[2],
-                                myBounds[3], myBounds[4], myBounds[5] );
+
+  if( SMESH::ComputeBounds( aPlaneData.ActorList, myBounds ) ) {
+    myPreviewWidget->PlaceWidget( myBounds[0], myBounds[1], myBounds[2],
+                                  myBounds[3], myBounds[4], myBounds[5] );
+    if( PreviewCheckBox->isChecked() )
+      myPreviewWidget->On();
+  }
+  else
+    myPreviewWidget->Off();
+
   SetCurrentPlaneParam();
 
   // Actors
@@ -1779,11 +1797,9 @@ void SMESHGUI_ClippingDlg::ClickOnApply()
       aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
     }
 
-    SMESH_Actor* anSMESHActor;
     anAllActors->InitTraversal();
     while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
       if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) {
-        anSMESHActor = anActor;
         anActor->SetOpenGLClippingPlane();
       }