[FC] Status bar preselection coordinates are aware of user unit setting ; fixes #4148
This commit is contained in:
@@ -79,6 +79,7 @@
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Document.h>
|
||||
@@ -479,14 +480,46 @@ bool SoFCUnifiedSelection::setHighlight(SoFullPath *path, const SoDetail *det,
|
||||
{
|
||||
const char *docname = vpd->getObject()->getDocument()->getName();
|
||||
const char *objname = vpd->getObject()->getNameInDocument();
|
||||
|
||||
|
||||
Base::Quantity mmx(Base::Quantity::MilliMetre);
|
||||
mmx.setValue(fabs(x)>1e-7?(double)x:0.0);
|
||||
Base::Quantity mmy(Base::Quantity::MilliMetre);
|
||||
mmy.setValue(fabs(y)>1e-7?(double)y:0.0);
|
||||
Base::Quantity mmz(Base::Quantity::MilliMetre);
|
||||
mmz.setValue(fabs(z)>1e-7?(double)z:0.0);
|
||||
|
||||
double xfactor, yfactor, zfactor, factor;
|
||||
QString xunit, yunit, zunit, unit;
|
||||
|
||||
QString xval = Base::UnitsApi::schemaTranslate(mmx, xfactor, xunit);
|
||||
QString yval = Base::UnitsApi::schemaTranslate(mmy, yfactor, yunit);
|
||||
QString zval = 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;
|
||||
}
|
||||
|
||||
float xuser = fabs(x)>1e-7 ? x / factor : 0.0;
|
||||
float yuser = fabs(y)>1e-7 ? y / factor : 0.0;
|
||||
float zuser = fabs(z)>1e-7 ? z / factor : 0.0;
|
||||
|
||||
this->preSelection = 1;
|
||||
static char buf[513];
|
||||
snprintf(buf,512,"Preselected: %s.%s.%s (%g, %g, %g)"
|
||||
snprintf(buf,512,"Preselected: %s.%s.%s (%f, %f, %f) %s"
|
||||
,docname,objname,element
|
||||
,fabs(x)>1e-7?x:0.0
|
||||
,fabs(y)>1e-7?y:0.0
|
||||
,fabs(z)>1e-7?z:0.0);
|
||||
,xuser,yuser,zuser,unit.toLatin1().data());
|
||||
|
||||
getMainWindow()->showMessage(QString::fromLatin1(buf));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user