diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index 3ad355525869..4a3433fd6565 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -845,7 +845,7 @@ int SelectionSingleton::setPreselect(const char* pDocName, const char* pObjectNa } namespace Gui { -std::array,3 > schemaTranslatePoint(double x, double y, double z, double precision) +std::array, 3> schemaTranslatePoint(double x, double y, double z, double precision) { Base::Quantity mmx(Base::Quantity::MilliMetre); mmx.setValue(fabs(x) > precision ? x : 0.0); @@ -854,33 +854,20 @@ std::array,3 > schemaTranslatePoint(double x, dou Base::Quantity mmz(Base::Quantity::MilliMetre); mmz.setValue(fabs(z) > precision ? z : 0.0); - double xfactor, yfactor, zfactor, factor; - QString xunit, yunit, zunit, unit; + double xfactor, yfactor, zfactor; + QString xunit, yunit, zunit; Base::UnitsApi::schemaTranslate(mmx, xfactor, xunit); Base::UnitsApi::schemaTranslate(mmy, yfactor, yunit); Base::UnitsApi::schemaTranslate(mmz, zfactor, zunit); - if (xfactor <= yfactor && xfactor <= zfactor) { - factor = xfactor; - unit = xunit; - } - else if (yfactor <= xfactor && yfactor <= zfactor) { - factor = yfactor; - unit = yunit; - } - else { - factor = zfactor; - unit = zunit; - } - - double xuser = fabs(x) > precision ? x / factor : 0.0; - double yuser = fabs(y) > precision ? y / factor : 0.0; - double zuser = fabs(z) > precision ? z / factor : 0.0; + double xuser = fabs(x) > precision ? x / xfactor : 0.0; + double yuser = fabs(y) > precision ? y / yfactor : 0.0; + double zuser = fabs(z) > precision ? z / zfactor : 0.0; - std::array, 3> ret = {std::make_pair(xuser, unit.toStdString()), - std::make_pair(yuser, unit.toStdString()), - std::make_pair(zuser, unit.toStdString())}; + std::array, 3> ret = {std::make_pair(xuser, xunit.toStdString()), + std::make_pair(yuser, yunit.toStdString()), + std::make_pair(zuser, zunit.toStdString())}; return ret; } } @@ -897,13 +884,13 @@ void SelectionSingleton::setPreselectCoord( float x, float y, float z) CurrentPreselection.z = z; auto pts = schemaTranslatePoint(x, y, z, 0.0); - snprintf(buf,512,"Preselected: %s.%s.%s (%f,%f,%f) %s",CurrentPreselection.pDocName - ,CurrentPreselection.pObjectName - ,CurrentPreselection.pSubName - ,pts[0].first - ,pts[1].first - ,pts[2].first - ,pts[0].second.c_str()); + snprintf(buf,512,"Preselected: %s.%s.%s (%f %s,%f %s,%f %s)" + ,CurrentPreselection.pDocName + ,CurrentPreselection.pObjectName + ,CurrentPreselection.pSubName + ,pts[0].first, pts[0].second.c_str() + ,pts[1].first, pts[1].second.c_str() + ,pts[2].first, pts[2].second.c_str()); if (getMainWindow()) getMainWindow()->showMessage(QString::fromLatin1(buf)); diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index 210b43295155..46fcca4e670e 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -407,14 +407,13 @@ SoFCSelection::handleEvent(SoHandleEventAction * action) const auto &pt = pp->getPoint(); auto pts = schemaTranslatePoint(pt[0], pt[1], pt[2], 1e-7); - snprintf(buf,512,"Preselected: %s.%s.%s (%f, %f, %f) %s" + snprintf(buf,512,"Preselected: %s.%s.%s (%f %s, %f %s, %f %s)" ,documentName.getValue().getString() ,objectName.getValue().getString() ,subElementName.getValue().getString() - ,pts[0].first - ,pts[1].first - ,pts[2].first - ,pts[0].second.c_str()); + ,pts[0].first, pts[0].second.c_str() + ,pts[1].first, pts[1].second.c_str() + ,pts[2].first, pts[2].second.c_str()); getMainWindow()->showMessage(QString::fromLatin1(buf)); } diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index 089da773f783..a098e6bc1aeb 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -488,9 +488,11 @@ bool SoFCUnifiedSelection::setHighlight(SoFullPath *path, const SoDetail *det, static char buf[513]; auto pts = schemaTranslatePoint(x, y, z, 1e-7); - snprintf(buf,512,"Preselected: %s.%s.%s (%f, %f, %f) %s" + snprintf(buf,512,"Preselected: %s.%s.%s (%f %s, %f %s, %f %s)" ,docname,objname,element - ,pts[0].first,pts[1].first,pts[2].first,pts[0].second.c_str()); + ,pts[0].first,pts[0].second.c_str() + ,pts[1].first,pts[1].second.c_str() + ,pts[2].first,pts[2].second.c_str()); getMainWindow()->showMessage(QString::fromLatin1(buf));