Salome HOME
NPAL16198: EDF462: Submeshes creation duplicate algorithms and hypotheses. Refix.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_StandardMeshInfosDlg.cxx
index 3b7916938be2c0666c903c9e9282aabd235af895..3fe48b107e74af8e78c2d137aedba5a8664a1576 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
 //
 //
 //
 #include "SMESHGUI_Utils.h"
 #include "SMESHGUI_MeshUtils.h"
 
-#include "SMESH.hxx"
 #include "SMESH_TypeFilter.hxx"
 
 #include "SALOMEDSClient_Study.hxx"
 #include "SALOMEDSClient_SObject.hxx"
 
+#include "SUIT_Desktop.h"
 #include "SUIT_Session.h"
 #include "SUIT_OverrideCursor.h"
+#include "SUIT_MessageBox.h"
 
-#include "SalomeApp_SelectionMgr.h"
+#include "LightApp_Application.h"
+
+#include "LightApp_SelectionMgr.h"
 #include "SALOME_ListIO.hxx"
 
 #include "utilities.h"
@@ -71,10 +74,12 @@ using namespace std;
  *  Constructor
  */
 //=================================================================================
-SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg (QWidget* parent, const char* name,
+SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg( SMESHGUI* theModule, const char* name,
                                                               bool modal, WFlags fl)
-     : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder |
-               WStyle_Title | WStyle_SysMenu | WDestructiveClose)
+     : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
+                WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+     mySMESHGUI( theModule ),
+     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
 {
   if (!name)
       setName("SMESHGUI_StandardMeshInfosDlg");
@@ -141,36 +146,38 @@ SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg (QWidget* parent, c
   myButtonsGroupLayout->setAlignment(Qt::AlignTop);
   myButtonsGroupLayout->setSpacing(6); myButtonsGroupLayout->setMargin(11);
 
-  // buttons --> OK button
+  // buttons --> OK and Help buttons
   myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), myButtonsGroup, "myOkBtn");
   myOkBtn->setAutoDefault(TRUE); myOkBtn->setDefault(TRUE);
-  myButtonsGroupLayout->addStretch();
+  myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP" ), myButtonsGroup, "myHelpBtn");
+  myHelpBtn->setAutoDefault(TRUE);
+
   myButtonsGroupLayout->addWidget(myOkBtn);
   myButtonsGroupLayout->addStretch();
+  myButtonsGroupLayout->addWidget(myHelpBtn);
 
   aDlgLayout->addWidget(myButtonsGroup, 2, 0);
 
-  mySelectionMgr = SMESHGUI::selectionMgr();
-  SMESHGUI::GetSMESHGUI()->SetActiveDialogBox(this);
+  mySMESHGUI->SetActiveDialogBox(this);
 
   // connect signals
-  connect(myOkBtn,                 SIGNAL(clicked()),                      this, SLOT(close()));
-  connect(mySelectBtn,             SIGNAL(clicked()),                      this, SLOT(onStartSelection()));
-  connect(SMESHGUI::GetSMESHGUI(), SIGNAL(SignalCloseAllDialogs()),        this, SLOT(close()));
-  connect(SMESHGUI::GetSMESHGUI(), SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
-  connect(mySelectionMgr,          SIGNAL(currentSelectionChanged()),      this, SLOT(onSelectionChanged()));
+  connect( myOkBtn,         SIGNAL(clicked()),                      this, SLOT(close()));
+  connect( myHelpBtn,       SIGNAL(clicked()),                      this, SLOT(onHelp()));
+  connect( mySelectBtn,     SIGNAL(clicked()),                      this, SLOT(onStartSelection()));
+  connect( mySMESHGUI,      SIGNAL(SignalCloseAllDialogs()),        this, SLOT(close()));
+  connect( mySMESHGUI,      SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
+  connect( mySelectionMgr,  SIGNAL(currentSelectionChanged()),      this, SLOT(onSelectionChanged()));
 
   // resize and move dialog, then show
   this->setMinimumSize(270, 428);
-  int x, y;
-  SMESHGUI::GetSMESHGUI()->DefineDlgPosition(this, x, y);
-  this->move(x, y);
   this->show();
 
   // init dialog with current selection
   myMeshFilter = new SMESH_TypeFilter (MESH);
   mySelectionMgr->installFilter(myMeshFilter);
   onSelectionChanged();
+
+  myHelpFileName = "mesh_infos_page.html#standard_mesh_infos_anchor";
 }
 
 //=================================================================================
@@ -243,7 +250,7 @@ void SMESHGUI_StandardMeshInfosDlg::DumpMeshInfos()
       bool hasGroup = false;
 
       // info about groups on nodes
-      aMeshSO->FindSubObject(Tag_NodeGroups, anObj);
+      aMeshSO->FindSubObject(SMESH::Tag_NodeGroups, anObj);
       if (anObj) {
         _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj);
        if (it->More()) {
@@ -276,7 +283,7 @@ void SMESHGUI_StandardMeshInfosDlg::DumpMeshInfos()
 
       // info about groups on edges
       anObj.reset();
-      aMeshSO->FindSubObject(Tag_EdgeGroups, anObj);
+      aMeshSO->FindSubObject(SMESH::Tag_EdgeGroups, anObj);
       if (anObj) {
         _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj);
         if (!hasGroup && it->More()) {
@@ -309,7 +316,7 @@ void SMESHGUI_StandardMeshInfosDlg::DumpMeshInfos()
 
       // info about groups on faces
       anObj.reset();
-      aMeshSO->FindSubObject(Tag_FaceGroups , anObj);
+      aMeshSO->FindSubObject(SMESH::Tag_FaceGroups , anObj);
       if (anObj) {
         _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj);
        if (!hasGroup && it->More()) {
@@ -342,7 +349,7 @@ void SMESHGUI_StandardMeshInfosDlg::DumpMeshInfos()
 
       // info about groups on volumes
       anObj.reset();
-      aMeshSO->FindSubObject(Tag_VolumeGroups, anObj);
+      aMeshSO->FindSubObject(SMESH::Tag_VolumeGroups, anObj);
       if (anObj) {
         _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj);
        if (!hasGroup && it->More())
@@ -394,7 +401,7 @@ void SMESHGUI_StandardMeshInfosDlg::onSelectionChanged()
 void SMESHGUI_StandardMeshInfosDlg::closeEvent (QCloseEvent* e)
 {
   mySelectionMgr->clearFilters();
-  SMESHGUI::GetSMESHGUI()->ResetState();
+  mySMESHGUI->ResetState();
   QDialog::closeEvent(e);
 }
 
@@ -426,7 +433,7 @@ void SMESHGUI_StandardMeshInfosDlg::DeactivateActiveDialog()
 void SMESHGUI_StandardMeshInfosDlg::ActivateThisDialog()
 {
   /* Emit a signal to deactivate any active dialog */
-  SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
+  mySMESHGUI->EmitSignalDeactivateDialog();
   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged()));
 }
 
@@ -442,3 +449,43 @@ void SMESHGUI_StandardMeshInfosDlg::onStartSelection()
   onSelectionChanged();
   myStartSelection = true;
 }
+
+//=================================================================================
+// function : onHelp()
+// purpose  :
+//=================================================================================
+void SMESHGUI_StandardMeshInfosDlg::onHelp()
+{
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app)
+    app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->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 : keyPressEvent()
+// purpose  :
+//=================================================================================
+void SMESHGUI_StandardMeshInfosDlg::keyPressEvent( QKeyEvent* e )
+{
+  QDialog::keyPressEvent( e );
+  if ( e->isAccepted() )
+    return;
+
+  if ( e->key() == Key_F1 )
+    {
+      e->accept();
+      onHelp();
+    }
+}