Salome HOME
Updated for PAL14857.
[modules/geom.git] / src / TransformationGUI / TransformationGUI_MultiRotationDlg.cxx
index 441abea0a72eb3c804abfbd11fc0d3c133826f97..88535e435aa0f89e87c5cb67c10585f26bfc8bcc 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 "TransformationGUI_MultiRotationDlg.h"
 
-#include "GEOMImpl_Types.hxx"
-
-#include "QAD_Config.h"
-#include "QAD_Desktop.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_Session.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
 
 #include <qcheckbox.h>
+#include <qlabel.h>
+
+#include "GEOMImpl_Types.hxx"
 
 #include "utilities.h"
 
@@ -46,12 +49,15 @@ using namespace std;
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg(QWidget* parent,  const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
-  :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg
+  (GeometryGUI* theGeometryGUI, QWidget* parent,  const char* name, bool modal, WFlags fl)
+  :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
+                     WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
-  QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_MULTIROTATION_SIMPLE")));
-  QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_MULTIROTATION_DOUBLE")));
-  QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
+  QPixmap image0(aResMgr->loadPixmap("GEOM",tr("ICON_DLG_MULTIROTATION_SIMPLE")));
+  QPixmap image1(aResMgr->loadPixmap("GEOM",tr("ICON_DLG_MULTIROTATION_DOUBLE")));
+  QPixmap image2(aResMgr->loadPixmap("GEOM",tr("ICON_SELECT")));
 
   setCaption(tr("GEOM_MULTIROTATION_TITLE"));
 
@@ -89,6 +95,8 @@ TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg(QWidget*
   Layout1->addWidget(GroupDimensions, 2, 0);
   /***************************************************************/
 
+  setHelpFileName("multi_rotation.htm");
+
   Init();
 }
 
@@ -110,19 +118,19 @@ TransformationGUI_MultiRotationDlg::~TransformationGUI_MultiRotationDlg()
 void TransformationGUI_MultiRotationDlg::Init()
 {
   /* Get setting of step value from file configuration */
-  QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
-  double step = St.toDouble();
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
 
   double SpecificStep1 = 5;
   double SpecificStep2 = 1;
   /* min, max, step and decimals for spin boxes & initial values */
-  GroupPoints->SpinBox_DX->RangeStepAndValidator(1.0, 999.999, SpecificStep2, 3);
+  GroupPoints->SpinBox_DX->RangeStepAndValidator(1.0, MAX_NUMBER, SpecificStep2, 3);
   GroupPoints->SpinBox_DX->SetValue(myNbTimes1);
 
-  GroupDimensions->SpinBox_DX1->RangeStepAndValidator(-999.999, 999.999, SpecificStep1, 3);
-  GroupDimensions->SpinBox_DY1->RangeStepAndValidator(1.0, 999.999, SpecificStep2, 3);
-  GroupDimensions->SpinBox_DX2->RangeStepAndValidator(-999.999, 999.999, step, 3);
-  GroupDimensions->SpinBox_DY2->RangeStepAndValidator(1.0, 999.999, SpecificStep2, 3);
+  GroupDimensions->SpinBox_DX1->RangeStepAndValidator(COORD_MIN, COORD_MAX, SpecificStep1, 3);
+  GroupDimensions->SpinBox_DY1->RangeStepAndValidator(1.0, MAX_NUMBER, SpecificStep2, 3);
+  GroupDimensions->SpinBox_DX2->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
+  GroupDimensions->SpinBox_DY2->RangeStepAndValidator(1.0, MAX_NUMBER, SpecificStep2, 3);
   GroupDimensions->SpinBox_DX1->SetValue(myAng);
   GroupDimensions->SpinBox_DY1->SetValue(myNbTimes1);
   GroupDimensions->SpinBox_DX2->SetValue(myStep);
@@ -157,7 +165,8 @@ void TransformationGUI_MultiRotationDlg::Init()
 
   connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseAngle()));
   
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
   initName( tr( "GEOM_MULTIROTATION" ) );
   ConstructorsClicked( 0 );
@@ -170,12 +179,12 @@ void TransformationGUI_MultiRotationDlg::Init()
 //=================================================================================
 void TransformationGUI_MultiRotationDlg::ConstructorsClicked(int constructorId)
 {
-  disconnect(mySelection, 0, this, 0);
-  
+  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+
   myAng = 45.0;
   myStep = 50.0;
   myNbTimes1 = myNbTimes2 = 2;
-  
+
   globalSelection( GEOM_ALLSHAPES );
 
   switch (constructorId)
@@ -215,7 +224,8 @@ void TransformationGUI_MultiRotationDlg::ConstructorsClicked(int constructorId)
 
   myEditCurrentArgument->setFocus();
   myBase = myVector = GEOM::GEOM_Object::_nil();
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
 }
 
 
@@ -245,16 +255,6 @@ bool TransformationGUI_MultiRotationDlg::ClickOnApply()
 }
 
 
-//=======================================================================
-// function : ClickOnCancel()
-// purpose  :
-//=======================================================================
-void TransformationGUI_MultiRotationDlg::ClickOnCancel()
-{
-  GEOMBase_Skeleton::ClickOnCancel();
-}
-
-
 //=================================================================================
 // function : SelectionIntoArgument()
 // purpose  : Called when selection as changed or other case
@@ -262,28 +262,32 @@ void TransformationGUI_MultiRotationDlg::ClickOnCancel()
 void TransformationGUI_MultiRotationDlg::SelectionIntoArgument()
 {
   myEditCurrentArgument->setText("");
-  
-  if(mySelection->IObjectCount() != 1) {
-    if(myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1)
+
+  if (IObjectCount() != 1) {
+    if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
+        myEditCurrentArgument == GroupDimensions->LineEdit1)
       myBase = GEOM::GEOM_Object::_nil();
-    else if(myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupDimensions->LineEdit2)
+    else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
+             myEditCurrentArgument == GroupDimensions->LineEdit2)
       myVector = GEOM::GEOM_Object::_nil();
     return;
   }
-  
+
   // nbSel == 1
   Standard_Boolean testResult = Standard_False;;
-  GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult );
+  GEOM::GEOM_Object_var aSelectedObject =
+    GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult );
 
-  if ( !testResult || CORBA::is_nil( aSelectedObject ) || !GEOMBase::IsShape( aSelectedObject ) )
+  if (!testResult || CORBA::is_nil(aSelectedObject) || !GEOMBase::IsShape(aSelectedObject))
     return;
 
-
-  if(myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1)
+  if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
+      myEditCurrentArgument == GroupDimensions->LineEdit1)
     myBase = aSelectedObject;
-  else if(myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupDimensions->LineEdit2)
+  else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
+           myEditCurrentArgument == GroupDimensions->LineEdit2)
     myVector = aSelectedObject;
-    
+
   myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
 
   displayPreview();
@@ -343,22 +347,13 @@ void TransformationGUI_MultiRotationDlg::LineEditReturnPressed()
 void TransformationGUI_MultiRotationDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
   
   ConstructorsClicked( getConstructorId() );
 }
 
 
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose  : public slot to deactivate if active
-//=================================================================================
-void TransformationGUI_MultiRotationDlg::DeactivateActiveDialog()
-{
-  GEOMBase_Skeleton::DeactivateActiveDialog();
-}
-
-
 //=================================================================================
 // function : enterEvent()
 // purpose  :
@@ -416,7 +411,7 @@ void TransformationGUI_MultiRotationDlg::ReverseAngle()
 //=================================================================================
 GEOM::GEOM_IOperations_ptr TransformationGUI_MultiRotationDlg::createOperation()
 {
-  return getGeomEngine()->GetITransformOperations( getStudyId() );
+  return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() );
 }
 
 
@@ -444,7 +439,8 @@ bool TransformationGUI_MultiRotationDlg::execute( ObjectList& objects )
     case 0 :
       {
        if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVector ) ) {
-         anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiRotate1D( myBase, myVector, myNbTimes1 );
+         anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
+            MultiRotate1D( myBase, myVector, myNbTimes1 );
          res = true;
        }
        break;
@@ -453,7 +449,8 @@ bool TransformationGUI_MultiRotationDlg::execute( ObjectList& objects )
       {
        if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVector ) )
          {
-           anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiRotate2D( myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2 );
+           anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
+              MultiRotate2D( myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2 );
            res = true;
          }
        break;
@@ -473,6 +470,6 @@ bool TransformationGUI_MultiRotationDlg::execute( ObjectList& objects )
 //=================================================================================
 void  TransformationGUI_MultiRotationDlg::closeEvent( QCloseEvent* e )
 {
-  myGeomGUI->SetState( -1 );
+  // myGeomGUI->SetState( -1 );
   GEOMBase_Skeleton::closeEvent( e );
 }