]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
IPAL21151 TC5.1.2: Incorrect name of new presentation V5_1_main_20090730 V5_1_main_20090804
authordmv <dmv@opencascade.com>
Mon, 27 Jul 2009 13:45:14 +0000 (13:45 +0000)
committerdmv <dmv@opencascade.com>
Mon, 27 Jul 2009 13:45:14 +0000 (13:45 +0000)
src/VISU_I/VISUConfig.cc

index 7f08f0a1e19e66c92b7e1ac5cec01d2f791b68da..882342406e7c30163cb0b0704cc43baff689c735 100644 (file)
@@ -677,13 +677,32 @@ namespace VISU
 
   //---------------------------------------------------------------
   QString 
-  GenerateName(const std::string& theFmt, int theId)
+  GenerateName(const std::string& theFmt, int /*theId*/) // theId was deprecated because of incorrect work IPAL21151
   {
     QString aName;
-    if(theId > 0)
-      aName.sprintf("%s:%d", theFmt.c_str(), theId);
-    else
-      aName.sprintf("%s", theFmt.c_str());
+    aName.sprintf("%s", theFmt.c_str());
+    int count = 0;
+
+    SalomeApp_Application* anApp =
+      dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+    if ( anApp) {
+      SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
+
+      if(aStudy){
+       while (1) {
+         std::vector<_PTR(SObject)> aList = aStudy->studyDS()->FindObjectByName(aName.toLatin1().data(), "VISU");
+         if ( aList.size() > 0 ) {
+           count++;
+           aName.sprintf("%s:%d", theFmt.c_str(), count);
+         } else
+           break;
+       }
+      }
+    }
+    
+    if(count > 0)
+      aName.sprintf("%s:%d", theFmt.c_str(), count);
+
     return aName;
   }