diff --git a/src/Mod/TechDraw/App/DrawBrokenView.cpp b/src/Mod/TechDraw/App/DrawBrokenView.cpp index 15df01ac78..79d63fd754 100644 --- a/src/Mod/TechDraw/App/DrawBrokenView.cpp +++ b/src/Mod/TechDraw/App/DrawBrokenView.cpp @@ -98,6 +98,11 @@ using SU = ShapeUtils; // DrawBrokenView //=========================================================================== +const char *DrawBrokenView::BreakTypeEnums[] = { + QT_TRANSLATE_NOOP("DrawBrokenView", "None"), + QT_TRANSLATE_NOOP("DrawBrokenView", "ZigZag"), + QT_TRANSLATE_NOOP("DrawBrokenView", "Simple"), + nullptr}; PROPERTY_SOURCE(TechDraw::DrawBrokenView, TechDraw::DrawViewPart) DrawBrokenView::DrawBrokenView() diff --git a/src/Mod/TechDraw/App/DrawBrokenView.h b/src/Mod/TechDraw/App/DrawBrokenView.h index b4d0a53930..6d1c2c9e0f 100644 --- a/src/Mod/TechDraw/App/DrawBrokenView.h +++ b/src/Mod/TechDraw/App/DrawBrokenView.h @@ -60,6 +60,14 @@ class TechDrawExport DrawBrokenView: public TechDraw::DrawViewPart PROPERTY_HEADER_WITH_OVERRIDE(TechDraw::DrawBrokenView); public: + enum BreakType + { + NONE, + ZIGZAG, + SIMPLE + }; + static const char* BreakTypeEnums[]; + DrawBrokenView(); ~DrawBrokenView() override; diff --git a/src/Mod/TechDraw/App/Preferences.cpp b/src/Mod/TechDraw/App/Preferences.cpp index 0dea12bf39..7373ea9b00 100644 --- a/src/Mod/TechDraw/App/Preferences.cpp +++ b/src/Mod/TechDraw/App/Preferences.cpp @@ -502,6 +502,11 @@ int Preferences::HiddenLineStyle() return getPreferenceGroup("Decorations")->GetInt("LineStyleHidden", 1) + 1; } +int Preferences::BreakLineStyle() +{ + return getPreferenceGroup("Decorations")->GetInt("LineStyleBreak", 0) + 1; +} + int Preferences::LineSpacingISO() { return getPreferenceGroup("Dimensions")->GetInt("LineSpacingFactorISO", 2); @@ -578,5 +583,9 @@ bool Preferences::useExactMatchOnDims() return getPreferenceGroup("Dimensions")->GetBool("UseMatcher", true); } +int Preferences::BreakType() +{ + return getPreferenceGroup("Decorations")->GetInt("BreakType", 2); +} diff --git a/src/Mod/TechDraw/App/Preferences.h b/src/Mod/TechDraw/App/Preferences.h index 1903d6cded..822286025f 100644 --- a/src/Mod/TechDraw/App/Preferences.h +++ b/src/Mod/TechDraw/App/Preferences.h @@ -119,6 +119,7 @@ public: static int CenterLineStyle(); static int HighlightLineStyle(); static int HiddenLineStyle(); + static int BreakLineStyle(); static int LineCapStyle(); static int LineCapIndex(); @@ -131,6 +132,8 @@ public: static bool showSectionLine(); static bool includeCutLine(); + static int BreakType(); + static bool useExactMatchOnDims(); }; diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui index d012ba3aad..e21e117665 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui @@ -65,6 +65,333 @@ + + + + This checkbox controls whether or not to display a highlight around the detail area in the detail's source view. + + + Detail Source Show Highlight + + + true + + + ShowDetailHighlight + + + /Mod/TechDraw/General + + + + + + + + true + + + + Section Cut Surface + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Style for balloon leader line ends + + + BalloonArrow + + + Mod/TechDraw/Decorations + + + + + + + + true + + + + Balloon Leader End + + + + + + + + true + + + + If checked, the cut line will be drawn on the Source view. If unchecked, only the change marks, arrows and symbols will be displayed. + + + Include Cut Line in Section Annotation + + + true + + + IncludeCutLine + + + 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 + + + + + + + This checkbox controls whether or not to display the outline around a detail view. + + + Detail View Show Matting + + + true + + + ShowDetailMatting + + + /Mod/TechDraw/General + + + + + + + + true + + + + If checked, the section annotation will be drawn on the Source view. If unchecked, no section line, arrows or symbol will be shown in the Source view. + + + Show Section Line in Source View + + + true + + + ShowSectionLine + + + Mod/TechDraw/Decorations + + + + + + + + false + + + + Detail View Outline Shape + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Restrict Filled Triangle line end to vertical or horizontal directions + + + Balloon Orthogonal Triangle + + + true + + + PyramidOrtho + + + Mod/TechDraw/Decorations + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Show arc centers in printed output + + + Print Center Marks + + + PrintCenterMarks + + + Mod/TechDraw/Decorations + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + true + + + + Forces last leader line segment to be horizontal + + + Leader Line Auto Horizontal + + + true + + + AutoHorizontal + + + Mod/TechDraw/LeaderLine + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + true + + + + Show arc center marks in views + + + Show Center Marks + + + true + + + ShowCenterMarks + + + Mod/TechDraw/Decorations + + + + + + + + true + + + + Balloon Shape + + + @@ -107,47 +434,47 @@ - - - - - true - + + + + + 0 + 0 + - - Balloon Leader End + + + 0 + 0 + - - - - - - - false - - - - Detail View Outline Shape - - - - - - This checkbox controls whether or not to display the outline around a detail view. - - - Detail View Show Matting - - - true + Outline shape for detail views - ShowDetailMatting + MattingStyle - /Mod/TechDraw/General + /Mod/TechDraw/Decorations + + + Circle + + + + :/icons/circular.svg:/icons/circular.svg + + + + + Square + + + + :/icons/square.svg:/icons/square.svg + + @@ -247,245 +574,6 @@ - - - - - true - - - - Balloon Shape - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Outline shape for detail views - - - MattingStyle - - - /Mod/TechDraw/Decorations - - - - Circle - - - - :/icons/circular.svg:/icons/circular.svg - - - - - Square - - - - :/icons/square.svg:/icons/square.svg - - - - - - - - - true - - - - Show or hide marks at direction changes on ComplexSection lines. - - - Complex Section Line Marks - - - true - - - SectionLineMarks - - - Mod/TechDraw/Decorations - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Restrict Filled Triangle line end to vertical or horizontal directions - - - Balloon Orthogonal Triangle - - - true - - - PyramidOrtho - - - Mod/TechDraw/Decorations - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Style for balloon leader line ends - - - BalloonArrow - - - Mod/TechDraw/Decorations - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - true - - - - Forces last leader line segment to be horizontal - - - Leader Line Auto Horizontal - - - true - - - AutoHorizontal - - - Mod/TechDraw/LeaderLine - - - - - - - - true - - - - Section Cut Surface - - - - - - - - true - - - - If checked, the section annotation will be drawn on the Source view. If unchecked, no section line, arrows or symbol will be shown in the Source view. - - - Show Section Line in Source View - - - true - - - ShowSectionLine - - - Mod/TechDraw/Decorations - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - This checkbox controls whether or not to display a highlight around the detail area in the detail's source view. - - - Detail Source Show Highlight - - - true - - - ShowDetailHighlight - - - /Mod/TechDraw/General - - - @@ -502,91 +590,43 @@ - - - - 0 - 0 - - - - - 0 - 0 - - + true - - Show arc center marks in views - - Show Center Marks - - - true - - - ShowCenterMarks - - - Mod/TechDraw/Decorations + Broken View Break Type - - - - 0 - 0 - - - - - 0 - 0 - - - - Show arc centers in printed output - - - Print Center Marks + + + 2 - PrintCenterMarks - - - Mod/TechDraw/Decorations - - - - - - - - true - - - - If checked, the cut line will be drawn on the Source view. If unchecked, only the change marks, arrows and symbols will be displayed. - - - Include Cut Line in Section Annotation - - - true - - - IncludeCutLine + BreakType Mod/TechDraw/Decorations + + + No Break Lines + + + + + ZigZag Lines + + + + + Simple Lines + + @@ -608,58 +648,6 @@ - - - - - true - - - - Section Line Style - - - - - - - - 0 - 0 - - - - 6 - - - - 32 - 32 - - - - LineStyleSection - - - /Mod/TechDraw/Decorations - - - - - - - - true - - - - Line style of detail highlight on base view - - - Detail Highlight Style - - - @@ -700,56 +688,6 @@ - - - - - 0 - 0 - - - - 6 - - - - 32 - 32 - - - - LineStyleCenter - - - /Mod/TechDraw/Decorations - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - LineGroup - - - /Mod/TechDraw/Decorations - - - - - - @@ -778,56 +716,28 @@ - - + + 0 0 - - - true - - - - Line group used to set line widths - - - Line Width Group - - - - - - - Hidden Line Style - - - - - - - Qt::Horizontal - - + - 40 - 20 + 0 + 22 - - - - - - - false - + + LineGroup - - Line Standard + + /Mod/TechDraw/Decorations + + + @@ -856,19 +766,71 @@ - - + + + + + true + + + + Line style of detail highlight on base view + + + Detail Highlight Style + + + + + + + + true + + + + Section Line Style + + + + + + + + 0 + 0 + + + + 6 + + + + 32 + 32 + + + + LineStyleSection + + + /Mod/TechDraw/Decorations + + + + + false - Line End Cap Shape + Line Standard - + @@ -916,6 +878,109 @@ if you are planning to use a drawing as a 1:1 cutting guide. + + + + + 0 + 0 + + + + 6 + + + + 32 + 32 + + + + LineStyleCenter + + + /Mod/TechDraw/Decorations + + + + + + + + 0 + 0 + + + + + true + + + + Line group used to set line widths + + + Line Width Group + + + + + + + + false + + + + Line End Cap Shape + + + + + + + Hidden Line Style + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + true + + + + Break Line Style + + + + + + + Style of line to be used in BrokenView. + + + LineStyleBreak + + + /Mod/TechDraw/Decorations + + + diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp index 36163b1501..19fb25184a 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp @@ -118,6 +118,9 @@ void DlgPrefsTechDrawAnnotationImp::saveSettings() ui->pcbDetailMatting->onSave(); ui->pcbDetailHighlight->onSave(); + + ui->pcbBreakType->onSave(); + ui->pcbBreakStyle->onSave(); } void DlgPrefsTechDrawAnnotationImp::loadSettings() @@ -177,7 +180,10 @@ void DlgPrefsTechDrawAnnotationImp::loadSettings() ui->pcbCenterStyle->onRestore(); ui->pcbHighlightStyle->onRestore(); ui->pcbHiddenStyle->onRestore(); + ui->pcbBreakStyle->onRestore(); loadLineStyleBoxes(); + + ui->pcbBreakType->onRestore(); } /** @@ -265,6 +271,11 @@ void DlgPrefsTechDrawAnnotationImp::loadLineStyleBoxes() if (ui->pcbHiddenStyle->count() > Preferences::HiddenLineStyle()) { ui->pcbHiddenStyle->setCurrentIndex(Preferences::HiddenLineStyle() - 1); } + + DrawGuiUtil::loadLineStyleChoices(ui->pcbBreakStyle, m_lineGenerator); + if (ui->pcbBreakStyle->count() > Preferences::BreakLineStyle()) { + ui->pcbBreakStyle->setCurrentIndex(Preferences::BreakLineStyle() - 1); + } } #include diff --git a/src/Mod/TechDraw/Gui/QGIBreakLine.cpp b/src/Mod/TechDraw/Gui/QGIBreakLine.cpp index 1862c836e5..894253e37a 100644 --- a/src/Mod/TechDraw/Gui/QGIBreakLine.cpp +++ b/src/Mod/TechDraw/Gui/QGIBreakLine.cpp @@ -71,7 +71,33 @@ QGIBreakLine::QGIBreakLine() void QGIBreakLine::draw() { - // Base::Console().Message("QGIBL::draw()\n"); + if (breakType() == 0) { + // none + m_background->hide(); + m_line0->hide(); + m_line1->hide(); + } + + if (breakType() == 1) { + drawLargeZigZag(); + m_background->show(); + m_line0->show(); + m_line1->show(); + } + + if (breakType() == 2) { + // simple line from pref + drawSimpleLines(); + m_background->hide(); + m_line0->show(); + m_line1->show(); + } + + update(); +} + +void QGIBreakLine::drawLargeZigZag() +{ Base::Vector3d horizontal{1.0, 0.0, 0.0}; prepareGeometryChange(); double offset = zigzagWidth / 2.0; @@ -100,11 +126,6 @@ void QGIBreakLine::draw() std::fabs(m_right - m_left + zigzagWidth), std::fabs(m_top - m_bottom + zigzagWidth)); m_background->setRect(backgroundRect); - - m_line0->show(); - m_line1->show(); - m_background->show(); - update(); } // start needs to be Rez'd and +Y up @@ -150,6 +171,44 @@ QPainterPath QGIBreakLine::makeVerticalZigZag(Base::Vector3d start) const return pPath; } + +void QGIBreakLine::drawSimpleLines() +{ + Base::Vector3d horizontal{1.0, 0.0, 0.0}; + prepareGeometryChange(); + if (DU::fpCompare(fabs(m_direction.Dot(horizontal)), 1.0, EWTOLERANCE)) { + // m_direction connects the two cut points. The break lines have + // to be perpendicular to m_direction + Base::Vector3d start = Base::Vector3d(m_left, m_bottom, 0.0); + Base::Vector3d end = Base::Vector3d(m_left, m_top, 0.0); + m_line0->setPath(pathFromPoints(start, end)); + + start = Base::Vector3d(m_right, m_bottom, 0.0); + end = Base::Vector3d(m_right, m_top, 0.0); + m_line1->setPath(pathFromPoints(start, end)); + } else { + // m_top is lower than m_bottom due to Qt Y+ down coords + // the higher break line + // 2x horizontal zigszags + Base::Vector3d start = Base::Vector3d(m_left, m_bottom, 0.0); + Base::Vector3d end = Base::Vector3d(m_right, m_bottom, 0.0); + m_line0->setPath(pathFromPoints(start, end)); + + // the lower break line + start = Base::Vector3d(m_left, m_top, 0.0); + end = Base::Vector3d(m_right, m_top, 0.0); + m_line1->setPath(pathFromPoints(start, end)); + } +} + +QPainterPath QGIBreakLine::pathFromPoints(Base::Vector3d start, Base::Vector3d end) +{ + QPainterPath result(DU::toQPointF(start)); + result.lineTo(DU::toQPointF(end)); + return result; +} + + void QGIBreakLine::setBounds(double left, double top, double right, double bottom) { // Base::Console().Message("QGIBL::setBounds(%.3f, %.3f, %.3f, %.3f\n", left, top, right, bottom); diff --git a/src/Mod/TechDraw/Gui/QGIBreakLine.h b/src/Mod/TechDraw/Gui/QGIBreakLine.h index 12c225234f..c8a5912a24 100644 --- a/src/Mod/TechDraw/Gui/QGIBreakLine.h +++ b/src/Mod/TechDraw/Gui/QGIBreakLine.h @@ -59,11 +59,18 @@ public: void setLinePen(QPen isoPen); void setBreakColor(QColor c); + void setBreakType(int style) { m_breakType = style; } + int breakType() const { return m_breakType; } + protected: private: + void drawLargeZigZag(); QPainterPath makeHorizontalZigZag(Base::Vector3d start) const; QPainterPath makeVerticalZigZag(Base::Vector3d start) const; + void drawSimpleLines(); + QPainterPath pathFromPoints(Base::Vector3d start, Base::Vector3d end); + void setTools(); QGraphicsPathItem* m_line0; @@ -76,6 +83,8 @@ private: double m_bottom; double m_left; double m_right; + + int m_breakType{0}; }; } diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 71575d560e..3ba81c8c29 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -1046,6 +1046,7 @@ void QGIViewPart::drawBreakLines() return; } + auto breakType = vp->BreakLineType.getValue(); auto breaks = dbv->Breaks.getValues(); for (auto& breakObj : breaks) { QGIBreakLine* breakLine = new QGIBreakLine(); @@ -1061,8 +1062,9 @@ void QGIViewPart::drawBreakLines() breakLine->setBounds(topLeft, bottomRight); breakLine->setPos(0.0, 0.0); breakLine->setLinePen( - m_dashedLineGenerator->getLinePen(1, vp->HiddenWidth.getValue())); + m_dashedLineGenerator->getLinePen(vp->BreakLineStyle.getValue(), vp->HiddenWidth.getValue())); breakLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue())); + breakLine->setBreakType(breakType); breakLine->setZValue(ZVALUE::SECTIONLINE); App::Color color = prefBreaklineColor(); breakLine->setBreakColor(color.asValue()); diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index 9d95bd7349..fcc4ebd482 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,7 @@ ViewProviderViewPart::ViewProviderViewPart() static const char *hgroup = "Highlight"; static const char *sgroup = "Section Line"; static const char *fgroup = "Faces"; + static const char *bvgroup = "Broken View"; //default line weights @@ -128,6 +130,13 @@ ViewProviderViewPart::ViewProviderViewPart() "Set highlight line color if applicable"); ADD_PROPERTY_TYPE(HighlightAdjust, (0.0), hgroup, App::Prop_None, "Adjusts the rotation of the Detail highlight"); + // properties that affect BrokenViews + BreakLineType.setEnums(DrawBrokenView::BreakTypeEnums); + ADD_PROPERTY_TYPE(BreakLineType, (Preferences::BreakType()), bvgroup, App::Prop_None, + "Adjusts the type of break line depiction on broken views"); + ADD_PROPERTY_TYPE(BreakLineStyle, (Preferences::BreakLineStyle()), bvgroup, App::Prop_None, + "Set break line style if applicable"); + ADD_PROPERTY_TYPE(ShowAllEdges ,(false),dgroup, App::Prop_None, "Temporarily show invisible lines"); // Faces related properties @@ -141,12 +150,15 @@ ViewProviderViewPart::ViewProviderViewPart() if (bodyName == "ISO") { SectionLineStyle.setEnums(ISOLineName::ISOLineNameEnums); HighlightLineStyle.setEnums(ISOLineName::ISOLineNameEnums); + BreakLineStyle.setEnums(ISOLineName::ISOLineNameEnums); } else if (bodyName == "ANSI") { SectionLineStyle.setEnums(ANSILineName::ANSILineNameEnums); HighlightLineStyle.setEnums(ANSILineName::ANSILineNameEnums); + BreakLineStyle.setEnums(ANSILineName::ANSILineNameEnums); } else if (bodyName == "ASME") { SectionLineStyle.setEnums(ASMELineName::ASMELineNameEnums); HighlightLineStyle.setEnums(ASMELineName::ASMELineNameEnums); + BreakLineStyle.setEnums(ASMELineName::ASMELineNameEnums); } } @@ -184,7 +196,9 @@ void ViewProviderViewPart::onChanged(const App::Property* prop) prop == &(HorizCenterLine) || prop == &(VertCenterLine) || prop == &(FaceColor) || - prop == &(FaceTransparency)) { + prop == &(FaceTransparency) || + prop == &(BreakLineType) || + prop == &(BreakLineStyle) ) { // redraw QGIVP QGIView* qgiv = getQView(); if (qgiv) { diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.h b/src/Mod/TechDraw/Gui/ViewProviderViewPart.h index 1509c1e048..65cc67ddf9 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.h +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.h @@ -60,6 +60,8 @@ public: App::PropertyEnumeration HighlightLineStyle; App::PropertyColor HighlightLineColor; App::PropertyFloat HighlightAdjust; + App::PropertyEnumeration BreakLineType; + App::PropertyEnumeration BreakLineStyle; App::PropertyBool ShowAllEdges; App::PropertyColor FaceColor; App::PropertyPercent FaceTransparency;