From: dmv Date: Mon, 27 Jul 2009 13:46:11 +0000 (+0000) Subject: IPAL21151 TC5.1.2: Incorrect name of new presentation X-Git-Tag: V4_1_0_maintainance_20090803 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9ad2667d687dd225acd09e0cbd140daacc6157f4;p=modules%2Fvisu.git IPAL21151 TC5.1.2: Incorrect name of new presentation --- diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index b38ce0fe..a25b0e58 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -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( anApp->activeStudy() ); + + if(aStudy){ + while (1) { + std::vector<_PTR(SObject)> aList = aStudy->studyDS()->FindObjectByName(aName.latin1(), "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; }