Use system Decimals, alternate or custom for Dimensions

- Also make Dimension arrowhead size adjustable
This commit is contained in:
WandererFan
2017-09-07 16:31:00 -04:00
committed by wmayer
parent fc6f8a91ce
commit c0cddda862
8 changed files with 273 additions and 173 deletions

View File

@@ -202,20 +202,12 @@ void CmdTechDrawNewDimension::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,dimType.c_str());
std::string contentStr;
if (dimType == "Radius") {
contentStr = "R%value%";
}
doCommand(Doc,"App.activeDocument().%s.FormatSpec = '%s'",FeatName.c_str()
,contentStr.c_str());
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
throw Base::Exception("CmdTechDrawNewDimension - dim not found\n");
}
dim->References2D.setValues(objs, subs);
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
commitCommand();
@@ -295,7 +287,6 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"Radius");
doCommand(Doc, "App.activeDocument().%s.FormatSpec = 'R%%value%%'", FeatName.c_str());
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
@@ -303,7 +294,6 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
}
dim->References2D.setValues(objs, subs);
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
commitCommand();
@@ -380,20 +370,10 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
return;
}
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
std::string diamSym = hGrp->GetASCII("DiameterSymbol","\xe2\x8c\x80");
diamSym = diamSym.substr (0,79); //coverity 156593
const char * format = "%value%";
char formatSpec[80];
std::strcpy (formatSpec,diamSym.c_str());
std::strcat (formatSpec,format);
openCommand("Create Dimension");
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"Diameter");
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%s'", FeatName.c_str(),formatSpec);
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
if (!dim) {
@@ -401,7 +381,6 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
}
dim->References2D.setValues(objs, subs);
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
commitCommand();
@@ -510,9 +489,6 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
}
dim->References2D.setValues(objs, subs);
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
commitCommand();
@@ -621,9 +597,6 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
}
dim->References2D.setValues(objs, subs);
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
commitCommand();
@@ -731,9 +704,6 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
}
dim->References2D.setValues(objs, subs);
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
commitCommand();
@@ -821,7 +791,6 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
}
dim->References2D.setValues(objs, subs);
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
commitCommand();

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>521</width>
<height>463</height>
<height>554</height>
</rect>
</property>
<property name="windowTitle">
@@ -21,7 +21,30 @@
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout" columnstretch="1,2,1">
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0">
<item row="6" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Arrow Style</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::PrefSpinBox" name="sbAltDecimals">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<number>2</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>AltDecimals</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="cbShowUnits">
<property name="text">
@@ -35,21 +58,21 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Font Size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="3" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -62,7 +85,7 @@
</property>
</spacer>
</item>
<item row="1" column="2">
<item row="3" column="2">
<widget class="Gui::PrefDoubleSpinBox" name="dsbFontSize">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -81,7 +104,7 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="4" column="2">
<widget class="Gui::PrefColorButton" name="colDimColor">
<property name="color">
<color>
@@ -98,14 +121,14 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Diameter Symbol</string>
</property>
</widget>
</item>
<item row="3" column="2">
<item row="5" column="2">
<widget class="Gui::PrefLineEdit" name="leDiameter">
<property name="font">
<font>
@@ -126,6 +149,121 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Alternate Decimals</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="cbGlobalDecimals">
<property name="text">
<string>Use Global Decimals</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseGlobalDecimals</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="Gui::PrefComboBox" name="pcbArrow">
<property name="toolTip">
<string>Preferred arrowhead style</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="maxVisibleItems">
<number>5</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>ArrowStyle</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
<item>
<property name="text">
<string>0 - Filled Triangle</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowfilled.svg</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>1 - Open Arrowhead</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowopen.svg</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>2 - Tick</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowtick.svg</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>3 - Dot</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowdot.svg</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>4 - Open Circle</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowopendot.svg</normalon>
</iconset>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Arrow Size</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="Gui::PrefDoubleSpinBox" name="dsbArrowSize">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<double>5.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>ArrowSize</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
@@ -151,7 +289,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,2,1">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,0">
<item row="0" column="2">
<widget class="Gui::PrefComboBox" name="pcbMatting">
<property name="prefEntry" stdset="0">
@@ -341,82 +479,6 @@
</spacer>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Arrow Style</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="Gui::PrefComboBox" name="pcbArrow">
<property name="toolTip">
<string>Preferred arrowhead style</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="maxVisibleItems">
<number>5</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>ArrowStyle</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
<item>
<property name="text">
<string>0 - Filled Triangle</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowfilled.svg</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>1 - Open Arrowhead</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowopen.svg</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>2 - Tick</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowtick.svg</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>3 - Dot</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowdot.svg</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>4 - Open Circle</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowopendot.svg</normalon>
</iconset>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_10">
<property name="toolTip">
<string>Default weight for GeomHatch lines</string>
@@ -426,7 +488,7 @@
</property>
</widget>
</item>
<item row="6" column="2">
<item row="5" column="2">
<widget class="Gui::PrefDoubleSpinBox" name="doubleSpinBox">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -460,19 +522,6 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
@@ -481,6 +530,11 @@
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefSpinBox</class>
<extends>QSpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefColorButton</class>
<extends>Gui::ColorButton</extends>

View File

@@ -53,6 +53,9 @@ void DlgPrefsTechDraw2Imp::saveSettings()
pcbSectionStyle->onSave();
colSectionLine->onSave();
pcbArrow->onSave();
cbGlobalDecimals->onSave();
sbAltDecimals->onSave();
dsbArrowSize->onSave();
}
void DlgPrefsTechDraw2Imp::loadSettings()
@@ -67,6 +70,9 @@ void DlgPrefsTechDraw2Imp::loadSettings()
pcbSectionStyle->onRestore();
colSectionLine->onRestore();
pcbArrow->onRestore();
cbGlobalDecimals->onRestore();
sbAltDecimals->onRestore();
dsbArrowSize->onRestore();
}
/**

View File

@@ -154,11 +154,21 @@ QPainterPath QGIArrow::makeOpenDot(double length, double width, bool flipped)
int QGIArrow::getPrefArrowStyle()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
int style = hGrp->GetInt("ArrowStyle", 0);
return style;
}
double QGIArrow::getPrefArrowSize()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
double style = hGrp->GetFloat("ArrowSize", 5.0);
return style;
}
void QGIArrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QStyleOptionGraphicsItem myOption(*option);

View File

@@ -50,6 +50,7 @@ public:
int getStyle() { return m_style; }
void setStyle(int s) { m_style = s; }
static int getPrefArrowStyle();
static double getPrefArrowSize();
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );

View File

@@ -612,9 +612,11 @@ void QGIViewDimension::draw()
datumLabel->setRotation((angle * 180 / M_PI) + angleOption);
aHead1->setStyle(QGIArrow::getPrefArrowStyle());
aHead1->setSize(QGIArrow::getPrefArrowSize());
aHead1->draw();
aHead2->flip(true);
aHead2->setStyle(QGIArrow::getPrefArrowStyle());
aHead2->setSize(QGIArrow::getPrefArrowSize());
aHead2->draw();
angle = atan2f(dir.y,dir.x);
float arrowAngle = angle * 180 / M_PI;
@@ -827,12 +829,12 @@ void QGIViewDimension::draw()
path.lineTo(arrow2Tip.x, arrow2Tip.y);
}
aHead1->setStyle(QGIArrow::getPrefArrowStyle());
aHead1->setSize(QGIArrow::getPrefArrowSize());
aHead1->draw();
aHead2->flip(true);
aHead2->setStyle(QGIArrow::getPrefArrowStyle());
aHead2->setSize(QGIArrow::getPrefArrowSize());
aHead2->draw();
float arAngle = atan2(dirDimLine.y, dirDimLine.x) * 180 / M_PI;
@@ -1062,6 +1064,7 @@ void QGIViewDimension::draw()
dimLines->setPath(dLinePath);
aHead1->setStyle(QGIArrow::getPrefArrowStyle());
aHead1->setSize(QGIArrow::getPrefArrowSize());
aHead1->draw();
Base::Vector3d ar1Pos = pointOnCurve;
@@ -1259,8 +1262,10 @@ void QGIViewDimension::draw()
aHead1->flip(true);
aHead1->setStyle(QGIArrow::getPrefArrowStyle());
aHead1->setSize(QGIArrow::getPrefArrowSize());
aHead1->draw();
aHead2->setStyle(QGIArrow::getPrefArrowStyle());
aHead2->setSize(QGIArrow::getPrefArrowSize());
aHead2->draw();
Base::Vector3d norm1 = p1-p0; //(-dir1.y, dir1.x, 0.);