Salome HOME
Updated for PAL14857.
[modules/geom.git] / src / TransformationGUI / TransformationGUI_TranslationDlg.cxx
index 0654d2ad4816b96a14a59afdeec569e38701396f..5e022bc8817c9a6972986ff9ade5b47cf9c87aa9 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_TranslationDlg.h"
 
-#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"
 
@@ -46,13 +49,16 @@ using namespace std;
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg(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_TranslationDlg::TransformationGUI_TranslationDlg
+  (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_TRANSLATION_DXYZ")));
-  QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TRANSLATION_POINTS")));
-  QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TRANSLATION_VECTOR")));
-  QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
+  QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSLATION_DXYZ")));
+  QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSLATION_POINTS")));
+  QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSLATION_VECTOR")));
+  QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
 
   setCaption(tr("GEOM_TRANSLATION_TITLE"));
 
@@ -79,6 +85,8 @@ TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg(QWidget* pare
   Layout1->addWidget(GroupPoints, 2, 0);
   /***************************************************************/
   
+  setHelpFileName("translation.htm");
+  
   Init();
 }
 
@@ -112,13 +120,13 @@ void TransformationGUI_TranslationDlg::Init()
   CreateCopyModeChanged(true);
   
   /* 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);
   
   /* min, max, step and decimals for spin boxes & initial values */
-  GroupPoints->SpinBox1->RangeStepAndValidator(-999.999, 999.999, step, 3);
-  GroupPoints->SpinBox2->RangeStepAndValidator(-999.999, 999.999, step, 3);
-  GroupPoints->SpinBox3->RangeStepAndValidator(-999.999, 999.999, step, 3);
+  GroupPoints->SpinBox1->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
+  GroupPoints->SpinBox2->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
+  GroupPoints->SpinBox3->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
   
   GroupPoints->SpinBox1->SetValue(0.0);
   GroupPoints->SpinBox2->SetValue(0.0);
@@ -133,7 +141,7 @@ void TransformationGUI_TranslationDlg::Init()
   connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
 
-  connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); // MZN: Delete ?
+  connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); //@ Delete ?
 
   connect(GroupPoints->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
   connect(GroupPoints->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
@@ -145,7 +153,8 @@ void TransformationGUI_TranslationDlg::Init()
   
   connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
   
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
 
   initName( tr( "GEOM_TRANSLATION" ) );
   ConstructorsClicked( 0 );
@@ -158,7 +167,7 @@ void TransformationGUI_TranslationDlg::Init()
 //=================================================================================
 void TransformationGUI_TranslationDlg::ConstructorsClicked(int constructorId)
 {
-  disconnect( mySelection, 0, this, 0 );
+  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
   
   myEditCurrentArgument = GroupPoints->LineEdit1;
   globalSelection();
@@ -196,7 +205,8 @@ void TransformationGUI_TranslationDlg::ConstructorsClicked(int constructorId)
     }
   
   myEditCurrentArgument->setFocus();
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 }
 
 
@@ -226,16 +236,6 @@ bool TransformationGUI_TranslationDlg::ClickOnApply()
 }
 
 
-//=======================================================================
-// function : ClickOnCancel()
-// purpose  :
-//=======================================================================
-void TransformationGUI_TranslationDlg::ClickOnCancel()
-{
-  GEOMBase_Skeleton::ClickOnCancel();
-}
-
-
 //=================================================================================
 // function : SelectionIntoArgument()
 // purpose  : Called when selection as changed or other case
@@ -247,21 +247,20 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument()
   
   if(myEditCurrentArgument == GroupPoints->LineEdit1)
     {
-      int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName);
+      int aNbSel = GEOMBase::GetNameOfSelectedIObjects(selectedIO(), aName);
+      
       if(aNbSel < 1)
        {
          myObjects.length(0);
          return;
        }
-      GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myObjects);
+      GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), myObjects);
       if (!myObjects.length())
        return;
-      if(aNbSel != 1)
-       aName = tr("%1_objects").arg(aNbSel);
     }
   else
     {
-      if (mySelection->IObjectCount() != 1) {
+      if (IObjectCount() != 1) {
        if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
          myPoint1 = GEOM::GEOM_Object::_nil();
        else if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2)
@@ -272,7 +271,7 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument()
       }
       
       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 ))
        return;
@@ -345,19 +344,10 @@ void TransformationGUI_TranslationDlg::SetEditCurrentArgument()
 void TransformationGUI_TranslationDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
-  
-  ConstructorsClicked( getConstructorId() );
-}
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
-
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose  : public slot to deactivate if active
-//=================================================================================
-void  TransformationGUI_TranslationDlg::DeactivateActiveDialog()
-{
-  GEOMBase_Skeleton::DeactivateActiveDialog();
+  ConstructorsClicked( getConstructorId() );
 }
 
 
@@ -388,7 +378,7 @@ void TransformationGUI_TranslationDlg::ValueChangedInSpinBox()
 //=================================================================================
 GEOM::GEOM_IOperations_ptr  TransformationGUI_TranslationDlg::createOperation()
 {
-  return getGeomEngine()->GetITransformOperations( getStudyId() );
+  return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() );
 }
 
 
@@ -507,7 +497,7 @@ bool TransformationGUI_TranslationDlg::execute( ObjectList& objects )
 //=================================================================================
 void  TransformationGUI_TranslationDlg::closeEvent( QCloseEvent* e )
 {
-  myGeomGUI->SetState( -1 );
+  // myGeomGUI->SetState( -1 );
   GEOMBase_Skeleton::closeEvent( e );
 }