fix #16 Units for Dimensions
This commit is contained in:
parent
5af541e340
commit
dc205d37fc
|
@ -37,6 +37,7 @@
|
|||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
|
||||
#include <Mod/Measure/App/Measurement.h>
|
||||
|
||||
|
@ -195,6 +196,7 @@ std::string DrawViewDimension::getFormatedValue() const
|
|||
{
|
||||
|
||||
QString str = QString::fromUtf8(FormatSpec.getStrValue().c_str());
|
||||
double val = std::abs(getDimValue());
|
||||
|
||||
QRegExp rx(QString::fromAscii("%(\\w+)%")); //any word bracketed by %
|
||||
QStringList list;
|
||||
|
@ -207,9 +209,14 @@ std::string DrawViewDimension::getFormatedValue() const
|
|||
|
||||
for(QStringList::const_iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if(*it == QString::fromAscii("%value%")){
|
||||
double val = std::abs(getDimValue());
|
||||
str.replace(*it, QString::number(val, 'f', Precision.getValue()) );
|
||||
} else { //insert new placeholder replacement logic here
|
||||
QString unitVal;
|
||||
if (Type.isValue("Angle")) {
|
||||
unitVal = Base::Quantity(val, Base::Unit::Angle).getUserString();
|
||||
} else {
|
||||
unitVal = Base::Quantity(val, Base::Unit::Length).getUserString();
|
||||
}
|
||||
str.replace(*it, unitVal);
|
||||
} else { //insert additional placeholder replacement logic here
|
||||
str.replace(*it, QString::fromAscii(""));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,9 +235,10 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
|||
}
|
||||
|
||||
std::string contentStr;
|
||||
if (dimType == "Angle") {
|
||||
contentStr = "%value%\x00b0";
|
||||
} else if (dimType == "Radius") {
|
||||
//if (dimType == "Angle") {
|
||||
// contentStr = "%value%\x00b0";
|
||||
//} else
|
||||
if (dimType == "Radius") {
|
||||
contentStr = "r%value%";
|
||||
}
|
||||
doCommand(Doc,"App.activeDocument().%s.FormatSpec = '%s'",FeatName.c_str()
|
||||
|
@ -803,9 +804,6 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
|
||||
,"Angle");
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.FormatSpec = '%s'",FeatName.c_str()
|
||||
,"%value%\u00b0"); // \u00b0 is degree sign
|
||||
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References2D.setValues(objs, subs);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user