Salome HOME
PAL12789. Add and use COORD_MIN and COORD_MAX macros
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Hypotheses.cxx
index c3bb0138206f7f504bcc35588289cc814a922bc7..6e90a709363baf58c15b77a09d672cf794cb0644 100644 (file)
-//  Copyright (C) 2003  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 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 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-
-#include <map>
-#include <string>
+// Copyright (C) 2005  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 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "SMESHGUI_Hypotheses.h"
+#include "SMESHGUI.h"
+#include "SMESHGUI_HypothesesUtils.h"
 #include "SMESHGUI_Utils.h"
+#include "SMESHGUI_SpinBox.h"
 
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
+#include <SALOMEDSClient_Study.hxx>
+#include <utilities.h>
 
-namespace SMESH{
-  
-  using namespace std;
+#include <SMESHGUI.h>
 
-  typedef map<string,HypothesisData*> THypothesisDataMap;
-  THypothesisDataMap myHypothesesMap;
-  THypothesisDataMap myAlgorithmsMap;
+#include <QtxIntSpinBox.h>
 
-  typedef map<string,SMESHGUI_GenericHypothesisCreator*> THypCreatorMap;
-  THypCreatorMap myHypCreatorMap;
+#include <SUIT_Session.h>
+#include <SUIT_MessageBox.h>
 
-  void InitAvailableHypotheses()
-  {
-    QAD_WaitCursor wc;
-    if (myHypothesesMap.empty() && myAlgorithmsMap.empty()) {
-      // Resource manager
-      QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
-      if (!resMgr) return;
-      
-      // Find name of a resource XML file ("SMESH_Meshers.xml");
-      QString HypsXml;
-      char* cenv = getenv("SMESH_MeshersList");
-      if (cenv)
-       HypsXml.sprintf("%s", cenv);
-      
-      QStringList HypsXmlList = QStringList::split( ":", HypsXml, false );
-      if (HypsXmlList.count() == 0)
-       {
-         QAD_MessageBox::error1(QAD_Application::getDesktop(),
-                                tr("SMESH_WRN_WARNING"),
-                                tr("MESHERS_FILE_NO_VARIABLE"),
-                                tr("SMESH_BUT_OK"));
-         return;
-       }
-      
-      // loop on files in HypsXml
-      QString aNoAccessFiles;
-      for ( int i = 0; i < HypsXmlList.count(); i++ ) {
-       QString HypsXml = HypsXmlList[ i ];
-       
-       // Find full path to the resource XML file
-       QString xmlFile = HypsXml + ".xml";
-       xmlFile = QAD_Tools::addSlash(resMgr->findFile(xmlFile, HypsXml)) + xmlFile;
-       
-       QFile file (QAD_Tools::unix2win(xmlFile));
-       if (file.exists() && file.open(IO_ReadOnly)) {
-         file.close();
-         
-         SMESHGUI_XmlHandler* myXmlHandler = new SMESHGUI_XmlHandler();
-         ASSERT(myXmlHandler);
-         
-         QXmlInputSource source (file);
-         QXmlSimpleReader reader;
-         reader.setContentHandler(myXmlHandler);
-         reader.setErrorHandler(myXmlHandler);
-         bool ok = reader.parse(source);
-         file.close();
-         if (ok) {
-           addMap( myXmlHandler->myHypothesesMap, myHypothesesMap );
-           addMap( myXmlHandler->myAlgorithmsMap, myAlgorithmsMap );
-         }
-         else {
-           QAD_MessageBox::error1(myDesktop, 
-                                  tr("INF_PARSE_ERROR"),
-                                  tr(myXmlHandler->errorProtocol()),
-                                  tr("SMESH_BUT_OK"));
-         }
-       }
-       else {
-         if (aNoAccessFiles.isEmpty())
-           aNoAccessFiles = xmlFile;
-         else
-           aNoAccessFiles += ", " + xmlFile;
-       }
-      } // end loop
-      
-      
-      if (!aNoAccessFiles.isEmpty()) {
-       QString aMess = tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n";
-       aMess += tr("MESHERS_FILE_CHECK_VARIABLE");
-       wc.stop();
-       QAD_MessageBox::warn1(QAD_Application::getDesktop(),
-                             tr("SMESH_WRN_WARNING"),
-                             aMess,
-                             tr("SMESH_BUT_OK"));
-       wc.start();
-      }
-    }
-  }
+#include <LightApp_Application.h>
+
+#include <qframe.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qpixmap.h>
+#include <qgroupbox.h>
+
+SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& aHypType )
+: myHypType( aHypType ),
+  myIsCreate( false )
+{
+}
+
+SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
+{
+}
+
+void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
+                                                QWidget* parent)
+{
+  MESSAGE( "Creation of hypothesis with initial params" );
+
+  if ( !CORBA::is_nil( initParamsHyp ) && hypType() == initParamsHyp->GetName() )
+    myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( initParamsHyp );
+  create( false, parent );
+}
+
+void SMESHGUI_GenericHypothesisCreator::create( const bool isAlgo, QWidget* parent )
+{
+  MESSAGE( "Creation of hypothesis" );
+
+  // Get default name for hypothesis/algorithm creation
+  HypothesisData* aHypData = SMESH::GetHypothesisData( hypType().latin1() );
+  QString aHypName = aHypData ? aHypData->Label : hypType();
 
+  myIsCreate = true;
 
-  GetAvailableHypotheses (const bool isAlgo)
+  // Create hypothesis/algorithm
+  if (isAlgo)
+    SMESH::CreateHypothesis( hypType(), aHypName, isAlgo );
+
+  else
   {
-    QStringList aHypList;
-    
-    // Init list of available hypotheses, if needed
-    InitAvailableHypotheses();
-    
-    // fill list of hypotheses/algorithms
-    THypothesisDataMap::iterator anIter;
-    if (isAlgo) {
-      anIter = myAlgorithmsMap.begin();
-      for (; anIter != myAlgorithmsMap.end(); anIter++) {
-       aHypList.append(((*anIter).first).c_str());
-      }
-    }
-    else {
-      anIter = myHypothesesMap.begin();
-      for (; anIter != myHypothesesMap.end(); anIter++) {
-       aHypList.append(((*anIter).first).c_str());
+    SMESH::SMESH_Hypothesis_var newHypo = SMESH::SMESH_Hypothesis::_narrow
+      ( SMESH::CreateHypothesis( hypType(), aHypName, false ) );
+  
+    if( !editHypothesis( newHypo.in(), parent ) )
+    { //remove just created hypothesis
+      _PTR(SObject) SHyp = SMESH::FindSObject( newHypo.in() );
+      _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+      if( aStudy && !aStudy->GetProperties()->IsLocked() )
+      {
+       _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+       aBuilder->RemoveObjectWithChildren( SHyp );
       }
     }
-    
-    return aHypList;
   }
-  
+  SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
+}
 
-  HypothesisData* GetHypothesisData (const char* aHypType)
-  {
-    HypothesisData* aHypData = 0;
+void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr h, QWidget* parent )
+{
+  if( CORBA::is_nil( h ) )
+    return;
 
-    // Init list of available hypotheses, if needed
-    InitAvailableHypotheses();
+  MESSAGE("Edition of hypothesis");
 
-    if (myHypothesesMap.find(aHypType) == myHypothesesMap.end()) {
-      if (myAlgorithmsMap.find(aHypType) != myAlgorithmsMap.end()) {
-       aHypData = myAlgorithmsMap[aHypType];
-      }
-    }
-    else {
-      aHypData = myHypothesesMap[aHypType];
+  myIsCreate = false;
+
+  if( !editHypothesis( h, parent ) )
+    return;
+
+  SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( h );
+  if( listSOmesh.size() > 0 )
+    for( int i=0; i<listSOmesh.size(); i++ )
+    {
+      _PTR(SObject) submSO = listSOmesh[i];
+      SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
+      SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
+      if( !aSubMesh->_is_nil() )
+       aMesh = aSubMesh->GetFather();
+      _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
+      SMESH::ModifiedMesh( meshSO, false);
     }
-    return aHypData;
-  }
+  SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
+}
 
+bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h, QWidget* parent )
+{
+  if( CORBA::is_nil( h ) )
+    return false;
 
-  SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator (const QString& aHypType)
-  {
-    const char* sHypType = aHypType.latin1();
-    if(MYDEBUG) MESSAGE("Get HypothesisCreator for " << sHypType);
+  bool res = true;
+  myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
 
-    SMESHGUI_GenericHypothesisCreator* aCreator = 0;
-    
-    // check, if creator for this hypothesis type already exists
-    if (myHypCreatorMap.find(sHypType) != myHypCreatorMap.end()) {
-      aCreator = myHypCreatorMap[sHypType];
-    }
-    else {
-      // 1. Init list of available hypotheses, if needed
-      InitAvailableHypotheses();
-
-      // 2. Get names of plugin libraries
-      HypothesisData* aHypData = GetHypothesisData(sHypType);
-      if (!aHypData) {
-       return aCreator;
-      }
-      QString aClientLibName = aHypData->ClientLibName;
-      QString aServerLibName = aHypData->ServerLibName;
-
-      // 3. Load Client Plugin Library
-      try {
-       // load plugin library
-       if(MYDEBUG) MESSAGE("Loading client meshers plugin library ...");
-       void* libHandle = dlopen (aClientLibName, RTLD_LAZY);
-       if (!libHandle) {
-         // report any error, if occured
-         const char* anError = dlerror();
-         if(MYDEBUG) MESSAGE(anError);
-       }
-       else {
-         // get method, returning hypothesis creator
-         if(MYDEBUG) MESSAGE("Find GetHypothesisCreator() method ...");
-         typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \
-           (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI);
-         GetHypothesisCreator procHandle =
-           (GetHypothesisCreator)dlsym( libHandle, "GetHypothesisCreator" );
-         if (!procHandle) {
-           if(MYDEBUG) MESSAGE("bad hypothesis client plugin library");
-           dlclose(libHandle);
-         }
-         else {
-           // get hypothesis creator
-           if(MYDEBUG) MESSAGE("Get Hypothesis Creator for " << aHypType);
-           aCreator = procHandle(aHypType, aServerLibName, smeshGUI);
-           if (!aCreator) {
-             if(MYDEBUG) MESSAGE("no such a hypothesis in this plugin");
-           }
-           else {
-             // map hypothesis creator to a hypothesis name
-             myHypCreatorMap[sHypType] = aCreator;
-           }
-         }
-       }
-      }
-      catch (const SALOME::SALOME_Exception& S_ex) {
-       QtCatchCorbaException(S_ex);
+  QFrame* fr = buildFrame();
+  if( fr )
+  {
+    SMESHGUI_HypothesisDlg* dlg = 
+      new SMESHGUI_HypothesisDlg( const_cast<SMESHGUI_GenericHypothesisCreator*>( this ), parent );
+    dlg->setCustomFrame( fr );
+    dlg->setCaption( caption() );
+    dlg->setHIcon( icon() );
+    dlg->setType( type() );
+    retrieveParams();
+    res = dlg->exec()==QDialog::Accepted;
+    if( res ) {
+      QString paramValues = storeParams();
+      if ( !paramValues.isEmpty() ) {
+        if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
+          SMESH::SetValue( SHyp, paramValues );
       }
     }
-
-    return aCreator;
+    delete dlg;
   }
+  changeWidgets().clear();
+  myHypo = SMESH::SMESH_Hypothesis::_nil();
+  myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
+  return res;
+}
 
+QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
+{
+  if( CORBA::is_nil( hypothesis() ) )
+    return 0;
 
-  SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const QString& aHypType,
-                                               const QString& aHypName,
-                                               const bool     isAlgo = false)
-  {
-    if(MYDEBUG) MESSAGE("Create " << aHypType << " with name " << aHypName);
+  ListOfStdParams params;
+  if( !stdParams( params ) || params.isEmpty() )
+    return 0;
 
-    SMESH::SMESH_Hypothesis_var Hyp;
-    
-    HypothesisData* aHypData = GetHypothesisData((char*)aHypType.latin1());
-    QString aServLib = aHypData->ServerLibName;
-    
-    try {
-      Hyp = SMESH::GetSMESHGen()->CreateHypothesis(aHypType, aServLib);
-      if (!Hyp->_is_nil()) {
-       SALOMEDS::SObject_var SHyp = SMESH::FindSObject(Hyp.in());
-       if (!SHyp->_is_nil()) {
-         if ( !aHypName.isEmpty() )
-           SMESH::SetName( SHyp, aHypName );
-         myActiveStudy->updateObjBrowser(true);
-         return Hyp._retn();
-       }
-      }
-    }
-    catch (const SALOME::SALOME_Exception & S_ex) {
-      QtCatchCorbaException(S_ex);
-    }
+  QFrame* fr = new QFrame( 0, "myframe" );
+  QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 );
 
-    return SMESH::SMESH_Hypothesis::_nil();
-  }
+  QGroupBox* GroupC1 = new QGroupBox( fr, "GroupC1" );
+  lay->addWidget( GroupC1 );
 
+  GroupC1->setTitle( tr( "SMESH_ARGUMENTS"  ) );
+  GroupC1->setColumnLayout(0, Qt::Vertical );
+  GroupC1->layout()->setSpacing( 0 );
+  GroupC1->layout()->setMargin( 0 );
+  QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
+  GroupC1Layout->setAlignment( Qt::AlignTop );
+  GroupC1Layout->setSpacing( 6 );
+  GroupC1Layout->setMargin( 11 );
 
-  bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp)
+  ListOfStdParams::const_iterator anIt = params.begin(), aLast = params.end();
+  for( int i=0; anIt!=aLast; anIt++, i++ )
   {
-    if(MYDEBUG) MESSAGE ("SMESHGUI::AddHypothesisOnMesh");
-    int res = SMESH::HYP_UNKNOWN_FATAL; 
-    QAD_WaitCursor wc;
-    
-    if ( !aMesh->_is_nil() ) {
-      SALOMEDS::SObject_var SM = SMESH::FindSObject( aMesh );
-      GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SM);
-      try {
-       res = aMesh->AddHypothesis( aShapeObject, aHyp );
-       if ( res < SMESH::HYP_UNKNOWN_FATAL ) {
-         SALOMEDS::SObject_var SH = SMESH::FindSObject(aHyp);
-         if ( !SM->_is_nil() && !SH->_is_nil() ) {
-           SMESH::ModifiedMesh(SM, false);
-         }
-       }
-       if ( res > SMESH::HYP_OK ) {
-         wc.stop();
-         processHypothesisStatus( res, aHyp, this, true );
-         wc.start();
-       }
-      }
-      catch( const SALOME::SALOME_Exception& S_ex ) {
-       wc.stop();
-       QtCatchCorbaException( S_ex );
-       res = SMESH::HYP_UNKNOWN_FATAL;
+    QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
+    GroupC1Layout->addWidget( lab, i, 0 );
+
+    QWidget* w = getCustomWidget( *anIt, GroupC1 );
+    if ( !w ) 
+      switch( (*anIt).myValue.type() )
+      {
+      case QVariant::Int:
+        {
+          QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
+          attuneStdWidget( sb, i );
+          sb->setValue( (*anIt).myValue.toInt() );
+          connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
+          w = sb;
+        }
+        break;
+      case QVariant::Double:
+        {
+          QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
+          attuneStdWidget( sb, i );
+          sb->setValue( (*anIt).myValue.toDouble() );
+          connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
+          w = sb;
+        }
+        break;
+      case QVariant::String:
+        {
+          QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
+          attuneStdWidget( le, i );
+          le->setText( (*anIt).myValue.toString() );
+          connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
+          w = le;
+        }
+        break;
       }
+
+    if( w )
+    {
+      GroupC1Layout->addWidget( w, i, 1 );
+      changeWidgets().append( w );
     }
-    return res < SMESH::HYP_UNKNOWN_FATAL;
   }
 
+  return fr;
+}
+
+void SMESHGUI_GenericHypothesisCreator::onValueChanged()
+{
+}
+
+bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
+{
+  return false;
+}
 
-  bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp)
+bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& params ) const
+{
+  bool res = true;
+  StdParam item;
+  ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
+  for( ; anIt!=aLast; anIt++ )
   {
-    if(MYDEBUG) MESSAGE( "SMESHGUI::AddHypothesisOnSubMesh() ");
-    int res = SMESH::HYP_UNKNOWN_FATAL;
-    QAD_WaitCursor wc;
+    item.myName = (*anIt)->name();
+    if( (*anIt)->inherits( "QtxIntSpinBox" ) )
+    {
+      QtxIntSpinBox* sb = ( QtxIntSpinBox* )( *anIt );
+      item.myValue = sb->value();
+      params.append( item );
+    }
     
-    if ( !aSubMesh->_is_nil() && ! aHyp->_is_nil() ) {
-      try {
-       SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
-       SALOMEDS::SObject_var SsubM = SMESH::FindSObject( aSubMesh );
-       GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SsubM );
-       if ( !aMesh->_is_nil() && !SsubM->_is_nil() && !aShapeObject->_is_nil() ) {
-         res = aMesh->AddHypothesis( aShapeObject, aHyp );
-         if ( res < SMESH::HYP_UNKNOWN_FATAL )  {
-           SMESH::ModifiedMesh( SsubM, false );
-         }
-         if ( res > SMESH::HYP_OK ) {
-           wc.stop();
-           processHypothesisStatus( res, aHyp, this, true );
-           wc.start();
-         }
-       }
-       else {
-         SCRUTE( aHyp->_is_nil() );
-         SCRUTE( aMesh->_is_nil() );
-         SCRUTE( SsubM->_is_nil() );
-         SCRUTE( aShapeObject->_is_nil() );
-       }
-      }
-      catch( const SALOME::SALOME_Exception& S_ex ) {
-       wc.stop();
-       QtCatchCorbaException( S_ex );
-       res = SMESH::HYP_UNKNOWN_FATAL;
-      }
+    else if( (*anIt)->inherits( "QtxDblSpinBox" ) )
+    {
+      QtxDblSpinBox* sb = ( QtxDblSpinBox* )( *anIt );
+      item.myValue = sb->value();
+      params.append( item );
+    }
+
+    else if( (*anIt)->inherits( "QLineEdit" ) )
+    {
+      QLineEdit* line = ( QLineEdit* )( *anIt );
+      item.myValue = line->text();
+      params.append( item );
     }
-    else {
-      SCRUTE( aSubMesh->_is_nil() );
-      SCRUTE( aHyp->_is_nil() );
+
+    else if ( getParamFromCustomWidget( item, *anIt ))
+    {
+      params.append( item );
     }
-    return res < SMESH::HYP_UNKNOWN_FATAL;
+
+    else
+      res = false;
   }
-  
-  bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject)
+  return res;
+}
+
+QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
+{
+  QString valueStr = "";
+  ListOfStdParams::const_iterator param = params.begin(), aLast = params.end();
+  for( int i=0; param!=aLast; param++, i++ )
   {
-    int res = SMESH::HYP_UNKNOWN_FATAL;
-    QAD_WaitCursor wc;
-    
-    if (IObject->hasReference()) {
-      try {
-       SMESH::SMESH_Hypothesis_var anHyp = 
-         SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(IObject);
-       SALOMEDS::SObject_var SO_Applied_Hypothesis =
-         smeshGUI->myStudy->FindObjectID(IObject->getReference());
-       if (!SO_Applied_Hypothesis->_is_nil()) {
-         SALOMEDS::SObject_var MorSM = SMESH::GetMeshOrSubmesh(SO_Applied_Hypothesis);
-         if (!MorSM->_is_nil()) {
-           GEOM::GEOM_Object_var aShape = SMESH::GetShapeOnMeshOrSubMesh(MorSM);
-           if (!aShape->_is_nil()){
-             SMESH::SMESH_Mesh_var aMesh = 
-               SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
-             SMESH::SMESH_subMesh_var aSubMesh =
-               SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
-             
-             if (!aSubMesh->_is_nil())
-               aMesh = aSubMesh->GetFather();
-             
-             if (!aMesh->_is_nil()) {
-               res = aMesh->RemoveHypothesis(aShape, anHyp);
-               if ( res < SMESH::HYP_UNKNOWN_FATAL )
-                 SMESH::ModifiedMesh(MorSM, false);
-               if ( res > SMESH::HYP_OK ) {
-                 wc.stop();
-                 processHypothesisStatus( res, anHyp, this, false );
-                 wc.start();
-               }
-             }
-           }
-         }
-         
-         SALOMEDS::SObject_var SO_Applied_Hypothesis =
-           smeshGUI->myStudy->FindObjectID(IObject->getReference());
-         if (!SO_Applied_Hypothesis->_is_nil()) {
-           SALOMEDS::SObject_var MorSM = SMESH::GetMeshOrSubmesh(SO_Applied_Hypothesis);
-           if (!MorSM->_is_nil()) {
-             GEOM::GEOM_Object_var aShapeObject =SMESH::GetShapeOnMeshOrSubMesh(MorSM);
-             if (!aShapeObject->_is_nil()){
-               SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
-               SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
-               
-               if (!aSubMesh->_is_nil())
-                 aMesh = aSubMesh->GetFather();
-               
-               if (!aMesh->_is_nil()) {
-                 res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
-                 if ( res < SMESH::HYP_UNKNOWN_FATAL )
-                   SMESH::ModifiedMesh(MorSM, false);
-                 if ( res > SMESH::HYP_OK ) {
-                   wc.stop();
-                   processHypothesisStatus( res, anHyp, this, false );
-                   wc.start();
-                 }
-               }
-             }
-           }
-         }
-       }
-      }
-      catch( const SALOME::SALOME_Exception& S_ex ) {
-       wc.stop();
-       QtCatchCorbaException( S_ex );
-       res = SMESH::HYP_UNKNOWN_FATAL;
-      }
-    } 
-    else if (IObject->hasEntry()) {
-      if(MYDEBUG) MESSAGE("IObject entry " << IObject->getEntry());
+    if ( i > 0 )
+      valueStr += "; ";
+    switch( (*param).myValue.type() )
+    {
+    case QVariant::Int:
+      valueStr += valueStr.number( (*param).myValue.toInt() );
+      break;
+    case QVariant::Double:
+      valueStr += valueStr.number( (*param).myValue.toDouble() );
+      break;
+    case QVariant::String:
+      valueStr += (*param).myValue.toString();
+      break;
+    default:
+      QVariant valCopy = (*param).myValue;
+      valueStr += valCopy.asString();
     }
-    return res < SMESH::HYP_UNKNOWN_FATAL;
   }
+  return valueStr;
+}
+
+SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() const
+{
+  return myHypo;
+}
+
+SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis() const
+{
+  if ( CORBA::is_nil( myInitParamsHypo ))
+    return myHypo;
+  return myInitParamsHypo;
+}
+
+QString SMESHGUI_GenericHypothesisCreator::hypType() const
+{
+  return myHypType;
+}
+
+const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
+{
+  return myParamWidgets;
+}
+
+SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::changeWidgets()
+{
+  return myParamWidgets;
+}
+
+bool SMESHGUI_GenericHypothesisCreator::isCreation() const
+{
+  return myIsCreate;
+}
+
+void SMESHGUI_GenericHypothesisCreator::attuneStdWidget( QWidget*, const int ) const
+{
+}
+
+QString SMESHGUI_GenericHypothesisCreator::caption() const
+{
+  return QString();
+}
+
+QPixmap SMESHGUI_GenericHypothesisCreator::icon() const
+{
+  return QPixmap();
+}
+
+QString SMESHGUI_GenericHypothesisCreator::type() const
+{
+  return QString();
+}
+QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
+                                                             QWidget*   /*parent*/) const
+{
+  return 0;
+}
+bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam& , QWidget* ) const
+{
+  return false;
+}
+
+
+
+
+SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator* creator, QWidget* parent )
+: QtxDialog( parent, "", true, true ),
+  myCreator( creator )
+{
+  setMinimumSize( 300, height() );
+//  setFixedSize( 300, height() );
+  myLayout = new QVBoxLayout( mainFrame(), 0, 0 );
+
+  QFrame* titFrame = new QFrame( mainFrame() );
+  QHBoxLayout* titLay = new QHBoxLayout( titFrame, 0, 5 );
   
-  bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM,
-                                         SMESH::SMESH_Hypothesis_ptr anHyp)
+  myIconLabel = new QLabel( titFrame );
+  myIconLabel->setScaledContents( false );
+  myIconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
+  myTypeLabel = new QLabel( titFrame );
+  if( creator )
+    myTypeLabel->setText( creator->hypType() );
+
+  titLay->addWidget( myIconLabel, 0 );
+  titLay->addWidget( myTypeLabel, 0 );
+  titLay->addStretch( 1 );
+
+  myLayout->addWidget( titFrame, 0 );
+
+  QString aHypType = creator->hypType();
+  if ( aHypType == "LocalLength" )
+    myHelpFileName = "/files/arithmetic_1d.htm#Average_length";
+  else if ( aHypType == "Arithmetic1D")
+    myHelpFileName = "/files/arithmetic_1d.htm#arithmetic_1D";
+  else if ( aHypType == "MaxElementArea")
+    myHelpFileName = "/files/max._element_area_hypothesis.htm";
+  else if ( aHypType == "MaxElementVolume")
+    myHelpFileName = "/files/max._element_volume_hypothsis.htm";
+  else if ( aHypType == "StartEndLength")
+    myHelpFileName = "/files/arithmetic_1d.htm#start_and_end_length";
+  else if ( aHypType == "Deflection1D")
+    myHelpFileName = "/files/arithmetic_1d.htm#deflection_1D";
+  else if ( aHypType == "AutomaticLength")
+    myHelpFileName = "/files/arithmetic_1d.htm#automatic_length";
+  else if ( aHypType == "NumberOfSegments")
+    myHelpFileName = "/files/arithmetic_1d.htm#Number_of_elements";
+  else
+    myHelpFileName = "";
+
+  connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
+
+}
+
+SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
+{
+}
+
+void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
+{
+  if( f )
   {
-    SALOMEDS::SObject_var AHR, aRef;
-    SALOMEDS::GenericAttribute_var anAttr;
-    SALOMEDS::AttributeIOR_var anIOR;
-    int res = SMESH::HYP_UNKNOWN_FATAL;
-    QAD_WaitCursor wc;
-    
-    if (!MorSM->_is_nil()) {
-      try {
-       GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM);
-       if (!aShapeObject->_is_nil()) {
-         SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
-         SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
-         
-         if ( !aSubMesh->_is_nil() )
-           aMesh = aSubMesh->GetFather();
-         
-         if (!aMesh->_is_nil()) {
-           res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
-           if ( res < SMESH::HYP_UNKNOWN_FATAL )
-             SMESH::ModifiedMesh(MorSM, false);
-           if ( res > SMESH::HYP_OK ) {
-             wc.stop();
-             processHypothesisStatus( res, anHyp, this, false );
-             wc.start();
-           }
-         }
-       }
-      } catch( const SALOME::SALOME_Exception& S_ex ) {
-       wc.stop();
-       QtCatchCorbaException( S_ex );
-       res = SMESH::HYP_UNKNOWN_FATAL;
-      }
-    }
-    return res < SMESH::HYP_UNKNOWN_FATAL;
+    f->reparent( mainFrame(), QPoint( 0, 0 ) );
+    myLayout->insertWidget( 1, f, 1 );
   }
+}
 
-  SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp )
-  {
-    SALOMEDS::Study::ListOfSObject_var listSOmesh =
-      new SALOMEDS::Study::ListOfSObject;
-    listSOmesh->length(0);
-    unsigned int index = 0;
-    if (!AlgoOrHyp->_is_nil()) {
-      SALOMEDS::SObject_var SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp);
-      if (!SO_Hypothesis->_is_nil()) {
-       SALOMEDS::Study::ListOfSObject_var listSO =
-         smeshGUI->myStudy->FindDependances(SO_Hypothesis);
-       if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<<listSO->length());
-       for (unsigned int i = 0; i < listSO->length(); i++) {
-         SALOMEDS::SObject_ptr SO = listSO[i];
-         if (!SO->_is_nil()) { 
-           SALOMEDS::SObject_var aFather = SO->GetFather();
-           if (!aFather->_is_nil()) {
-             SALOMEDS::SObject_var SOfatherFather = aFather->GetFather();
-             if (!SOfatherFather->_is_nil()) {
-               if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list");
-               index++;
-               listSOmesh->length(index);
-               listSOmesh[index - 1] = SOfatherFather;
-             }
-           }
-         }
-       }
-      }
-    }
-    if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed");
-    return listSOmesh._retn();
+void SMESHGUI_HypothesisDlg::accept()
+{
+  if( !myCreator || myCreator->checkParams() )
+    QtxDialog::accept();
+}
+
+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);
+  }
+  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"));
   }
+}
+
+void SMESHGUI_HypothesisDlg::setHIcon( const QPixmap& p )
+{
+  myIconLabel->setPixmap( p );  
+}
 
+void SMESHGUI_HypothesisDlg::setType( const QString& t )
+{
+  myTypeLabel->setText( t );
 }