From 762e1b53ffa6b09bf56b28cdf02c6216f28ca6b1 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 16 Nov 2023 11:33:45 -0500 Subject: [PATCH] [TD]Standard Line Styles - Gui components --- src/Mod/TechDraw/App/Cosmetic.cpp | 5 +- src/Mod/TechDraw/App/LineGenerator.cpp | 2 +- src/Mod/TechDraw/App/LineGenerator.h | 2 +- src/Mod/TechDraw/App/Preferences.cpp | 93 +- src/Mod/TechDraw/App/Preferences.h | 2 - src/Mod/TechDraw/Gui/CommandExtensionPack.cpp | 12 +- .../TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui | 570 +++++---- .../Gui/DlgPrefsTechDrawAdvancedImp.cpp | 4 - .../Gui/DlgPrefsTechDrawAnnotation.ui | 1031 ++++++++--------- .../Gui/DlgPrefsTechDrawAnnotationImp.cpp | 57 +- .../Gui/DlgPrefsTechDrawAnnotationImp.h | 6 +- .../Gui/DlgPrefsTechDrawDimensions.ui | 2 +- .../Gui/DlgPrefsTechDrawDimensionsImp.cpp | 3 + .../TechDraw/Gui/DlgPrefsTechDrawGeneral.ui | 107 +- .../Gui/DlgPrefsTechDrawGeneralImp.cpp | 5 +- src/Mod/TechDraw/Gui/DrawGuiUtil.cpp | 80 +- src/Mod/TechDraw/Gui/DrawGuiUtil.h | 4 + src/Mod/TechDraw/Gui/PreferencesGui.cpp | 5 + src/Mod/TechDraw/Gui/QGICenterLine.cpp | 5 + src/Mod/TechDraw/Gui/QGICenterLine.h | 2 + src/Mod/TechDraw/Gui/QGIEdge.cpp | 11 +- src/Mod/TechDraw/Gui/QGIEdge.h | 5 +- src/Mod/TechDraw/Gui/QGIHighlight.cpp | 7 +- src/Mod/TechDraw/Gui/QGIHighlight.h | 2 + src/Mod/TechDraw/Gui/QGIPrimPath.cpp | 35 +- src/Mod/TechDraw/Gui/QGIPrimPath.h | 2 + src/Mod/TechDraw/Gui/QGISectionLine.cpp | 30 +- src/Mod/TechDraw/Gui/QGISectionLine.h | 3 + src/Mod/TechDraw/Gui/QGIViewPart.cpp | 79 +- src/Mod/TechDraw/Gui/QGIViewPart.h | 5 +- src/Mod/TechDraw/Gui/TaskCenterLine.cpp | 25 +- src/Mod/TechDraw/Gui/TaskCenterLine.h | 1 - src/Mod/TechDraw/Gui/TaskCenterLine.ui | 230 ++-- src/Mod/TechDraw/Gui/TaskLineDecor.cpp | 23 +- src/Mod/TechDraw/Gui/TaskLineDecor.h | 11 +- src/Mod/TechDraw/Gui/TaskLineDecor.ui | 251 ++-- .../TechDraw/Gui/TaskSelectLineAttributes.cpp | 56 +- .../TechDraw/Gui/TaskSelectLineAttributes.h | 3 + .../TechDraw/Gui/TaskSelectLineAttributes.ui | 85 +- .../TechDraw/Gui/ViewProviderDimension.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp | 24 +- src/Mod/TechDraw/Gui/ViewProviderViewPart.h | 2 - 42 files changed, 1494 insertions(+), 1395 deletions(-) diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp index f227199fce..bd161ace0f 100644 --- a/src/Mod/TechDraw/App/Cosmetic.cpp +++ b/src/Mod/TechDraw/App/Cosmetic.cpp @@ -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)) { } diff --git a/src/Mod/TechDraw/App/LineGenerator.cpp b/src/Mod/TechDraw/App/LineGenerator.cpp index 29a601efaf..1088e83411 100644 --- a/src/Mod/TechDraw/App/LineGenerator.cpp +++ b/src/Mod/TechDraw/App/LineGenerator.cpp @@ -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); diff --git a/src/Mod/TechDraw/App/LineGenerator.h b/src/Mod/TechDraw/App/LineGenerator.h index 6546488292..8237102793 100644 --- a/src/Mod/TechDraw/App/LineGenerator.h +++ b/src/Mod/TechDraw/App/LineGenerator.h @@ -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 getAvailableLineStandards(); static std::string getLineStandardsBody(); diff --git a/src/Mod/TechDraw/App/Preferences.cpp b/src/Mod/TechDraw/App/Preferences.cpp index fcfbeaba7c..b726b7e2b3 100644 --- a/src/Mod/TechDraw/App/Preferences.cpp +++ b/src/Mod/TechDraw/App/Preferences.cpp @@ -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 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 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(0x20); //round; + break; + case 1: + result = static_cast(0x10); //square; + break; + case 2: + result = static_cast(0x00); //flat + break; + default: + result = static_cast(0x20); + } + return result; +} + +//! returns the line cap index without conversion to a Qt::PenCapStyle +int Preferences::LineCapIndex() +{ + return getPreferenceGroup("General")->GetInt("EdgeCapStyle", 0x20); +} + diff --git a/src/Mod/TechDraw/App/Preferences.h b/src/Mod/TechDraw/App/Preferences.h index 9fc75da93c..40b34db064 100644 --- a/src/Mod/TechDraw/App/Preferences.h +++ b/src/Mod/TechDraw/App/Preferences.h @@ -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; diff --git a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp index d067c2346d..e805f4f3a6 100644 --- a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp +++ b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp @@ -2202,31 +2202,35 @@ void _createThreadLines(std::vector 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; } diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui index 5bf49d9ee2..a63aa8e32b 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui @@ -7,7 +7,7 @@ 0 0 474 - 416 + 424 @@ -40,44 +40,8 @@ - - - - - 0 - 20 - - - - 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. - - - Qt::AlignRight - - - 1 - - - 1000000 - - - 100 - - - 10000 - - - MaxSVGTile - - - Mod/TechDraw/Decorations - - - - - + + 0 @@ -90,48 +54,64 @@ Then you need to increase the tile limit. 20 - - - true - - - Perform a fuse operation on input shape(s) before Section view processing + Highlights border of section cut in section views - Fuse Before Section - - - SectionFuseFirst - - - Mod/TechDraw/General - - - - - - - If checked, system will attempt to automatically correct dimension references when the model changes. - - - - - - Auto Correct Dimension Refs + Show Section Edges true - AutoCorrectRefs + ShowSectionEdges - Mod/TechDraw/Dimensions + /Mod/TechDraw/General - + + + + Issue progress messages while building View geometry + + + Report Progress + + + ReportProgress + + + /Mod/TechDraw/General + + + + + + + + true + + + + Overlap Edges Scrub Passes + + + + + + + + true + + + + Line End Cap Shape + + + + @@ -172,7 +152,67 @@ Each unit is approx. 0.1 mm wide - + + + + 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. + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + ScrubCount + + + Mod/TechDraw/General + + + + + + + If checked, FreeCAD will use the new face finder algorithm. If not checked, FreeCAD will use the original face finder. + + + Use New Face Finder Algorithm + + + true + + + NewFaceFinder + + + Mod/TechDraw/General + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Edge Fuzz + + + + @@ -207,30 +247,81 @@ when hatching a face with a PAT pattern - - - - Max SVG Hatch Tiles + + + + + 0 + 0 + - - - - - Issue progress messages while building View geometry + 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. - Report Progress + Detect Faces + + + true - ReportProgress + HandleFaces /Mod/TechDraw/General - + + + + + 0 + 0 + + + + + 0 + 20 + + + + + true + + + + Perform a fuse operation on input shape(s) before Section view processing + + + Fuse Before Section + + + SectionFuseFirst + + + Mod/TechDraw/General + + + + + + + + 0 + 0 + + + + Mark Fuzz + + + + @@ -271,7 +362,7 @@ Each unit is approx. 0.1 mm wide - + @@ -299,39 +390,107 @@ Each unit is approx. 0.1 mm wide - - - - - true - - - - Line End Cap Shape - - - - - + + 0 - 0 + 20 - - Mark Fuzz + + 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. + + + Qt::AlignRight + + + 1 + + + 1000000 + + + 100 + + + 10000 + + + MaxSVGTile + + + Mod/TechDraw/Decorations - + Max PAT Hatch Segments - + + + + If checked, system will attempt to automatically correct dimension references when the model changes. + + + + + + Auto Correct Dimension Refs + + + true + + + AutoCorrectRefs + + + Mod/TechDraw/Dimensions + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Dump intermediate results during Section view processing + + + Debug Section + + + debugSection + + + Mod/TechDraw/debug + + + + @@ -353,56 +512,15 @@ Each unit is approx. 0.1 mm wide - - - - - 0 - 0 - - - - - 0 - 20 - - - - Highlights border of section cut in section views - + + - Show Section Edges - - - true - - - ShowSectionEdges - - - /Mod/TechDraw/General + Max SVG Hatch Tiles - + - - - 0 - 0 - - - - - 0 - 24 - - - - - false - - Shape of line end caps. Only change unless you know what you are doing! @@ -430,166 +548,6 @@ Only change unless you know what you are doing! - - - - - 0 - 0 - - - - Dump intermediate results during Section view processing - - - Debug Section - - - debugSection - - - Mod/TechDraw/debug - - - - - - - - 0 - 0 - - - - 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. - - - Detect Faces - - - true - - - HandleFaces - - - /Mod/TechDraw/General - - - - - - - - 0 - 20 - - - - Include 2D Objects in projection - - - Show Loose 2D Geom - - - false - - - ShowLoose2d - - - Mod/TechDraw/General - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Edge Fuzz - - - - - - - If checked, FreeCAD will use the new face finder algorithm. If not checked, FreeCAD will use the original face finder. - - - Use New Face Finder Algorithm - - - true - - - NewFaceFinder - - - Mod/TechDraw/General - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - true - - - - Overlap Edges Scrub Passes - - - - - - - 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. - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - ScrubCount - - - Mod/TechDraw/General - - - diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvancedImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvancedImp.cpp index 65a3080187..fa570ce342 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvancedImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvancedImp.cpp @@ -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(); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui index f6e75910e7..491d61d6ff 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui @@ -6,8 +6,8 @@ 0 0 - 450 - 541 + 580 + 687 @@ -25,77 +25,31 @@ 0 - 365 + 0 Annotation - - + + - - - - false - - - - Detail View Outline Shape - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - + true - Show arc center marks in views + Length of horizontal portion of Balloon leader - Show Center Marks - - - true - - - ShowCenterMarks - - - Mod/TechDraw/Decorations + Ballon Leader Kink Length - + @@ -123,8 +77,8 @@ - - + + 0 @@ -138,17 +92,188 @@ - Style for balloon leader line ends + Length of balloon leader line kink + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5.000000000000000 - BalloonArrow + BalloonKink + + + Mod/TechDraw/Dimensions + + + + + + + + true + + + + Balloon Shape + + + + + + + + 0 + 22 + + + + Default appearance of cut surface in section view + + + 2 + + + CutSurfaceDisplay + + + /Mod/TechDraw/Decorations + + + + Hide + + + + + Solid Color + + + + + SVG Hatch + + + + + PAT Hatch + + + + + + + + + true + + + + Balloon Leader End + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Restrict Filled Triangle line end to vertical or horizontal directions + + + Balloon Orthogonal Triangle + + + true + + + PyramidOrtho Mod/TechDraw/Decorations - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + true + + + + Show or hide marks at direction changes on ComplexSection lines. + + + Complex Section Line Marks + + + true + + + SectionLineMarks + + + Mod/TechDraw/Decorations + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Forces last leader line segment to be horizontal + + + Leader Line Auto Horizontal + + + true + + + AutoHorizontal + + + Mod/TechDraw/LeaderLine + + + + @@ -191,280 +316,8 @@ - - - - - true - - - - Balloon Shape - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Style for section lines - - - 2 - - - SectionLine - - - /Mod/TechDraw/Decorations - - - - NeverShow - - - - :/icons/arrownone.svg:/icons/arrownone.svg - - - - - Continuous - - - - :/icons/continuous-line.svg:/icons/continuous-line.svg - - - - - Dash - - - - :/icons/dash-line.svg:/icons/dash-line.svg - - - - - Dot - - - - :/icons/dot-line.svg:/icons/dot-line.svg - - - - - DashDot - - - - :/icons/dashDot-line.svg:/icons/dashDot-line.svg - - - - - DashDotDot - - - - :/icons/dashDotDot-line.svg:/icons/dashDotDot-line.svg - - - - - - - - - true - - - - Section Line Standard - - - - - - - - 0 - 0 - - - - - 184 - 22 - - - - Standard to be used to draw section lines - - - 1 - - - SectionLineStandard - - - Mod/TechDraw/Standards - - - - ANSI - - - - - ISO - - - - - - - - - true - - - - Line style of detail highlight on base view - - - Detail Highlight Style - - - - - - - - true - - - - Length of horizontal portion of Balloon leader - - - Ballon Leader Kink Length - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - LineGroup - - - /Mod/TechDraw/Decorations - - - - - - - - - - - 0 - 0 - - - - 2 - - - HighlightStyle - - - /Mod/TechDraw/Decorations - - - - NeverShow - - - - :/icons/arrownone.svg:/icons/arrownone.svg - - - - - Continuous - - - - :/icons/continuous-line.svg:/icons/continuous-line.svg - - - - - Dash - - - - :/icons/dash-line.svg:/icons/dash-line.svg - - - - - Dot - - - - :/icons/dot-line.svg:/icons/dot-line.svg - - - - - DashDot - - - - :/icons/dashDot-line.svg:/icons/dashDot-line.svg - - - - - DashDotDot - - - - :/icons/dashDotDot-line.svg:/icons/dashDotDot-line.svg - - - - - - + 0 @@ -478,66 +331,53 @@ - Length of balloon leader line kink - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5.000000000000000 + Style for balloon leader line ends - BalloonKink - - - Mod/TechDraw/Dimensions - - - - - - - - true - - - - Balloon Leader End - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Restrict Filled Triangle line end to vertical or horizontal directions - - - Balloon Orthogonal Triangle - - - true - - - PyramidOrtho + BalloonArrow Mod/TechDraw/Decorations - + + + + + 0 + 0 + + + + + 0 + 0 + + + + + true + + + + Show arc center marks in views + + + Show Center Marks + + + true + + + ShowCenterMarks + + + Mod/TechDraw/Decorations + + + + @@ -634,89 +474,7 @@ - - - - - 0 - 0 - - - - - 0 - 0 - - - - Type for centerlines - - - 2 - - - CenterLine - - - /Mod/TechDraw/Decorations - - - - NeverShow - - - - :/icons/arrownone.svg:/icons/arrownone.svg - - - - - Continuous - - - - :/icons/continuous-line.svg:/icons/continuous-line.svg - - - - - Dash - - - - :/icons/dash-line.svg:/icons/dash-line.svg - - - - - Dot - - - - :/icons/dot-line.svg:/icons/dot-line.svg - - - - - DashDot - - - - :/icons/dashDot-line.svg:/icons/dashDot-line.svg - - - - - DashDotDot - - - - :/icons/dashDotDot-line.svg:/icons/dashDotDot-line.svg - - - - - + @@ -728,38 +486,38 @@ - - - - - 0 - 0 - - - - - 0 - 0 - - - - Forces last leader line segment to be horizontal + + + + + false + - Leader Line Auto Horizontal - - - true - - - AutoHorizontal - - - Mod/TechDraw/LeaderLine + Detail View Outline Shape - + + + + + + + + + + 0 + 0 + + + + Lines + + + + + @@ -771,7 +529,66 @@ - + + + + + 0 + 0 + + + + + 32 + 32 + + + + LineStyleSection + + + /Mod/TechDraw/Decorations + + + + + + + + true + + + + Line style of detail highlight on base view + + + Detail Highlight Style + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + LineStyleHidden + + + /Mod/TechDraw/Decorations + + + + @@ -783,8 +600,61 @@ - - + + + + + 0 + 0 + + + + + 32 + 32 + + + + LineStyleCenter + + + /Mod/TechDraw/Decorations + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + LineGroup + + + /Mod/TechDraw/Decorations + + + + + + + + + + + 0 + 0 + + 0 @@ -792,41 +662,27 @@ - Default appearance of cut surface in section view + Standard to be used to draw non-continuous lines. - 2 + -1 - CutSurfaceDisplay + LineStandard - /Mod/TechDraw/Decorations + Mod/TechDraw/Standards - - - Hide - - - - - Solid Color - - - - - SVG Hatch - - - - - PAT Hatch - - - + + + + 0 + 0 + + true @@ -841,27 +697,117 @@ - + + + Hidden Line Style + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - true + false + + + + Line Standard + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + LineStyleHighlight + + + /Mod/TechDraw/Decorations + + + + + + + + false + + + + Line End Cap Shape + + + + + + + + 0 + 0 + + + + + 0 + 24 + + + + + false - Show or hide marks at direction changes on ComplexSection lines. - - - Complex Section Line Marks - - - true + Shape of line end caps. The default (round) should almost +always be the right choice. Flat or square caps are useful +if you are planning to use a drawing as a 1:1 cutting guide. + - SectionLineMarks + EdgeCapStyle - Mod/TechDraw/Decorations + Mod/TechDraw/General + + + Round + + + + + Square + + + + + Flat + + @@ -870,19 +816,16 @@ - - - - 10 - false - + + + + 0 + 0 + <html><head/><body><p><span style=" font-weight:600;">Note:</span> Items in <span style=" font-style:italic;">italics</span> are default values for new objects. They have no effect on existing objects.</p></body></html> - - true - @@ -893,7 +836,7 @@ 20 - 20 + 40 diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp index 91849f6f00..58b2f871e2 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp @@ -27,13 +27,15 @@ # include #endif +#include + #include +#include +#include #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(&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()); + } } /** diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.h b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.h index 9514a17626..b465977c00 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.h +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.h @@ -25,10 +25,13 @@ #define DRAWINGGUI_DLGPREFSTECHDRAWIMPANNOTATION_H #include - +#include #include #include +namespace TechDraw { +class LineGenerator; +} namespace TechDrawGui { class Ui_DlgPrefsTechDrawAnnotationImp; @@ -53,6 +56,7 @@ protected: private: std::unique_ptr ui; + TechDraw::LineGenerator* m_lineGenerator; }; } // namespace TechDrawGui diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensions.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensions.ui index d9b2b082a1..eb4870f3f4 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensions.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensions.ui @@ -587,7 +587,7 @@ Normally, no gap is used. If a gap is used, the recommended value is 6. Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - 0.000000000000000 + 2.000000000000000 LineSpacingFactorISO diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp index 829bca5a97..0b4b276e3e 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp @@ -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(); + } /** diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneral.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneral.ui index 7d16326e2f..3b173bc8f3 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneral.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneral.ui @@ -7,7 +7,7 @@ 0 0 499 - 776 + 768 @@ -359,14 +359,7 @@ for ProjectionGroups - - - - - Projection Group Angle - - - + @@ -380,6 +373,13 @@ for ProjectionGroups + + + + Projection Group Angle + + + @@ -420,15 +420,8 @@ for ProjectionGroups - - - - Hidden Line Style - - - - + 0 @@ -437,39 +430,46 @@ for ProjectionGroups - 0 - 0 + 184 + 22 - Style for hidden lines + Standard to be used to draw section lines. This affects the position of arrows and symbol. + + + 0 - HiddenLine + SectionLineStandard - Mod/TechDraw/General + Mod/TechDraw/Standards - Continuous - - - - :/icons/continuous-line.svg:/icons/continuous-line.svg + ANSI - Dashed - - - - :/icons/dash-line.svg:/icons/dash-line.svg + ISO + + + + + true + + + + Section Line Convention + + + @@ -793,7 +793,20 @@ for ProjectionGroups - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -830,19 +843,6 @@ for ProjectionGroups - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -932,13 +932,26 @@ for ProjectionGroups - <html><head/><body><p><span style=" font-weight:600;">Note:</span> Items in <span style=" font-style:italic;">italics</span> are default values for new objects. They have no effect on existing objects.</p></body></html> + <html><head/><body><p><span style=" font-weight:600;">Note:</span> Items in <span style=" font-style:italic;">italics</span> are default values for new objects. They have no effect on existing objects.</p></body></html> true + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp index 35ffd23d7b..a258476c7e 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp @@ -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(); diff --git a/src/Mod/TechDraw/Gui/DrawGuiUtil.cpp b/src/Mod/TechDraw/Gui/DrawGuiUtil.cpp index 83d6e0c79b..495e2f1ccc 100644 --- a/src/Mod/TechDraw/Gui/DrawGuiUtil.cpp +++ b/src/Mod/TechDraw/Gui/DrawGuiUtil.cpp @@ -25,6 +25,7 @@ #ifndef _PreComp_ # include +# include # include # include # include @@ -43,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -52,11 +54,15 @@ #include #include #include +#include #include + #include +#include #include #include #include +#include #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 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 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 //=========================================================================== diff --git a/src/Mod/TechDraw/Gui/DrawGuiUtil.h b/src/Mod/TechDraw/Gui/DrawGuiUtil.h index f5082f9fee..29a7e2fca8 100644 --- a/src/Mod/TechDraw/Gui/DrawGuiUtil.h +++ b/src/Mod/TechDraw/Gui/DrawGuiUtil.h @@ -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 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); diff --git a/src/Mod/TechDraw/Gui/PreferencesGui.cpp b/src/Mod/TechDraw/Gui/PreferencesGui.cpp index 8f106b032c..d2b1565bf1 100644 --- a/src/Mod/TechDraw/Gui/PreferencesGui.cpp +++ b/src/Mod/TechDraw/Gui/PreferencesGui.cpp @@ -34,6 +34,8 @@ #include #include #include +#include + #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 (Preferences::getPreferenceGroup("Decorations")->GetInt("SectionLine", 2)); @@ -274,3 +278,4 @@ QColor PreferencesGui::lightenColor(QColor orig) return QColor(red, green, blue, alpha); } + diff --git a/src/Mod/TechDraw/Gui/QGICenterLine.cpp b/src/Mod/TechDraw/Gui/QGICenterLine.cpp index c2840a9298..dd52aed552 100644 --- a/src/Mod/TechDraw/Gui/QGICenterLine.cpp +++ b/src/Mod/TechDraw/Gui/QGICenterLine.cpp @@ -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; +} diff --git a/src/Mod/TechDraw/Gui/QGICenterLine.h b/src/Mod/TechDraw/Gui/QGICenterLine.h index 37b00b2fee..c3994806aa 100644 --- a/src/Mod/TechDraw/Gui/QGICenterLine.h +++ b/src/Mod/TechDraw/Gui/QGICenterLine.h @@ -49,6 +49,8 @@ public: void setIntersection(bool isIntersecting); + void setLinePen(QPen isoPen); + protected: QColor getCenterColor(); Qt::PenStyle getCenterStyle(); diff --git a/src/Mod/TechDraw/Gui/QGIEdge.cpp b/src/Mod/TechDraw/Gui/QGIEdge.cpp index 65e559897a..c39c758138 100644 --- a/src/Mod/TechDraw/Gui/QGIEdge.cpp +++ b/src/Mod/TechDraw/Gui/QGIEdge.cpp @@ -37,10 +37,9 @@ #include #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 (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; +} diff --git a/src/Mod/TechDraw/Gui/QGIEdge.h b/src/Mod/TechDraw/Gui/QGIEdge.h index 4667ce45f9..8c76cdf729 100644 --- a/src/Mod/TechDraw/Gui/QGIEdge.h +++ b/src/Mod/TechDraw/Gui/QGIEdge.h @@ -51,7 +51,10 @@ public: bool getSmoothEdge() { return(isSmoothEdge); } void setPrettyNormal() override; - double getEdgeFuzz(void) const; + double getEdgeFuzz() const; + + void setLinePen(QPen isoPen); + protected: diff --git a/src/Mod/TechDraw/Gui/QGIHighlight.cpp b/src/Mod/TechDraw/Gui/QGIHighlight.cpp index 35aab98e0a..b31911e212 100644 --- a/src/Mod/TechDraw/Gui/QGIHighlight.cpp +++ b/src/Mod/TechDraw/Gui/QGIHighlight.cpp @@ -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; +} diff --git a/src/Mod/TechDraw/Gui/QGIHighlight.h b/src/Mod/TechDraw/Gui/QGIHighlight.h index 18409846fc..f623947c12 100644 --- a/src/Mod/TechDraw/Gui/QGIHighlight.h +++ b/src/Mod/TechDraw/Gui/QGIHighlight.h @@ -63,6 +63,8 @@ public: void onDragFinished() override; + void setLinePen(QPen isoPen); + protected: QColor getHighlightColor(); Qt::PenStyle getHighlightStyle(); diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp index 8f8c7179ee..23e15a09e7 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp @@ -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(s); m_styleNormal = static_cast(s); } @@ -245,23 +247,7 @@ Base::Reference 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(0x20); //round; - break; - case 1: - result = static_cast(0x10); //square; - break; - case 2: - result = static_cast(0x00); //flat - break; - default: - result = static_cast(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); diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.h b/src/Mod/TechDraw/Gui/QGIPrimPath.h index 09acc6f03e..20f42dff45 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.h +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.h @@ -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; diff --git a/src/Mod/TechDraw/Gui/QGISectionLine.cpp b/src/Mod/TechDraw/Gui/QGISectionLine.cpp index 703bd46154..3780c770eb 100644 --- a/src/Mod/TechDraw/Gui/QGISectionLine.cpp +++ b/src/Mod/TechDraw/Gui/QGISectionLine.cpp @@ -500,32 +500,8 @@ void QGISectionLine::paint ( QPainter * painter, const QStyleOptionGraphicsItem void QGISectionLine::setTools() { - // Use our own style - if (m_styleCurrent == Qt::DashDotLine) { - QVector 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; +} diff --git a/src/Mod/TechDraw/Gui/QGISectionLine.h b/src/Mod/TechDraw/Gui/QGISectionLine.h index 3d07f2f15f..23df1fe4b7 100644 --- a/src/Mod/TechDraw/Gui/QGISectionLine.h +++ b/src/Mod/TechDraw/Gui/QGISectionLine.h @@ -70,6 +70,9 @@ public: void clearChangePoints(); void draw() override; + void setLinePen(QPen isoPen); + + protected: QColor getSectionColor(); Qt::PenStyle getSectionStyle(); diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index e692adf21e..0d63b907d1 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -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(getViewObject())); auto vp = static_cast(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()); - 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()); - 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(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()); - 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(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(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(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()); 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(getViewObject())); TechDraw::DrawViewDetail* dvd = nullptr; if (viewPart && viewPart->isDerivedFrom(TechDraw::DrawViewDetail::getClassTypeId())) { diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.h b/src/Mod/TechDraw/Gui/QGIViewPart.h index 21f3716749..1df080f87c 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.h +++ b/src/Mod/TechDraw/Gui/QGIViewPart.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -40,7 +41,7 @@ class DrawHatch; class DrawGeomHatch; class DrawViewDetail; class DrawView; - +class LineGenerator; } namespace TechDrawGui @@ -132,6 +133,8 @@ protected: private: QList deleteItems; PathBuilder* m_pathBuilder; + TechDraw::LineGenerator* m_dashedLineGenerator; + }; } // namespace diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp index 16c729bad1..e9144f3874 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp @@ -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()); 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(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 (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; diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.h b/src/Mod/TechDraw/Gui/TaskCenterLine.h index 0316838c36..10ccb2715f 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.h +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.h @@ -85,7 +85,6 @@ protected: double getCenterWidth(); QColor getCenterColor(); - Qt::PenStyle getCenterStyle(); double getExtendBy(); int checkPathologicalEdges(int inMode); diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.ui b/src/Mod/TechDraw/Gui/TaskCenterLine.ui index 4bab1a28d0..8173ecc129 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.ui +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.ui @@ -9,8 +9,8 @@ 0 0 - 250 - 352 + 300 + 390 @@ -137,6 +137,69 @@ + + + + + + Color + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0.100000000000000 + + + 0.500000000000000 + + + + + + + + 0 + 0 + 0 + + + + + + + + Weight + + + + + + + Style + + + + + + + -1 + + + + + + + + + Qt::Horizontal + + + @@ -146,6 +209,25 @@ + + + + + 0 + 20 + + + + Move line +Up or -Down + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + @@ -172,25 +254,6 @@ - - - - - 0 - 20 - - - - Move line +Up or -Down - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - @@ -220,25 +283,14 @@ - - - - - - Qt::Horizontal - - - - - - + Extend By - + @@ -260,105 +312,21 @@ - - - - Color - - - - - - - - 0 - 0 - 0 - - - - - - - - Weight - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0.100000000000000 - - - 0.500000000000000 - - - - - - - Style - - - - - - - 1 - - - - Continuous - - - - :/icons/continuous-line.svg:/icons/continuous-line.svg - - - - - Dash - - - - :/icons/dash-line.svg:/icons/dash-line.svg - - - - - Dot - - - - :/icons/dot-line.svg:/icons/dot-line.svg - - - - - DashDot - - - - :/icons/dashDot-line.svg:/icons/dashDot-line.svg - - - - - DashDotDot - - - - :/icons/dashDotDot-line.svg:/icons/dashDotDot-line.svg - - - - + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp index 13870a408a..db67963ac2 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp @@ -36,12 +36,15 @@ #include #include #include +#include + #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(&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()); 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); } } } diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.h b/src/Mod/TechDraw/Gui/TaskLineDecor.h index c773a1a21e..de7763d02e 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.h +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.h @@ -23,6 +23,7 @@ #ifndef GUI_TASKVIEW_TASKLINEDECOR_H #define GUI_TASKVIEW_TASKLINEDECOR_H +#include #include #include #include @@ -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 diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.ui b/src/Mod/TechDraw/Gui/TaskLineDecor.ui index 15ffa309cd..97e1884c68 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.ui +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.ui @@ -6,8 +6,8 @@ 0 0 - 350 - 200 + 355 + 311 @@ -28,113 +28,7 @@ - - - - View - - - - - - - false - - - false - - - Qt::NoFocus - - - false - - - - - - - Lines - - - - - - - false - - - - - - - Qt::Horizontal - - - - - - - Style - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 40 - 20 - - - - - - - - 0 - - - - Continuous - - - - - Dash - - - - - Dot - - - - - DashDot - - - - - DashDotDot - - - - - - - - Color - - - - + @@ -145,34 +39,21 @@ - + Weight - - - - Thickness of pattern lines. - - - Qt::AlignCenter - - - 0.500000000000000 - - - - - + + - Visible + Lines - + 1 @@ -198,8 +79,124 @@ + + + + Color + + + + + + + View + + + + + + + The use of the Qt line style is being phased out. Please use a standard line style instead. + + + -1 + + + + 32 + 32 + + + + + + + + Style + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + + + + Thickness of pattern lines. + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0.500000000000000 + + + + + + + Visible + + + + + + + false + + + + + + + false + + + false + + + Qt::NoFocus + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.cpp b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.cpp index c25f1b9b11..043b67e80c 100644 --- a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.cpp +++ b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.cpp @@ -24,20 +24,22 @@ #include +#include + #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)); diff --git a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h index 4416120532..161a0891ff 100644 --- a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h +++ b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h @@ -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; + + TechDraw::LineGenerator* m_lineGenerator; }; // class TaskSelectLineAttributes class TaskDlgSelectLineAttributes : public Gui::TaskView::TaskDialog diff --git a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.ui b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.ui index 4b334c936b..9e30a0574f 100644 --- a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.ui +++ b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.ui @@ -6,8 +6,8 @@ 0 0 - 250 - 482 + 332 + 401 @@ -27,7 +27,7 @@ - + @@ -35,63 +35,8 @@ - - - - Set line style to solid - - - Solid - - - true - - - bgLineStyles - - - - - - - Dashed - - - true - - - bgLineStyles - - - - - - - Dotted - - - true - - - bgLineStyles - - - - - - - Dashdot - - - true - - - true - - - bgLineStyles - - + + @@ -307,6 +252,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -314,7 +272,7 @@ - + true @@ -324,10 +282,5 @@ true - - - true - - diff --git a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp index 14fa7ab328..4fb5f660a6 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp @@ -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); diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index fdd12dda48..4d6de46286 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -49,6 +49,9 @@ #include #include #include +#include +#include + #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, diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.h b/src/Mod/TechDraw/Gui/ViewProviderViewPart.h index 8ae24bf453..b4a35d718f 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.h +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.h @@ -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 &) override;