0020632: EDF 1173 GEOM : Extrusion with multiple selection

Additional changes (to set object name in the dialog boxes properly)
This commit is contained in:
vsr 2010-02-18 11:02:56 +00:00
parent 2407281573
commit e1706ff05c
4 changed files with 32 additions and 4 deletions

View File

@ -806,7 +806,7 @@ bool GEOMBase::DefineDlgPosition(QWidget* aDlg, int& x, int& y)
// function : GetDefaultName() // function : GetDefaultName()
// purpose : Generates default names // purpose : Generates default names
//======================================================================= //=======================================================================
QString GEOMBase::GetDefaultName(const QString& theOperation) QString GEOMBase::GetDefaultName(const QString& theOperation, const bool extractPrefix)
{ {
QString aName = ""; QString aName = "";
@ -830,8 +830,23 @@ QString GEOMBase::GetDefaultName(const QString& theOperation)
// build a unique name // build a unique name
int aNumber = 0; int aNumber = 0;
bool isUnique = false; bool isUnique = false;
QString prefix = theOperation;
if ( extractPrefix ) {
QStringList parts = prefix.split( "_", QString::KeepEmptyParts );
if ( parts.count() > 1 ) {
bool ok;
aNumber = parts.last().toLong(&ok);
if ( ok ) {
parts.removeLast();
prefix = parts.join( "_" );
aNumber--;
}
}
}
while (!isUnique) { while (!isUnique) {
aName = theOperation + "_" + QString::number(++aNumber); aName = prefix + "_" + QString::number(++aNumber);
isUnique = (aSet.count(aName.toStdString()) == 0); isUnique = (aSet.count(aName.toStdString()) == 0);
} }

View File

@ -108,7 +108,8 @@ public :
static bool DefineDlgPosition(QWidget* aDlg, int& x, int& y); static bool DefineDlgPosition(QWidget* aDlg, int& x, int& y);
/* This method generates default names for results of geometrical operations */ /* This method generates default names for results of geometrical operations */
static QString GetDefaultName(const QString& theOperation); static QString GetDefaultName(const QString& theOperation, const bool extractPrefix = false);
/* Shows message box with error code and comment */ /* Shows message box with error code and comment */
static void ShowErrorMessage(const char* theErrorCode, const char* theComment = 0); static void ShowErrorMessage(const char* theErrorCode, const char* theComment = 0);

View File

@ -824,7 +824,7 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
aName = getPrefix(obj); aName = getPrefix(obj);
if (nbObjs <= 30) { if (nbObjs <= 30) {
// Try to find a unique name // Try to find a unique name
aName = GEOMBase::GetDefaultName(aName); aName = GEOMBase::GetDefaultName(aName, extractPrefix());
} else { } else {
// Don't check name uniqueness in case of numerous objects // Don't check name uniqueness in case of numerous objects
aName = aName + "_" + QString::number(aNumber++); aName = aName + "_" + QString::number(aNumber++);
@ -959,6 +959,17 @@ QString GEOMBase_Helper::getNewObjectName() const
return QString::null; return QString::null;
} }
//================================================================
// Function : extractPrefix
// Purpose : Redefine this method to return \c true if necessary
// to extract prefix when generating new name for the
// object(s) being created
//================================================================
bool GEOMBase_Helper::extractPrefix() const
{
return false;
}
//================================================================ //================================================================
// Function : getPrefix // Function : getPrefix
// Purpose : Get prefix for name of created object // Purpose : Get prefix for name of created object

View File

@ -161,6 +161,7 @@ protected:
// as a top-level object. // as a top-level object.
virtual QString getNewObjectName() const; virtual QString getNewObjectName() const;
virtual bool extractPrefix() const;
virtual void addSubshapesToStudy(); virtual void addSubshapesToStudy();
GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, const QString& theName ); GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, const QString& theName );