X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMBase%2FGEOMBase_Helper.cxx;h=fe51c488fd99f95035a985c9d5f75f2aa5e6d24f;hb=611ec94e27c211452a3098d014709d519b954e51;hp=c2e7114d335a8a75a1b20b150a445a8c83d6343c;hpb=c1745184cb4eb0e72088753b40a23902200aa62a;p=modules%2Fgeom.git diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index c2e7114d3..fe51c488f 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -17,7 +17,7 @@ // 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.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -109,7 +109,8 @@ GEOMBase_Helper::~GEOMBase_Helper() globalSelection( GEOM_ALLOBJECTS, true ); - delete myDisplayer; + if (myDisplayer) + delete myDisplayer; } //================================================================ @@ -214,7 +215,8 @@ void GEOMBase_Helper::redisplay( GEOM::GEOM_Object_ptr object, SalomeApp_Study* aDoc = getStudy(); if ( aDoc && aDoc->studyDS() ) { _PTR(Study) aStudy = aDoc->studyDS(); - _PTR(SObject) aSObj (aStudy->FindObjectIOR(SalomeApp_Application::orb()->object_to_string(object))); + CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(object); + _PTR(SObject) aSObj (aStudy->FindObjectIOR(string(objStr.in()))); if ( aSObj ) { _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) ); for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) { @@ -301,7 +303,8 @@ void GEOMBase_Helper::displayPreview( GEOM::GEOM_Object_ptr object, getDisplayer()->SetToActivate( activate ); // Make a reference to GEOM_Object - getDisplayer()->SetName( SalomeApp_Application::orb()->object_to_string( object ) ); + CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string( object ); + getDisplayer()->SetName( objStr.in() ); // Build prs SALOME_Prs* aPrs = getDisplayer()->BuildPrs( object ); @@ -570,11 +573,13 @@ char* GEOMBase_Helper::getEntry( GEOM::GEOM_Object_ptr object ) const { SalomeApp_Study* study = getStudy(); if ( study ) { - string IOR = GEOMBase::GetIORFromObject( object); + char * objIOR = GEOMBase::GetIORFromObject( object ); + string IOR( objIOR ); + free( objIOR ); if ( IOR != "" ) { _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) ); if ( SO ) { - return TCollection_AsciiString((char*)SO->GetID().c_str()).ToCString(); + return TCollection_AsciiString((char*)SO->GetID().c_str()).ToCString(); } } } @@ -601,15 +606,15 @@ void GEOMBase_Helper::clearShapeBuffer( GEOM::GEOM_Object_ptr theObj ) if ( CORBA::is_nil( theObj ) ) return; - string IOR = SalomeApp_Application::orb()->object_to_string( theObj ); - TCollection_AsciiString asciiIOR( strdup( IOR.c_str() ) ); + CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj ); + TCollection_AsciiString asciiIOR( (char *)IOR.in() ); GEOM_Client().RemoveShapeFromBuffer( asciiIOR ); if ( !getStudy() || !getStudy()->studyDS() ) return; _PTR(Study) aStudy = getStudy()->studyDS(); - _PTR(SObject) aSObj ( aStudy->FindObjectIOR( IOR ) ); + _PTR(SObject) aSObj ( aStudy->FindObjectIOR( string( IOR ) ) ); if ( !aSObj ) return; @@ -758,13 +763,21 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction ) else { const int nbObjs = objects.size(); bool withChildren = false; + int aNumber = 1; for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) { if ( publish ) { - QString aName(""); - if ( nbObjs > 1 ) - aName = strlen( getNewObjectName() ) ? GEOMBase::GetDefaultName( getNewObjectName() ) : GEOMBase::GetDefaultName( getPrefix( *it ) ); - else { - aName = getNewObjectName(); + QString aName = getNewObjectName(); + if ( nbObjs > 1 ) { + if (aName.isEmpty()) + aName = getPrefix(*it); + if (nbObjs <= 30) { + // Try to find a unique name + aName = GEOMBase::GetDefaultName(aName); + } else { + // Don't check name uniqueness in case of numerous objects + aName = aName + "_" + QString::number(aNumber++); + } + } else { // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName() if ( aName.isEmpty() ) aName = GEOMBase::GetDefaultName( getPrefix( *it ) ); @@ -926,7 +939,7 @@ const SALOME_ListIO& GEOMBase_Helper::selectedIO() SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); if ( app ) { - SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr(); + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( aSelMgr ) aSelMgr->selectedObjects( mySelected ); }