Salome HOME
Fix for bug PAL12858(EDF210 GEOM Preferences menu of GEOM: color of the wireframe?)
[modules/geom.git] / src / RepairGUI / RepairGUI_GlueDlg.cxx
index 6a5b0d07a6ecc53808277308f5ae515404ef5272..bcdb30715cbc295b3ff5c9d8a21b90374c531008 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
 //
 //
 //
 //  Module : GEOM
 //  $Header$
 
-using namespace std;
 #include "RepairGUI_GlueDlg.h"
-
 #include "DlgRef_1Sel_Ext.h"
+#include "GEOMImpl_Types.hxx"
+
+#include "QtxDblSpinBox.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Tools.h"
 
-#include "QAD_Desktop.h"
-#include "QAD_SpinBoxDbl.h"
-#include "QAD_MessageBox.h"
-#include "QAD_WaitCursor.h"
+#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_OverrideCursor.h"
 
-#include "OCCViewer_Viewer3d.h"
 #include "SALOME_ListIteratorOfListIO.hxx"
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
 
-#include "GEOMImpl_Types.hxx"
+#include <TCollection_AsciiString.hxx>
 
-#define DEFAULT_TOLERANCE_VALUE 1e-07
+#include <qapplication.h>
+#include <qlabel.h>
 
+using namespace std;
+
+#define DEFAULT_TOLERANCE_VALUE 1e-07
 
 //=================================================================================
 // class    : RepairGUI_GlueDlg()
@@ -52,11 +58,13 @@ using namespace std;
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-RepairGUI_GlueDlg::RepairGUI_GlueDlg(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)
+RepairGUI_GlueDlg::RepairGUI_GlueDlg(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_GLUE_FACES")));
-  QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_GLUE_FACES")));
+  QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
 
   setCaption(tr("GEOM_GLUE_TITLE"));
 
@@ -76,7 +84,8 @@ RepairGUI_GlueDlg::RepairGUI_GlueDlg(QWidget* parent, const char* name, SALOME_S
 
   QGridLayout* aLay = new QGridLayout( 0, 2, 2, 0, 6, "aLay" );
   QLabel* aLbl1 = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints->GroupBox1 );
-  myTolEdt = new QAD_SpinBoxDbl( GroupPoints->GroupBox1, 0, 100, 1e-7, 10, 1e-10 );
+  myTolEdt = new QtxDblSpinBox( 0, 100, 1e-7, GroupPoints->GroupBox1 );
+  myTolEdt->setPrecision( 10 );
   myTolEdt->setValue( DEFAULT_TOLERANCE_VALUE );
 
   aLay->addWidget( aLbl1, 0, 0 );
@@ -85,6 +94,8 @@ RepairGUI_GlueDlg::RepairGUI_GlueDlg(QWidget* parent, const char* name, SALOME_S
   GroupPoints->getGroupBoxLayout()->addLayout( aLay, 3, 0 );
   /***************************************************************/
 
+  setHelpFileName("glue_faces.htm");
+
   Init();
 }
 
@@ -109,21 +120,18 @@ void RepairGUI_GlueDlg::Init()
 
   myObject = GEOM::GEOM_Object::_nil();
 
-  myGeomGUI->SetState( 0 );
+  //myGeomGUI->SetState( 0 );
   globalSelection( GEOM_COMPOUND );
 
   /* signals and slots connections */
-  connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
-  connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
-  connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
-
   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
 
   connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
 
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
   initName( tr( "GLUE_NEW_OBJ_NAME" ) );
 }
@@ -140,7 +148,6 @@ void RepairGUI_GlueDlg::ClickOnOk()
 }
 
 
-
 //=================================================================================
 // function : ClickOnApply()
 // purpose  :
@@ -161,16 +168,6 @@ bool RepairGUI_GlueDlg::ClickOnApply()
 }
 
 
-//=================================================================================
-// function : ClickOnCancel()
-// purpose  :
-//=================================================================================
-void RepairGUI_GlueDlg::ClickOnCancel()
-{
-  GEOMBase_Skeleton::ClickOnCancel();
-}
-
-
 //=================================================================================
 // function : SelectionIntoArgument()
 // purpose  : Called when selection
@@ -181,8 +178,8 @@ void RepairGUI_GlueDlg::SelectionIntoArgument()
   myEditCurrentArgument->setText("");
   myObject = GEOM::GEOM_Object::_nil();
 
-  if ( mySelection->IObjectCount() == 1 ) {
-    Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject();
+  if ( IObjectCount() == 1 ) {
+    Handle(SALOME_InteractiveObject) anIO = firstIObject();
     Standard_Boolean aRes;
     myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
     if ( aRes )
@@ -218,17 +215,6 @@ void RepairGUI_GlueDlg::LineEditReturnPressed()
 }
 
 
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose  :
-//=================================================================================
-void RepairGUI_GlueDlg::DeactivateActiveDialog()
-{
-  myGeomGUI->SetState( -1 );
-  GEOMBase_Skeleton::DeactivateActiveDialog();
-}
-
-
 //=================================================================================
 // function : ActivateThisDialog()
 // purpose  :
@@ -236,12 +222,13 @@ void RepairGUI_GlueDlg::DeactivateActiveDialog()
 void RepairGUI_GlueDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
   GroupPoints->LineEdit1->setText("");
   myObject = GEOM::GEOM_Object::_nil();
 
-  myGeomGUI->SetState( 0 );
+  //myGeomGUI->SetState( 0 );
   globalSelection( GEOM_COMPOUND );
 }
 
@@ -263,7 +250,7 @@ void RepairGUI_GlueDlg::enterEvent(QEvent* e)
 //=================================================================================
 void RepairGUI_GlueDlg::closeEvent(QCloseEvent* e)
 {
-  myGeomGUI->SetState( -1 );
+  //myGeomGUI->SetState( -1 );
   GEOMBase_Skeleton::closeEvent( e );
 }
 
@@ -310,25 +297,25 @@ void RepairGUI_GlueDlg::clearShapeBufferLocal( GEOM::GEOM_Object_ptr theObj )
   if ( CORBA::is_nil( theObj ) )
     return;
 
-  string IOR = GeometryGUI::GetORB()->object_to_string( theObj );
+  string IOR = myGeomGUI->getApp()->orb()->object_to_string( theObj );
   TCollection_AsciiString asciiIOR( strdup( IOR.c_str() ) );
-  GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( asciiIOR );
+  myGeomGUI->GetShapeReader().RemoveShapeFromBuffer( asciiIOR );
 
-  if ( !getStudy() || CORBA::is_nil( getStudy()->getStudyDocument() ) )
+  if ( !getStudy() || !( getStudy()->studyDS() ) )
     return;
 
-  SALOMEDS::Study_var aStudy = getStudy()->getStudyDocument();
-  SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( IOR.c_str() );
-  if ( CORBA::is_nil( aSObj ) )
+  _PTR(Study) aStudy = getStudy()->studyDS();
+  _PTR(SObject) aSObj ( aStudy->FindObjectIOR( IOR ) );
+  if ( !aSObj )
     return;
 
-  SALOMEDS::ChildIterator_var anIt = aStudy->NewChildIterator( aSObj );
+  _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
   for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
-    SALOMEDS::GenericAttribute_var anAttr;
+    _PTR(GenericAttribute) anAttr;
     if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
-      SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-      TCollection_AsciiString asciiIOR( anIOR->Value() );
-      GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( asciiIOR );      
+      _PTR(AttributeIOR) anIOR ( anAttr );
+      TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
+      myGeomGUI->GetShapeReader().RemoveShapeFromBuffer( asciiIOR );      
     }
   }
 }
@@ -341,16 +328,18 @@ void RepairGUI_GlueDlg::clearShapeBufferLocal( GEOM::GEOM_Object_ptr theObj )
 //================================================================
 bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransaction )
 {
-  QAD_Study* aDoc = QAD_Application::getDesktop()->getActiveStudy();
-  SALOMEDS::Study_var aStudy = aDoc->getStudyDocument();
+  if ( !getStudy() || !( getStudy()->studyDS() ) )
+    return false;
+
+  _PTR(Study) aStudy = getStudy()->studyDS();
 
   bool aLocked = aStudy->GetProperties()->IsLocked();
   if ( aLocked ) {
     MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
-    QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
-                          QObject::tr("WRN_WARNING"), 
-                          QObject::tr("WRN_STUDY_LOCKED"),
-                          QObject::tr("BUT_OK") );
+    SUIT_MessageBox::warn1 ( (QWidget*)(SUIT_Session::session()->activeApplication()->desktop()),
+                            QObject::tr("WRN_WARNING"), 
+                            QObject::tr("WRN_STUDY_LOCKED"),
+                            QObject::tr("BUT_OK") );
     return false;
   }
 
@@ -364,13 +353,15 @@ bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransac
 
   try {
     if ( ( !publish && !useTransaction ) || openCommand() ) {
-      QAD_WaitCursor wc;
-      QAD_Application::getDesktop()->putInfo( "" );
+
+      SUIT_OverrideCursor wc;
+
+      SUIT_Session::session()->activeApplication()->putInfo( "" );
       ObjectList objects;
       // JFA 28.12.2004 if ( !execute( objects ) || !getOperation()->IsDone() ) {
       if ( !execute( objects ) ) { // JFA 28.12.2004 // To enable warnings
-       wc.stop();
-       abortCommand();
+       wc.suspend();
+        abortCommand();
        showError();
       }
       else {
@@ -402,7 +393,7 @@ bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransac
        if ( nbObjs ) {
          commitCommand();
          updateObjBrowser();
-         QAD_Application::getDesktop()->putInfo( QObject::tr("GEOM_PRP_DONE") );
+         SUIT_Session::session()->activeApplication()->putInfo( QObject::tr("GEOM_PRP_DONE") );
        }
        else {
          abortCommand();
@@ -411,12 +402,12 @@ bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransac
         // JFA 28.12.2004 BEGIN // To enable warnings
         if ( !getOperation()->_is_nil() ) {
           if ( !getOperation()->IsDone() ) {
-            wc.stop();
-            QString msgw = QObject::tr( getOperation()->GetErrorCode() );
-            QAD_MessageBox::warn1(QAD_Application::getDesktop(), 
-                                  QObject::tr( "WRN_WARNING" ), 
-                                  msgw, 
-                                  QObject::tr( "BUT_OK" ));
+            wc.suspend();
+           QString msgw = QObject::tr( getOperation()->GetErrorCode() );
+            SUIT_MessageBox::warn1((QWidget*)(SUIT_Session::session()->activeApplication()->desktop()),
+                                  QObject::tr( "WRN_WARNING" ), 
+                                  msgw, 
+                                  QObject::tr( "BUT_OK" ));
           }
         }
         // JFA 28.12.2004 END
@@ -424,7 +415,7 @@ bool RepairGUI_GlueDlg::onAcceptLocal( const bool publish, const bool useTransac
     }
   }
   catch( const SALOME::SALOME_Exception& e ) {
-    QtCatchCorbaException( e );
+    SalomeApp_Tools::QtCatchCorbaException( e );
     abortCommand();
   }