Salome HOME
Additional fix for bug NPAL19028 (see remarks from Olivier Giorgis).
[modules/geom.git] / src / GEOMBase / GEOMBase_Skeleton.cxx
index 84760134d3a45ff2bc892dc0f6ab811c47f1e31e..0d24030c98bd46432eb58568e003b4725fe5dab9 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 "GEOMBase_Skeleton.h"
+
 #include "GeometryGUI.h"
 
-#include "SUIT_Session.h"
 #include "SalomeApp_Application.h"
+#include "LightApp_Application.h"
 #include "LightApp_SelectionMgr.h"
+#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
 
+#include <qlabel.h>
 #include <qpushbutton.h>
+#include <qcheckbox.h>
 
 using namespace std;
 
 //=================================================================================
 // class    : GEOMBase_Skeleton()
-// purpose  : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the 
+// purpose  : Constructs a GEOMBase_Skeleton which is a child of 'parent', with the
 //            name 'name' and widget flags set to 'f'.
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-GEOMBase_Skeleton::GEOMBase_Skeleton(QWidget* parent, const char* name, bool modal, WFlags fl)
-  :DlgRef_Skeleton_QTD( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), 
-   GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) )
+GEOMBase_Skeleton::GEOMBase_Skeleton (GeometryGUI* theGeometryGUI, QWidget* parent,
+                                      const char* name, bool modal, WFlags fl)
+  : DlgRef_Skeleton_QTD( parent, name, modal, WStyle_Customize | WStyle_NormalBorder
+                         | WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
+   GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
+   myGeomGUI( theGeometryGUI )
 {
   if (!name)
     setName("GEOMBase_Skeleton");
 
+  GroupBoxName->setTitle(tr("GEOM_RESULT_NAME_GRP"));
+  NameLabel->setText(tr("GEOM_RESULT_NAME_LBL"));
+
+  GroupBoxPublish->setTitle(tr("GEOM_PUBLISH_RESULT_GRP"));
+  CheckBoxRestoreSS->setText(tr("GEOM_RESTORE_SUB_SHAPES"));
+
   buttonCancel->setText(tr("GEOM_BUT_CLOSE"));
-  buttonOk->setText(tr("GEOM_BUT_OK"));
+  buttonOk->setText(tr("GEOM_BUT_APPLY_AND_CLOSE"));
   buttonApply->setText(tr("GEOM_BUT_APPLY"));
+  buttonHelp->setText(tr("GEOM_BUT_HELP"));
 
-  GroupMedium->close(TRUE);
   resize(0, 0);
 
   Init();
 }
 
-
 //=================================================================================
 // function : ~GEOMBase_Skeleton()
 // purpose  : Destroys the object and frees any allocated resources
@@ -72,46 +85,40 @@ GEOMBase_Skeleton::~GEOMBase_Skeleton()
     myGeomGUI->SetActiveDialogBox( 0 );
 }
 
-
 //=================================================================================
 // function : Init()
 // purpose  :
 //=================================================================================
 void GEOMBase_Skeleton::Init()
 {
-  myGeomGUI = 0;
   SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
-  if (app)
-    {
-      SalomeApp_Module* module = dynamic_cast<SalomeApp_Module*>(app->loadModule("Geometry"));
-      if (module)
-       myGeomGUI =  dynamic_cast<GeometryGUI*>(module);
-    }
-  
+  if (!myGeomGUI && app)
+    myGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
+
   /* init variables */
-  myGeomBase = new GEOMBase();  // SAN -- TO BE REMOVED !!!
-  myGeomGUI->SetActiveDialogBox(this);
-  
+  if (myGeomGUI)
+    myGeomGUI->SetActiveDialogBox(this);
+
   /* signals and slots connections */
   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
-  if (myGeomGUI) 
-    {
-      connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
-      connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
-    }
-  
-  /* Move widget on the botton right corner of main widget */
-//   int x, y;
-//   myGeomBase->DefineDlgPosition( this, x, y );
+  if (myGeomGUI)
+  {
+    connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
+    connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
+  }
+
+  // connect help button on a private slot that displays help information
+  connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
 
   /* displays Dialog */
   RadioButton1->setChecked(TRUE);
   RadioButton4->hide();
+  RadioButton5->hide();
 
-  return;
+  CheckBoxRestoreSS->setChecked(FALSE);
+  GroupBoxPublish->hide();
 }
 
-
 //=================================================================================
 // function : ClickOnCancel()
 // purpose  :
@@ -121,7 +128,6 @@ void GEOMBase_Skeleton::ClickOnCancel()
   close();
 }
 
-
 //=================================================================================
 // function : LineEditReturnPressed()
 // purpose  :
@@ -136,14 +142,11 @@ void GEOMBase_Skeleton::LineEditReturnPressed()
   /* so SelectionIntoArgument() is automatically called.           */
   const QString objectUserName = myEditCurrentArgument->text();
   QWidget* thisWidget = (QWidget*)this;
-  
+
   if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO()))
      myEditCurrentArgument->setText(objectUserName);
-
-  return;
 }
 
-
 //=================================================================================
 // function : DeactivateActiveDialog()
 // purpose  :
@@ -152,13 +155,12 @@ void GEOMBase_Skeleton::DeactivateActiveDialog()
 {
   this->setEnabled(false);
   globalSelection();
-  disconnect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
-  if (myGeomGUI) myGeomGUI->SetActiveDialogBox(0);
-    
-  return;
+  if (myGeomGUI) {
+    myGeomGUI->SetActiveDialogBox(0);
+    disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+  }
 }
 
-
 //=================================================================================
 // function : ActivateThisDialog()
 // purpose  :
@@ -169,20 +171,17 @@ void GEOMBase_Skeleton::ActivateThisDialog()
   if (myGeomGUI) myGeomGUI->EmitSignalDeactivateDialog();
   this->setEnabled(true);
   if (myGeomGUI) myGeomGUI->SetActiveDialogBox((QDialog*)this);
-  return;
 }
 
-
 //=================================================================================
 // function : closeEvent()
 // purpose  : same than click on cancel button
 //=================================================================================
 void GEOMBase_Skeleton::closeEvent(QCloseEvent* e)
 {
-  SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
-  if(app) {
-    disconnect( app->selectionMgr(), 0, this, 0);
-    app->updateActions();
+  if (myGeomGUI) {
+    disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+    myGeomGUI->getApp()->updateActions();
   }
   QDialog::closeEvent( e );
 }
@@ -217,3 +216,52 @@ int GEOMBase_Skeleton::getConstructorId() const
     return GroupConstructors->id( GroupConstructors->selected() );
   return -1;
 }
+
+//=================================================================================
+// function : ClickOnHelp()
+// purpose  :
+//=================================================================================
+void GEOMBase_Skeleton::ClickOnHelp()
+{
+  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, QObject::tr("WRN_WARNING"),
+                          QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                          arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
+                          QObject::tr("BUT_OK"));
+  }
+}
+
+//=================================================================================
+//  function : setHelpFileName()
+//  purpose  : set name for help file html
+//=================================================================================
+void GEOMBase_Skeleton::setHelpFileName(const QString& theName)
+{
+    myHelpFileName = theName;
+}
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose  :
+//=================================================================================
+void GEOMBase_Skeleton::keyPressEvent( QKeyEvent* e )
+{
+  QDialog::keyPressEvent( e );
+  if ( e->isAccepted() )
+    return;
+
+  if ( e->key() == Key_F1 )
+  {
+    e->accept();
+    ClickOnHelp();
+  }
+}