[TD]adjustable extension line gap

This commit is contained in:
Wanderer Fan
2022-04-25 12:32:50 -04:00
committed by WandererFan
parent f18ef718ad
commit fe47248dea
8 changed files with 307 additions and 181 deletions

View File

@@ -319,3 +319,21 @@ std::string Preferences::bitmapFill(void)
}
return result;
}
double Preferences::ISOGap()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Dimensions");
double factor = hGrp->GetFloat("ISOGap", 8.0);
return factor;
}
double Preferences::ASMEGap()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Dimensions");
double factor = hGrp->GetFloat("ASMEGap", 6.0);
return factor;
}

View File

@@ -73,7 +73,12 @@ static int mattingStyle();
static std::string svgFile();
static std::string patFile();
static std::string bitmapFill(void);
static double ISOGap();
static double ASMEGap();
};
} //end namespace TechDraw

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>440</width>
<height>380</height>
<height>498</height>
</rect>
</property>
<property name="sizePolicy">
@@ -46,21 +46,81 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_16">
<item row="8" column="2">
<widget class="Gui::PrefUnitSpinBox" name="plsb_ArrowSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Arrowhead size</string>
</property>
<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>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Standard and Style</string>
<string>Dimension Format</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="Gui::PrefComboBox" name="pcbArrow">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Arrowhead style</string>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>ArrowStyle</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Diameter Symbol</string>
</property>
</widget>
</item>
@@ -109,33 +169,15 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="cbGlobalDecimals">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Use system setting for number of decimals</string>
</property>
<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>
<string>Font Size</string>
</property>
</widget>
</item>
@@ -167,100 +209,24 @@
</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="2" column="2">
<widget class="Gui::PrefSpinBox" name="sbAltDecimals">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_16">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Number of decimals if 'Use Global Decimals' is not used</string>
</property>
<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="3" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Dimension Format</string>
<string>Standard and Style</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="Gui::PrefLineEdit" name="leFormatSpec">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Leave blank for automatic dimension format. Use %f, %g or %w specifiers to override.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="prefEntry" stdset="0">
<cstring>formatSpec</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Font Size</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="2">
<widget class="Gui::PrefUnitSpinBox" name="plsb_FontSize">
<property name="sizePolicy">
@@ -292,27 +258,27 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lbl_LabelFont">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<item row="8" column="0">
<widget class="QLabel" name="label_12">
<property name="font">
<font>
<italic>false</italic>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Tolerance Text Scale</string>
<string>Arrow Size</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Arrow Style</string>
</property>
</widget>
</item>
@@ -360,10 +326,61 @@ Multiplier of 'Font Size'</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_8">
<item row="5" column="0">
<widget class="QLabel" name="lbl_LabelFont">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Diameter Symbol</string>
<string>Tolerance Text Scale</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::PrefSpinBox" name="sbAltDecimals">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Number of decimals if 'Use Global Decimals' is not used</string>
</property>
<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>
@@ -403,90 +420,141 @@ Multiplier of 'Font Size'</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Arrow Style</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="Gui::PrefComboBox" name="pcbArrow">
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="cbGlobalDecimals">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Arrowhead style</string>
<string>Use system setting for number of decimals</string>
</property>
<property name="currentIndex">
<number>-1</number>
<property name="text">
<string>Use Global Decimals</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ArrowStyle</cstring>
<cstring>UseGlobalDecimals</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
<cstring>/Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_12">
<item row="4" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Alternate Decimals</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Controls the size of gap between dimension point and start of extension line for ISO dimensions.</string>
</property>
<property name="text">
<string>Arrow Size</string>
<string>Extension Gap Factor - ISO</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="Gui::PrefUnitSpinBox" name="plsb_ArrowSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="3" column="2">
<widget class="Gui::PrefLineEdit" name="leFormatSpec">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Leave blank for automatic dimension format. Use %f, %g or %w specifiers to override.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="prefEntry" stdset="0">
<cstring>formatSpec</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Arrowhead size</string>
<string>Controls the size of gap between dimension point and start of extension line for ASME dimensions.</string>
</property>
<property name="text">
<string>Extension Gap Factor - ASME</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="Gui::PrefDoubleSpinBox" name="pdsbISOGap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Controls the size of gap between dimension point and start of extension line for ISO dimensions. Value * linewidth is the gap.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<double>5.000000000000000</double>
<double>8.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>ArrowSize</cstring>
<cstring>GapISO</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
</layout>
<item row="10" column="2">
<widget class="Gui::PrefDoubleSpinBox" name="pdsbASMEGap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Controls the size of gap between dimension point and start of extension line for ASME dimensions. Value * linewidth is the gap.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<double>6.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>GapASME</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@@ -500,7 +568,7 @@ Multiplier of 'Font Size'</string>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=" font-weight:600;"&gt;Note:&lt;/span&gt; Items in &lt;span style=" font-style:italic;"&gt;italics&lt;/span&gt; are default values for new objects. They have no effect on existing objects.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; Items in &lt;span style=&quot; font-style:italic;&quot;&gt;italics&lt;/span&gt; are default values for new objects. They have no effect on existing objects.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>

View File

@@ -69,6 +69,8 @@ void DlgPrefsTechDrawDimensionsImp::saveSettings()
ui->pcbArrow->onSave();
ui->plsb_ArrowSize->onSave();
ui->leFormatSpec->onSave();
ui->pdsbISOGap->onSave();
ui->pdsbASMEGap->onSave();
}
void DlgPrefsTechDrawDimensionsImp::loadSettings()
@@ -97,6 +99,9 @@ void DlgPrefsTechDrawDimensionsImp::loadSettings()
ui->leFormatSpec->setText(Base::Tools::fromStdString(Preferences::formatSpec()));
ui->leFormatSpec->onRestore();
ui->pdsbISOGap->onRestore();
ui->pdsbASMEGap->onRestore();
}
/**

View File

@@ -1567,11 +1567,20 @@ void QGIViewDimension::drawDistanceExecutive(const Base::Vector2d &startPoint, c
arrowCount = 0;
}
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
assert(vp);
if (arrowCount > 0 && renderExtent >= ViewProviderDimension::REND_EXTENT_REDUCED) {
double gapSize = 0.0;
if (standardStyle == ViewProviderDimension::STD_STYLE_ASME_REFERENCING
|| standardStyle == ViewProviderDimension::STD_STYLE_ASME_INLINED) {
gapSize = getDefaultAsmeExtensionLineGap();
double factor = vp->GapFactorASME.getValue();
gapSize = Rez::appX(m_lineWidth * factor);
}
if (standardStyle == ViewProviderDimension::STD_STYLE_ISO_REFERENCING
|| standardStyle == ViewProviderDimension::STD_STYLE_ISO_ORIENTED) {
double factor = vp->GapFactorISO.getValue();
gapSize = Rez::appX(m_lineWidth * factor);
}
Base::Vector2d extensionOrigin;
@@ -1745,12 +1754,22 @@ void QGIViewDimension::drawDistanceOverride(const Base::Vector2d &startPoint, co
arrowCount = 0;
}
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
assert(vp);
if (arrowCount > 0 && renderExtent >= ViewProviderDimension::REND_EXTENT_REDUCED) {
double gapSize = 0.0;
if (standardStyle == ViewProviderDimension::STD_STYLE_ASME_REFERENCING
|| standardStyle == ViewProviderDimension::STD_STYLE_ASME_INLINED) {
gapSize = getDefaultAsmeExtensionLineGap();
double factor = vp->GapFactorASME.getValue();
gapSize = Rez::appX(m_lineWidth * factor);
}
if (standardStyle == ViewProviderDimension::STD_STYLE_ISO_REFERENCING
|| standardStyle == ViewProviderDimension::STD_STYLE_ISO_ORIENTED) {
double factor = vp->GapFactorISO.getValue();
gapSize = Rez::appX(m_lineWidth * factor);
}
Base::Vector2d extensionOrigin;
Base::Vector2d extensionTarget(computeExtensionLinePoints(endPoint, endCross, lineAngle + M_PI_2,
@@ -2307,12 +2326,22 @@ void QGIViewDimension::drawAngle(TechDraw::DrawViewDimension *dimension, ViewPro
arrowCount = 0;
}
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
assert(vp);
if (arrowCount > 0 && renderExtent >= ViewProviderDimension::REND_EXTENT_REDUCED) {
double gapSize = 0.0;
if (standardStyle == ViewProviderDimension::STD_STYLE_ASME_REFERENCING
|| standardStyle == ViewProviderDimension::STD_STYLE_ASME_INLINED) {
gapSize = getDefaultAsmeExtensionLineGap();
double factor = vp->GapFactorASME.getValue();
gapSize = Rez::appX(m_lineWidth * factor);
}
if (standardStyle == ViewProviderDimension::STD_STYLE_ISO_REFERENCING
|| standardStyle == ViewProviderDimension::STD_STYLE_ISO_ORIENTED) {
double factor = vp->GapFactorISO.getValue();
gapSize = Rez::appX(m_lineWidth * factor);
}
Base::Vector2d extensionOrigin;
Base::Vector2d extensionTarget(computeExtensionLinePoints(endPoint,
@@ -2492,12 +2521,6 @@ double QGIViewDimension::getDefaultAsmeHorizontalLeaderLength() const
return Rez::appX(m_lineWidth*12);
}
double QGIViewDimension::getDefaultAsmeExtensionLineGap() const
{
// Not specified by ASME Y14.5M, this is a best guess
return Rez::appX(m_lineWidth*6.0);
}
//frame, border, caption are never shown in QGIVD, so shouldn't be in bRect
QRectF QGIViewDimension::boundingRect() const
{

View File

@@ -297,7 +297,6 @@ private:
double getDefaultIsoDimensionLineSpacing() const;
double getDefaultIsoReferenceLineOverhang() const;
double getDefaultAsmeHorizontalLeaderLength() const;
double getDefaultAsmeExtensionLineGap() const;
/* QGIView* m_parent; //for edit dialog set up eventually*/

View File

@@ -81,6 +81,10 @@ ViewProviderDimension::ViewProviderDimension()
RenderingExtent.setEnums(RenderingExtentEnums);
ADD_PROPERTY_TYPE(FlipArrowheads, (false), group, App::Prop_None,
"Reverses usual direction of dimension line terminators");
ADD_PROPERTY_TYPE(GapFactorISO, (Preferences::ISOGap()), group, App::Prop_None,
"Adjusts the gap between dimension point and extension line");
ADD_PROPERTY_TYPE(GapFactorASME, (Preferences::ASMEGap()), group, App::Prop_None,
"Adjusts the gap between dimension point and extension line");
}
ViewProviderDimension::~ViewProviderDimension()
@@ -196,8 +200,9 @@ void ViewProviderDimension::onChanged(const App::Property* p)
(p == &LineWidth) ||
(p == &StandardAndStyle) ||
(p == &RenderingExtent) ||
(p == &FlipArrowheads))
{
(p == &FlipArrowheads) ||
(p == &GapFactorASME) ||
(p == &GapFactorISO)) {
QGIView* qgiv = getQView();
if (qgiv) {
qgiv->updateView(true);

View File

@@ -64,6 +64,9 @@ public:
App::PropertyBool FlipArrowheads;
App::PropertyFloat GapFactorISO;
App::PropertyFloat GapFactorASME;
virtual void attach(App::DocumentObject *);
virtual void setDisplayMode(const char* ModeName);
virtual bool useNewSelectionModel(void) const {return false;}