Status bar message : reduce number of decimals to use system preference.

This commit is contained in:
Paddle
2023-11-19 21:50:33 +01:00
committed by Chris Hennes
parent cce89e4fec
commit ec305a93e0
3 changed files with 49 additions and 27 deletions

View File

@@ -720,8 +720,6 @@ std::array<std::pair<double, std::string>, 3> schemaTranslatePoint(double x, dou
void SelectionSingleton::setPreselectCoord( float x, float y, float z)
{
static char buf[513];
// if nothing is in preselect ignore
if(CurrentPreselection.Object.getObjectName().empty())
return;
@@ -730,17 +728,24 @@ void SelectionSingleton::setPreselectCoord( float x, float y, float z)
CurrentPreselection.y = y;
CurrentPreselection.z = z;
auto pts = schemaTranslatePoint(x, y, z, 0.0);
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()) {
auto pts = schemaTranslatePoint(x, y, z, 0.0);
if (getMainWindow())
getMainWindow()->showMessage(QString::fromUtf8(buf));
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);
}
}
void SelectionSingleton::rmvPreselect(bool signal)

View File

@@ -40,6 +40,8 @@
# include <Inventor/misc/SoState.h>
#endif
#include <Base/UnitsApi.h>
#include "SoFCSelection.h"
#include "MainWindow.h"
#include "SoFCSelectionAction.h"
@@ -383,15 +385,21 @@ 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 %s, %f %s, %f %s)"
,documentName.getValue().getString()
,objectName.getValue().getString()
,subElementName.getValue().getString()
,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::fromUtf8(buf));
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);
}
else { // picked point
if (highlighted) {

View File

@@ -73,6 +73,7 @@
#include <App/Document.h>
#include <App/ElementNamingUtils.h>
#include <Base/Tools.h>
#include <Base/UnitsApi.h>
#include "SoFCUnifiedSelection.h"
#include "Application.h"
@@ -494,16 +495,24 @@ bool SoFCUnifiedSelection::setHighlight(SoFullPath *path, const SoDetail *det,
const char *objname = vpd->getObject()->getNameInDocument();
this->preSelection = 1;
static char buf[513];
auto pts = schemaTranslatePoint(x, y, z, 1e-7);
snprintf(buf,512,"Preselected: %s.%s.%s (%f %s, %f %s, %f %s)"
,docname,objname,element
,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::fromUtf8(buf));
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);
int ret = Gui::Selection().setPreselect(docname,objname,element,x,y,z);
if(ret<0 && currenthighlight)