-// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <Events_InfoMessage.h>
#include <GeomAPI_Shape.h>
-#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAPI_IndexedMapOfShape.h>
#include <TopoDS_Shape.hxx>
return true;
}
+//******************************************************************
+bool isValidName(const QString& theName)
+{
+ QChar aChar;
+ for (int i = 0; i < theName.size(); i++) {
+ aChar = theName[i];
+ if (!aChar.isLetterOrNumber()) {
+ if ((aChar != "_") && (!aChar.isSpace()))
+ return false;
+ }
+ }
+ return true;
+}
+
//******************************************************************
bool canRename(const ObjectPtr& theObject, const QString& theName)
{
double aValue;
ResultParameterPtr aParam;
if (ModelAPI_Tools::findVariable(theObject->document(),
- FeaturePtr(), qPrintable(theName), aValue, aParam)) {
+ FeaturePtr(), theName.toStdWString(), aValue, aParam)) {
const char* aKeyStr = "Selected parameter can not be renamed to: %1. "
"There is a parameter with the same name. Its value is: %2.";
QString aErrMsg(QObject::tr(aKeyStr).arg(theName).arg(aValue));
}
}
else {
+ if (!isValidName(theName))
+ return false;
+
DocumentPtr aDoc = theObject->document();
ObjectPtr aObj =
aDoc->objectByName(aType, theName.toStdWString());
aTypeName = "shape";
break;
}
- int aId = GeomAlgoAPI_CompoundBuilder::id(aContext, aSubShape);
+ GeomAPI_IndexedMapOfShape aSubShapesMap (aContext);
+ int aId = aSubShapesMap.FindIndexEqualLocations(aSubShape);
aName += QString("/%1_%2").arg(aTypeName).arg(aId);
}
}