mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-18 10:50:37 +05:00
0020632: EDF 1173 GEOM : Extrusion with multiple selection
Additional changes (to set object name in the dialog boxes properly)
This commit is contained in:
parent
2407281573
commit
e1706ff05c
@ -806,7 +806,7 @@ bool GEOMBase::DefineDlgPosition(QWidget* aDlg, int& x, int& y)
|
||||
// function : GetDefaultName()
|
||||
// purpose : Generates default names
|
||||
//=======================================================================
|
||||
QString GEOMBase::GetDefaultName(const QString& theOperation)
|
||||
QString GEOMBase::GetDefaultName(const QString& theOperation, const bool extractPrefix)
|
||||
{
|
||||
QString aName = "";
|
||||
|
||||
@ -830,8 +830,23 @@ QString GEOMBase::GetDefaultName(const QString& theOperation)
|
||||
// build a unique name
|
||||
int aNumber = 0;
|
||||
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) {
|
||||
aName = theOperation + "_" + QString::number(++aNumber);
|
||||
aName = prefix + "_" + QString::number(++aNumber);
|
||||
isUnique = (aSet.count(aName.toStdString()) == 0);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,8 @@ public :
|
||||
static bool DefineDlgPosition(QWidget* aDlg, int& x, int& y);
|
||||
|
||||
/* 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 */
|
||||
static void ShowErrorMessage(const char* theErrorCode, const char* theComment = 0);
|
||||
|
||||
|
@ -824,7 +824,7 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction )
|
||||
aName = getPrefix(obj);
|
||||
if (nbObjs <= 30) {
|
||||
// Try to find a unique name
|
||||
aName = GEOMBase::GetDefaultName(aName);
|
||||
aName = GEOMBase::GetDefaultName(aName, extractPrefix());
|
||||
} else {
|
||||
// Don't check name uniqueness in case of numerous objects
|
||||
aName = aName + "_" + QString::number(aNumber++);
|
||||
@ -959,6 +959,17 @@ QString GEOMBase_Helper::getNewObjectName() const
|
||||
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
|
||||
// Purpose : Get prefix for name of created object
|
||||
|
@ -161,6 +161,7 @@ protected:
|
||||
// as a top-level object.
|
||||
|
||||
virtual QString getNewObjectName() const;
|
||||
virtual bool extractPrefix() const;
|
||||
virtual void addSubshapesToStudy();
|
||||
|
||||
GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, const QString& theName );
|
||||
|
Loading…
Reference in New Issue
Block a user