diff --git a/src/App/GeoFeature.cpp b/src/App/GeoFeature.cpp index 98e627f7c0..d87f405ceb 100644 --- a/src/App/GeoFeature.cpp +++ b/src/App/GeoFeature.cpp @@ -134,7 +134,7 @@ ElementNamePair GeoFeature::_getElementName(const char* name, } } -DocumentObject* GeoFeature::resolveElement(DocumentObject* obj, +DocumentObject* GeoFeature::resolveElement(const DocumentObject* obj, const char* subname, ElementNamePair& elementName, bool append, diff --git a/src/App/GeoFeature.h b/src/App/GeoFeature.h index 7288a5f3bd..cb4dcfbd66 100644 --- a/src/App/GeoFeature.h +++ b/src/App/GeoFeature.h @@ -104,7 +104,7 @@ public: * * @return Return the owner object of the element */ - static DocumentObject* resolveElement(App::DocumentObject* obj, + static DocumentObject* resolveElement(const App::DocumentObject* obj, const char* subname, ElementNamePair& elementName, bool append = false, diff --git a/src/Mod/Part/Gui/TaskAttacher.cpp b/src/Mod/Part/Gui/TaskAttacher.cpp index 547ff84d25..eb0ae41413 100644 --- a/src/Mod/Part/Gui/TaskAttacher.cpp +++ b/src/Mod/Part/Gui/TaskAttacher.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -63,32 +64,22 @@ namespace sp = std::placeholders; // Create reference name from PropertyLinkSub values in a translatable fashion const QString makeRefString(const App::DocumentObject* obj, const std::string& sub) { - if (!obj) + if (!obj) { return QObject::tr("No reference selected"); + } - if (obj->isDerivedFrom() || - obj->isDerivedFrom()) - // App::Plane, Line or Datum feature + if (obj->isDerivedFrom() || obj->isDerivedFrom()) { return QString::fromLatin1(obj->getNameInDocument()); + } - if ((sub.size() > 4) && (sub.substr(0, 4) == "Face")) { - int subId = std::atoi(&sub[4]); - return QString::fromLatin1(obj->getNameInDocument()) + QString::fromLatin1(":") + QObject::tr("Face") + QString::number(subId); - } - else if ((sub.size() > 4) && (sub.substr(0, 4) == "Edge")) { - int subId = std::atoi(&sub[4]); - return QString::fromLatin1(obj->getNameInDocument()) + QString::fromLatin1(":") + QObject::tr("Edge") + QString::number(subId); - } - else if ((sub.size() > 6) && (sub.substr(0, 6) == "Vertex")) { - int subId = std::atoi(&sub[6]); - return QString::fromLatin1(obj->getNameInDocument()) + QString::fromLatin1(":") + QObject::tr("Vertex") + QString::number(subId); - } - else { - //something else that face/edge/vertex. Can be empty string. - return QString::fromLatin1(obj->getNameInDocument()) - + (sub.length() > 0 ? QString::fromLatin1(":") : QString()) - + QString::fromLatin1(sub.c_str()); - } + // Hide the TNP string from the user. ie show "Body.Pad.Face6" and not : + // "Body.Pad.;#a:1;:G0;XTR;:Hc94:8,F.Face6" + App::ElementNamePair el; + App::GeoFeature::resolveElement(obj, sub.c_str(), el, true); + + return QString::fromLatin1(obj->getNameInDocument()) + + (sub.length() > 0 ? QString::fromLatin1(":") : QString()) + + QString::fromLatin1(el.oldName.c_str()); } void TaskAttacher::makeRefStrings(std::vector& refstrings, std::vector& refnames) {