From: fps Date: Thu, 25 Apr 2013 14:44:51 +0000 (+0000) Subject: add virtual method getObjectName() to check if a GEOM_Object already has a name X-Git-Tag: siman1_BR_V7_main_Field~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f74d6b98cb75c178620269746c80fd5c04d49a42;p=modules%2Fgeom.git add virtual method getObjectName() to check if a GEOM_Object already has a name --- diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 8fea8899a..59d3f34c2 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -862,21 +862,24 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) { GEOM::GEOM_Object_var obj=*it; if ( publish ) { - QString aName = getNewObjectName(); - if ( nbObjs > 1 ) { - if (aName.isEmpty()) - aName = getPrefix(obj); - if (nbObjs <= 30) { - // Try to find a unique name - aName = GEOMBase::GetDefaultName(aName, extractPrefix()); + QString aName = getObjectName(obj); + if (aName.isEmpty()) { + aName = getNewObjectName(); + if ( nbObjs > 1 ) { + if (aName.isEmpty()) + aName = getPrefix(obj); + if (nbObjs <= 30) { + // Try to find a unique name + aName = GEOMBase::GetDefaultName(aName, extractPrefix()); + } else { + // Don't check name uniqueness in case of numerous objects + aName = aName + "_" + QString::number(aNumber++); + } } else { - // Don't check name uniqueness in case of numerous objects - aName = aName + "_" + QString::number(aNumber++); + // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName() + if ( aName.isEmpty() ) + aName = GEOMBase::GetDefaultName( getPrefix( obj ) ); } - } else { - // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName() - if ( aName.isEmpty() ) - aName = GEOMBase::GetDefaultName( getPrefix( obj ) ); } anEntryList << addInStudy( obj, aName.toLatin1().constData() ); // updateView=false @@ -1002,6 +1005,15 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::getFather( GEOM::GEOM_Object_ptr theObj ) return GEOM::GEOM_Object::_nil(); } +//================================================================ +// Function : getObjectName +// Purpose : Redefine this method to return proper name for the given object +//================================================================ +QString GEOMBase_Helper::getObjectName(GEOM::GEOM_Object_ptr object) const +{ + return QString::null; +} + //================================================================ // Function : getNewObjectName // Purpose : Redefine this method to return proper name for a new object diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index 5d32fd268..9737fa700 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -163,7 +163,8 @@ protected: // for or a nil reference if should be published // as a top-level object. - virtual QString getNewObjectName() const; + virtual QString getNewObjectName() const; + virtual QString getObjectName(GEOM::GEOM_Object_ptr object) const; virtual bool extractPrefix() const; virtual void addSubshapesToStudy();