[TD]Standard Line Styles - Gui components

This commit is contained in:
wandererfan
2023-11-16 11:33:45 -05:00
committed by WandererFan
parent b64fd9ac03
commit 762e1b53ff
42 changed files with 1494 additions and 1395 deletions

View File

@@ -38,6 +38,7 @@
#include "DrawViewPart.h"
#include "GeometryObject.h"
#include "LineGroup.h"
#include "LineGenerator.h"
#include "Preferences.h"
@@ -54,7 +55,7 @@ LineFormat::LineFormat()
m_weight = getDefEdgeWidth();
m_color= getDefEdgeColor();
m_visible = true;
m_lineNumber = InvalidLine;
m_lineNumber = LineGenerator::fromQtStyle((Qt::PenStyle)m_style);
}
LineFormat::LineFormat(const int style,
@@ -65,7 +66,7 @@ LineFormat::LineFormat(const int style,
m_weight(weight),
m_color(color),
m_visible(visible),
m_lineNumber(InvalidLine)
m_lineNumber(LineGenerator::fromQtStyle((Qt::PenStyle)m_style))
{
}

View File

@@ -171,7 +171,7 @@ QPen LineGenerator::getLinePen(size_t lineNumber, double nominalLineWidth)
//! convert Qt line style to closest ISO line number
int LineGenerator::fromQtStyle(Qt::PenStyle style) const
int LineGenerator::fromQtStyle(Qt::PenStyle style)
{
// Base::Console().Message("DLG::fromQtStyle(%d)\n", style);

View File

@@ -58,8 +58,8 @@ public:
QPen getBestPen(size_t lineNumber, Qt::PenStyle qtStyle, double width);
QPen getLinePen(size_t lineNumber, double nominalLineWidth);
int fromQtStyle(Qt::PenStyle style) const;
static int fromQtStyle(Qt::PenStyle style);
static std::vector<std::string> getAvailableLineStandards();
static std::string getLineStandardsBody();

View File

@@ -247,7 +247,7 @@ bool Preferences::showDetailMatting()
bool Preferences::showDetailHighlight()
{
return getPreferenceGroup("General")->GetBool("ShowDetailHighLight", true);
return getPreferenceGroup("General")->GetBool("ShowDetailHighlight", true);
}
std::string Preferences::svgFile()
@@ -418,3 +418,94 @@ bool Preferences::SectionUsePreviousCut()
{
return getPreferenceGroup("General")->GetBool("SectionUsePreviousCut", false);
}
//! an index into the list of available line standards/version found in LineGroupDirectory
int Preferences::lineStandard()
{
return getPreferenceGroup("Standards")->GetInt("LineStandard", 1);
}
std::string Preferences::lineDefinitionLocation()
{
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/LineGroup/";
std::string prefDir = getPreferenceGroup("Files")->GetASCII("LineDefLocation", defaultDir.c_str());
return prefDir;
}
std::string Preferences::lineElementsLocation()
{
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/LineGroup/";
std::string prefDir = getPreferenceGroup("Files")->GetASCII("LineElementLocation", defaultDir.c_str());
return prefDir;
}
int Preferences::SectionLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleSection", 4);
}
int Preferences::CenterLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleCenter", 10);
}
int Preferences::HighlightLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleHighLight", 10);
}
int Preferences::HiddenLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleHidden", 1);
}
int Preferences::LineSpacingISO()
{
return getPreferenceGroup("Dimensions")->GetInt("LineSpacingFactorISO", 2);
}
std::string Preferences::currentLineDefFile()
{
std::string lineDefDir = Preferences::lineDefinitionLocation();
std::vector<std::string> choices = LineGenerator::getAvailableLineStandards();
std::string fileName = choices.at(Preferences::lineStandard()) + ".LineDef.csv";
return lineDefDir + fileName;
}
std::string Preferences::currentElementDefFile()
{
std::string lineDefDir = Preferences::lineElementsLocation();
std::vector<std::string> choices = LineGenerator::getAvailableLineStandards();
std::string fileName = choices.at(Preferences::lineStandard()) + ".ElementDef.csv";
return lineDefDir + fileName;
}
//! returns a Qt::PenCapStyle based on the index of the preference comboBox.
//! the comboBox choices are 0-Round, 1-Square, 2-Flat. The Qt::PenCapStyles are
//! 0x00-Flat, 0x10-Square, 0x20-Round
int Preferences::LineCapStyle()
{
int currentIndex = LineCapIndex();
int result{0x20};
switch (currentIndex) {
case 0:
result = static_cast<Qt::PenCapStyle>(0x20); //round;
break;
case 1:
result = static_cast<Qt::PenCapStyle>(0x10); //square;
break;
case 2:
result = static_cast<Qt::PenCapStyle>(0x00); //flat
break;
default:
result = static_cast<Qt::PenCapStyle>(0x20);
}
return result;
}
//! returns the line cap index without conversion to a Qt::PenCapStyle
int Preferences::LineCapIndex()
{
return getPreferenceGroup("General")->GetInt("EdgeCapStyle", 0x20);
}

View File

@@ -64,7 +64,6 @@ public:
static bool keepPagesUpToDate();
static int projectionAngle();
static int lineGroup();
static int balloonArrow();
static double balloonKinkLength();
@@ -72,7 +71,6 @@ public:
static QString defaultTemplate();
static QString defaultTemplateDir();
static std::string lineGroupFile();
static const double DefaultFontSizeInMM;
static const double DefaultArrowSize;

View File

@@ -2202,31 +2202,35 @@ void _createThreadLines(std::vector<std::string> SubNames, TechDraw::DrawViewPar
void _setLineAttributes(TechDraw::CosmeticEdge* cosEdge)
{
// set line attributes of a cosmetic edge
cosEdge->m_format.m_style = _getActiveLineAttributes().getStyle();
cosEdge->m_format.m_style = 2;
cosEdge->m_format.m_weight = _getActiveLineAttributes().getWidthValue();
cosEdge->m_format.m_color = _getActiveLineAttributes().getColorValue();
cosEdge->m_format.m_lineNumber = _getActiveLineAttributes().getStyle();
}
void _setLineAttributes(TechDraw::CenterLine* cosEdge)
{
// set line attributes of a cosmetic edge
cosEdge->m_format.m_style = _getActiveLineAttributes().getStyle();
cosEdge->m_format.m_style = 2;
cosEdge->m_format.m_weight = _getActiveLineAttributes().getWidthValue();
cosEdge->m_format.m_color = _getActiveLineAttributes().getColorValue();
cosEdge->m_format.m_lineNumber = _getActiveLineAttributes().getStyle();
}
void _setLineAttributes(TechDraw::CosmeticEdge* cosEdge, int style, float weight, App::Color color)
{
// set line attributes of a cosmetic edge
cosEdge->m_format.m_style = style;
cosEdge->m_format.m_style = 2;
cosEdge->m_format.m_weight = weight;
cosEdge->m_format.m_color = color;
cosEdge->m_format.m_lineNumber = style;
}
void _setLineAttributes(TechDraw::CenterLine* cosEdge, int style, float weight, App::Color color)
{
// set line attributes of a centerline
cosEdge->m_format.m_style = style;
cosEdge->m_format.m_style = 2;
cosEdge->m_format.m_lineNumber = style;
cosEdge->m_format.m_weight = weight;
cosEdge->m_format.m_color = color;
}

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>474</width>
<height>416</height>
<height>424</height>
</rect>
</property>
<property name="windowTitle">
@@ -40,44 +40,8 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0">
<item row="11" column="2">
<widget class="Gui::PrefSpinBox" name="sbMaxTiles">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Limit of 64x64 pixel SVG tiles used to hatch a single face.
For large scalings you might get an error about to many SVG tiles.
Then you need to increase the tile limit.</string>
</property>
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>10000</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>MaxSVGTile</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::PrefCheckBox" name="cbFuseBeforeSection">
<item row="2" column="0">
<widget class="Gui::PrefCheckBox" name="cbShowSectionEdges">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -90,48 +54,64 @@ Then you need to increase the tile limit.</string>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Perform a fuse operation on input shape(s) before Section view processing</string>
<string>Highlights border of section cut in section views</string>
</property>
<property name="text">
<string>Fuse Before Section</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>SectionFuseFirst</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Gui::PrefCheckBox" name="cbAutoCorrectRefs">
<property name="toolTip">
<string>If checked, system will attempt to automatically correct dimension references when the model changes.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Auto Correct Dimension Refs</string>
<string>Show Section Edges</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AutoCorrectRefs</cstring>
<cstring>ShowSectionEdges</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
<cstring>/Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="9" column="2">
<item row="0" column="2">
<widget class="Gui::PrefCheckBox" name="cbReportProgress">
<property name="toolTip">
<string>Issue progress messages while building View geometry</string>
</property>
<property name="text">
<string>Report Progress</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ReportProgress</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Overlap Edges Scrub Passes</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Line End Cap Shape</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="Gui::PrefDoubleSpinBox" name="pdsbMarkFuzz">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -172,7 +152,67 @@ Each unit is approx. 0.1 mm wide</string>
</property>
</widget>
</item>
<item row="12" column="2">
<item row="6" column="2">
<widget class="Gui::PrefSpinBox" name="sbScrubCount">
<property name="toolTip">
<string>The number of times FreeCAD should try to remove overlapping edges returned by the Hidden Line Removal algorithm. A value of 0 indicates no scrubbing, 1 indicates a single pass and 2 indicates a second pass should be performed. Values above 2 are generally not productive. Each pass adds to the time required to produce the drawing.</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string/>
</property>
<property name="prefix">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>ScrubCount</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="cbNewFaceFinder">
<property name="toolTip">
<string>If checked, FreeCAD will use the new face finder algorithm. If not checked, FreeCAD will use the original face finder.</string>
</property>
<property name="text">
<string>Use New Face Finder Algorithm</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>NewFaceFinder</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<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="text">
<string>Edge Fuzz</string>
</property>
</widget>
</item>
<item row="11" column="2">
<widget class="Gui::PrefSpinBox" name="sbMaxPat">
<property name="minimumSize">
<size>
@@ -207,30 +247,81 @@ when hatching a face with a PAT pattern</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Max SVG Hatch Tiles</string>
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="cbDetectFaces">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::PrefCheckBox" name="cbReportProgress">
<property name="toolTip">
<string>Issue progress messages while building View geometry</string>
<string>If checked, TechDraw will attempt to build faces using the
line segments returned by the hidden line removal algorithm.
Faces must be detected in order to use hatching, but there
can be a performance penalty in complex models.</string>
</property>
<property name="text">
<string>Report Progress</string>
<string>Detect Faces</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ReportProgress</cstring>
<cstring>HandleFaces</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="8" column="2">
<item row="2" column="2">
<widget class="Gui::PrefCheckBox" name="cbFuseBeforeSection">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Perform a fuse operation on input shape(s) before Section view processing</string>
</property>
<property name="text">
<string>Fuse Before Section</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>SectionFuseFirst</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Mark Fuzz</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="Gui::PrefDoubleSpinBox" name="pdsbEdgeFuzz">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -271,7 +362,7 @@ Each unit is approx. 0.1 mm wide</string>
</property>
</widget>
</item>
<item row="5" column="2">
<item row="4" column="2">
<widget class="Gui::PrefCheckBox" name="cbDebugDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -299,39 +390,107 @@ Each unit is approx. 0.1 mm wide</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Line End Cap Shape</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_4">
<item row="10" column="2">
<widget class="Gui::PrefSpinBox" name="sbMaxTiles">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<height>20</height>
</size>
</property>
<property name="text">
<string>Mark Fuzz</string>
<property name="toolTip">
<string>Limit of 64x64 pixel SVG tiles used to hatch a single face.
For large scalings you might get an error about to many SVG tiles.
Then you need to increase the tile limit.</string>
</property>
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>10000</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>MaxSVGTile</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="12" column="0">
<item row="11" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Max PAT Hatch Segments</string>
</property>
</widget>
</item>
<item row="4" column="2">
<item row="1" column="2">
<widget class="Gui::PrefCheckBox" name="cbAutoCorrectRefs">
<property name="toolTip">
<string>If checked, system will attempt to automatically correct dimension references when the model changes.</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Auto Correct Dimension Refs</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AutoCorrectRefs</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="5" 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="0">
<widget class="Gui::PrefCheckBox" name="cbDebugSection">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Dump intermediate results during Section view processing</string>
</property>
<property name="text">
<string>Debug Section</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>debugSection</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/debug</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="Gui::PrefCheckBox" name="cbCrazyEdges">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -353,56 +512,15 @@ Each unit is approx. 0.1 mm wide</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="Gui::PrefCheckBox" name="cbShowSectionEdges">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Highlights border of section cut in section views</string>
</property>
<item row="10" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Show Section Edges</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowSectionEdges</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/General</cstring>
<string>Max SVG Hatch Tiles</string>
</property>
</widget>
</item>
<item row="10" column="2">
<item row="9" column="2">
<widget class="Gui::PrefComboBox" name="cbEndCap">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<italic>false</italic>
</font>
</property>
<property name="toolTip">
<string>Shape of line end caps.
Only change unless you know what you are doing!</string>
@@ -430,166 +548,6 @@ Only change unless you know what you are doing!</string>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="Gui::PrefCheckBox" name="cbDebugSection">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Dump intermediate results during Section view processing</string>
</property>
<property name="text">
<string>Debug Section</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>debugSection</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/debug</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="cbDetectFaces">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>If checked, TechDraw will attempt to build faces using the
line segments returned by the hidden line removal algorithm.
Faces must be detected in order to use hatching, but there
can be a performance penalty in complex models.</string>
</property>
<property name="text">
<string>Detect Faces</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>HandleFaces</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="Gui::PrefCheckBox" name="cbShowLoose">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Include 2D Objects in projection</string>
</property>
<property name="text">
<string>Show Loose 2D Geom</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowLoose2d</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_5">
<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="text">
<string>Edge Fuzz</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="cbNewFaceFinder">
<property name="toolTip">
<string>If checked, FreeCAD will use the new face finder algorithm. If not checked, FreeCAD will use the original face finder.</string>
</property>
<property name="text">
<string>Use New Face Finder Algorithm</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>NewFaceFinder</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
<item row="6" 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="7" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Overlap Edges Scrub Passes</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="Gui::PrefSpinBox" name="sbScrubCount">
<property name="toolTip">
<string>The number of times FreeCAD should try to remove overlapping edges returned by the Hidden Line Removal algorithm. A value of 0 indicates no scrubbing, 1 indicates a single pass and 2 indicates a second pass should be performed. Values above 2 are generally not productive. Each pass adds to the time required to produce the drawing.</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string/>
</property>
<property name="prefix">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>ScrubCount</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@@ -50,10 +50,8 @@ void DlgPrefsTechDrawAdvancedImp::saveSettings()
ui->cbDebugDetail->onSave();
ui->cbCrazyEdges->onSave();
ui->cbFuseBeforeSection->onSave();
ui->cbShowLoose->onSave();
ui->pdsbEdgeFuzz->onSave();
ui->pdsbMarkFuzz->onSave();
ui->cbEndCap->onSave();
ui->sbMaxTiles->onSave();
ui->sbMaxPat->onSave();
ui->cbReportProgress->onSave();
@@ -70,10 +68,8 @@ void DlgPrefsTechDrawAdvancedImp::loadSettings()
ui->cbDebugDetail->onRestore();
ui->cbCrazyEdges->onRestore();
ui->cbFuseBeforeSection->onRestore();
ui->cbShowLoose->onRestore();
ui->pdsbEdgeFuzz->onRestore();
ui->pdsbMarkFuzz->onRestore();
ui->cbEndCap->onRestore();
ui->sbMaxTiles->onRestore();
ui->sbMaxPat->onRestore();
ui->cbReportProgress->onRestore();

File diff suppressed because it is too large Load Diff

View File

@@ -27,13 +27,15 @@
# include <vector>
#endif
#include <Base/Tools.h>
#include <Mod/TechDraw/App/LineGroup.h>
#include <Mod/TechDraw/App/Preferences.h>
#include <Mod/TechDraw/App/LineGenerator.h>
#include "DlgPrefsTechDrawAnnotationImp.h"
#include "ui_DlgPrefsTechDrawAnnotation.h"
#include "DrawGuiUtil.h"
#include "PreferencesGui.h"
using namespace TechDrawGui;
using namespace TechDraw;
@@ -50,6 +52,7 @@ DlgPrefsTechDrawAnnotationImp::DlgPrefsTechDrawAnnotationImp( QWidget* parent )
// connect the LineGroup the update the tooltip if index changed
connect(ui->pcbLineGroup, qOverload<int>(&QComboBox::currentIndexChanged),
this, &DlgPrefsTechDrawAnnotationImp::onLineGroupChanged);
m_lineGenerator = new LineGenerator();
}
DlgPrefsTechDrawAnnotationImp::~DlgPrefsTechDrawAnnotationImp()
@@ -62,18 +65,23 @@ void DlgPrefsTechDrawAnnotationImp::saveSettings()
ui->cbAutoHoriz->onSave();
ui->cbPrintCenterMarks->onSave();
ui->cbPyramidOrtho->onSave();
ui->cbSectionLineStd->onSave();
ui->cbComplexMarks->onSave();
ui->cbShowCenterMarks->onSave();
ui->pcbLineGroup->onSave();
ui->pcbBalloonArrow->onSave();
ui->pcbBalloonShape->onSave();
ui->pcbCenterStyle->onSave();
ui->pcbMatting->onSave();
ui->pcbSectionStyle->onSave();
ui->pdsbBalloonKink->onSave();
ui->cbCutSurface->onSave();
ui->pcbLineGroup->onSave();
ui->pcbLineStandard->onSave();
ui->pcbSectionStyle->onSave();
ui->pcbCenterStyle->onSave();
ui->pcbHighlightStyle->onSave();
ui->cbEndCap->onSave();
ui->pcbHiddenStyle->onSave();
}
void DlgPrefsTechDrawAnnotationImp::loadSettings()
@@ -101,21 +109,50 @@ void DlgPrefsTechDrawAnnotationImp::loadSettings()
ui->cbAutoHoriz->onRestore();
ui->cbPrintCenterMarks->onRestore();
ui->cbPyramidOrtho->onRestore();
ui->cbSectionLineStd->onRestore();
ui->cbComplexMarks->onRestore();
ui->cbShowCenterMarks->onRestore();
ui->pcbLineGroup->onRestore();
ui->pcbBalloonArrow->onRestore();
ui->pcbBalloonShape->onRestore();
ui->pcbCenterStyle->onRestore();
ui->pcbMatting->onRestore();
ui->pcbSectionStyle->onRestore();
ui->pdsbBalloonKink->onRestore();
ui->cbCutSurface->onRestore();
ui->pcbHighlightStyle->onRestore();
ui->pcbBalloonArrow->onRestore();
DrawGuiUtil::loadArrowBox(ui->pcbBalloonArrow);
ui->pcbBalloonArrow->setCurrentIndex(prefBalloonArrow());
ui->cbEndCap->onRestore();
ui->pcbLineStandard->onRestore();
DrawGuiUtil::loadLineStandardsChoices(ui->pcbLineStandard);
if (ui->pcbLineStandard->count() > Preferences::lineStandard()) {
ui->pcbLineStandard->setCurrentIndex(Preferences::lineStandard());
}
ui->pcbSectionStyle->onRestore();
DrawGuiUtil::loadLineStyleChoices(ui->pcbSectionStyle, m_lineGenerator);
if (ui->pcbSectionStyle->count() > Preferences::SectionLineStyle()) {
ui->pcbSectionStyle->setCurrentIndex(Preferences::SectionLineStyle());
}
ui->pcbCenterStyle->onRestore();
DrawGuiUtil::loadLineStyleChoices(ui->pcbCenterStyle, m_lineGenerator);
if (ui->pcbCenterStyle->count() > Preferences::CenterLineStyle()) {
ui->pcbCenterStyle->setCurrentIndex(Preferences::CenterLineStyle());
}
ui->pcbHighlightStyle->onRestore();
DrawGuiUtil::loadLineStyleChoices(ui->pcbHighlightStyle, m_lineGenerator);
if (ui->pcbHighlightStyle->count() > Preferences::HighlightLineStyle()) {
ui->pcbHighlightStyle->setCurrentIndex(Preferences::HighlightLineStyle());
}
ui->pcbHiddenStyle->onRestore();
DrawGuiUtil::loadLineStyleChoices(ui->pcbHiddenStyle, m_lineGenerator);
if (ui->pcbHiddenStyle->count() > Preferences::HiddenLineStyle()) {
ui->pcbHiddenStyle->setCurrentIndex(Preferences::HiddenLineStyle());
}
}
/**

View File

@@ -25,10 +25,13 @@
#define DRAWINGGUI_DLGPREFSTECHDRAWIMPANNOTATION_H
#include <memory>
#include <Gui/PrefWidgets.h>
#include <Gui/PropertyPage.h>
#include <Mod/TechDraw/TechDrawGlobal.h>
namespace TechDraw {
class LineGenerator;
}
namespace TechDrawGui {
class Ui_DlgPrefsTechDrawAnnotationImp;
@@ -53,6 +56,7 @@ protected:
private:
std::unique_ptr<Ui_DlgPrefsTechDrawAnnotationImp> ui;
TechDraw::LineGenerator* m_lineGenerator;
};
} // namespace TechDrawGui

View File

@@ -587,7 +587,7 @@ Normally, no gap is used. If a gap is used, the recommended value is 6.</string>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<double>0.000000000000000</double>
<double>2.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>LineSpacingFactorISO</cstring>

View File

@@ -66,6 +66,7 @@ void DlgPrefsTechDrawDimensionsImp::saveSettings()
ui->leFormatSpec->onSave();
ui->pdsbGapISO->onSave();
ui->pdsbGapASME->onSave();
ui->pdsbLineSpacingFactorISO->onSave();
}
void DlgPrefsTechDrawDimensionsImp::loadSettings()
@@ -98,6 +99,8 @@ void DlgPrefsTechDrawDimensionsImp::loadSettings()
ui->pdsbGapISO->onRestore();
ui->pdsbGapASME->onRestore();
ui->pdsbLineSpacingFactorISO->onRestore();
}
/**

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>499</width>
<height>776</height>
<height>768</height>
</rect>
</property>
<property name="sizePolicy">
@@ -359,14 +359,7 @@ for ProjectionGroups</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_6" columnstretch="1,0,1">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Projection Group Angle</string>
</property>
</widget>
</item>
<layout class="QGridLayout" name="gridLayout_6" columnstretch="1,0,0">
<item row="0" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
@@ -380,6 +373,13 @@ for ProjectionGroups</string>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Projection Group Angle</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::PrefComboBox" name="cbProjAngle">
<property name="sizePolicy">
@@ -420,15 +420,8 @@ for ProjectionGroups</string>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Hidden Line Style</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="Gui::PrefComboBox" name="cbHiddenLineStyle">
<widget class="Gui::PrefComboBox" name="cbSectionLineStd">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -437,39 +430,46 @@ for ProjectionGroups</string>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>184</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Style for hidden lines</string>
<string>Standard to be used to draw section lines. This affects the position of arrows and symbol.</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>HiddenLine</cstring>
<cstring>SectionLineStandard</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/General</cstring>
<cstring>Mod/TechDraw/Standards</cstring>
</property>
<item>
<property name="text">
<string>Continuous</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/continuous-line.svg</normaloff>:/icons/continuous-line.svg</iconset>
<string>ANSI</string>
</property>
</item>
<item>
<property name="text">
<string>Dashed</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dash-line.svg</normaloff>:/icons/dash-line.svg</iconset>
<string>ISO</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Section Line Convention</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@@ -793,7 +793,20 @@ for ProjectionGroups</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,1">
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0">
<item row="1" 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="0" column="0">
<widget class="Gui::PrefCheckBox" name="cb_ShowGrid">
<property name="font">
@@ -830,19 +843,6 @@ for ProjectionGroups</string>
</property>
</widget>
</item>
<item row="1" 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="1" column="2">
<widget class="Gui::PrefUnitSpinBox" name="psb_GridSpacing">
<property name="toolTip">
@@ -932,13 +932,26 @@ for ProjectionGroups</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>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<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>

View File

@@ -27,6 +27,7 @@
#include "DlgPrefsTechDrawGeneralImp.h"
#include "ui_DlgPrefsTechDrawGeneral.h"
#include "PreferencesGui.h"
#include "DrawGuiUtil.h"
using namespace TechDrawGui;
@@ -60,7 +61,7 @@ void DlgPrefsTechDrawGeneralImp::saveSettings()
ui->plsb_LabelSize->onSave();
ui->cbProjAngle->onSave();
ui->cbHiddenLineStyle->onSave();
ui->cbSectionLineStd->onSave();
ui->pfc_DefTemp->onSave();
ui->pfc_DefDir->onSave();
@@ -92,7 +93,7 @@ void DlgPrefsTechDrawGeneralImp::loadSettings()
ui->plsb_LabelSize->onRestore();
ui->cbProjAngle->onRestore();
ui->cbHiddenLineStyle->onRestore();
ui->cbSectionLineStd->onRestore();
ui->pfc_DefTemp->onRestore();
ui->pfc_DefDir->onRestore();

View File

@@ -25,6 +25,7 @@
#ifndef _PreComp_
# include <sstream>
# include <QBitmap>
# include <QComboBox>
# include <QMessageBox>
# include <QPointF>
@@ -43,6 +44,7 @@
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include <Base/Tools.h>
#include <Base/Type.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
@@ -52,11 +54,15 @@
#include <Gui/Selection.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Gui/PrefWidgets.h>
#include <Inventor/SbVec3f.h>
#include <Mod/TechDraw/App/ArrowPropEnum.h>
#include <Mod/TechDraw/App/LineNameEnum.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/LineGenerator.h>
#include "DlgPageChooser.h"
#include "DrawGuiUtil.h"
@@ -64,7 +70,6 @@
#include "QGSPage.h"
#include "ViewProviderPage.h"
using namespace TechDrawGui;
using namespace TechDraw;
@@ -79,6 +84,79 @@ void DrawGuiUtil::loadArrowBox(QComboBox* qcb)
}
}
void DrawGuiUtil::loadLineStandardsChoices(QComboBox* combo)
{
combo->clear();
std::vector<std::string> choices = LineGenerator::getAvailableLineStandards();
for (auto& entry : choices) {
QString qentry = Base::Tools::fromStdString(entry);
combo->addItem(qentry);
}
}
void DrawGuiUtil::loadLineStyleChoices(QComboBox* combo, LineGenerator* generator)
{
combo->clear();
std::vector<std::string> choices;
if (generator) {
choices = generator->getLoadedDescriptions();
} else {
choices = LineGenerator::getLineDescriptions();
}
int itemNumber{0};
for (auto& entry : choices) {
QString qentry = Base::Tools::fromStdString(entry);
combo->addItem(qentry);
if (generator) {
combo->setItemIcon(itemNumber, iconForLine(itemNumber + 1, generator));
}
itemNumber++;
}
}
//! make an icon that shows a sample of lineNumber in the current line standard
QIcon DrawGuiUtil::iconForLine(size_t lineNumber, TechDraw::LineGenerator* generator)
{
// Base::Console().Message("DGU::iconForLine(lineNumber: %d)\n", lineNumber);
constexpr int iconSize{64};
constexpr int borderSize{4};
constexpr double iconLineWeight{1.0};
size_t lineCount{4};
double maxLineLength = iconSize - borderSize * 2.0;
QBitmap bitmap{iconSize, iconSize};
bitmap.clear();
QPainter painter(&bitmap);
QPen linePen = generator->getLinePen(lineNumber, iconLineWeight);
linePen.setDashOffset(0.0);
linePen.setCapStyle(Qt::FlatCap);
linePen.setColor(Qt::color1);
// handle simple case of continuous line
if (linePen.style() == Qt::SolidLine) {
linePen.setWidthF(iconLineWeight * lineCount);
painter.setPen(linePen);
painter.drawLine(borderSize, iconSize / 2, iconSize - borderSize, iconSize / 2);
return QIcon{bitmap};
}
// dashed line
linePen.setWidthF(iconLineWeight);
painter.setPen(linePen);
double yHeight = (iconSize / 2) - (lineCount * iconLineWeight);
size_t iLine = 0;
// draw multiple lines to stretch the line vertically without horizontal
// distortion
for ( ; iLine < lineCount; iLine++){
painter.drawLine(borderSize, yHeight, maxLineLength, yHeight);
yHeight += iconLineWeight;
}
return QIcon{bitmap};
}
//===========================================================================
// validate helper routines
//===========================================================================

View File

@@ -44,6 +44,7 @@ class Feature;
namespace TechDraw {
class DrawPage;
class LineGenerator;
}
namespace Gui {
class Command;
@@ -70,6 +71,9 @@ class TechDrawGuiExport DrawGuiUtil {
static std::pair<Base::Vector3d, Base::Vector3d> getProjDirFromFace(App::DocumentObject* obj,
std::string faceName);
static void loadArrowBox(QComboBox* qcb);
static void loadLineStandardsChoices(QComboBox* combo);
static void loadLineStyleChoices(QComboBox* combo, TechDraw::LineGenerator* generator = nullptr);
static QIcon iconForLine(size_t lineNumber, TechDraw::LineGenerator* generator);
static double roundToDigits(double original, int digits);

View File

@@ -34,6 +34,8 @@
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Mod/TechDraw/App/Preferences.h>
#include <Mod/TechDraw/App/LineGenerator.h>
#include "PreferencesGui.h"
#include "Rez.h"
@@ -154,6 +156,8 @@ double PreferencesGui::edgeFuzz()
return Preferences::getPreferenceGroup("General")->GetFloat("EdgeFuzz", 10.0);
}
// this is for the iso vs ansi positioning of arrows and text. rename to sectionLineConvention?
Qt::PenStyle PreferencesGui::sectionLineStyle()
{
Qt::PenStyle sectStyle = static_cast<Qt::PenStyle> (Preferences::getPreferenceGroup("Decorations")->GetInt("SectionLine", 2));
@@ -274,3 +278,4 @@ QColor PreferencesGui::lightenColor(QColor orig)
return QColor(red, green, blue, alpha);
}

View File

@@ -135,3 +135,8 @@ void QGICenterLine::setTools()
m_pen.setColor(m_colCurrent);
m_line->setPen(m_pen);
}
void QGICenterLine::setLinePen(QPen isoPen)
{
m_pen = isoPen;
}

View File

@@ -49,6 +49,8 @@ public:
void setIntersection(bool isIntersecting);
void setLinePen(QPen isoPen);
protected:
QColor getCenterColor();
Qt::PenStyle getCenterStyle();

View File

@@ -37,10 +37,9 @@
#include <Mod/TechDraw/App/DrawViewPart.h>
#include "QGIEdge.h"
#include "QGIViewPart.h"
#include "PreferencesGui.h"
#include "TaskLineDecor.h"
#include "QGIView.h"
using namespace TechDrawGui;
using namespace TechDraw;
@@ -96,6 +95,7 @@ Qt::PenStyle QGIEdge::getHiddenStyle()
{
//Qt::PenStyle - NoPen, Solid, Dashed, ...
//Preferences::General - Solid, Dashed
// Dashed lines should use ISO Line #2 instead of Qt::DashedLine
Qt::PenStyle hidStyle = static_cast<Qt::PenStyle> (Preferences::getPreferenceGroup("General")->GetInt("HiddenLine", 0) + 1);
return hidStyle;
}
@@ -131,3 +131,10 @@ void QGIEdge::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Gui::Control().showDialog(new TaskDlgLineDecor(baseFeat, edgeName));
}
}
void QGIEdge::setLinePen(QPen linePen)
{
m_pen = linePen;
}

View File

@@ -51,7 +51,10 @@ public:
bool getSmoothEdge() { return(isSmoothEdge); }
void setPrettyNormal() override;
double getEdgeFuzz(void) const;
double getEdgeFuzz() const;
void setLinePen(QPen isoPen);
protected:

View File

@@ -197,7 +197,8 @@ void QGIHighlight::setTools()
{
m_pen.setWidthF(m_width);
m_pen.setColor(m_colCurrent);
m_pen.setStyle(m_styleCurrent);
m_pen.setStyle(Qt::CustomDashLine);
m_brush.setStyle(m_brushCurrent);
m_brush.setColor(m_colCurrent);
@@ -207,3 +208,7 @@ void QGIHighlight::setTools()
m_reference->setDefaultTextColor(m_colCurrent);
}
void QGIHighlight::setLinePen(QPen isoPen)
{
m_pen = isoPen;
}

View File

@@ -63,6 +63,8 @@ public:
void onDragFinished() override;
void setLinePen(QPen isoPen);
protected:
QColor getHighlightColor();
Qt::PenStyle getHighlightStyle();

View File

@@ -212,14 +212,16 @@ void QGIPrimPath::setWidth(double w)
void QGIPrimPath::setStyle(Qt::PenStyle s)
{
// Base::Console().Message("QGIPP::setStyle(QTPS: %d)\n", s);
// TODO: edge lines for faces are drawn with setStyle(Qt::NoPen) and trigger this message.
// Base::Console().Warning("QGIPP::setStyle(Qt: %d) is deprecated. Use setLinePen instead\n", s);
m_styleNormal = s;
m_styleCurrent = s;
}
void QGIPrimPath::setStyle(int s)
{
// Base::Console().Message("QGIPP::setStyle(int: %d)\n", s);
// TODO: edge lines for faces are drawn with setStyle(Qt::NoPen) and trigger this message.
// Base::Console().Warning("QGIPP::setStyle(int: %d) is deprecated. Use setLinePen instead\n", s);
m_styleCurrent = static_cast<Qt::PenStyle>(s);
m_styleNormal = static_cast<Qt::PenStyle>(s);
}
@@ -245,23 +247,7 @@ Base::Reference<ParameterGrp> QGIPrimPath::getParmGroup()
//EdgeCapStyle param changed from UInt (Qt::PenCapStyle) to Int (QComboBox index)
Qt::PenCapStyle QGIPrimPath::prefCapStyle()
{
Qt::PenCapStyle result;
int newStyle;
newStyle = Preferences::getPreferenceGroup("General")->GetInt("EdgeCapStyle", 32); //0x00 FlatCap, 0x10 SquareCap, 0x20 RoundCap
switch (newStyle) {
case 0:
result = static_cast<Qt::PenCapStyle>(0x20); //round;
break;
case 1:
result = static_cast<Qt::PenCapStyle>(0x10); //square;
break;
case 2:
result = static_cast<Qt::PenCapStyle>(0x00); //flat
break;
default:
result = static_cast<Qt::PenCapStyle>(0x20);
}
return result;
return (Qt::PenCapStyle)Preferences::LineCapStyle();
}
void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent *event)
@@ -331,16 +317,19 @@ void QGIPrimPath::setFillColor(QColor c)
{
m_colNormalFill = c;
m_fillColorCurrent = m_colNormalFill;
// m_colDefFill = c;
}
void QGIPrimPath::setCurrentPen()
{
m_pen.setWidthF(m_width);
m_pen.setColor(m_colCurrent);
}
void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
m_pen.setWidthF(m_width);
m_pen.setColor(m_colCurrent);
m_pen.setStyle(m_styleCurrent);
setCurrentPen();
setPen(m_pen);
m_brush.setColor(m_fillColorCurrent);

View File

@@ -74,6 +74,8 @@ public:
QColor getFillColor() { return m_colDefFill; }
void setFillOverride(bool b) { m_fillOverride = b; }
virtual void setCurrentPen();
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;

View File

@@ -500,32 +500,8 @@ void QGISectionLine::paint ( QPainter * painter, const QStyleOptionGraphicsItem
void QGISectionLine::setTools()
{
// Use our own style
if (m_styleCurrent == Qt::DashDotLine) {
QVector<qreal> dashes;
// the stroke width is double the one of center lines, but we like to
// have the same spacing. thus these values must be half as large
qreal space = 2; // in unit r_width
qreal dash = 8;
// dot must be really small when using CapStyle RoundCap but > 0
// for CapStyle FlatCap you would need to set it to 1
qreal dot = 0.000001;
dashes << dot << space << dash << space;
// TODO for fanciness: calculate the offset so both arrows start with a
// dash!
m_pen.setDashPattern(dashes);
m_pen.setDashOffset(2);
}
else {
m_pen.setStyle(m_styleCurrent);
}
m_pen.setWidthF(m_width);
m_pen.setColor(m_colCurrent);
m_pen.setCapStyle(Qt::RoundCap);
m_brush.setStyle(m_brushCurrent);
m_brush.setColor(m_colCurrent);
@@ -541,3 +517,9 @@ void QGISectionLine::setTools()
m_symbol1->setDefaultTextColor(m_colCurrent);
m_symbol2->setDefaultTextColor(m_colCurrent);
}
void QGISectionLine::setLinePen(QPen isoPen)
{
m_pen = isoPen;
}

View File

@@ -70,6 +70,9 @@ public:
void clearChangePoints();
void draw() override;
void setLinePen(QPen isoPen);
protected:
QColor getSectionColor();
Qt::PenStyle getSectionStyle();

View File

@@ -62,7 +62,6 @@
#include "ZVALUE.h"
#include "PathBuilder.h"
using namespace TechDraw;
using namespace TechDrawGui;
using namespace std;
@@ -72,7 +71,6 @@ using DU = DrawUtil;
#define COSMETICEDGE 1
#define CENTERLINE 2
const float lineScaleFactor = Rez::guiX(1.);// temp fiddle for devel
QGIViewPart::QGIViewPart()
@@ -87,12 +85,14 @@ QGIViewPart::QGIViewPart()
showSection = false;
m_pathBuilder = new PathBuilder(this);
m_dashedLineGenerator = new LineGenerator();
}
QGIViewPart::~QGIViewPart()
{
tidy();
delete m_pathBuilder;
delete m_dashedLineGenerator;
}
QVariant QGIViewPart::itemChange(GraphicsItemChange change, const QVariant& value)
@@ -279,8 +279,6 @@ void QGIViewPart::drawAllEdges()
auto dvp(static_cast<TechDraw::DrawViewPart*>(getViewObject()));
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
// float lineWidthExtra = dvp->ExtraWidth.getValue() * lineScaleFactor; //extra lines not used here
const TechDraw::BaseGeomPtrVector& geoms = dvp->getEdgeGeometry();
TechDraw::BaseGeomPtrVector::const_iterator itGeom = geoms.begin();
QGIEdge* item;
@@ -294,9 +292,7 @@ void QGIViewPart::drawAllEdges()
addToGroup(item); //item is created at scene(0, 0), not group(0, 0)
item->setPath(drawPainterPath(*itGeom));
item->setWidth(vp->LineWidth.getValue() * lineScaleFactor); //thick
item->setNormalColor(PreferencesGui::getAccessibleQColor(PreferencesGui::normalQColor()));
item->setStyle(Qt::SolidLine);
if ((*itGeom)->getCosmetic()) {
// cosmetic edge - format appropriately
int source = (*itGeom)->source();
@@ -318,21 +314,34 @@ void QGIViewPart::drawAllEdges()
if (gf) {
App::Color color = Preferences::getAccessibleColor(gf->m_format.m_color);
item->setNormalColor(color.asValue<QColor>());
item->setWidth(gf->m_format.m_weight * lineScaleFactor);
item->setStyle(gf->m_format.m_style);
int lineNumber = gf->m_format.getLineNumber();
int qtStyle = gf->m_format.m_style;
item->setLinePen(m_dashedLineGenerator->getBestPen(lineNumber, (Qt::PenStyle)qtStyle,
gf->m_format.m_weight));
// but we need to actually draw the lines in QGScene coords (0.1 mm).
item->setWidth(Rez::guiX(gf->m_format.m_weight));
showItem = gf->m_format.m_visible;
} else {
// unformatted line, draw as continuous line
item->setLinePen(m_dashedLineGenerator->getLinePen(1, vp->LineWidth.getValue()));
item->setWidth(Rez::guiX(vp->LineWidth.getValue()));
}
}
if (!(*itGeom)->getHlrVisible()) {
// TODO: item->setISOLineNumber(getISOLineNumber(iEdge));
item->setWidth(vp->HiddenWidth.getValue() * lineScaleFactor); //thin
item->setHiddenEdge(true);
// the HiddenLine parameter is 0 (solid) or 1 (dashed)
// Qt PenStyle(1) is continuous and PenStyle(2) is dashed
int qtStyle = Preferences::getPreferenceGroup("General")->GetInt("HiddenLine", 0) + 1;
item->setLinePen(m_dashedLineGenerator->getBestPen( 0, (Qt::PenStyle)qtStyle,
vp->HiddenWidth.getValue()));
item->setWidth(Rez::guiX(vp->HiddenWidth.getValue())); //thin
item->setZValue(ZVALUE::HIDEDGE);
}
if ((*itGeom)->getClassOfEdge() == ecUVISO) {
item->setWidth(vp->IsoWidth.getValue() * lineScaleFactor); //graphic
// we don't have a style option for iso-parametric lines so draw continuous
item->setLinePen(m_dashedLineGenerator->getLinePen(1, vp->IsoWidth.getValue()));
item->setWidth(Rez::guiX(vp->IsoWidth.getValue())); //graphic
}
item->setPos(0.0, 0.0);//now at group(0, 0)
@@ -470,8 +479,10 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
if (ce) {
App::Color color = Preferences::getAccessibleColor(ce->m_format.m_color);
item->setNormalColor(color.asValue<QColor>());
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
item->setStyle(ce->m_format.m_style);
item->setLinePen(m_dashedLineGenerator->getBestPen(ce->m_format.getLineNumber(),
(Qt::PenStyle)ce->m_format.m_style,
ce->m_format.m_weight));
item->setWidth(Rez::guiX(ce->m_format.m_weight));
result = ce->m_format.m_visible;
}
return result;
@@ -480,15 +491,17 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
bool QGIViewPart::formatGeomFromCenterLine(std::string cTag, QGIEdge* item)
{
// Base::Console().Message("QGIVP::formatGeomFromCenterLine(%d)\n", sourceIndex);
// Base::Console().Message("QGIVP::formatGeomFromCenterLine()\n");
bool result = true;
auto partFeat(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
TechDraw::CenterLine* cl = partFeat ? partFeat->getCenterLine(cTag) : nullptr;
if (cl) {
App::Color color = Preferences::getAccessibleColor(cl->m_format.m_color);
item->setNormalColor(color.asValue<QColor>());
item->setWidth(cl->m_format.m_weight * lineScaleFactor);
item->setStyle(cl->m_format.m_style);
item->setLinePen(m_dashedLineGenerator->getBestPen(cl->m_format.getLineNumber(),
(Qt::PenStyle)cl->m_format.m_style,
cl->m_format.m_weight));
item->setWidth(Rez::guiX(cl->m_format.m_weight));
result = cl->m_format.m_visible;
}
return result;
@@ -626,7 +639,6 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
if (!vp) {
return;
}
float lineWidthThin = vp->HiddenWidth.getValue() * lineScaleFactor;//thin
if (b) {
QGISectionLine* sectionLine = new QGISectionLine();
@@ -671,7 +683,11 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
//set the general parameters
sectionLine->setPos(0.0, 0.0);
sectionLine->setWidth(lineWidthThin);
// sectionLines are typically ISO 8 (long dash, short dash) or ISO 4 (long dash, dot)
sectionLine->setLinePen(
m_dashedLineGenerator->getLinePen((size_t)vp->SectionLineStyle.getValue(),
vp->HiddenWidth.getValue()));
sectionLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
double fontSize = Preferences::dimFontSizeMM();
sectionLine->setFont(getFont(), fontSize);
sectionLine->setZValue(ZVALUE::SECTIONLINE);
@@ -692,7 +708,6 @@ void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection,
if (!vp) {
return;
}
float lineWidthThin = vp->HiddenWidth.getValue() * lineScaleFactor;//thin
auto dcs = static_cast<DrawComplexSection*>(viewSection);
BaseGeomPtrVector edges = dcs->makeSectionLineGeometry();
@@ -743,7 +758,11 @@ void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection,
//set the general parameters
sectionLine->setPos(0.0, 0.0);
sectionLine->setWidth(lineWidthThin);
// sectionLines are typically ISO 8 (long dash, short dash) or ISO 4 (long dash, dot)
sectionLine->setLinePen(
m_dashedLineGenerator->getLinePen((size_t)vp->SectionLineStyle.getValue(),
vp->HiddenWidth.getValue()));
sectionLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
double fontSize = Preferences::dimFontSizeMM();
sectionLine->setFont(getFont(), fontSize);
sectionLine->setZValue(ZVALUE::SECTIONLINE);
@@ -752,6 +771,7 @@ void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection,
}
//TODO: use Cosmetic::CenterLine object for this to make it usable for dims.
// these are the view center lines (ie x,y axes)
void QGIViewPart::drawCenterLines(bool b)
{
TechDraw::DrawViewPart* viewPart = dynamic_cast<TechDraw::DrawViewPart*>(getViewObject());
@@ -780,7 +800,10 @@ void QGIViewPart::drawCenterLines(bool b)
yVal = 0.0;
centerLine->setIntersection(horiz && vert);
centerLine->setBounds(-xVal, -yVal, xVal, yVal);
centerLine->setLinePen(m_dashedLineGenerator->getLinePen((size_t)Preferences::CenterLineStyle(),
vp->HiddenWidth.getValue()));
centerLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
centerLine->setColor(Qt::green);
centerLine->setZValue(ZVALUE::SECTIONLINE);
centerLine->draw();
}
@@ -794,7 +817,10 @@ void QGIViewPart::drawCenterLines(bool b)
yVal = sectionSpan / 2.0;
centerLine->setIntersection(horiz && vert);
centerLine->setBounds(-xVal, -yVal, xVal, yVal);
centerLine->setLinePen(m_dashedLineGenerator->getLinePen((size_t)Preferences::CenterLineStyle(),
vp->HiddenWidth.getValue()));
centerLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
centerLine->setColor(Qt::red);
centerLine->setZValue(ZVALUE::SECTIONLINE);
centerLine->draw();
}
@@ -803,6 +829,9 @@ void QGIViewPart::drawCenterLines(bool b)
void QGIViewPart::drawAllHighlights()
{
if (!Preferences::showDetailHighlight()) {
return;
}
// dvp and vp already validated
auto dvp(static_cast<TechDraw::DrawViewPart*>(getViewObject()));
@@ -828,12 +857,11 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b)
return;
}
if (b) {
// double fontSize = getPrefFontSize();
double fontSize = Preferences::labelFontSizeMM();
QGIHighlight* highlight = new QGIHighlight();
scene()->addItem(highlight);
highlight->setReference(viewDetail->Reference.getValue());
highlight->setStyle((Qt::PenStyle)vp->HighlightLineStyle.getValue());
App::Color color = Preferences::getAccessibleColor(vp->HighlightLineColor.getValue());
highlight->setColor(color.asValue<QColor>());
highlight->setFeatureName(viewDetail->getNameInDocument());
@@ -849,6 +877,8 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b)
double radius = viewDetail->Radius.getValue() * viewPart->getScale();
highlight->setBounds(center.x - radius, center.y + radius, center.x + radius,
center.y - radius);
highlight->setLinePen(m_dashedLineGenerator->getLinePen((size_t)vp->HighlightLineStyle.getValue(),
vp->IsoWidth.getValue()));
highlight->setWidth(Rez::guiX(vp->IsoWidth.getValue()));
highlight->setFont(getFont(), fontSize);
highlight->setZValue(ZVALUE::HIGHLIGHT);
@@ -880,6 +910,9 @@ void QGIViewPart::highlightMoved(QGIHighlight* highlight, QPointF newPos)
void QGIViewPart::drawMatting()
{
if (!Preferences::showDetailMatting()) {
return;
}
auto viewPart(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
TechDraw::DrawViewDetail* dvd = nullptr;
if (viewPart && viewPart->isDerivedFrom(TechDraw::DrawViewDetail::getClassTypeId())) {

View File

@@ -26,6 +26,7 @@
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <Mod/TechDraw/App/Geometry.h>
#include <Mod/TechDraw/App/LineGenerator.h>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
@@ -40,7 +41,7 @@ class DrawHatch;
class DrawGeomHatch;
class DrawViewDetail;
class DrawView;
class LineGenerator;
}
namespace TechDrawGui
@@ -132,6 +133,8 @@ protected:
private:
QList<QGraphicsItem*> deleteItems;
PathBuilder* m_pathBuilder;
TechDraw::LineGenerator* m_dashedLineGenerator;
};
} // namespace

View File

@@ -42,6 +42,7 @@
#include "PreferencesGui.h"
#include "QGIView.h"
#include "ViewProviderViewPart.h"
#include "DrawGuiUtil.h"
using namespace Gui;
@@ -177,7 +178,11 @@ void TaskCenterLine::setUiPrimary()
}
ui->cpLineColor->setColor(getCenterColor());
ui->dsbWeight->setValue(getCenterWidth());
ui->cboxStyle->setCurrentIndex(getCenterStyle() - 1);
DrawGuiUtil::loadLineStyleChoices(ui->cboxStyle);
if (ui->cboxStyle->count() >= Preferences::CenterLineStyle() ) {
ui->cboxStyle->setCurrentIndex(Preferences::CenterLineStyle() - 1);
}
ui->qsbVertShift->setUnit(Base::Unit::Length);
ui->qsbHorizShift->setUnit(Base::Unit::Length);
@@ -213,7 +218,11 @@ void TaskCenterLine::setUiEdit()
}
ui->cpLineColor->setColor(m_cl->m_format.m_color.asValue<QColor>());
ui->dsbWeight->setValue(m_cl->m_format.m_weight);
ui->cboxStyle->setCurrentIndex(m_cl->m_format.m_style - 1);
DrawGuiUtil::loadLineStyleChoices(ui->cboxStyle);
if (ui->cboxStyle->count() >= m_cl->m_format.m_style ) {
ui->cboxStyle->setCurrentIndex(m_cl->m_format.m_style - 1);
}
ui->rbVertical->setChecked(false);
ui->rbHorizontal->setChecked(false);
@@ -329,7 +338,7 @@ void TaskCenterLine::onStyleChanged()
return;
}
m_cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1;
m_cl->m_format.setLineNumber(ui->cboxStyle->currentIndex() + 1);
m_partFeat->recomputeFeature();
}
@@ -424,7 +433,7 @@ void TaskCenterLine::createCenterLine()
ac.setValue<QColor>(ui->cpLineColor->color());
cl->m_format.m_color = ac;
cl->m_format.m_weight = ui->dsbWeight->value().getValue();
cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1; //Qt Styles start at 0:NoLine
cl->m_format.setLineNumber(ui->cboxStyle->currentIndex() + 1);
cl->m_format.m_visible = true;
m_partFeat->addCenterLine(cl);
@@ -510,12 +519,6 @@ double TaskCenterLine::getCenterWidth()
return partVP->IsoWidth.getValue();
}
Qt::PenStyle TaskCenterLine::getCenterStyle()
{
Qt::PenStyle centerStyle = static_cast<Qt::PenStyle> (Preferences::getPreferenceGroup("Decorations")->GetInt("CenterLine", 2));
return centerStyle;
}
QColor TaskCenterLine::getCenterColor()
{
return PreferencesGui::centerQColor();
@@ -555,7 +558,7 @@ bool TaskCenterLine::reject()
// restore the initial centerline
m_cl->m_format.m_color = (&orig_cl)->m_format.m_color;
m_cl->m_format.m_weight = (&orig_cl)->m_format.m_weight;
m_cl->m_format.m_style = (&orig_cl)->m_format.m_style;
m_cl->m_format.setLineNumber((&orig_cl)->m_format.getLineNumber());
m_cl->m_format.m_visible = (&orig_cl)->m_format.m_visible;
m_cl->m_mode = (&orig_cl)->m_mode;
m_cl->m_rotate = (&orig_cl)->m_rotate;

View File

@@ -85,7 +85,6 @@ protected:
double getCenterWidth();
QColor getCenterColor();
Qt::PenStyle getCenterStyle();
double getExtendBy();
int checkPathologicalEdges(int inMode);

View File

@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>250</width>
<height>352</height>
<width>300</width>
<height>390</height>
</rect>
</property>
<property name="windowTitle">
@@ -137,6 +137,69 @@
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="Gui::QuantitySpinBox" name="dsbWeight">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::ColorButton" name="cpLineColor">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cboxStyle">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
@@ -146,6 +209,25 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbVertShift">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Move line +Up or -Down</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbHorizShift">
<property name="minimumSize">
@@ -172,25 +254,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbVertShift">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Move line +Up or -Down</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
@@ -220,25 +283,14 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Extend By</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="3" column="1">
<widget class="Gui::QuantitySpinBox" name="qsbExtend">
<property name="minimumSize">
<size>
@@ -260,105 +312,21 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::ColorButton" name="cpLineColor">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::QuantitySpinBox" name="dsbWeight">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="cboxStyle">
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Continuous</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/continuous-line.svg</normaloff>:/icons/continuous-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Dash</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dash-line.svg</normaloff>:/icons/dash-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Dot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dot-line.svg</normaloff>:/icons/dot-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>DashDot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dashDot-line.svg</normaloff>:/icons/dashDot-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>DashDotDot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dashDotDot-line.svg</normaloff>:/icons/dashDotDot-line.svg</iconset>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<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>

View File

@@ -36,12 +36,15 @@
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/CenterLine.h>
#include <Mod/TechDraw/App/Geometry.h>
#include <Mod/TechDraw/App/LineGenerator.h>
#include "TaskLineDecor.h"
#include "ui_TaskLineDecor.h"
#include "ui_TaskRestoreLines.h"
#include "QGIView.h"
#include "ViewProviderViewPart.h"
#include "DrawGuiUtil.h"
using namespace Gui;
@@ -56,9 +59,11 @@ TaskLineDecor::TaskLineDecor(TechDraw::DrawViewPart* partFeat,
m_apply(true)
{
initializeRejectArrays();
m_lineGenerator = new TechDraw::LineGenerator;
ui->setupUi(this);
getDefaults();
ui->setupUi(this);
initUi();
connect(ui->cb_Style, qOverload<int>(&QComboBox::currentIndexChanged), this, &TaskLineDecor::onStyleChanged);
@@ -69,6 +74,7 @@ TaskLineDecor::TaskLineDecor(TechDraw::DrawViewPart* partFeat,
TaskLineDecor::~TaskLineDecor()
{
delete m_lineGenerator;
}
void TaskLineDecor::initUi()
@@ -87,11 +93,16 @@ void TaskLineDecor::initUi()
}
ui->le_Lines->setText(Base::Tools::fromStdString(temp));
ui->cb_Style->setCurrentIndex(m_style - 1); //combobox does not have 0:NoLine choice
ui->cc_Color->setColor(m_color.asValue<QColor>());
ui->dsb_Weight->setValue(m_weight);
ui->dsb_Weight->setSingleStep(0.1);
ui->cb_Visible->setCurrentIndex(m_visible);
// line numbering starts at 1, not 0
DrawGuiUtil::loadLineStyleChoices(ui->cb_Style, m_lineGenerator);
if (ui->cb_Style->count() >= m_lineNumber ) {
ui->cb_Style->setCurrentIndex(m_lineNumber - 1);
}
}
TechDraw::LineFormat *TaskLineDecor::getFormatAccessPtr(const std::string &edgeName, std::string *newFormatTag)
@@ -133,7 +144,7 @@ TechDraw::LineFormat *TaskLineDecor::getFormatAccessPtr(const std::string &edgeN
}
}
}
return nullptr;
return {};
}
void TaskLineDecor::initializeRejectArrays()
@@ -157,10 +168,10 @@ void TaskLineDecor::initializeRejectArrays()
void TaskLineDecor::getDefaults()
{
// Base::Console().Message("TLD::getDefaults()\n");
m_style = LineFormat::getDefEdgeStyle();
m_color = LineFormat::getDefEdgeColor();
m_weight = LineFormat::getDefEdgeWidth();
m_visible = true;
m_lineNumber = 1;
//set defaults to format of 1st edge
if (!m_originalFormats.empty()) {
@@ -169,12 +180,13 @@ void TaskLineDecor::getDefaults()
m_color = lf.m_color;
m_weight = lf.m_weight;
m_visible = lf.m_visible;
m_lineNumber = lf.getLineNumber();
}
}
void TaskLineDecor::onStyleChanged()
{
m_style = ui->cb_Style->currentIndex() + 1;
m_lineNumber = ui->cb_Style->currentIndex() + 1;
applyDecorations();
m_partFeat->requestPaint();
}
@@ -210,6 +222,7 @@ void TaskLineDecor::applyDecorations()
lf->m_color = m_color;
lf->m_weight = m_weight;
lf->m_visible = m_visible;
lf->setLineNumber(m_lineNumber);
}
}
}

View File

@@ -23,6 +23,7 @@
#ifndef GUI_TASKVIEW_TASKLINEDECOR_H
#define GUI_TASKVIEW_TASKLINEDECOR_H
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
#include <Mod/TechDraw/TechDrawGlobal.h>
@@ -33,11 +34,16 @@ namespace App
class DocumentObject;
}
namespace TechDraw
{
class LineGenerator;
}
namespace TechDrawGui
{
class Ui_TaskLineDecor;
class Ui_TaskRestoreLines;
class TaskLineDecor : public QWidget
{
Q_OBJECT
@@ -82,6 +88,9 @@ private:
double m_weight;
bool m_visible;
bool m_apply;
int m_lineNumber;
TechDraw::LineGenerator* m_lineGenerator;
};
class TaskRestoreLines : public QWidget

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>200</height>
<width>355</width>
<height>311</height>
</rect>
</property>
<property name="sizePolicy">
@@ -28,113 +28,7 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>View</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="le_View">
<property name="enabled">
<bool>false</bool>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Lines</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="le_Lines">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="cb_Style">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Continuous</string>
</property>
</item>
<item>
<property name="text">
<string>Dash</string>
</property>
</item>
<item>
<property name="text">
<string>Dot</string>
</property>
</item>
<item>
<property name="text">
<string>DashDot</string>
</property>
</item>
<item>
<property name="text">
<string>DashDotDot</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="4" column="2">
<item row="5" column="2">
<widget class="Gui::ColorButton" name="cc_Color">
<property name="color">
<color>
@@ -145,34 +39,21 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="Gui::QuantitySpinBox" name="dsb_Weight">
<property name="toolTip">
<string>Thickness of pattern lines.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label">
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Visible</string>
<string>Lines</string>
</property>
</widget>
</item>
<item row="6" column="2">
<item row="7" column="2">
<widget class="QComboBox" name="cb_Visible">
<property name="currentIndex">
<number>1</number>
@@ -198,8 +79,124 @@
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>View</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QComboBox" name="cb_Style">
<property name="toolTip">
<string>The use of the Qt line style is being phased out. Please use a standard line style instead.</string>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="Gui::QuantitySpinBox" name="dsb_Weight">
<property name="toolTip">
<string>Thickness of pattern lines.</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Visible</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="le_Lines">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="le_View">
<property name="enabled">
<bool>false</bool>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<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>

View File

@@ -24,20 +24,22 @@
#include <Gui/BitmapFactory.h>
#include <Mod/TechDraw/App/LineGenerator.h>
#include "ui_TaskSelectLineAttributes.h"
#include "TaskSelectLineAttributes.h"
#include "DrawGuiUtil.h"
using namespace Gui;
using namespace TechDraw;
using namespace TechDrawGui;
enum class EdgeStyle {
solid = 1,
dashed = 2,
dotted = 3,
dashdotted = 4
};
//enum class EdgeStyle {
// solid = 1,
// dashed = 2,
// dotted = 3,
// dashdotted = 4
//};
enum class EdgeWidth {
small = 1,
@@ -62,7 +64,7 @@ enum class EdgeColor {
lineAttributes::lineAttributes()
{
style = int(EdgeStyle::dotted);
style = 2;
width = int(EdgeWidth::middle);
color = int(EdgeColor::black);
}
@@ -150,6 +152,7 @@ TaskSelectLineAttributes::TaskSelectLineAttributes(lineAttributes * ptActiveAttr
activeAttributes(ptActiveAttributes),
ui(new Ui_TaskSelectLineAttributes)
{
m_lineGenerator = new TechDraw::LineGenerator;
ui->setupUi(this);
@@ -158,7 +161,7 @@ TaskSelectLineAttributes::TaskSelectLineAttributes(lineAttributes * ptActiveAttr
TaskSelectLineAttributes::~TaskSelectLineAttributes()
{
delete m_lineGenerator;
}
void TaskSelectLineAttributes::updateTask()
@@ -180,21 +183,10 @@ void TaskSelectLineAttributes::setUiEdit()
{
setWindowTitle(tr("Select line attributes"));
int lineStyle = activeAttributes->getStyle();
switch(EdgeStyle(lineStyle)) {
case EdgeStyle::solid:
ui->rbSolid->setChecked(true);
break;
case EdgeStyle::dashed:
ui->rbDashed->setChecked(true);
break;
case EdgeStyle::dotted:
ui->rbDotted->setChecked(true);
break;
case EdgeStyle::dashdotted:
ui->rbDashDotted->setChecked(true);
break;
default:
ui->rbDashDotted->setChecked(true);
// line numbering starts at 1, not 0
DrawGuiUtil::loadLineStyleChoices(ui->cbLineStyle, m_lineGenerator);
if (ui->cbLineStyle->count() >= lineStyle ) {
ui->cbLineStyle->setCurrentIndex(lineStyle - 1);
}
int lineWidth = activeAttributes->getWidth();
@@ -251,21 +243,7 @@ void TaskSelectLineAttributes::setUiEdit()
bool TaskSelectLineAttributes::accept()
{
if (ui->rbSolid->isChecked()){
activeAttributes->setStyle(int(EdgeStyle::solid));
}
else if (ui->rbDashed->isChecked()){
activeAttributes->setStyle(int(EdgeStyle::dashed));
}
else if (ui->rbDotted->isChecked()){
activeAttributes->setStyle(int(EdgeStyle::dotted));
}
else if (ui->rbDashDotted->isChecked()){
activeAttributes->setStyle(int(EdgeStyle::dashdotted));
}
else {
activeAttributes->setStyle(int(EdgeStyle::dashdotted));
}
activeAttributes->setStyle(ui->cbLineStyle->currentIndex() + 1);
if (ui->rbThin->isChecked()){
activeAttributes->setWidth(int(EdgeWidth::small));

View File

@@ -56,6 +56,7 @@ class LineFormat;
namespace TechDraw
{
class Face;
class LineGenerator;
}
namespace TechDrawGui
@@ -107,6 +108,8 @@ protected:
private:
lineAttributes* activeAttributes;
std::unique_ptr<Ui_TaskSelectLineAttributes> ui;
TechDraw::LineGenerator* m_lineGenerator;
}; // class TaskSelectLineAttributes
class TaskDlgSelectLineAttributes : public Gui::TaskView::TaskDialog

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>250</width>
<height>482</height>
<width>332</width>
<height>401</height>
</rect>
</property>
<property name="sizePolicy">
@@ -27,7 +27,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="lineStyles">
<layout class="QGridLayout" name="lineStyles" columnstretch="1,2">
<item row="0" column="0">
<widget class="QLabel" name="label_styles">
<property name="text">
@@ -35,63 +35,8 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="rbSolid">
<property name="toolTip">
<string>Set line style to solid</string>
</property>
<property name="text">
<string>Solid</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bgLineStyles</string>
</attribute>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="rbDashed">
<property name="text">
<string>Dashed</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bgLineStyles</string>
</attribute>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="rbDotted">
<property name="text">
<string>Dotted</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bgLineStyles</string>
</attribute>
</widget>
</item>
<item row="4" column="0">
<widget class="QRadioButton" name="rbDashDotted">
<property name="text">
<string>Dashdot</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bgLineStyles</string>
</attribute>
</widget>
<item row="0" column="1">
<widget class="QComboBox" name="cbLineStyle"/>
</item>
</layout>
</item>
@@ -307,6 +252,19 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<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>
<resources>
@@ -314,7 +272,7 @@
</resources>
<connections/>
<buttongroups>
<buttongroup name="bgLineStyles">
<buttongroup name="bgLineColor">
<property name="exclusive">
<bool>true</bool>
</property>
@@ -324,10 +282,5 @@
<bool>true</bool>
</property>
</buttongroup>
<buttongroup name="bgLineColor">
<property name="exclusive">
<bool>true</bool>
</property>
</buttongroup>
</buttongroups>
</ui>

View File

@@ -89,7 +89,7 @@ ViewProviderDimension::ViewProviderDimension()
"Adjusts the gap between dimension point and extension line");
ADD_PROPERTY_TYPE(GapFactorASME, (Preferences::GapASME()), group, App::Prop_None,
"Adjusts the gap between dimension point and extension line");
ADD_PROPERTY_TYPE(LineSpacingFactorISO, (2.0), group, App::Prop_None,
ADD_PROPERTY_TYPE(LineSpacingFactorISO, (Preferences::LineSpacingISO()), group, App::Prop_None,
"Adjusts the gap between dimension line and dimension text");
StackOrder.setValue(ZVALUE::DIMENSION);

View File

@@ -49,6 +49,9 @@
#include <Mod/TechDraw/App/LineGroup.h>
#include <Mod/TechDraw/App/Cosmetic.h>
#include <Mod/TechDraw/App/CenterLine.h>
#include <Mod/TechDraw/App/LineNameEnum.h>
#include <Mod/TechDraw/App/LineGenerator.h>
#include "PreferencesGui.h"
#include "QGIView.h"
@@ -65,13 +68,6 @@ using DU = DrawUtil;
PROPERTY_SOURCE(TechDrawGui::ViewProviderViewPart, TechDrawGui::ViewProviderDrawingView)
const char* ViewProviderViewPart::LineStyleEnums[] = { "NoLine",
"Continuous",
"Dash",
"Dot",
"DashDot",
"DashDotDot",
nullptr };
const App::PropertyIntegerConstraint::Constraints intPercent = { 0, 100, 5 };
@@ -111,9 +107,20 @@ ViewProviderViewPart::ViewProviderViewPart()
ADD_PROPERTY_TYPE(ArcCenterMarks ,(defShowCenters), dgroup, App::Prop_None, "Center marks on/off");
ADD_PROPERTY_TYPE(CenterScale, (defScale), dgroup, App::Prop_None, "Center mark size adjustment, if enabled");
std::string bodyName = LineGenerator::getLineStandardsBody();
if (bodyName == "ISO") {
SectionLineStyle.setEnums(ISOLineName::ISOLineNameEnums);
HighlightLineStyle.setEnums(ISOLineName::ISOLineNameEnums);
} else if (bodyName == "ANSI") {
SectionLineStyle.setEnums(ANSILineName::ANSILineNameEnums);
HighlightLineStyle.setEnums(ANSILineName::ANSILineNameEnums);
} else if (bodyName == "ASME") {
SectionLineStyle.setEnums(ASMELineName::ASMELineNameEnums);
HighlightLineStyle.setEnums(ASMELineName::ASMELineNameEnums);
}
//properties that affect Section Line
ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,sgroup, App::Prop_None, "Show/hide section line if applicable");
SectionLineStyle.setEnums(LineStyleEnums);
ADD_PROPERTY_TYPE(SectionLineStyle, (PreferencesGui::sectionLineStyle()), sgroup, App::Prop_None,
"Set section line style if applicable");
ADD_PROPERTY_TYPE(SectionLineColor, (prefSectionColor()), sgroup, App::Prop_None,
@@ -122,7 +129,6 @@ ViewProviderViewPart::ViewProviderViewPart()
"Show marks at direction changes for ComplexSection");
//properties that affect Detail Highlights
HighlightLineStyle.setEnums(LineStyleEnums);
ADD_PROPERTY_TYPE(HighlightLineStyle, (prefHighlightStyle()), hgroup, App::Prop_None,
"Set highlight line style if applicable");
ADD_PROPERTY_TYPE(HighlightLineColor, (prefHighlightColor()), hgroup, App::Prop_None,

View File

@@ -63,8 +63,6 @@ public:
App::PropertyColor FaceColor;
App::PropertyPercent FaceTransparency;
static const char* LineStyleEnums[];
void attach(App::DocumentObject *) override;
bool useNewSelectionModel(void) const override {return false;}
bool onDelete(const std::vector<std::string> &) override;