Salome HOME
Make meshes with different names if several GEOM objects selected
authoreap <eap@opencascade.com>
Thu, 20 Feb 2014 08:55:58 +0000 (12:55 +0400)
committereap <eap@opencascade.com>
Thu, 20 Feb 2014 08:55:58 +0000 (12:55 +0400)
src/SMESHGUI/SMESHGUI_MeshOp.cxx
src/SMESHGUI/SMESHGUI_MeshOp.h

index f91dbca30f379f4f2f83e0ea9c3186a57627b5d7..679348f2a9521f0f940650ff5291dcbae1bd9beb 100644 (file)
@@ -1637,9 +1637,6 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
 {
   theMess = "";
 
-  //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
-  //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
-
   QStringList aList;
   myDlg->selectedObject( SMESHGUI_MeshDlg::Geom, aList );
   if ( aList.isEmpty() )
@@ -1659,8 +1656,20 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
     }
     return true;
   }
+  QString namePrefix;
+  if ( aList.count() > 1 )
+  {
+    namePrefix = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
+    int i = namePrefix.length() - 1;
+    while ( i > 0 && namePrefix[i].isDigit() )
+      --i;
+    if ( i < namePrefix.length() - 1 )
+      namePrefix.chop( namePrefix.length() - 1 - i );
+    else
+      namePrefix += "_";
+  }
   QStringList::Iterator it = aList.begin();
-  for ( ; it!=aList.end(); it++)
+  for ( int i = 0; it!=aList.end(); it++, ++i )
   {
     QString aGeomEntry = *it;
     _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
@@ -1679,8 +1688,9 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
       return false;
     _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar.in() );
     if ( aMeshSO ) {
-      SMESH::SetName( aMeshSO, myDlg->objectText( SMESHGUI_MeshDlg::Obj ) );
       theEntryList.append( aMeshSO->GetID().c_str() );
+      if ( i > 0 ) setDefaultName( namePrefix );
+      SMESH::SetName( aMeshSO, myDlg->objectText( SMESHGUI_MeshDlg::Obj ) );
     }
 
     for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ ) {
@@ -1896,13 +1906,17 @@ void SMESHGUI_MeshOp::setCurrentHyp( const int theDim,
  * Generates and sets default mesh/submesh name(Mesh_1, Mesh_2, etc.)
  */
 //================================================================================
-void SMESHGUI_MeshOp::setDefaultName() const
+void SMESHGUI_MeshOp::setDefaultName( const QString& thePrefix ) const
 {
   QString aResName;
 
   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
   int i = 1;
-  QString aPrefix = tr( myIsMesh ? "SMESH_OBJECT_MESH" : "SMESH_SUBMESH" ) + "_";
+
+  QString aPrefix = thePrefix;
+  if ( aPrefix.isEmpty() )
+    aPrefix = tr( myIsMesh ? "SMESH_OBJECT_MESH" : "SMESH_SUBMESH" ) + "_";
+
   _PTR(SObject) anObj;
   do
   {
index 90d49e276043c9803a3bd146aa4bef220bba8b5b..783bb08317f971387e1298376b30a90e2ae538fb 100644 (file)
@@ -118,7 +118,7 @@ private:
   int                            currentHyp( const int, const int ) const;
   bool                           isAccessibleDim( const int ) const;
   void                           setCurrentHyp( const int, const int, const int );
-  void                           setDefaultName() const;
+  void                           setDefaultName( const QString& prefix="" ) const;
   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
   void                           readMesh();
   QString                        name( _PTR(SObject) ) const;