Salome HOME
Updated for PAL14857.
[modules/geom.git] / src / TransformationGUI / TransformationGUI_OffsetDlg.cxx
index ba0cd6381082c5a199115c705975309ba4a721c3..6a33e47e837a62d7d2064f5dc8e3ae38f88a5a9c 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
 //
 //
 //
 //  $Header$
 
 #include "TransformationGUI_OffsetDlg.h"
-#include <QAD_Desktop.h>
-#include "utilities.h"
 
+#include "SUIT_Desktop.h"
+#include "SUIT_Session.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+
+#include <qlabel.h>
 #include <qcheckbox.h>
 
+#include "utilities.h"
+
 using namespace std;
 
 //=================================================================================
@@ -41,11 +47,13 @@ using namespace std;
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-TransformationGUI_OffsetDlg::TransformationGUI_OffsetDlg(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_OffsetDlg::TransformationGUI_OffsetDlg(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_OFFSET")));
-  QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_OFFSET")));
+  QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
 
   setCaption(tr("GEOM_OFFSET_TITLE"));
 
@@ -69,6 +77,8 @@ TransformationGUI_OffsetDlg::TransformationGUI_OffsetDlg(QWidget* parent,  const
   Layout1->addWidget(GroupPoints, 2, 0);
   
   /***************************************************************/
+
+  setHelpFileName("offset_surface.htm");  
   
   Init();
 }
@@ -98,9 +108,9 @@ void TransformationGUI_OffsetDlg::Init()
   double step = 1;
    
   /* min, max, step and decimals for spin boxes & initial values */
-  GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3);
+  GroupPoints->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
   GroupPoints->SpinBox_DX->setPrecision(5);
-  GroupPoints->SpinBox_DX->setDblPrecision(1e-05);    
+  //@ GroupPoints->SpinBox_DX->setDblPrecision(1e-05);    
   GroupPoints->SpinBox_DX->SetValue(1e-05);
   
   // Activate Create a Copy mode
@@ -112,7 +122,8 @@ void TransformationGUI_OffsetDlg::Init()
   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
   
   connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
   connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
   connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
@@ -149,16 +160,6 @@ bool TransformationGUI_OffsetDlg::ClickOnApply()
 }
 
 
-//=======================================================================
-// function : ClickOnCancel()
-// purpose  :
-//=======================================================================
-void TransformationGUI_OffsetDlg::ClickOnCancel()
-{
-  GEOMBase_Skeleton::ClickOnCancel();
-}
-
-
 //=================================================================================
 // function : SelectionIntoArgument()
 // purpose  : Called when selection has changed
@@ -168,7 +169,7 @@ void TransformationGUI_OffsetDlg::SelectionIntoArgument()
   myEditCurrentArgument->setText("");
   QString aName;
 
-  int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName);
+  int aNbSel = GEOMBase::GetNameOfSelectedIObjects(selectedIO(), aName);
   if(aNbSel < 1)
     {
       myObjects.length(0);
@@ -176,12 +177,10 @@ void TransformationGUI_OffsetDlg::SelectionIntoArgument()
     }
 
   // nbSel > 0
-  GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myObjects);
+  GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), myObjects);
   if (!myObjects.length())
     return;
-  if(aNbSel != 1)
-    aName = tr("%1_objects").arg(aNbSel);
-
+  
   myEditCurrentArgument->setText( aName );
   
   displayPreview();
@@ -238,23 +237,14 @@ void TransformationGUI_OffsetDlg::enterEvent(QEvent * e)
 void TransformationGUI_OffsetDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
   globalSelection( GEOM_ALLSHAPES );
   myEditCurrentArgument = GroupPoints->LineEdit1;
   myEditCurrentArgument->setFocus();
 }
 
 
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose  : public slot to deactivate if active
-//=================================================================================
-void TransformationGUI_OffsetDlg::DeactivateActiveDialog()
-{
- GEOMBase_Skeleton::DeactivateActiveDialog();
-}
-
-
 //=================================================================================
 // function : ValueChangedInSpinBox()
 // purpose  :
@@ -280,7 +270,18 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_OffsetDlg::createOperation()
 //=================================================================================
 bool TransformationGUI_OffsetDlg::isValid( QString& msg )
 {
-  return !(myObjects.length() == 0);
+  //return !(myObjects.length() == 0);
+  if (myObjects.length() == 0) return false;
+
+  for (int i = 0; i < myObjects.length(); i++)
+  {
+    GEOM::shape_type aType = myObjects[i]->GetShapeType();
+    if( aType != GEOM::FACE && aType != GEOM::SHELL && aType != GEOM::SOLID ){
+       msg = tr("ERROR_SHAPE_TYPE");
+       return false;
+    }
+  }
+  return true;
 }
 
 
@@ -298,6 +299,7 @@ bool TransformationGUI_OffsetDlg::execute( ObjectList& objects )
   if (GroupPoints->CheckButton1->isChecked() || IsPreview())
     for (int i = 0; i < myObjects.length(); i++)
       {
+
        anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->OffsetShapeCopy( myObjects[i], GetOffset() );
        if ( !anObj->_is_nil() )
          objects.push_back( anObj._retn() );
@@ -321,7 +323,7 @@ bool TransformationGUI_OffsetDlg::execute( ObjectList& objects )
 //=================================================================================
 void TransformationGUI_OffsetDlg::closeEvent( QCloseEvent* e )
 {
-  myGeomGUI->SetState( -1 );
+  // myGeomGUI->SetState( -1 );
   GEOMBase_Skeleton::closeEvent( e );
 }