Refactor all element name pairs into clearer struct names - renames
This commit is contained in:
@@ -9640,7 +9640,7 @@ const char *SketchObject::convertInternalName(const char *name)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::pair<std::string,std::string> SketchObject::getElementName(
|
||||
App::ElementNamePair SketchObject::getElementName(
|
||||
const char *name, ElementNameType type) const
|
||||
{
|
||||
// Todo: Toponaming Project March 2024: This method override breaks the sketcher - selection and deletion
|
||||
@@ -9650,7 +9650,7 @@ std::pair<std::string,std::string> SketchObject::getElementName(
|
||||
#ifndef FC_USE_TNP_FIX
|
||||
return Part2DObject::getElementName(name,type);
|
||||
#endif
|
||||
std::pair<std::string, std::string> ret;
|
||||
App::ElementNamePair ret;
|
||||
if(!name) return ret;
|
||||
|
||||
if(hasSketchMarker(name))
|
||||
@@ -9658,40 +9658,40 @@ std::pair<std::string,std::string> SketchObject::getElementName(
|
||||
|
||||
const char *mapped = Data::isMappedElement(name);
|
||||
Data::IndexedName index = checkSubName(name);
|
||||
index.appendToStringBuffer(ret.second);
|
||||
if (auto realName = convertInternalName(ret.second.c_str())) {
|
||||
index.appendToStringBuffer(ret.oldName);
|
||||
if (auto realName = convertInternalName(ret.oldName.c_str())) {
|
||||
Data::MappedElement mappedElement;
|
||||
(void)realName;
|
||||
// Todo: Do we need to add the InternalShape?
|
||||
// if (mapped)
|
||||
// mappedElement = InternalShape.getShape().getElementName(name);
|
||||
// else if (type == ElementNameType::Export)
|
||||
// ret.first = getExportElementName(InternalShape.getShape(), realName).first;
|
||||
// ret.newName = getExportElementName(InternalShape.getShape(), realName).first;
|
||||
// else
|
||||
// mappedElement = InternalShape.getShape().getElementName(realName);
|
||||
|
||||
if (mapped || type != ElementNameType::Export) {
|
||||
if (mappedElement.index) {
|
||||
ret.second = internalPrefix();
|
||||
mappedElement.index.appendToStringBuffer(ret.second);
|
||||
ret.oldName = internalPrefix();
|
||||
mappedElement.index.appendToStringBuffer(ret.oldName);
|
||||
}
|
||||
if (mappedElement.name) {
|
||||
ret.first = Data::ComplexGeoData::elementMapPrefix();
|
||||
mappedElement.name.appendToBuffer(ret.first);
|
||||
ret.newName = Data::ComplexGeoData::elementMapPrefix();
|
||||
mappedElement.name.appendToBuffer(ret.newName);
|
||||
}
|
||||
else if (mapped)
|
||||
ret.first = name;
|
||||
ret.newName = name;
|
||||
}
|
||||
|
||||
if (ret.first.size()) {
|
||||
if (auto dot = strrchr(ret.first.c_str(), '.'))
|
||||
ret.first.resize(dot+1-ret.first.c_str());
|
||||
if (ret.newName.size()) {
|
||||
if (auto dot = strrchr(ret.newName.c_str(), '.'))
|
||||
ret.newName.resize(dot+1-ret.newName.c_str());
|
||||
else
|
||||
ret.first += ".";
|
||||
ret.first += ret.second;
|
||||
ret.newName += ".";
|
||||
ret.newName += ret.oldName;
|
||||
}
|
||||
if (mapped && (!mappedElement.index || !mappedElement.name))
|
||||
ret.second.insert(0, Data::MISSING_PREFIX);
|
||||
ret.oldName.insert(0, Data::MISSING_PREFIX);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -9701,14 +9701,14 @@ std::pair<std::string,std::string> SketchObject::getElementName(
|
||||
return Part2DObject::getElementName(name,type);
|
||||
}
|
||||
if(index && type==ElementNameType::Export) {
|
||||
if(boost::starts_with(ret.second,"Vertex"))
|
||||
ret.second[0] = 'v';
|
||||
else if(boost::starts_with(ret.second,"Edge"))
|
||||
ret.second[0] = 'e';
|
||||
if(boost::starts_with(ret.oldName,"Vertex"))
|
||||
ret.oldName[0] = 'v';
|
||||
else if(boost::starts_with(ret.oldName,"Edge"))
|
||||
ret.oldName[0] = 'e';
|
||||
}
|
||||
ret.first = convertSubName(index, true);
|
||||
if(!Data::isMappedElement(ret.first.c_str()))
|
||||
ret.first.clear();
|
||||
ret.newName = convertSubName(index, true);
|
||||
if(!Data::isMappedElement(ret.newName.c_str()))
|
||||
ret.newName.clear();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user