Salome HOME
0021308: EDF 1923 SMESH: Remove hard-coded dependency of the external mesh plugins...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Hypotheses.cxx
index 30aeaa3c850fb04428379d077bc0430939c7b0dc..2832c7afd7464562aa016d2fc1e6aa8b6f8c7916 100644 (file)
@@ -1,25 +1,24 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-//  SMESH SMESHGUI : GUI for SMESH component
 //  File   : SMESHGUI_Hypotheses.cxx
 //  Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
 //  SMESH includes
@@ -94,7 +93,7 @@ void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
       SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
 #ifdef WITHGENERICOBJ
     if (!CORBA::is_nil(anAlgo))
-      anAlgo->Destroy();
+      anAlgo->UnRegister();
 #endif
   }
   else {
@@ -103,7 +102,7 @@ void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
     editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
 #ifdef WITHGENERICOBJ
     if (!CORBA::is_nil(aHypothesis))
-      aHypothesis->Destroy();
+      aHypothesis->UnRegister();
 #endif
   }
 }
@@ -151,8 +150,10 @@ void SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_
     Dlg->show();
     Dlg->resize( Dlg->minimumSizeHint() );
   }
-  else
+  else {
     emit finished( QDialog::Accepted );
+        delete myDlg;
+  }
 }
 
 QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
@@ -302,7 +303,7 @@ void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
   }
   SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
 #ifdef WITHGENERICOBJ
-  myHypo->Destroy();
+  myHypo->UnRegister();
 #endif
   myHypo = SMESH::SMESH_Hypothesis::_nil();
   myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
@@ -331,18 +332,20 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
     {
       SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
       item.myValue = sb->value();
+      item.myText = sb->text();
       params.append( item );
     }
     else if( (*anIt)->inherits( "SalomeApp_DoubleSpinBox" ) )
     {
       SalomeApp_DoubleSpinBox* sb = ( SalomeApp_DoubleSpinBox* )( *anIt );
       item.myValue = sb->value();
+      item.myText = sb->text();
       params.append( item );
     }
     else if( (*anIt)->inherits( "QLineEdit" ) )
     {
       QLineEdit* line = ( QLineEdit* )( *anIt );
-      item.myValue = line->text();
+      item.myValue = item.myText = line->text();
       params.append( item );
     }
     else if ( getParamFromCustomWidget( item, *anIt ))
@@ -355,6 +358,16 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
   return res;
 }
 
+QString SMESHGUI_GenericHypothesisCreator::getVariableName(const char* methodName) const
+{
+  SMESH::SMESH_Hypothesis_var h = hypothesis();
+  if ( !h->_is_nil() )
+  {
+    CORBA::String_var aVaribaleName = h->GetVarParameter( methodName );
+    return QString( aVaribaleName.in() );
+  }
+  return QString();
+}
 
 QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
 {
@@ -557,20 +570,19 @@ QString SMESHGUI_GenericHypothesisCreator::helpPage() const
     aHelpFileName = "segments_around_vertex_algo_page.html";
   else if ( aHypType == "QuadrangleParams")
     aHelpFileName = "a2d_meshing_hypo_page.html#hypo_quad_params_anchor";
+  else if ( aHypType == "ViscousLayers")
+    aHelpFileName = "additional_hypo_page.html#viscous_layers_anchor";
   else if ( aHypType == "ImportSource1D" || aHypType == "ImportSource2D")
     aHelpFileName = "import_algos_page.html";
   return aHelpFileName;
 }
 
-
-
-
 SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
 : QtxDialog( parent, false, true ),
   myCreator( creator )
 {
   setAttribute(Qt::WA_DeleteOnClose, true);
-  setMinimumSize( 300, height() );
// setMinimumSize( 300, height() );
 //  setFixedSize( 300, height() );
   QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
   topLayout->setMargin( 0 );
@@ -637,8 +649,17 @@ void SMESHGUI_HypothesisDlg::onHelp()
 {
   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
   if (app) {
-    SMESHGUI* aSMESHGUI = dynamic_cast<SMESHGUI*>( app->activeModule() );
-    app->onHelpContextModule(aSMESHGUI ? app->moduleName(aSMESHGUI->moduleName()) : QString(""), myHelpFileName);
+    QString name = "SMESH";
+    if(myCreator) {
+      QVariant pluginName = myCreator->property( PLUGIN_NAME );
+      if( pluginName.isValid() ) {
+       QString rootDir = pluginName.toString() + "PLUGIN_ROOT_DIR";
+       QString varValue = QString( getenv(rootDir.toLatin1().constData()));
+       if(!varValue.isEmpty())
+         name = pluginName.toString() + "PLUGIN";
+      }
+    }    
+    app->onHelpContextModule(name, myHelpFileName);
   }
   else {
     QString platform;
@@ -698,7 +719,8 @@ HypothesisData::HypothesisData( const QString& theTypeName,
 
 HypothesesSet::HypothesesSet( const QString& theSetName )
   : myHypoSetName( theSetName ),
-    myIsAlgo( false )
+    myIsAlgo( false ),
+    myIsCustom( false )
 {
 }
 
@@ -708,7 +730,8 @@ HypothesesSet::HypothesesSet( const QString&     theSetName,
   : myHypoSetName( theSetName ),
     myHypoList( theHypoList ),
     myAlgoList( theAlgoList ),
-    myIsAlgo( false )
+    myIsAlgo( false ),
+    myIsCustom( false )
 {
 }
 
@@ -762,3 +785,28 @@ QString HypothesesSet::current() const
 {
   return list()->at(myIndex);
 }
+
+void HypothesesSet::setIsCustom( bool isCustom )
+{
+  myIsCustom = isCustom;
+}
+
+bool HypothesesSet::getIsCustom() const
+{
+  return myIsCustom;
+}
+
+int HypothesesSet::maxDim() const
+{
+  HypothesesSet * thisSet = (HypothesesSet*) this;
+  int dim = -1;
+  for ( int isAlgo = 0; isAlgo < 2; ++isAlgo )
+  {
+    thisSet->init( isAlgo );
+    while ( thisSet->next(), thisSet->more() )
+      if ( HypothesisData* hypData = SMESH::GetHypothesisData( thisSet->current() ))
+        for ( int i = 0; i < hypData->Dim.count(); ++i )
+          dim = qMax( dim, hypData->Dim[i] );
+  }
+  return dim;
+}