diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index ba66c6ef22..94bdf9974f 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -716,6 +716,44 @@ std::array, 3> schemaTranslatePoint(double x, dou std::make_pair(zuser, zunit.toUtf8().constBegin())}; return ret; } + +QString getPreselectionInfo(const char* documentName, + const char* objectName, + const char* subElementName, + float x, float y, float z, + double precision) +{ + auto pts = schemaTranslatePoint(x, y, z, precision); + + int numberDecimals = std::min(6, Base::UnitsApi::getDecimals()); + + QString message = QStringLiteral("Preselected: %1.%2.%3 (%4 %5, %6 %7, %8 %9)") + .arg(QString::fromUtf8(documentName)) + .arg(QString::fromUtf8(objectName)) + .arg(QString::fromUtf8(subElementName)) + .arg(QString::number(pts[0].first, 'f', numberDecimals)) + .arg(QString::fromStdString(pts[0].second)) + .arg(QString::number(pts[1].first, 'f', numberDecimals)) + .arg(QString::fromStdString(pts[1].second)) + .arg(QString::number(pts[2].first, 'f', numberDecimals)) + .arg(QString::fromStdString(pts[2].second)); + return message; +} + +void printPreselectionInfo(const char* documentName, + const char* objectName, + const char* subElementName, + float x, float y, float z, + double precision) +{ + if (getMainWindow()) { + QString message = getPreselectionInfo(documentName, + objectName, + subElementName, + x, y, z, precision); + getMainWindow()->showMessage(message); + } +} } void SelectionSingleton::setPreselectCoord( float x, float y, float z) @@ -728,24 +766,10 @@ void SelectionSingleton::setPreselectCoord( float x, float y, float z) CurrentPreselection.y = y; CurrentPreselection.z = z; - if (getMainWindow()) { - auto pts = schemaTranslatePoint(x, y, z, 0.0); - - int numberDecimals = std::min(6, Base::UnitsApi::getDecimals()); - - QString message = QStringLiteral("Preselected: %1.%2.%3 (%4 %5, %6 %7, %8 %9)") - .arg(QString::fromUtf8(CurrentPreselection.pDocName)) - .arg(QString::fromUtf8(CurrentPreselection.pObjectName)) - .arg(QString::fromUtf8(CurrentPreselection.pSubName)) - .arg(QString::number(pts[0].first, 'f', numberDecimals)) - .arg(QString::fromStdString(pts[0].second)) - .arg(QString::number(pts[1].first, 'f', numberDecimals)) - .arg(QString::fromStdString(pts[1].second)) - .arg(QString::number(pts[2].first, 'f', numberDecimals)) - .arg(QString::fromStdString(pts[2].second)); - - getMainWindow()->showMessage(message); - } + printPreselectionInfo(CurrentPreselection.pDocName, + CurrentPreselection.pObjectName, + CurrentPreselection.pSubName, + x, y, z, 0.0); } void SelectionSingleton::rmvPreselect(bool signal) diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index e5e511e648..5317a4b50f 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -55,7 +55,11 @@ using namespace Gui; namespace Gui { -std::array,3 > schemaTranslatePoint(double x, double y, double z, double precision); +void printPreselectionInfo(const char* documentName, + const char* objectName, + const char* subElementName, + float x, float y, float z, + double precision); } SoFullPath * Gui::SoFCSelection::currenthighlight = nullptr; @@ -384,22 +388,10 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) const auto &pt = pp->getPoint(); - auto pts = schemaTranslatePoint(pt[0], pt[1], pt[2], 1e-7); - - int numberDecimals = std::min(6, Base::UnitsApi::getDecimals()); - - QString message = QStringLiteral("Preselected: %1.%2.%3 (%4 %5, %6 %7, %8 %9)") - .arg(QString::fromUtf8(documentName.getValue().getString())) - .arg(QString::fromUtf8(objectName.getValue().getString())) - .arg(QString::fromUtf8(subElementName.getValue().getString())) - .arg(QString::number(pts[0].first, 'f', numberDecimals)) - .arg(QString::fromStdString(pts[0].second)) - .arg(QString::number(pts[1].first, 'f', numberDecimals)) - .arg(QString::fromStdString(pts[1].second)) - .arg(QString::number(pts[2].first, 'f', numberDecimals)) - .arg(QString::fromStdString(pts[2].second)); - - getMainWindow()->showMessage(message); + printPreselectionInfo(documentName.getValue().getString(), + objectName.getValue().getString(), + subElementName.getValue().getString(), + pt[0], pt[1], pt[2], 1e-7); } else { // picked point if (highlighted) { diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index 0a95d96dc3..0b71cc8a39 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -91,7 +91,11 @@ FC_LOG_LEVEL_INIT("SoFCUnifiedSelection",false,true,true) using namespace Gui; namespace Gui { -std::array,3 > schemaTranslatePoint(double x, double y, double z, double precision); +void printPreselectionInfo(const char* documentName, + const char* objectName, + const char* subElementName, + float x, float y, float z, + double precision); } SoFullPath * Gui::SoFCUnifiedSelection::currenthighlight = nullptr; @@ -496,22 +500,7 @@ bool SoFCUnifiedSelection::setHighlight(SoFullPath *path, const SoDetail *det, this->preSelection = 1; - auto pts = schemaTranslatePoint(x, y, z, 1e-7); - - int numberDecimals = std::min(6, Base::UnitsApi::getDecimals()); - - QString message = QStringLiteral("Preselected: %1.%2.%3 (%4 %5, %6 %7, %8 %9)") - .arg(QString::fromUtf8(docname)) - .arg(QString::fromUtf8(objname)) - .arg(QString::fromUtf8(element)) - .arg(QString::number(pts[0].first, 'f', numberDecimals)) - .arg(QString::fromStdString(pts[0].second)) - .arg(QString::number(pts[1].first, 'f', numberDecimals)) - .arg(QString::fromStdString(pts[1].second)) - .arg(QString::number(pts[2].first, 'f', numberDecimals)) - .arg(QString::fromStdString(pts[2].second)); - - getMainWindow()->showMessage(message); + printPreselectionInfo(docname, objname, element, x, y, z, 1e-7); int ret = Gui::Selection().setPreselect(docname,objname,element,x,y,z);