Salome HOME
NPAL17431: About WhatIs dialog box. Set font-dependent height.
[modules/geom.git] / src / OperationGUI / OperationGUI_FilletDlg.cxx
index 3516a9280560d305c0b4e22280a811e3300453eb..76aae8dc0ce0f5fc47e0eb7e6568e5f6b3cef4d9 100644 (file)
@@ -17,7 +17,7 @@
 //  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 
 #include "OperationGUI_FilletDlg.h"
 #include "DlgRef_1Sel1Spin.h"
-#include "DlgRef_2Sel1Spin.h"
+#include "DlgRef_2Sel3Spin2Rb.h"
 
 #include "SUIT_Desktop.h"
 #include "SUIT_Session.h"
 #include "SalomeApp_Application.h"
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_SelectionMgr.h"
 #include "OCCViewer_ViewModel.h"
 
 #include "qlabel.h"
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-OperationGUI_FilletDlg::OperationGUI_FilletDlg( QWidget* parent )
-  :GEOMBase_Skeleton( parent, "OperationGUI_FilletDlg", false,
-                     WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+OperationGUI_FilletDlg::OperationGUI_FilletDlg(GeometryGUI* theGeometryGUI, QWidget* parent)
+  :GEOMBase_Skeleton(theGeometryGUI, parent, "OperationGUI_FilletDlg", false,
+                     WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
   myConstructorId = -1;
-  
-  QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_ALL" ) ) );
-  QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_EDGE" ) ) );
-  QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_FACE" ) ) );
-  
-  QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
 
-  setCaption( tr( "GEOM_FILLET_TITLE" ) );
+  SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
+  QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_ALL")));
+  QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_EDGE")));
+  QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_FACE")));
+
+  QPixmap iconSelect(aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
+
+  setCaption(tr("GEOM_FILLET_TITLE"));
 
   /***************************************************************/
   GroupConstructors->setTitle( tr( "GEOM_FILLET" ) );
@@ -78,21 +79,25 @@ OperationGUI_FilletDlg::OperationGUI_FilletDlg( QWidget* parent )
   Group1->PushButton1->setPixmap( iconSelect );
   Group1->LineEdit1->setReadOnly( true );
 
-  Group2 = new DlgRef_2Sel1Spin( this, "Group2" );
+  Group2 = new DlgRef_2Sel3Spin2Rb( this, "Group2" );
   Group2->GroupBox1->setTitle( tr( "GEOM_FILLET_EDGES" ) );
   Group2->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
   Group2->TextLabel2->setText( tr( "SELECTED_EDGES" ) );
   Group2->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
+  Group2->TextLabel4->setText( tr( "GEOM_R1" ) );
+  Group2->TextLabel5->setText( tr( "GEOM_R2" ) );
   Group2->PushButton1->setPixmap( iconSelect );
   Group2->PushButton2->setPixmap( iconSelect );
   Group2->LineEdit1->setReadOnly( true );
   Group2->LineEdit2->setReadOnly( true );
 
-  Group3 = new DlgRef_2Sel1Spin( this, "Group3" );
+  Group3 = new DlgRef_2Sel3Spin2Rb( this, "Group3" );
   Group3->GroupBox1->setTitle(tr( "GEOM_FILLET_FACES" ) );
   Group3->TextLabel1->setText(tr( "GEOM_MAIN_OBJECT" ) );
   Group3->TextLabel2->setText(tr( "SELECTED_FACES" ) );
   Group3->TextLabel3->setText(tr( "GEOM_RADIUS" ) );
+  Group3->TextLabel4->setText(tr( "GEOM_R1" ) );
+  Group3->TextLabel5->setText(tr( "GEOM_R2" ) );
   Group3->PushButton1->setPixmap( iconSelect );
   Group3->PushButton2->setPixmap( iconSelect );
   Group3->LineEdit1->setReadOnly( true );
@@ -104,9 +109,15 @@ OperationGUI_FilletDlg::OperationGUI_FilletDlg( QWidget* parent )
   /***************************************************************/
 
   double SpecificStep = 10.0;
-  Group1->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3);
-  Group2->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3);
-  Group3->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3);
+  Group1->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
+  Group2->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
+  Group2->SpinBox_DY->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
+  Group2->SpinBox_DZ->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
+  Group3->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
+  Group3->SpinBox_DY->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
+  Group3->SpinBox_DZ->RangeStepAndValidator(0.001, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
+
+  setHelpFileName("fillet.htm");
 
   /* Initialisations */
   Init();
@@ -155,20 +166,27 @@ void OperationGUI_FilletDlg::Init()
   // spin boxes  
   connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
   connect(Group2->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(Group2->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(Group2->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
   connect(Group3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(Group3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+  connect(Group3->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+
+  //RadioButtons
+  connect( Group2->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButton_Clicked() ) );
+  connect( Group2->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButton_Clicked() ) );
+  connect( Group3->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButton_Clicked() ) );
+  connect( Group3->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButton_Clicked() ) );
 
     // selection
-  connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-          SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-  
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+          SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
   initName( tr( "GEOM_FILLET" ) );
 
   Group2->hide();
   Group3->hide();
   Group1->show();
-
-  this->show();
 }
 
 
@@ -189,10 +207,18 @@ void OperationGUI_FilletDlg::ConstructorsClicked( int constructorId )
     return;
 
   // Get radius from previous widget
-  double R = 5;
+  double R = 5, R1 = 5, R2 = 5;
   if      ( myConstructorId == 0 ) R = Group1->SpinBox_DX->GetValue();
-  else if ( myConstructorId == 1 ) R = Group2->SpinBox_DX->GetValue();
-  else                             R = Group3->SpinBox_DX->GetValue();
+  else if ( myConstructorId == 1 ) {
+    R = Group2->SpinBox_DX->GetValue();
+    R1 = Group2->SpinBox_DY->GetValue();
+    R2 = Group2->SpinBox_DZ->GetValue();
+  }
+  else {
+    R = Group3->SpinBox_DX->GetValue();
+    R1 = Group3->SpinBox_DY->GetValue();
+    R2 = Group3->SpinBox_DZ->GetValue();
+  }
 
   myConstructorId = constructorId;
 
@@ -209,12 +235,16 @@ void OperationGUI_FilletDlg::ConstructorsClicked( int constructorId )
         Group2->show();
         Group3->hide();
         Group2->SpinBox_DX->SetValue( R );
+        Group2->SpinBox_DY->SetValue( R1 );
+        Group2->SpinBox_DZ->SetValue( R2 );
     break;
     case 2:
         Group1->hide();
         Group2->hide();
         Group3->show();
         Group3->SpinBox_DX->SetValue( R );
+        Group3->SpinBox_DY->SetValue( R1 );
+        Group3->SpinBox_DZ->SetValue( R2 );
     break;
     default:
     break;
@@ -308,31 +338,31 @@ void OperationGUI_FilletDlg::SelectionIntoArgument()
 
       if ( aResult && !anObj->_is_nil() )
       {
-         TColStd_IndexedMapOfInteger anIndexes;
-        ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
-
-         if ( anIndexes.Extent() > 0 )
-         {
-           QString aName;
-           if ( anIndexes.Extent() == 1 )
-           {
-             int anIndex = anIndexes( 1 );
-
-             aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
-           }
-           else
-             aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
-
-           myEditCurrentArgument->setText( aName );
-
-           if ( myConstructorId == 1 )
-             myEdges = anIndexes;
-           else
-             myFaces = anIndexes;
-           
-           displayPreview();
-           return;
-         }
+        TColStd_IndexedMapOfInteger anIndexes;
+        myGeomGUI->getApp()->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
+
+        if ( anIndexes.Extent() > 0 )
+        {
+          QString aName;
+          if ( anIndexes.Extent() == 1 )
+          {
+            int anIndex = anIndexes( 1 );
+
+            aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
+          }
+          else
+            aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
+
+          myEditCurrentArgument->setText( aName );
+
+          if ( myConstructorId == 1 )
+            myEdges = anIndexes;
+          else
+            myFaces = anIndexes;
+
+          displayPreview();
+          return;
+        }
       }
     }
     myFaces.Clear();
@@ -400,17 +430,6 @@ void OperationGUI_FilletDlg::SetEditCurrentArgument()
 }
 
 
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose  :
-//=================================================================================
-void OperationGUI_FilletDlg::DeactivateActiveDialog()
-{
-  GEOMBase_Skeleton::DeactivateActiveDialog();
-  return;
-}
-
-
 //=================================================================================
 // function : ActivateThisDialog()
 // purpose  :
@@ -419,8 +438,8 @@ void OperationGUI_FilletDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
 
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-          SIGNAL(currentSelectionChanged()), this, SLOT( SelectionIntoArgument() ) );
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+          SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
   activateSelection();
   displayPreview();
@@ -455,7 +474,11 @@ void OperationGUI_FilletDlg::reset()
   // Set Initial values of spinboxes
   Group1->SpinBox_DX->SetValue( 5 );
   Group2->SpinBox_DX->SetValue( 5 );
+  Group2->SpinBox_DY->SetValue( 5 );
+  Group2->SpinBox_DZ->SetValue( 5 );
   Group3->SpinBox_DX->SetValue( 5 );
+  Group3->SpinBox_DY->SetValue( 5 );
+  Group3->SpinBox_DZ->SetValue( 5 );
 
   Group1->LineEdit1->setText( "" );
   Group2->LineEdit1->setText( "" );
@@ -583,8 +606,7 @@ bool OperationGUI_FilletDlg::execute( ObjectList& objects )
   int anId = getConstructorId();
   if ( anId == 0 )
     anObj = GEOM::GEOM_ILocalOperations::_narrow(
-      getOperation() )->MakeFilletAll( myShape,
-                                       getRadius() );
+      getOperation() )->MakeFilletAll( myShape, getRadius() );
   else if ( anId == 1 )
   {
     GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
@@ -592,9 +614,14 @@ bool OperationGUI_FilletDlg::execute( ObjectList& objects )
 
     for ( int i = 1, n = myEdges.Extent(); i <= n; i++ )
       aList[ i - 1 ] = myEdges( i );
-
-    anObj = GEOM::GEOM_ILocalOperations::_narrow(
-      getOperation() )->MakeFilletEdges( myShape, getRadius(), aList );
+    if ( Group2->RadioButton1->isChecked() )
+      anObj = GEOM::GEOM_ILocalOperations::_narrow(
+              getOperation() )->MakeFilletEdges( myShape, getRadius(), aList );
+    else
+      anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->MakeFilletEdgesR1R2( myShape,
+                                                   (Group2->SpinBox_DY->GetValue()),
+                                                   (Group2->SpinBox_DZ->GetValue()),
+                                                   aList );
   }
   else if ( anId == 2 )
   {
@@ -604,9 +631,13 @@ bool OperationGUI_FilletDlg::execute( ObjectList& objects )
 
     for ( int i = 1, n = myFaces.Extent(); i <= n; i++ )
       aList[ i - 1 ] = myFaces( i );
-
-    anObj = GEOM::GEOM_ILocalOperations::_narrow(
-      getOperation() )->MakeFilletFaces( myShape, getRadius(), aList );
+    if ( Group3->RadioButton1->isChecked() )
+       anObj = GEOM::GEOM_ILocalOperations::_narrow(
+               getOperation() )->MakeFilletFaces( myShape, getRadius(), aList );
+    else
+       anObj = GEOM::GEOM_ILocalOperations::_narrow(
+               getOperation() )->MakeFilletFacesR1R2( myShape, (Group3->SpinBox_DY->GetValue()),
+                                                      (Group3->SpinBox_DZ->GetValue()), aList );
   }
 
   if ( !anObj->_is_nil() )
@@ -627,9 +658,25 @@ double OperationGUI_FilletDlg::getRadius() const
   else                  return Group3->SpinBox_DX->GetValue();
 }
 
+//=================================================================================
+// function : RadiobuttonClicked
+// purpose  :
+//=================================================================================
 
-
-
-
-
-
+void OperationGUI_FilletDlg::RadioButton_Clicked()
+{
+    bool flag = ( (Group2->RadioButton1->isChecked()) && (Group3->RadioButton1->isChecked()) );
+    flag = !flag;
+
+    Group2->SpinBox_DX->setEnabled(flag);
+    Group2->SpinBox_DY->setEnabled(!flag);
+    Group2->SpinBox_DZ->setEnabled(!flag);
+    Group2->RadioButton1->setChecked(flag);
+    Group2->RadioButton2->setChecked(!flag);
+    Group3->SpinBox_DX->setEnabled(flag);
+    Group3->SpinBox_DY->setEnabled(!flag);
+    Group3->SpinBox_DZ->setEnabled(!flag);
+    Group3->RadioButton1->setChecked(flag);
+    Group3->RadioButton2->setChecked(!flag);
+    displayPreview();  
+}