Skip to content

Commit

Permalink
Diameter symbol & text orientation to standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan authored and wwmayer committed Aug 12, 2016
1 parent 3eb9037 commit ef69519
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/Mod/TechDraw/App/DrawViewDimension.cpp
Expand Up @@ -198,7 +198,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)

std::string DrawViewDimension::getFormatedValue() const
{
QString str = QString::fromUtf8(FormatSpec.getStrValue().c_str());
QString str = QString::fromUtf8(FormatSpec.getStrValue().data(),FormatSpec.getStrValue().size());
double val = std::abs(getDimValue());

Base::Quantity qVal;
Expand All @@ -210,7 +210,7 @@ std::string DrawViewDimension::getFormatedValue() const
}
QString userStr = qVal.getUserString();

QRegExp rx(QString::fromAscii("%(\\w+)%")); //any word bracketed by %
QRegExp rx(QString::fromUtf8("%(\\w+)%")); //any word bracketed by %
QStringList list;
int pos = 0;

Expand All @@ -220,12 +220,12 @@ std::string DrawViewDimension::getFormatedValue() const
}

for(QStringList::const_iterator it = list.begin(); it != list.end(); ++it) {
if(*it == QString::fromAscii("%value%")){
if(*it == QString::fromUtf8("%value%")){
str.replace(*it,userStr);
// } else { //insert additional placeholder replacement logic here
}
}
return str.toStdString();
return str.toUtf8().constData();
}

double DrawViewDimension::getDimValue() const
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/TechDraw/Gui/CommandCreateDims.cpp
Expand Up @@ -237,7 +237,7 @@ void CmdTechDrawNewDimension::activated(int iMsg)

std::string contentStr;
if (dimType == "Radius") {
contentStr = "r%value%";
contentStr = "R%value%";
}
doCommand(Doc,"App.activeDocument().%s.FormatSpec = '%s'",FeatName.c_str()
,contentStr.c_str());
Expand Down Expand Up @@ -332,7 +332,7 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.CentreLines = False", FeatName.c_str());
}

doCommand(Doc, "App.activeDocument().%s.FormatSpec = 'r%%value%%'", FeatName.c_str());
doCommand(Doc, "App.activeDocument().%s.FormatSpec = 'R%%value%%'", FeatName.c_str());

dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
dim->References2D.setValues(objs, subs);
Expand Down Expand Up @@ -425,7 +425,7 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.CentreLines = False", FeatName.c_str());
}

doCommand(Doc, "App.activeDocument().%s.FormatSpec = '\u00d8%%value%%'", FeatName.c_str()); // \u00d8 is Capital O with stroke
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '\u2300%%value%%'", FeatName.c_str());

dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
dim->References2D.setValues(objs, subs);
Expand Down
10 changes: 6 additions & 4 deletions src/Mod/TechDraw/Gui/QGIViewDimension.cpp
Expand Up @@ -240,11 +240,10 @@ void QGIViewDimension::updateDim()
return;

const TechDraw::DrawViewDimension *dim = dynamic_cast<TechDraw::DrawViewDimension *>(getViewObject());
QString labelText = QString::fromStdString(dim->getFormatedValue());

QString labelText = QString::fromUtf8(dim->getFormatedValue().data(),dim->getFormatedValue().size());
QFont font = datumLabel->font();
font.setPointSizeF(dim->Fontsize.getValue()); //scene units (mm), not points
font.setFamily(QString::fromAscii(dim->Font.getValue()));
font.setFamily(QString::fromUtf8(dim->Font.getValue()));

datumLabel->setPlainText(labelText);
datumLabel->setFont(font);
Expand Down Expand Up @@ -411,7 +410,10 @@ void QGIViewDimension::draw()

// Get magnitude of angle between dir and horizontal
float angle = atan2f(dir.y,dir.x);
if (angle > M_PI_2+M_PI/12) {
//Vertical text should be legible from the right
if (std::abs(angle + M_PI/2.0) < FLT_EPSILON) {
//noop
} else if (angle > M_PI_2+M_PI/12) { //keeps some diagonal dims from turning upside down?
angle -= (float)M_PI;
} else if (angle <= -M_PI_2+M_PI/12) {
angle += (float)M_PI;
Expand Down

0 comments on commit ef69519

Please sign in to comment.