[TD]fix dim text for multi value schemas
This commit is contained in:
@@ -515,13 +515,36 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
bool DrawViewDimension::isMultiValueSchema(void) const
|
||||
{
|
||||
bool result = false;
|
||||
bool angularMeasure = false;
|
||||
if ( (Type.isValue("Angle")) ||
|
||||
(Type.isValue("Angle3Pt")) ) {
|
||||
angularMeasure = true;
|
||||
}
|
||||
|
||||
Base::UnitSystem uniSys = Base::UnitsApi::getSchema();
|
||||
|
||||
if (((uniSys == Base::UnitSystem::Imperial1) ||
|
||||
(uniSys == Base::UnitSystem::ImperialBuilding) ) &&
|
||||
!angularMeasure) {
|
||||
result = true;
|
||||
} else if ((uniSys == Base::UnitSystem::ImperialCivil) &&
|
||||
angularMeasure) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string DrawViewDimension::getFormatedValue(int partial)
|
||||
{
|
||||
// Base::Console().Message("DVD::getFormatedValue()\n");
|
||||
// Base::Console().Message("DVD::getFormatedValue(%d)\n", partial);
|
||||
std::string result;
|
||||
if (Arbitrary.getValue()) {
|
||||
return FormatSpec.getStrValue();
|
||||
}
|
||||
bool multiValueSchema = false;
|
||||
|
||||
QString specStr = QString::fromUtf8(FormatSpec.getStrValue().data(),FormatSpec.getStrValue().size());
|
||||
QString specStrCopy = specStr;
|
||||
@@ -554,24 +577,32 @@ std::string DrawViewDimension::getFormatedValue(int partial)
|
||||
|
||||
//handle multi value schemes
|
||||
std::string pre = getPrefix();
|
||||
QString qMultiValueStr;
|
||||
QString qPre = QString::fromUtf8(pre.data(),pre.size());
|
||||
if (((uniSys == Base::UnitSystem::Imperial1) ||
|
||||
(uniSys == Base::UnitSystem::ImperialBuilding) ) &&
|
||||
!angularMeasure) {
|
||||
multiValueSchema = true;
|
||||
qMultiValueStr = userStr;
|
||||
specStr = userStr;
|
||||
if (!pre.empty()) {
|
||||
qMultiValueStr = qPre + userStr;
|
||||
specStr = qPre + userStr;
|
||||
}
|
||||
} else if ((uniSys == Base::UnitSystem::ImperialCivil) &&
|
||||
angularMeasure) {
|
||||
multiValueSchema = true;
|
||||
QString dispMinute = QString::fromUtf8("\'");
|
||||
QString dispSecond = QString::fromUtf8("\"");
|
||||
QString schemeMinute = QString::fromUtf8("M");
|
||||
QString schemeSecond = QString::fromUtf8("S");
|
||||
specStr = userStr.replace(schemeMinute,dispMinute);
|
||||
specStr = specStr.replace(schemeSecond,dispSecond);
|
||||
multiValueSchema = true;
|
||||
qMultiValueStr = specStr;
|
||||
if (!pre.empty()) {
|
||||
specStr = qPre + userStr;
|
||||
qMultiValueStr = qPre + specStr;
|
||||
specStr = qPre + specStr;
|
||||
}
|
||||
} else {
|
||||
//handle single value schemes
|
||||
@@ -646,6 +677,11 @@ std::string DrawViewDimension::getFormatedValue(int partial)
|
||||
std::string ssPrefix = Base::Tools::toStdString(formatPrefix);
|
||||
std::string ssSuffix = Base::Tools::toStdString(formatSuffix);
|
||||
result = specStr.toUtf8().constData();
|
||||
if (multiValueSchema) {
|
||||
result = ssPrefix +
|
||||
Base::Tools::toStdString(qMultiValueStr) +
|
||||
ssSuffix;
|
||||
}
|
||||
if (partial == 1) { //just the number (+prefix & suffix)
|
||||
// result = Base::Tools::toStdString(specVal);
|
||||
result = ssPrefix +
|
||||
|
||||
@@ -142,6 +142,8 @@ public:
|
||||
bool leaderIntersectsArc(Base::Vector3d s, Base::Vector3d pointOnCircle);
|
||||
bool references(std::string geomName) const;
|
||||
|
||||
bool isMultiValueSchema(void) const;
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
virtual void onDocumentRestored();
|
||||
|
||||
@@ -546,8 +546,12 @@ void QGIViewDimension::updateDim()
|
||||
if (dim->Arbitrary.getValue()) {
|
||||
labelText = QString::fromUtf8(dim->getFormatedValue(1).c_str()); //just the number pref/spec/suf
|
||||
} else {
|
||||
labelText = QString::fromUtf8(dim->getFormatedValue(1).c_str()); //just the number pref/spec/suf
|
||||
unitText = QString::fromUtf8(dim->getFormatedValue(2).c_str()); //just the unit
|
||||
if (dim->isMultiValueSchema()) {
|
||||
labelText = QString::fromUtf8(dim->getFormatedValue(0).c_str()); //don't format multis
|
||||
} else {
|
||||
labelText = QString::fromUtf8(dim->getFormatedValue(1).c_str()); //just the number pref/spec/suf
|
||||
unitText = QString::fromUtf8(dim->getFormatedValue(2).c_str()); //just the unit
|
||||
}
|
||||
}
|
||||
|
||||
QFont font = datumLabel->getFont();
|
||||
|
||||
Reference in New Issue
Block a user