Salome HOME
Fix global links to local for correct work on any station
[modules/geom.git] / src / RepairGUI / RepairGUI_FreeBoundDlg.cxx
index 7d2c882888cb9a3bc8fef86542b46dcd029d5849..9b8f1e0854014522cf689852510c5aff075735ff 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
 //
 //
 //
@@ -33,7 +33,9 @@
 #include "GEOMImpl_Types.hxx"
 
 #include "SalomeApp_Application.h"
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "SUIT_MessageBox.h"
 #include "SUIT_Session.h"
 
 #include <TColStd_MapOfInteger.hxx>
 #define SPACING 5
 #define MARGIN 10
 
-/*
-  Calss       : RepairGUI_FreeBoundDlg
+/*!
+  Class       : RepairGUI_FreeBoundDlg
   Description : Dialog for displaying free boundaries of selected face, shell or solid
 */
 
-
 //=================================================================================
 // function : RepairGUI_FreeBoundDlg
 // purpose  : Constructor
 //=================================================================================
-RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg( GeometryGUI* theGUI, QWidget* theParent )
+RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg(GeometryGUI* theGUI, QWidget* theParent, const char*)
 : QDialog( theParent, "RepairGUI_FreeBoundDlg", false,
           WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
-  myGeomGUI ( theGUI )
+  GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( theParent ) ),
+  myGeomGUI( theGUI )
 {
   setCaption( tr( "CAPTION" ) );
 
@@ -83,10 +85,11 @@ RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg( GeometryGUI* theGUI, QWidget* th
   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 );
@@ -94,7 +97,10 @@ RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg( GeometryGUI* theGUI, QWidget* th
   aLay->addWidget( aMainGrp );
   aLay->addWidget( aFrame );
   
+  myHelpFileName = "check_free_boundaries.htm";
+
   connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) );
+  connect( aHelpBtn, SIGNAL( clicked() ), SLOT( onHelp() ) );
 
   Init();
 }
@@ -120,6 +126,29 @@ void RepairGUI_FreeBoundDlg::onClose()
   erasePreview();
 }
 
+//=================================================================================
+// function : onHelp()
+// purpose  :
+//=================================================================================
+void RepairGUI_FreeBoundDlg::onHelp()
+{
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app)
+    app->onHelpContextModule(myGeomGUI ? app->moduleName(myGeomGUI->moduleName()) : QString(""), myHelpFileName);
+  else {
+               QString platform;
+#ifdef WIN32
+               platform = "winapplication";
+#else
+               platform = "application";
+#endif
+    SUIT_MessageBox::warn1
+      (0, tr("WRN_WARNING"), tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+       arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
+       tr("BUT_OK"));
+  }
+}
+
 //=================================================================================
 // function : onDeactivate
 // purpose  : Deactivate this dialog
@@ -128,7 +157,7 @@ void RepairGUI_FreeBoundDlg::onDeactivate()
 {
   setEnabled(false);
   globalSelection();
-  disconnect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0 );
+  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
   myGeomGUI->SetActiveDialogBox( 0 );
 }
 
@@ -167,7 +196,6 @@ void RepairGUI_FreeBoundDlg::onSelectionDone()
     myObj = anObj;
     displayPreview( false, true, true, 3 );
   }
-
 }
 
 //=================================================================================
@@ -278,13 +306,18 @@ bool RepairGUI_FreeBoundDlg::execute( ObjectList& objects )
 }
 
 //=================================================================================
-// function : getDesktop()
+// function : keyPressEvent()
 // purpose  :
 //=================================================================================
-SUIT_Desktop* RepairGUI_FreeBoundDlg::getDesktop() const
+void RepairGUI_FreeBoundDlg::keyPressEvent( QKeyEvent* e )
 {
-  return dynamic_cast<SUIT_Desktop*>( parentWidget() );
-}
-
-
+  QDialog::keyPressEvent( e );
+  if ( e->isAccepted() )
+    return;
 
+  if ( e->key() == Key_F1 )
+    {
+      e->accept();
+      onHelp();
+    }
+}