Salome HOME
PAL12607: Static objects in Geometry GUI libraries.
[modules/geom.git] / src / RepairGUI / RepairGUI_FreeFacesDlg.cxx
index 54b50e9641520488dcec45bd5febee926df3f7d9..fbfce16383b221035f8622972820847012911daa 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_FreeFacesDlg.h"
 
-#include "QAD_Desktop.h"
-#include "QAD_WaitCursor.h"
+#include "LightApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_Tools.h"
+
+#include "SUIT_MessageBox.h"
+#include "SUIT_Session.h"
+#include "SUIT_OverrideCursor.h"
 
 #include "SALOME_ListIteratorOfListIO.hxx"
 
 #include "GEOMImpl_Types.hxx"
 #include <TopTools_IndexedMapOfShape.hxx>
+#include <TColStd_MapOfInteger.hxx>
 #include <TopExp.hxx>
 #include "GEOMBase.h"
 #include "GeometryGUI.h"
 #include "GEOM_Displayer.h"
-#include "SALOMEGUI_QtCatchCorbaException.hxx"
-#include "SALOME_Selection.h"
-#include "SALOME_Prs.h"
-
 
+#include <qapplication.h>
 #include <qlineedit.h>
 #include <qlabel.h>
 #include <qlayout.h>
@@ -54,6 +57,7 @@ using namespace std;
 #define MARGIN 10
 #define MIN_WIDTH 200
 
+using namespace std;
 
 //=================================================================================
 // class    : RepairGUI_FreeFacesDlg()
@@ -62,14 +66,17 @@ using namespace std;
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg(QWidget* parent, const char* name, SALOME_Selection* theSelection, bool modal, WFlags fl)
-:QDialog( parent, "RepairGUI_FreeBoundDlg", false,
-    WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
+RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg(GeometryGUI* GUI, QWidget* parent,
+                                               const char* name, bool modal, WFlags fl)
+  :QDialog(parent, "RepairGUI_FreeBoundDlg", false,
+           WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+   GEOMBase_Helper(dynamic_cast<SUIT_Desktop*>(parent)),
+   myGeomGUI(GUI)
 {
   myDisplayer = 0;
 
   setSizeGripEnabled( TRUE );
-  QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
 
   setCaption(tr("GEOM_FREE_FACES_TITLE"));
 
@@ -93,10 +100,11 @@ RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg(QWidget* parent, const char* name
   QFrame* aFrame = new QFrame( this );
   aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
   QPushButton* aCloseBtn = new QPushButton( tr( "GEOM_BUT_CLOSE" ), aFrame );
+  QPushButton* aHelpBtn = new QPushButton( tr( "GEOM_BUT_HELP" ), aFrame );
   QHBoxLayout* aBtnLay = new QHBoxLayout( aFrame, MARGIN, SPACING );
-  aBtnLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
   aBtnLay->addWidget( aCloseBtn );
   aBtnLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+  aBtnLay->addWidget( aHelpBtn );
 
   QVBoxLayout* aLay = new QVBoxLayout( this );
   aLay->setSpacing( SPACING );
@@ -105,12 +113,15 @@ RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg(QWidget* parent, const char* name
   aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
   aLay->addWidget( aFrame );
   
+  myHelpFileName = "check_free_faces.htm";
+
   connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) );
+  connect( aHelpBtn, SIGNAL( clicked() ), SLOT( onHelp() ) );
   connect( mySelBtn,    SIGNAL( clicked() ),
            this,        SLOT  ( onSetEditCurrentArgument() ) );
   /***************************************************************/
 
-  Init( theSelection );
+  Init();
 }
 
 
@@ -130,12 +141,29 @@ RepairGUI_FreeFacesDlg::~RepairGUI_FreeFacesDlg()
 void RepairGUI_FreeFacesDlg::onClose()
 {
   globalSelection();
-  disconnect( mySelection, 0, this, 0 );
-  GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 );
+  disconnect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0 );
+  myGeomGUI->SetActiveDialogBox( 0 );
   reject();
   erasePreview();
 }
 
+//=================================================================================
+// function : onHelp()
+// purpose  :
+//=================================================================================
+void RepairGUI_FreeFacesDlg::onHelp()
+{
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app)
+    app->onHelpContextModule(myGeomGUI ? app->moduleName(myGeomGUI->moduleName()) : QString(""), myHelpFileName);
+  else {
+    SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+                          QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                          arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
+                          QObject::tr("BUT_OK"));
+  }
+}
+
 //=================================================================================
 // function : onDeactivate
 // purpose  : Deactivate this dialog
@@ -144,8 +172,8 @@ void RepairGUI_FreeFacesDlg::onDeactivate()
 {
   setEnabled(false);
   globalSelection();
-  disconnect( mySelection, 0, this, 0 );
-  GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 );
+  disconnect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0 );
+  myGeomGUI->SetActiveDialogBox( 0 );
 }
 
 //=================================================================================
@@ -154,10 +182,11 @@ void RepairGUI_FreeFacesDlg::onDeactivate()
 //=================================================================================
 void RepairGUI_FreeFacesDlg::onActivate()
 {
-  GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog();
+  myGeomGUI->EmitSignalDeactivateDialog();
   setEnabled( true );
-  GeometryGUI::GetGeomGUI()->SetActiveDialogBox( this );
-  connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT  ( onSelectionDone() ) );
+  myGeomGUI->SetActiveDialogBox( this );
+  connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+          SIGNAL( currentSelectionChanged() ), SLOT  ( onSelectionDone() ) );
   activateSelection();
 }
 
@@ -165,16 +194,14 @@ void RepairGUI_FreeFacesDlg::onActivate()
 // function : Init()
 // purpose  :
 //=================================================================================
-void RepairGUI_FreeFacesDlg::Init(SALOME_Selection* theSel)
+void RepairGUI_FreeFacesDlg::Init()
 {
   myObj = GEOM::GEOM_Object::_nil();
 
-  mySelection = theSel;
-
   /* signals and slots connections */
-  GeometryGUI* aGeomGUI = GeometryGUI::GetGeomGUI();
-  connect( aGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT  ( onDeactivate() ) );
-  connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT  ( onSelectionDone() ) );
+  connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT  ( onDeactivate() ) );
+  connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
+          SIGNAL( currentSelectionChanged() ), SLOT  ( onSelectionDone() ) );
 
   activateSelection();
   onSelectionDone();
@@ -187,7 +214,7 @@ void RepairGUI_FreeFacesDlg::Init(SALOME_Selection* theSel)
 void RepairGUI_FreeFacesDlg::onSelectionDone()
 {
   erasePreview();
-  if( mySelection->IObjectCount() != 1 )
+  if( IObjectCount() != 1 )
   {
     myEdit->setText( "" );
     return;
@@ -195,7 +222,7 @@ void RepairGUI_FreeFacesDlg::onSelectionDone()
 
   Standard_Boolean isOk = Standard_False;
   GEOM::GEOM_Object_var anObj =
-    GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), isOk );
+    GEOMBase::ConvertIOinGEOMObject( firstIObject(), isOk );
 
   if ( !isOk || anObj->_is_nil() || !GEOMBase::IsShape( anObj ) )
   {
@@ -278,11 +305,12 @@ bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects )
       erasePreview( true );
       return false;
     }
+    
+    SUIT_OverrideCursor();
 
     TopExp::MapShapes( aSelShape, anIndices);
     SALOME_Prs* aPrs = 0;
-    QAD_WaitCursor wc;
-
+    
     for ( int i = 0, n = aFaceLst->length(); i < n; i++ )
     {
       aFace = anIndices.FindKey( aFaceLst[i] );
@@ -296,7 +324,7 @@ bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects )
       }
       catch( const SALOME::SALOME_Exception& e )
       {
-        QtCatchCorbaException( e );
+        SalomeApp_Tools::QtCatchCorbaException( e );
       }
     }
   }
@@ -310,7 +338,7 @@ bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects )
 GEOM_Displayer* RepairGUI_FreeFacesDlg::getDisplayer()
 {
   if ( !myDisplayer )
-    myDisplayer = new GEOM_Displayer();
+    myDisplayer = new GEOM_Displayer( getStudy() );
   return myDisplayer;
 }