Salome HOME
22359: Body Fitting algorithm: grid orientation
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ClippingDlg.cxx
index 9078e7b6ebb7106f99143b7f47e5d7fe1a345ef8..75e83d5f2a8415de4ade518e5c4e4c024fe09014 100644 (file)
@@ -79,8 +79,6 @@
 #include <vtkCallbackCommand.h>
 #include <vtkImplicitPlaneWidget.h>
 
-#include <math.h>
-
 #define SPACING 6
 #define MARGIN  11
 #define SIZEFACTOR 1.1
@@ -478,7 +476,6 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( SMESHGUI* theModule, SVTK_ViewWindow
 
   SliderDistance = new QSlider( Qt::Horizontal, GroupParameters );
   SliderDistance->setObjectName( "SliderDistance" );
-  SliderDistance->setFocusPolicy( Qt::NoFocus );
   SliderDistance->setMinimumSize( 300, 0 );
   SliderDistance->setMinimum( 0 );
   SliderDistance->setMaximum( 100 );
@@ -500,7 +497,6 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( SMESHGUI* theModule, SVTK_ViewWindow
 
   SliderRotation1 = new QSlider( Qt::Horizontal, GroupParameters );
   SliderRotation1->setObjectName( "SliderRotation1" );
-  SliderRotation1->setFocusPolicy( Qt::NoFocus );
   SliderRotation1->setMinimumSize( 300, 0 );
   SliderRotation1->setMinimum( -180 );
   SliderRotation1->setMaximum( 180 );
@@ -523,7 +519,6 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( SMESHGUI* theModule, SVTK_ViewWindow
 
   SliderRotation2 = new QSlider( Qt::Horizontal, GroupParameters );
   SliderRotation2->setObjectName( "SliderRotation2" );
-  SliderRotation2->setFocusPolicy( Qt::NoFocus );
   SliderRotation2->setMinimumSize( 300, 0 );
   SliderRotation2->setMinimum( -180 );
   SliderRotation2->setMaximum( 180 );
@@ -767,22 +762,22 @@ void rotationToNormal ( double theRotation[2],
   switch ( theOrientation ) {
   case 0:
   case 1:
-       theDir[0][1] = anU[0];
-       theDir[0][2] = aV[0];
-       theDir[1][0] = anU[1];
-       theDir[1][2] = aV[1];
+    theDir[0][1] = anU[0];
+    theDir[0][2] = aV[0];
+    theDir[1][0] = anU[1];
+    theDir[1][2] = aV[1];
     break;
   case 2:
-       theDir[0][2] = anU[0];
-       theDir[0][0] = aV[0];
-       theDir[1][1] = anU[1];
-       theDir[1][0] = aV[1];
+    theDir[0][2] = anU[0];
+    theDir[0][0] = aV[0];
+    theDir[1][1] = anU[1];
+    theDir[1][0] = aV[1];
     break;
   case 3:
-       theDir[0][0] = anU[0];
-       theDir[0][1] = aV[0];
-       theDir[1][2] = anU[1];
-       theDir[1][1] = aV[1];
+    theDir[0][0] = anU[0];
+    theDir[0][1] = aV[0];
+    theDir[1][2] = anU[1];
+    theDir[1][1] = aV[1];
     break;
   }
 
@@ -804,12 +799,12 @@ bool SMESHGUI_ClippingDlg::AddPlane ( SMESH::TActorList       theActorList,
 
   int anOrientation;
   if ( thePlane->PlaneMode == SMESH::Absolute )
-   anOrientation = thePlane->myAbsoluteOrientation;
+    anOrientation = thePlane->myAbsoluteOrientation;
   else if ( thePlane->PlaneMode == SMESH::Relative )
-   anOrientation = thePlane->myRelativeOrientation + 1;
+    anOrientation = thePlane->myRelativeOrientation + 1;
 
   if ( anOrientation == 0 ) {
-       // compute a direction for plane in absolute mode
+    // compute a direction for plane in absolute mode
     double znam = sqrt( thePlane->Dx*thePlane->Dx + thePlane->Dy*thePlane->Dy + thePlane->Dz*thePlane->Dz );
     double aRotation = acos( thePlane->Dy/znam )/aCoeff;
     if ( thePlane->Dy >= 0.0 && thePlane->Dz >= 0.0 )      thePlane->myAngle[0] = 90.0 + aRotation;
@@ -910,10 +905,10 @@ bool SMESHGUI_ClippingDlg::AddPlane ( SMESH::TActorList       theActorList,
   for ( ; anIter != theActorList.end(); anIter++ )
     if( vtkActor* aVTKActor = *anIter )
       if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) {
-       if( thePlane->IsOpenGLClipping )
+        if( thePlane->IsOpenGLClipping )
           anActor->AddOpenGLClippingPlane( thePlane->InvertPlane() );
-       else
-               anActor->AddClippingPlane( thePlane );
+        else
+          anActor->AddClippingPlane( thePlane );
       }
 
   return true;
@@ -1174,7 +1169,7 @@ void SMESHGUI_ClippingDlg::updateActorItem( QListWidgetItem* theItem,
 
         SMESH::ComputeBounds( anActorList, myBounds );
         myPreviewWidget->PlaceWidget( myBounds[0], myBounds[1], myBounds[2],
-                                                 myBounds[3], myBounds[4], myBounds[5] );
+                                      myBounds[3], myBounds[4], myBounds[5] );
       }
     }
   }
@@ -1372,7 +1367,7 @@ 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] );
+                                myBounds[3], myBounds[4], myBounds[5] );
   SetCurrentPlaneParam();
 
   // Actors
@@ -1459,9 +1454,9 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
   double aRot[2] = { getRotation1(), getRotation2() };
   int anOrient;
   if ( aPlane->PlaneMode == SMESH::Absolute )
-       anOrient = CBAbsoluteOrientation->currentIndex();
+    anOrient = CBAbsoluteOrientation->currentIndex();
   else if ( aPlane->PlaneMode == SMESH::Relative )
-       anOrient = CBRelativeOrientation->currentIndex() + 1;
+    anOrient = CBRelativeOrientation->currentIndex() + 1;
 
   if ( aPlane->PlaneMode == SMESH::Relative ) {
     aPlane->myAngle[0] = aRot[0];
@@ -1471,7 +1466,7 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
   }
 
   if ( anOrient == 0 ) {
-       // compute a direction for plane in absolute mode
+    // compute a direction for plane in absolute mode
     double znam = sqrt( aPlane->Dx*aPlane->Dx + aPlane->Dy*aPlane->Dy + aPlane->Dz*aPlane->Dz );
     double aRotation = acos( aPlane->Dy/znam )/aCoeff;
     if ( aPlane->Dy >= 0.0 && aPlane->Dz >= 0.0 )     aRot[0] = 90.0 + aRotation;
@@ -1513,7 +1508,7 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
     anOrigin[1] = aPlane->Y;
     anOrigin[2] = aPlane->Z;
   }
-  
+
   if( anIsOk ) {
     aPlane->SetNormal( aNormal );
     aPlane->SetOrigin( anOrigin );
@@ -1619,7 +1614,7 @@ void SMESHGUI_ClippingDlg::setBoundsForPreviewWidget()
     if( anOrigin[2] < aBounds[4] ) {
       myBounds[4] = anOrigin[2]; isBoundsChanged = true; }
     if( anOrigin[2] > aBounds[5] ) {
-       myBounds[5] = anOrigin[2]; isBoundsChanged = true; }
+        myBounds[5] = anOrigin[2]; isBoundsChanged = true; }
   }
 
   if( isBoundsChanged )
@@ -1703,10 +1698,10 @@ void SMESHGUI_ClippingDlg::absolutePlaneToRelative ( double theOrigin[3], double
   else if( aDirection[0] < 0 && aDirection[1] < 0 && aDirection[2] < 0 && aRot[0] > 0 ) {
     aRot[0] = aRotation1 + 270.0; aRot[1] = aRotation2 + 90.0; }
 
-  SliderRotation1HasMoved( round( aRot[0] ) );
-  SliderRotation1->setValue( round( aRot[0] ) );
-  SliderRotation2HasMoved( round( aRot[1] ) );
-  SliderRotation2->setValue( round( aRot[1] ) );
+  SliderRotation1HasMoved( qRound( aRot[0] ) );
+  SliderRotation1->setValue( qRound( aRot[0] ) );
+  SliderRotation2HasMoved( qRound( aRot[1] ) );
+  SliderRotation2->setValue( qRound( aRot[1] ) );
 
   int aCurPlaneIndex = ComboBoxPlanes->currentIndex();
   const SMESH::TPlaneData& aPlaneData = myPlanes[ aCurPlaneIndex ];
@@ -1722,8 +1717,8 @@ void SMESHGUI_ClippingDlg::absolutePlaneToRelative ( double theOrigin[3], double
   else if( aDist < 0.0 )
     aDist = 0.0;
 
-  SliderDistanceHasMoved( round( aDist*100 ) );
-  SliderDistance->setValue( round( aDist*100 ) );
+  SliderDistanceHasMoved( qRound( aDist*100 ) );
+  SliderDistance->setValue( qRound( aDist*100 ) );
   return;
 }
 
@@ -1808,10 +1803,10 @@ void SMESHGUI_ClippingDlg::ClickOnApply()
       for( ; anIter3 != anActorList.end(); anIter3++ )
         if( vtkActor* aVTKActor = *anIter3 )
           if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) {
-               if( anOrientedPlane->IsOpenGLClipping )
+            if( anOrientedPlane->IsOpenGLClipping )
               anActor->AddOpenGLClippingPlane( anOrientedPlane->InvertPlane() );
-               else
-                       anActor->AddClippingPlane( anOrientedPlane );
+            else
+              anActor->AddClippingPlane( anOrientedPlane );
           }
 
       SMESH::ClippingPlaneInfo aClippingPlaneInfo;
@@ -1825,7 +1820,7 @@ void SMESHGUI_ClippingDlg::ClickOnApply()
     anAllActors->InitTraversal();
     while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
       if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) {
-       anSMESHActor = anActor;
+        anSMESHActor = anActor;
         anActor->SetOpenGLClippingPlane();
       }