Salome HOME
Implementation of Bug PAL13901
authormaintenance team <salome-mnt@opencascade.com>
Mon, 6 Aug 2007 13:19:44 +0000 (13:19 +0000)
committermaintenance team <salome-mnt@opencascade.com>
Mon, 6 Aug 2007 13:19:44 +0000 (13:19 +0000)
 - EDF PAL 327 : SMESH : name of hypothesis incremental ?

src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_Hypotheses.cxx
src/SMESHGUI/SMESHGUI_Hypotheses.h
src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx
src/SMESHGUI/SMESHGUI_MeshOp.cxx
src/SMESHGUI/SMESHGUI_MeshOp.h
src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.cxx
src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.h
src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx

index 67032b6d6200dbbdad99e36553260e000e9b886b..6a6910a1ceb50f5ffb0a1155deda689142b714f2 100644 (file)
@@ -308,7 +308,7 @@ using namespace std;
              there must be check on others mesh elements not equal triangles
            */
            if (aMesh->NbTriangles() < 1) {
-              int aRet = SUIT_MessageBox::warn1
+              SUIT_MessageBox::warn1
                 (SMESHGUI::desktop(),
                  QObject::tr("SMESH_WRN_WARNING"),
                  QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
@@ -1857,17 +1857,18 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       int nbSel = selected.Extent();
 
       if (nbSel == 1) {
-       SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
+        Handle(SALOME_InteractiveObject) anIObject = selected.First();
+       SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
 
         /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
         /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects                   */
         /* Warning : however by internal mechanism all subMeshes icons are changed !                     */
-        if ( !Hyp->_is_nil() )
+        if ( !aHypothesis->_is_nil() )
         {
-          char* sName = Hyp->GetName();
-          SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
+          CORBA::String_var aHypType = aHypothesis->GetName();
+          SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
           if (aCreator)
-            aCreator->edit( Hyp.in(), desktop() );
+            aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
           else
           {
             // report error
@@ -3097,7 +3098,7 @@ void SMESHGUI::createPreferences()
 
   int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
   addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
-  int renumber=addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
+  addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
 
   int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
   int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
index 858fa53e8d6ac9ac9e3de7e9d359e63f0ded5c25..230327ff630451f387b66af6ad4a40415b3e3a0e 100644 (file)
@@ -45,8 +45,8 @@
 
 #include <qapplication.h>
 
-SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& aHypType )
-  : myHypType( aHypType ), myIsCreate( false ), myDlg( 0 )
+SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& theHypType )
+  : myHypType( theHypType ), myIsCreate( false ), myDlg( 0 )
 {
 }
 
@@ -55,63 +55,62 @@ SMESHGUI_GenericHypothesisCreator::~SMESHGUI_GenericHypothesisCreator()
 }
 
 void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
+                                               const QString& theHypName,
                                                 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 );
+  create( false, theHypName, parent );
 }
 
-void SMESHGUI_GenericHypothesisCreator::create( const bool isAlgo, QWidget* parent )
+void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
+                                               const QString& theHypName,
+                                               QWidget* theParent )
 {
   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;
 
   // Create hypothesis/algorithm
   if (isAlgo)
-    SMESH::CreateHypothesis( hypType(), aHypName, isAlgo );
-
+    SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
   else
   {
-    SMESH::SMESH_Hypothesis_var newHypo = SMESH::SMESH_Hypothesis::_narrow
-      ( SMESH::CreateHypothesis( hypType(), aHypName, false ) );
-  
-    if( !editHypothesis( newHypo.in(), parent ) )
+    SMESH::SMESH_Hypothesis_var aHypothesis = 
+      SMESH::CreateHypothesis( hypType(), theHypName, false );
+    if( !editHypothesis( aHypothesis.in(), theHypName, theParent ) )
     { //remove just created hypothesis
-      _PTR(SObject) SHyp = SMESH::FindSObject( newHypo.in() );
+      _PTR(SObject) aHypSObject = SMESH::FindSObject( aHypothesis.in() );
       _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
       if( aStudy && !aStudy->GetProperties()->IsLocked() )
       {
        _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
-       aBuilder->RemoveObjectWithChildren( SHyp );
+       aBuilder->RemoveObjectWithChildren( aHypSObject );
       }
     }
   }
   SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
 }
 
-void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr h, QWidget* parent )
+void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis,
+                                             const QString& theHypName,
+                                             QWidget* theParent )
 {
-  if( CORBA::is_nil( h ) )
+  if( CORBA::is_nil( theHypothesis ) )
     return;
 
   MESSAGE("Edition of hypothesis");
 
   myIsCreate = false;
 
-  if( !editHypothesis( h, parent ) )
+  if( !editHypothesis( theHypothesis, theHypName, theParent ) )
     return;
 
-  SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( h );
+  SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( theHypothesis );
   if( listSOmesh.size() > 0 )
-    for( int i=0; i<listSOmesh.size(); i++ )
+    for( int i = 0; i < listSOmesh.size(); i++ )
     {
       _PTR(SObject) submSO = listSOmesh[i];
       SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
@@ -124,29 +123,30 @@ void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr h, QWi
   SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
 }
 
-bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h, QWidget* parent )
+bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h, 
+                                                       const QString& theHypName,
+                                                       QWidget* theParent )
 {
   if( CORBA::is_nil( h ) )
     return false;
 
   bool res = true;
+  myHypName = theHypName;
   myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
 
-  SMESHGUI_HypothesisDlg* Dlg =
-    new SMESHGUI_HypothesisDlg( const_cast<SMESHGUI_GenericHypothesisCreator*>( this ), parent );
+  SMESHGUI_HypothesisDlg* Dlg = new SMESHGUI_HypothesisDlg( this, theParent );
   myDlg = Dlg;
   QFrame* fr = buildFrame();
   if( fr )
   {
     Dlg->setCustomFrame( fr );
     Dlg->setCaption( caption() );
+    Dlg->setName( theHypName );
     Dlg->setHIcon( icon() );
     Dlg->setType( type() );
     retrieveParams();
     Dlg->show();
-    //connect(myDlg, SIGNAL( closed() ), this, SLOT( onDlgClosed() ));
     qApp->enter_loop(); // make myDlg not modal
-//     res = myDlg->exec()==QDialog::Accepted;
     res = myDlg->result();
     if( res ) {
       QString paramValues = storeParams();
@@ -332,6 +332,11 @@ QString SMESHGUI_GenericHypothesisCreator::hypType() const
   return myHypType;
 }
 
+QString SMESHGUI_GenericHypothesisCreator::hypName() const
+{
+  return myHypName;
+}
+
 const SMESHGUI_GenericHypothesisCreator::ListOfWidgets& SMESHGUI_GenericHypothesisCreator::widgets() const
 {
   return myParamWidgets;
index 8373f9103da4c8eb55373b07fd5baefbe3451c42..e3c64a51ef32b529fcbd0d99a7a8bd631a98a5fb 100644 (file)
@@ -45,18 +45,19 @@ class SMESHGUI_GenericHypothesisCreator : public QObject
   Q_OBJECT
 
 public:
-  SMESHGUI_GenericHypothesisCreator( const QString& );
+  SMESHGUI_GenericHypothesisCreator( const QString& theHypType );
   virtual ~SMESHGUI_GenericHypothesisCreator();
 
-          void create( const bool isAlgo, QWidget* );
-          void edit( SMESH::SMESH_Hypothesis_ptr, QWidget* );
-          void create( SMESH::SMESH_Hypothesis_ptr, QWidget* );
+  void create( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*);
+  void create( bool isAlgo, const QString&, QWidget*);
+  void edit( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*);
 
   virtual bool checkParams() const = 0;
   virtual void onReject();
 
-  QString                     hypType() const;
-  bool                        isCreation() const;
+  QString hypType() const;
+  QString hypName() const;
+  bool    isCreation() const;
 
 protected:
   typedef struct
@@ -93,10 +94,11 @@ protected slots:
   virtual void onValueChanged();
 
 private:
-          bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, QWidget* );
+  bool editHypothesis( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget* );
 
 private:
   SMESH::SMESH_Hypothesis_var  myHypo, myInitParamsHypo;
+  QString                      myHypName;
   QString                      myHypType;
   ListOfWidgets                myParamWidgets;
   bool                         myIsCreate;
@@ -111,9 +113,9 @@ public:
   SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
   virtual ~SMESHGUI_HypothesisDlg();
 
-          void setHIcon( const QPixmap& );
-          void setCustomFrame( QFrame* );
-          void setType( const QString& );
+  void setHIcon( const QPixmap& );
+  void setCustomFrame( QFrame* );
+  void setType( const QString& );
 
 protected slots:
   virtual void accept();
@@ -123,7 +125,8 @@ protected slots:
 private:
   SMESHGUI_GenericHypothesisCreator*   myCreator;
   QVBoxLayout*                         myLayout;
-  QLabel                              *myIconLabel, *myTypeLabel;
+  QLabel*                              myIconLabel;
+  QLabel*                              myTypeLabel;
   QString                              myHelpFileName;
 };
 
index a21492653776950e56f21e5714ba25f8310dad67..99205c049fc98519303588a234fa928b29c462db 100644 (file)
@@ -365,30 +365,21 @@ namespace SMESH{
                                               const bool isAlgo)
   {
     if(MYDEBUG) MESSAGE("Create " << aHypType << " with name " << aHypName);
-
-    SMESH::SMESH_Hypothesis_var Hyp;
-
     HypothesisData* aHypData = GetHypothesisData(aHypType);
     QString aServLib = aHypData->ServerLibName;
-
     try {
-      Hyp = SMESHGUI::GetSMESHGen()->CreateHypothesis(aHypType, aServLib);
-      if (!Hyp->_is_nil()) {
-       _PTR(SObject) SHyp = SMESH::FindSObject(Hyp.in());
-       if (SHyp) {
-         //if (strcmp(aHypName,"") != 0)
+      SMESH::SMESH_Hypothesis_var aHypothesis;
+      aHypothesis = SMESHGUI::GetSMESHGen()->CreateHypothesis(aHypType, aServLib);
+      if (!aHypothesis->_is_nil()) {
+       _PTR(SObject) aHypSObject = SMESH::FindSObject(aHypothesis.in());
+       if (aHypSObject) {
          if (strlen(aHypName) > 0)
-           SMESH::SetName(SHyp, aHypName);
-         //SalomeApp_Application* app =
-         //  dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
-         //if (app)
-         //  app->objectBrowser()->updateTree();
-          SMESHGUI::GetSMESHGUI()->updateObjBrowser();
-         return Hyp._retn();
+           SMESH::SetName(aHypSObject, aHypName);
+         SMESHGUI::GetSMESHGUI()->updateObjBrowser();
+         return aHypothesis._retn();
        }
       }
-    }
-    catch (const SALOME::SALOME_Exception & S_ex) {
+    } catch (const SALOME::SALOME_Exception & S_ex) {
       SalomeApp_Tools::QtCatchCorbaException(S_ex);
     }
 
index 9aa469e68ccf909ef99a60a3f68957f6ebad73ae..ca82f9dd3207a601558ebc0d1c24e0857233098a 100644 (file)
@@ -693,7 +693,6 @@ void SMESHGUI_MeshOp::availableHyps( const int       theDim,
   * \param theHypType - specifies whether algorims or hypotheses or additional ones
   * are retrieved (possible values are in HypType enumeration)
   * \param theFather - start object for finding ( may be component, mesh, or sub-mesh )
-  * \param theDataList - output list of hypotheses data
   * \param theHyps - output list of names.
   * \param theHypVars - output list of variables.
   * \param theAlgoData - to select hypos able to be used by this algo (optional)
@@ -706,12 +705,12 @@ void SMESHGUI_MeshOp::existingHyps( const int theDim,
                                     const int theHypType,
                                     _PTR(SObject) theFather,
                                     QStringList& theHyps,
-                                    QValueList<SMESH::SMESH_Hypothesis_var>& theHypVars,
+                                    THypList& theHypList,
                                     HypothesisData* theAlgoData)
 {
   // Clear hypoheses list
   theHyps.clear();
-  theHypVars.clear();
+  theHypList.clear();
 
   if ( !theFather )
     return;
@@ -754,15 +753,15 @@ void SMESHGUI_MeshOp::existingHyps( const int theDim,
           SMESH::SMESH_Hypothesis_var aHypVar = SMESH::SMESH_Hypothesis::_narrow( aVar );
           if ( !aHypVar->_is_nil() )
           {
-            QString aHypType( aHypVar->GetName() );
+            CORBA::String_var aHypType( aHypVar->GetName() );
             HypothesisData* aData = SMESH::GetHypothesisData( aHypType );
             if ( ( theDim == -1 || aData->Dim.contains( theDim ) ) &&
                  ( isCompatible ( theAlgoData, aData, theHypType )) &&
                  ( isAux == aData->IsAux ))
             {
-              //theDataList.append( aData );
-              theHyps.append( aName->Value().c_str() );
-              theHypVars.append( aHypVar );
+             std::string aHypName = aName->Value();
+              theHyps.append( aHypName.c_str() );
+              theHypList.append( THypItem( aHypVar, aHypName.c_str() ) );
             }
           }
         }
@@ -884,6 +883,19 @@ void SMESHGUI_MeshOp::onCreateHyp( const int theHypType, const int theIndex )
  *  \param theTypeName - specifies hypothesis to be created
  */
 //================================================================================
+namespace
+{
+  QString GetUniqueName (const QStringList& theHypNames,
+                        const QString& theName,
+                        size_t theIteration = 1)
+  {
+    QString aName = theName + "_" + QString::number( theIteration );
+    if ( theHypNames.contains( aName ) )
+      return GetUniqueName( theHypNames, theName, ++theIteration );
+    return aName;
+  }
+}
+
 void SMESHGUI_MeshOp::createHypothesis (const int theDim,
                                         const int theType,
                                         const QString& theTypeName)
@@ -896,13 +908,30 @@ void SMESHGUI_MeshOp::createHypothesis (const int theDim,
   if (!aData)
     return;
 
+  QStringList aHypNames;
+  TDim2Type2HypList::const_iterator aDimIter = myExistingHyps.begin();
+  for( ; aDimIter != myExistingHyps.end(); aDimIter++ ) {
+    const TType2HypList& aType2HypList = aDimIter.data();
+    TType2HypList::const_iterator aTypeIter = aType2HypList.begin();
+    for( ; aTypeIter != aType2HypList.end(); aTypeIter++ ) {
+      const THypList& aHypList = aTypeIter.data();
+      THypList::const_iterator anIter = aHypList.begin();
+      for( ; anIter != aHypList.end(); anIter++ ) {
+       const THypItem& aHypItem = *anIter;
+       const QString& aHypName = aHypItem.second;
+       aHypNames.append(aHypName);
+      }      
+    }    
+  }
+  QString aHypName = GetUniqueName( aHypNames, aData->Label);
+
   // existing hypos
   int nbHyp = myExistingHyps[theDim][theType].count();
 
   QString aClientLibName = aData->ClientLibName;
   if (aClientLibName == "") {
     // Call hypothesis creation server method (without GUI)
-    SMESH::CreateHypothesis(theTypeName, aData->Label, false);
+    SMESH::CreateHypothesis(theTypeName, aHypName, false);
   } else {
     // Get hypotheses creator client (GUI)
     SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
@@ -914,10 +943,10 @@ void SMESHGUI_MeshOp::createHypothesis (const int theDim,
       SMESH::SMESH_Hypothesis_var initParamHyp =
         getInitParamsHypothesis(theTypeName, aData->ServerLibName);
       myDlg->setEnabled( false );
-      aCreator->create(initParamHyp, myDlg);
+      aCreator->create(initParamHyp, aHypName, myDlg);
       myDlg->setEnabled( true );
     } else {
-      SMESH::CreateHypothesis(theTypeName, aData->Label, false);
+      SMESH::CreateHypothesis(theTypeName, aHypName, false);
     }
   }
 
@@ -949,18 +978,19 @@ void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
   if (aDim == -1)
     return;
 
-  QValueList<SMESH::SMESH_Hypothesis_var> aList = myExistingHyps[ aDim ][ theHypType ];
+  const THypList& aList = myExistingHyps[ aDim ][ theHypType ];
   if ( theIndex < 0 || theIndex >= aList.count() )
     return;
-  SMESH::SMESH_Hypothesis_var aHyp = aList[ theIndex ];
+  const THypItem& aHypItem = aList[ theIndex ];
+  SMESH::SMESH_Hypothesis_var aHyp = aHypItem.first;
   if ( aHyp->_is_nil() )
     return;
 
-  char* aTypeName = aHyp->GetName();
+  CORBA::String_var aTypeName = aHyp->GetName();
   SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aTypeName );
   if ( aCreator ) {
     myDlg->setEnabled( false );
-    aCreator->edit( aHyp.in(), dlg() );
+    aCreator->edit( aHyp.in(), aHypItem.second, dlg() );
     myDlg->setEnabled( true );
   }
 }
@@ -1093,17 +1123,18 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
 
       SMESH::SMESH_Hypothesis_var curHyp;
       if ( hypIndex >= 0 && hypIndex < myExistingHyps[ dim ][ type ].count() )
-        curHyp = myExistingHyps[ dim ][ type ][ hypIndex ];
+        curHyp = myExistingHyps[ dim ][ type ][ hypIndex ].first;
 
       if ( !myToCreate && !curAlgo && !curHyp->_is_nil() ) { // edition, algo not selected
         // try to find algo by selected hypothesis in order to keep it selected
         bool algoDeselectedByUser = ( theDim < 0 && aDim == dim );
-        QString curHypType = curHyp->GetName();
+        CORBA::String_var curHypType = curHyp->GetName();
         if ( !algoDeselectedByUser &&
              myObjHyps[ dim ][ type ].count() > 0 &&
-             curHypType == myObjHyps[ dim ][ type ][ 0 ]->GetName())
+             curHypType == myObjHyps[ dim ][ type ].first().first->GetName())
         {
-          HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
+         CORBA::String_var aName = curHyp->GetName();
+          HypothesisData* hypData = SMESH::GetHypothesisData( aName );
           for ( int i = 0 ; i < myAvailableHypData[ dim ][ Algo ].count(); ++i ) {
             curAlgo = myAvailableHypData[ dim ][ Algo ][ i ];
             if ( curAlgo && hypData && isCompatible( curAlgo, hypData, type ))
@@ -1118,7 +1149,8 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
       {
         // check if a selected hyp is compatible with the curAlgo
         if ( !curHyp->_is_nil() ) {
-          HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
+         CORBA::String_var aName = curHyp->GetName();
+          HypothesisData* hypData = SMESH::GetHypothesisData( aName );
           if ( !isCompatible( curAlgo, hypData, type ))
             curHyp = SMESH::SMESH_Hypothesis::_nil();
         }
@@ -1136,10 +1168,10 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
         hypIndex = -1;
       if ( !isSubmesh && hypIndex < 0 && anExisting.count() == 1 ) {
         // none is yet selected => select the sole existing if it is not optional
-        QString hypTypeName = myExistingHyps[ dim ][ type ][ 0 ]->GetName();
+        CORBA::String_var hypTypeName = myExistingHyps[ dim ][ type ].first().first->GetName();
         bool isOptional = true;
         if ( algoByDim[ dim ] &&
-             SMESH::IsAvailableHypothesis( algoByDim[ dim ], hypTypeName, isOptional ) &&
+             SMESH::IsAvailableHypothesis( algoByDim[ dim ], hypTypeName.in(), isOptional ) &&
              !isOptional )
           hypIndex = 0;
       }
@@ -1251,7 +1283,7 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess )
       for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ ) {
         int aHypIndex = currentHyp( aDim, aHypType );
         if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() ) {
-          SMESH::SMESH_Hypothesis_var aHypVar = myExistingHyps[ aDim ][ aHypType ][ aHypIndex ];
+          SMESH::SMESH_Hypothesis_var aHypVar = myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
           if ( !aHypVar->_is_nil() )
             SMESH::AddHypothesisOnMesh( aMeshVar, aHypVar );
         }
@@ -1379,7 +1411,7 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess )
       if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() )
       {
         SMESH::SMESH_Hypothesis_var aHypVar =
-          myExistingHyps[ aDim ][ aHypType ][ aHypIndex ];
+          myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
         if ( !aHypVar->_is_nil() )
           SMESH::AddHypothesisOnSubMesh( aSubMeshVar, aHypVar );
       }
@@ -1493,12 +1525,13 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
   existingHyps( theDim, Algo, pObj, tmp, myExistingHyps[ theDim ][ Algo ]);
 
   // look for anexisting algo of such a type
-  QValueList<SMESH::SMESH_Hypothesis_var>& aHypVarList = myExistingHyps[ theDim ][ Algo ];
-  QValueList<SMESH::SMESH_Hypothesis_var>::iterator anIter;
-  for ( anIter = aHypVarList.begin(); anIter != aHypVarList.end(); anIter++ )
+  THypList& aHypVarList = myExistingHyps[ theDim ][ Algo ];
+  THypList::iterator anIter = aHypVarList.begin();
+  for ( ; anIter != aHypVarList.end(); anIter++ )
   {
-    SMESH::SMESH_Hypothesis_var aHypVar = *anIter;
-    if ( !aHypVar->_is_nil() && aHypName == aHypVar->GetName() )
+    SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
+    CORBA::String_var aName = aHypVar->GetName();
+    if ( !aHypVar->_is_nil() && aHypName == aName )
     {
       anAlgoVar = aHypVar;
       break;
@@ -1518,7 +1551,7 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
 
         // Create algorithm
         if (aCreator)
-          aCreator->create(true, myDlg);
+          aCreator->create(true, aHypName, myDlg);
         else
           SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
       }
@@ -1527,11 +1560,12 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
       existingHyps( theDim, Algo, aFather, tmpList, myExistingHyps[ theDim ][ Algo ] );
     }
 
-    QValueList<SMESH::SMESH_Hypothesis_var>& aNewHypVarList = myExistingHyps[ theDim ][ Algo ];
+    THypList& aNewHypVarList = myExistingHyps[ theDim ][ Algo ];
     for ( anIter = aNewHypVarList.begin(); anIter != aNewHypVarList.end(); ++anIter )
     {
-      SMESH::SMESH_Hypothesis_var aHypVar = *anIter;
-      if ( !aHypVar->_is_nil() && aHypName == aHypVar->GetName() )
+      SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
+      CORBA::String_var aName = aHypVar->GetName();
+      if ( !aHypVar->_is_nil() && aHypName == aName )
       {
         anAlgoVar = aHypVar;
         break;
@@ -1590,8 +1624,8 @@ void SMESHGUI_MeshOp::readMesh()
     int aHypIndex = -1;
     if ( myObjHyps[ dim ][ Algo ].count() > 0 )
     {
-      SMESH::SMESH_Hypothesis_var aVar = myObjHyps[ dim ][ Algo ].first();
-      QString aHypTypeName = aVar->GetName();
+      SMESH::SMESH_Hypothesis_var aVar = myObjHyps[ dim ][ Algo ].first().first;
+      CORBA::String_var aHypTypeName = aVar->GetName();
       HypothesisData* algoData = SMESH::GetHypothesisData( aHypTypeName );
       aHypIndex = myAvailableHypData[ dim ][ Algo ].findIndex ( algoData );
 //       if ( aHypIndex < 0 && algoData ) {
@@ -1616,7 +1650,7 @@ void SMESHGUI_MeshOp::readMesh()
       // find index of requered hypothesis among existing ones for this dimension and type
       int aHypIndex = -1;
       if ( myObjHyps[ dim ][ hypType ].count() > 0 ) {
-        aHypIndex = find( myObjHyps[ dim ][ hypType ].first(),
+        aHypIndex = find( myObjHyps[ dim ][ hypType ].first().first,
                           myExistingHyps[ dim ][ hypType ] );
         if ( aHypIndex < 0 ) {
           // assigned hypothesis is incompatible with the algorithm
@@ -1673,16 +1707,16 @@ QString SMESHGUI_MeshOp::name( _PTR(SObject) theSO ) const
  */
 //================================================================================
 int SMESHGUI_MeshOp::find( const SMESH::SMESH_Hypothesis_var& theHyp,
-                           const QValueList<SMESH::SMESH_Hypothesis_var>& theHypList ) const
+                           const THypList& theHypList ) const
 {
   int aRes = -1;
   if ( !theHyp->_is_nil() )
   {
     int i = 0;
-    QValueList<SMESH::SMESH_Hypothesis_var>::const_iterator anIter;
-    for ( anIter = theHypList.begin(); anIter != theHypList.end(); ++ anIter )
+    THypList::const_iterator anIter = theHypList.begin();
+    for ( ; anIter != theHypList.end(); ++ anIter )
     {
-      if ( theHyp->_is_equivalent( *anIter ) )
+      if ( theHyp->_is_equivalent( (*anIter).first ) )
       {
         aRes = i;
         break;
@@ -1718,20 +1752,23 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
   SUIT_OverrideCursor aWaitCursor;
 
   // Set new name
-  SMESH::SetName( pObj, myDlg->objectText( SMESHGUI_MeshDlg::Obj ).latin1() );
+  QString aName = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
+  SMESH::SetName( pObj, aName.latin1() );
 
   // First, remove old algos in order to avoid messages on algorithm hiding
   for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
   {
     if ( isAccessibleDim( dim ) && myObjHyps[ dim ][ Algo ].count() > 0 )
     {
-      SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first();
+      SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first().first;
+      CORBA::String_var anOldName = anOldAlgo->GetName();
       SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
+      CORBA::String_var anAlgoName = anAlgoVar->GetName();
       if ( anAlgoVar->_is_nil() || // no new algo selected or
-           strcmp(anOldAlgo->GetName(), anAlgoVar->GetName()) ) // algo change
+           strcmp(anOldName.in(), anAlgoName.in()) ) // algo change
       {
         // remove old algorithm
-        SMESH::RemoveHypothesisOrAlgorithmOnMesh ( pObj, myObjHyps[ dim ][ Algo ].first() );
+        SMESH::RemoveHypothesisOrAlgorithmOnMesh ( pObj, myObjHyps[ dim ][ Algo ].first().first );
         myObjHyps[ dim ][ Algo ].clear();
       }
     }
@@ -1749,8 +1786,9 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
     if ( !anAlgoVar->_is_nil() && // some algo selected and
          myObjHyps[ dim ][ Algo ].count() == 0 ) // no algo assigned
     {
-      SMESH::SMESH_Mesh_var aMeshVar =
-        SMESH::SMESH_Mesh::_narrow( _CAST(SObject,pObj)->GetObject() );
+      SALOMEDS_SObject* aSObject = _CAST(SObject, pObj);
+      CORBA::Object_var anObject = aSObject->GetObject();
+      SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_narrow( anObject );
       bool isMesh = !aMeshVar->_is_nil();
       if ( isMesh ) {
         SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
@@ -1760,7 +1798,7 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
         if ( !aVar->_is_nil() )
           SMESH::AddHypothesisOnSubMesh( aVar, anAlgoVar );
       }
-      myObjHyps[ dim ][ Algo ].append( anAlgoVar );
+      myObjHyps[ dim ][ Algo ].append( THypItem( anAlgoVar, aName) );
     }
 
     // assign hypotheses
@@ -1772,13 +1810,13 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
       // remove old hypotheses
       if ( myObjHyps[ dim ][ hypType ].count() > 0 )
       {
-        anOldHypIndex = find( myObjHyps[ dim ][ hypType ].first(),
+        anOldHypIndex = find( myObjHyps[ dim ][ hypType ].first().first ,
                               myExistingHyps[ dim ][ hypType ] );
         if ( aNewHypIndex != anOldHypIndex || // different hyps
              anOldHypIndex == -1 )            // hyps of different algos
         {
           SMESH::RemoveHypothesisOrAlgorithmOnMesh
-            ( pObj, myObjHyps[ dim ][ hypType ].first() );
+            ( pObj, myObjHyps[ dim ][ hypType ].first().first );
           myObjHyps[ dim ][ hypType ].clear();
         }
       }
@@ -1792,7 +1830,7 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
         if ( isMesh )
         {
           SMESH::AddHypothesisOnMesh
-            (aMeshVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ] );
+            (aMeshVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
         }
         else
         {
@@ -1800,7 +1838,7 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
             SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
           if ( !aVar->_is_nil() )
             SMESH::AddHypothesisOnSubMesh
-              ( aVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ] );
+              ( aVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
         }
       }
       // reread all hypotheses of mesh if necessary
index f74f5049d54d05ba3f9d5e993685f2a4f1dbdc37..3ab0c9a936aec853e903668e59c35c73648afe6b 100644 (file)
 #define SMESHGUI_MeshOp_H
 
 #include "SMESHGUI_SelectionOp.h"
-#include <qstringlist.h>
 
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(GEOM_Gen)
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 
+#include <qstringlist.h>
+
 class SMESHGUI_MeshDlg;
 class SMESHGUI_ShapeByMeshOp;
 class HypothesisData;
@@ -56,6 +57,15 @@ public:
 
   enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
 
+  typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
+  typedef QValueList< THypItem > THypList;
+
+  typedef int THypType;
+  typedef QMap< THypType, THypList > TType2HypList;
+
+  typedef int THypDim;
+  typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
+
   SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh = true );
   virtual ~SMESHGUI_MeshOp();
   
@@ -92,7 +102,7 @@ private:
                                                const int     theHypType, 
                                                _PTR(SObject) theFather,
                                                QStringList&  theHyps, 
-                                               QValueList<SMESH::SMESH_Hypothesis_var>& theHypVars,
+                                               THypList& theHypList,
                                                HypothesisData* theAlgoData = 0);
   HypothesisData*                hypData( const int theDim,
                                           const int theHypType,
@@ -113,7 +123,7 @@ private:
   void                           readMesh();
   QString                        name( _PTR(SObject) ) const;
   int                            find( const SMESH::SMESH_Hypothesis_var&,
-                                       const QValueList<SMESH::SMESH_Hypothesis_var>& ) const;
+                                       const THypList& theHypList) const;
   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString& aHypType,
                                                           const QString& aServerLib ) const;
   bool                           isSubshapeOk() const;
@@ -121,16 +131,13 @@ private:
   void                           selectObject( _PTR(SObject) ) const;
 
 private:
-  typedef QMap< int, QValueList<SMESH::SMESH_Hypothesis_var> > IdToHypListMap;
-  typedef QMap< int, IdToHypListMap > DimToHypMap;
-
   SMESHGUI_MeshDlg*              myDlg;
   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
   bool                           myToCreate;
   bool                           myIsMesh;
 
-  DimToHypMap                    myExistingHyps; //!< all hypothesis of SMESH module
-  DimToHypMap                    myObjHyps;      //!< hypothesis assigned to the current 
+  TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
+  TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current 
                                                  //   edited mesh/sub-mesh
 
   // hypdata corresponding to hypotheses present in myDlg
index 7537e621b041a6c543d889abe4a406a06496a3f8..ed77aaf61b21284e99c5df0680737f7de390ad5c 100644 (file)
  */
 //================================================================================
 
-StdMeshersGUI_LayerDistributionParamWdg::StdMeshersGUI_LayerDistributionParamWdg
-( SMESH::SMESH_Hypothesis_ptr hyp,
-  QDialog*                    dlg ): QHGroupBox(), myDlg( dlg )
+StdMeshersGUI_LayerDistributionParamWdg
+::StdMeshersGUI_LayerDistributionParamWdg(SMESH::SMESH_Hypothesis_ptr hyp,
+                                         const QString& theName,
+                                          QDialog* dlg): 
+  QHGroupBox(), myName(theName), myDlg( dlg )
 {
   init();
   set( hyp );
@@ -204,7 +206,7 @@ void StdMeshersGUI_LayerDistributionParamWdg::onEdit()
   try {
     QWidget* parent = this;
     if ( myDlg ) parent = myDlg->parentWidget();
-    editor->edit( myHyp, parent );
+    editor->edit( myHyp, myName, parent );
   }
   catch(...) {
   }
index fec3785f0fb9bded48554fb8caa9cf0798ee28f7..c8f82b1712d445b270479f92501ae08f9b34f25d 100644 (file)
@@ -48,7 +48,8 @@ class StdMeshersGUI_LayerDistributionParamWdg : public QHGroupBox
 
 public:
   StdMeshersGUI_LayerDistributionParamWdg(SMESH::SMESH_Hypothesis_ptr hyp,
-                                          QDialog*                    dlg);
+                                         const QString& theName,
+                                          QDialog* dlg);
   ~StdMeshersGUI_LayerDistributionParamWdg();
 
   SMESH::SMESH_Hypothesis_var GetHypothesis() { return myHyp; }
@@ -74,6 +75,7 @@ private:
  QPushButton*           myEditButton;
  QPopupMenu*            myHypTypePopup;
  QDialog*               myDlg;
+ QString                myName;
  QString                myParamValue;
 
  QStringList            myHypTypes;
index 02bb83a356cdcb578b31c91ef7f67121d99f86db..f5468b118c6d13995b8fde295f45d8d9f496f788 100644 (file)
@@ -251,8 +251,7 @@ bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisDa
   StdMeshers::StdMeshers_NumberOfSegments_var h =
     StdMeshers::StdMeshers_NumberOfSegments::_narrow( initParamsHypothesis() );
 
-  HypothesisData* data = SMESH::GetHypothesisData( hypType() );
-  h_data.myName = isCreation() && data ? data->Label : "";
+  h_data.myName = hypName();
 
   h_data.myNbSeg = (int) h->GetNumberOfSegments();
   int distr = (int) h->GetDistrType();
index 1be50e5d19a41676b2a34cd10245a54e5c407f80..cfa7002360e423c662f21c380b0ab66e813564c6 100644 (file)
@@ -512,7 +512,7 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
   {
     HypothesisData* data = SMESH::GetHypothesisData( hypType() );
     item.myName = tr( "SMESH_NAME" );
-    item.myValue = data ? data->Label : QString();
+    item.myValue = data ? hypName() : QString();
     p.append( item );
     customWidgets()->append(0);
   }
@@ -615,7 +615,7 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
 
     item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
     customWidgets()->append
-      ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), dlg()));
+      ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
   }
   else if( hypType()=="ProjectionSource1D" )
   {