Use system Decimals, alternate or custom for Dimensions
- Also make Dimension arrowhead size adjustable
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Quantity.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
|
||||
#include <Mod/Measure/App/Measurement.h>
|
||||
@@ -96,14 +97,15 @@ DrawViewDimension::DrawViewDimension(void)
|
||||
ADD_PROPERTY_TYPE(References3D,(0,0),"",(App::PropertyType)(App::Prop_None),"3D Geometry References");
|
||||
ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),"Format",App::Prop_None, "The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(Fontsize,(fontSize) ,"Format",(App::PropertyType)(App::Prop_None),"Dimension text size in mm");
|
||||
ADD_PROPERTY_TYPE(FormatSpec,("%value%") ,"Format",(App::PropertyType)(App::Prop_None),"Dimension Format");
|
||||
ADD_PROPERTY_TYPE(FormatSpec,(getDefaultFormatSpec().c_str()) ,
|
||||
"Format",(App::PropertyType)(App::Prop_None),"Dimension Format");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(0.5) ,"Format",(App::PropertyType)(App::Prop_None),"Dimension line weight");
|
||||
//ADD_PROPERTY_TYPE(CentreLines,(0) ,"Format",(App::PropertyType)(App::Prop_None),"Arc Dimension Center Mark");
|
||||
|
||||
Type.setEnums(TypeEnums); //dimension type: length, radius etc
|
||||
ADD_PROPERTY(Type,((long)0));
|
||||
MeasureType.setEnums(MeasureTypeEnums);
|
||||
ADD_PROPERTY(MeasureType, ((long)0)); //True or Projected measurement
|
||||
ADD_PROPERTY(MeasureType, ((long)1)); //Projected (or True) measurement
|
||||
|
||||
|
||||
//hide the properties the user can't edit in the property editor
|
||||
@@ -193,7 +195,8 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
||||
|
||||
std::string DrawViewDimension::getFormatedValue()
|
||||
{
|
||||
QString str = QString::fromUtf8(FormatSpec.getStrValue().data(),FormatSpec.getStrValue().size());
|
||||
std::string result;
|
||||
QString specStr = QString::fromUtf8(FormatSpec.getStrValue().data(),FormatSpec.getStrValue().size());
|
||||
double val = std::abs(getDimValue());
|
||||
|
||||
Base::Quantity qVal;
|
||||
@@ -204,31 +207,50 @@ std::string DrawViewDimension::getFormatedValue()
|
||||
qVal.setUnit(Base::Unit::Length);
|
||||
}
|
||||
QString userStr = qVal.getUserString(); //this handles mm to inch/km/parsec etc and decimal positions
|
||||
QRegExp rx2(QString::fromUtf8("\\D*$"));
|
||||
QRegExp rxUnits(QString::fromUtf8("\\D*$")); //any non digits at end of string
|
||||
|
||||
QString userVal = userStr;
|
||||
userVal.remove(rx2);
|
||||
userVal.remove(rxUnits); //getUserString(defaultDecimals) without units
|
||||
|
||||
QRegExp rx(QString::fromUtf8("%(\\w+)%")); //any word bracketed by %
|
||||
QStringList list;
|
||||
QString userUnits;
|
||||
int pos = 0;
|
||||
if ((pos = rxUnits.indexIn(userStr, 0)) != -1) {
|
||||
userUnits = rxUnits.cap(0); //entire capture - non numerics at end of userString
|
||||
}
|
||||
|
||||
while ((pos = rx.indexIn(str, pos)) != -1) {
|
||||
list << rx.cap(0);
|
||||
pos += rx.matchedLength();
|
||||
std::string prefixSym = getPrefix(); //get Radius/Diameter/... symbol
|
||||
|
||||
//have dimensionVal, whole userString, val(userString), units(userString), prefixSymbol
|
||||
|
||||
//find the %x.y tag in FormatSpec
|
||||
QRegExp rxFormat(QString::fromUtf8("%[0-9]*\\.[0-9]*[aefgAEFG]")); //printf double format spec
|
||||
QString match;
|
||||
QString specVal = Base::Tools::fromStdString("%.2f"); //sensible default
|
||||
pos = 0;
|
||||
if ((pos = rxFormat.indexIn(specStr, 0)) != -1) {
|
||||
match = rxFormat.cap(0); //entire capture of rx
|
||||
QString qs2;
|
||||
specVal = qs2.sprintf(Base::Tools::toStdString(match).c_str(),val);
|
||||
}
|
||||
|
||||
QString repl = userVal;
|
||||
if (showUnits()) {
|
||||
repl = userStr;
|
||||
}
|
||||
|
||||
for(QStringList::const_iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if(*it == QString::fromUtf8("%value%")){
|
||||
str.replace(*it,repl);
|
||||
// } else { //insert additional placeholder replacement logic here
|
||||
if (useDecimals()) {
|
||||
if (showUnits()) {
|
||||
repl = userStr;
|
||||
} else {
|
||||
repl = userVal;
|
||||
}
|
||||
} else {
|
||||
if (showUnits()) {
|
||||
repl = specVal + userUnits;
|
||||
} else {
|
||||
repl = specVal;
|
||||
}
|
||||
}
|
||||
return str.toUtf8().constData();
|
||||
repl = Base::Tools::fromStdString(getPrefix()) + repl;
|
||||
specStr.replace(match,repl);
|
||||
|
||||
return specStr.toUtf8().constData();
|
||||
}
|
||||
|
||||
|
||||
@@ -251,26 +273,6 @@ double DrawViewDimension::getDimValue()
|
||||
return result;
|
||||
}
|
||||
|
||||
if(Type.isValue("Distance")) {
|
||||
result = measurement->delta().Length();
|
||||
} else if(Type.isValue("DistanceX")){
|
||||
Base::Vector3d delta = measurement->delta();
|
||||
result = delta.x;
|
||||
} else if(Type.isValue("DistanceY")){
|
||||
Base::Vector3d delta = measurement->delta();
|
||||
result = delta.y;
|
||||
} else if(Type.isValue("DistanceZ")){
|
||||
Base::Vector3d delta = measurement->delta();
|
||||
result = delta.z;
|
||||
} else if(Type.isValue("Radius")){
|
||||
result = measurement->radius();
|
||||
} else if(Type.isValue("Diameter")){
|
||||
result = measurement->radius() * 2.0;
|
||||
} else if(Type.isValue("Angle")){
|
||||
result = measurement->angle();
|
||||
} else {
|
||||
throw Base::Exception("getDimValue() - Unknown Dimension Type (1)");
|
||||
}
|
||||
} else {
|
||||
// Projected Values
|
||||
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
|
||||
@@ -667,6 +669,56 @@ bool DrawViewDimension::showUnits() const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DrawViewDimension::useDecimals() const
|
||||
{
|
||||
bool result = false;
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
result = hGrp->GetBool("UseGlobalDecimals", true);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string DrawViewDimension::getPrefix() const
|
||||
{
|
||||
std::string result = "";
|
||||
if(Type.isValue("Distance")) {
|
||||
result = "";
|
||||
} else if(Type.isValue("DistanceX")){
|
||||
result = "";
|
||||
} else if(Type.isValue("DistanceY")){
|
||||
result = "";
|
||||
} else if(Type.isValue("DistanceZ")){
|
||||
result = "";
|
||||
} else if(Type.isValue("Radius")){
|
||||
result = "R";
|
||||
} else if(Type.isValue("Diameter")){
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
std::string diamSym = hGrp->GetASCII("DiameterSymbol","\xe2\x8c\x80");
|
||||
result = diamSym;
|
||||
} else if(Type.isValue("Angle")){
|
||||
result = "";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string DrawViewDimension::getDefaultFormatSpec() const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
QString format1 = Base::Tools::fromStdString("%.");
|
||||
QString format2 = Base::Tools::fromStdString("f");
|
||||
int precision;
|
||||
if (useDecimals()) {
|
||||
precision = Base::UnitsApi::getDecimals();
|
||||
} else {
|
||||
precision = hGrp->GetInt("AltDecimals", 2);
|
||||
}
|
||||
QString formatPrecision = QString::number(precision);
|
||||
QString formatSpec = format1 + formatPrecision + format2;
|
||||
return Base::Tools::toStdString(formatSpec);
|
||||
}
|
||||
|
||||
PyObject *DrawViewDimension::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
|
||||
@@ -97,6 +97,9 @@ protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
virtual void onDocumentRestored();
|
||||
bool showUnits() const;
|
||||
bool useDecimals() const;
|
||||
std::string getPrefix() const;
|
||||
std::string getDefaultFormatSpec() const;
|
||||
|
||||
protected:
|
||||
Measure::Measurement *measurement;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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.);
|
||||
|
||||
Reference in New Issue
Block a user