From 1d3aca07339c1b8a47b2a5ff2597eafb4e8e11ef Mon Sep 17 00:00:00 2001 From: wandererfan Date: Wed, 25 Oct 2023 19:08:02 -0400 Subject: [PATCH] [TD]handle loose geometry via HLR --- src/Mod/TechDraw/App/DrawViewDetail.cpp | 2 +- src/Mod/TechDraw/App/DrawViewPart.cpp | 28 +- src/Mod/TechDraw/App/DrawViewPart.h | 2 +- src/Mod/TechDraw/App/DrawViewSection.cpp | 2 +- src/Mod/TechDraw/App/ShapeExtractor.cpp | 18 +- src/Mod/TechDraw/App/ShapeExtractor.h | 3 +- .../TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui | 716 ++++++++---------- 7 files changed, 350 insertions(+), 421 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 56308c31fd..b4d662ab67 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -167,7 +167,7 @@ App::DocumentObjectExecReturn* DrawViewDetail::execute() } detailExec(shape, dvp, dvs); - addShapes2d(); + addPoints(); dvp->requestPaint();//to refresh detail highlight in base view return DrawView::execute(); diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index c45f485769..cdd99747eb 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -201,15 +201,12 @@ std::vector DrawViewPart::getAllSources() const return result; } -//! pick supported 2d shapes out of the Source properties and +//! pick vertex objects out of the Source properties and //! add them directly to the geometry without going through HLR -//! NOTE: this is for loose 2d shapes such as Part line or circle and is -//! not meant to include complex 2d shapes such as Sketches. -void DrawViewPart::addShapes2d(void) +void DrawViewPart::addPoints(void) { -// Base::Console().Message("DVP::addShapes2d()\n"); - // get all the 2d shapes in the sources, then pick through them for loose edges - // or vertices. +// Base::Console().Message("DVP::addPoints()\n"); + // get all the 2d shapes in the sources, then pick through them for vertices. std::vector shapes = ShapeExtractor::getShapes2d(getAllSources()); for (auto& s : shapes) { if (s.ShapeType() == TopAbs_VERTEX) { @@ -221,21 +218,6 @@ void DrawViewPart::addShapes2d(void) TechDraw::VertexPtr v1(std::make_shared(projected)); geometryObject->addVertex(v1); } - else if (s.ShapeType() == TopAbs_EDGE) { - TopoDS_Shape sTrans = ShapeUtils::moveShape(s, - m_saveCentroid * -1.0); - TopoDS_Shape sScale = ShapeUtils::scaleShape(sTrans, - getScale()); - TopoDS_Shape sMirror = ShapeUtils::mirrorShape(sScale); - TopoDS_Edge edge = TopoDS::Edge(sMirror); - BaseGeomPtr bg = projectEdge(edge); - - geometryObject->addEdge(bg); - - } else { - // message for developers. - //Base::Console().Message("DEVEL: DVP::addShapes2d - shape is not a vertex or edge\n"); - } } } @@ -448,7 +430,7 @@ void DrawViewPart::postHlrTasks(void) addCosmeticVertexesToGeom(); addCosmeticEdgesToGeom(); addReferencesToGeom(); - addShapes2d(); + addPoints(); //balloons need to be recomputed here because their //references will be invalid until the geometry exists diff --git a/src/Mod/TechDraw/App/DrawViewPart.h b/src/Mod/TechDraw/App/DrawViewPart.h index b0c0c2cdd2..d4ab35e1df 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.h +++ b/src/Mod/TechDraw/App/DrawViewPart.h @@ -225,7 +225,7 @@ protected: const gp_Ax2& viewAxis); virtual TechDraw::GeometryObjectPtr makeGeometryForShape(TopoDS_Shape& shape);//const?? void partExec(TopoDS_Shape& shape); - virtual void addShapes2d(void); + virtual void addPoints(void); void extractFaces(); void findFacesNew(const std::vector& goEdges); diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 2d35be7d8c..3d527715ae 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -421,7 +421,7 @@ App::DocumentObjectExecReturn* DrawViewSection::execute() } sectionExec(baseShape); - addShapes2d(); + addPoints(); return DrawView::execute(); } diff --git a/src/Mod/TechDraw/App/ShapeExtractor.cpp b/src/Mod/TechDraw/App/ShapeExtractor.cpp index f647ccea48..c1aefc982a 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.cpp +++ b/src/Mod/TechDraw/App/ShapeExtractor.cpp @@ -47,7 +47,6 @@ #include "ShapeExtractor.h" #include "DrawUtil.h" -#include "Preferences.h" #include "ShapeUtils.h" @@ -55,14 +54,15 @@ using namespace TechDraw; using DU = DrawUtil; using SU = ShapeUtils; -std::vector ShapeExtractor::getShapes2d(const std::vector links, bool overridePref) + +//! pick out the 2d document objects objects in the list of links and return a vector of their shapes +//! Note that point objects will not make it through the hlr/projection process. +std::vector ShapeExtractor::getShapes2d(const std::vector links) { // Base::Console().Message("SE::getShapes2d() - links: %d\n", links.size()); std::vector shapes2d; - if (!prefAdd2d() && !overridePref) { - return shapes2d; - } + for (auto& l:links) { const App::GroupExtension* gex = dynamic_cast(l); if (gex) { @@ -333,7 +333,7 @@ TopoDS_Shape ShapeExtractor::getShapesFused(const std::vector shapes2d = getShapes2d(links, true); + std::vector shapes2d = getShapes2d(links); if (!shapes2d.empty()) { shapes2d.push_back(baseShape); return DrawUtil::shapeVectorToCompound(shapes2d, false); @@ -472,9 +472,3 @@ TopoDS_Shape ShapeExtractor::getLocatedShape(const App::DocumentObject* docObj) return shape.getShape(); } -//! true if we should include loose 2d geometry -bool ShapeExtractor::prefAdd2d() -{ - return Preferences::getPreferenceGroup("General")->GetBool("ShowLoose2d", false); -} - diff --git a/src/Mod/TechDraw/App/ShapeExtractor.h b/src/Mod/TechDraw/App/ShapeExtractor.h index 0575cda726..baabb4537c 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.h +++ b/src/Mod/TechDraw/App/ShapeExtractor.h @@ -40,7 +40,7 @@ class TechDrawExport ShapeExtractor { public: static TopoDS_Shape getShapes(const std::vector links, bool include2d = true); - static std::vector getShapes2d(const std::vector links, bool overridePref = false); + static std::vector getShapes2d(const std::vector links); static std::vector getXShapes(const App::Link* xLink); static std::vector getShapesFromObject(const App::DocumentObject* docObj); static TopoDS_Shape getShapesFused(const std::vector links); @@ -51,7 +51,6 @@ public: static bool isPointType(App::DocumentObject* obj); static bool isDraftPoint(App::DocumentObject* obj); static Base::Vector3d getLocation3dFromFeat(App::DocumentObject *obj); - static bool prefAdd2d(); static TopoDS_Shape stripInfiniteShapes(TopoDS_Shape inShape); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui index a63aa8e32b..91db4dd5bc 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvanced.ui @@ -40,6 +40,316 @@ + + + + + 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 + + + + Dump intermediate results during Section view processing + + + Debug Section + + + debugSection + + + Mod/TechDraw/debug + + + + + + + + 0 + 0 + + + + + 174 + 0 + + + + + 0 + 0 + + + + Size of selection area around edges +Each unit is approx. 0.1 mm wide + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 10.000000000000000 + + + EdgeFuzz + + + Mod/TechDraw/General + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Edge Fuzz + + + + + + + + 0 + 0 + + + + Include edges with unexpected geometry (zero length etc.) in results + + + Allow Crazy Edges + + + allowCrazyEdge + + + Mod/TechDraw/debug + + + + + + + + 0 + 20 + + + + Maximum hatch line segments to use +when hatching a face with a PAT pattern + + + Qt::AlignRight + + + 1 + + + 1000000 + + + 100 + + + 10000 + + + MaxSeg + + + Mod/TechDraw/PAT + + + + + + + + 0 + 0 + + + + Mark Fuzz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 174 + 0 + + + + + 0 + 0 + + + + Selection area around center marks +Each unit is approx. 0.1 mm wide + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5.000000000000000 + + + MarkFuzz + + + Mod/TechDraw/General + + + + + + + Max SVG Hatch Tiles + + + + + + + + 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 + 0 + + + + + 0 + 20 + + + + Dump intermediate results during Detail view processing + + + Debug Detail + + + debugDetail + + + Mod/TechDraw/debug + + + @@ -87,93 +397,6 @@ - - - - - true - - - - Overlap Edges Scrub Passes - - - - - - - - true - - - - Line End Cap Shape - - - - - - - - 0 - 0 - - - - - 174 - 0 - - - - - 0 - 0 - - - - Selection area around center marks -Each unit is approx. 0.1 mm wide - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5.000000000000000 - - - MarkFuzz - - - Mod/TechDraw/General - - - - - - - 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 - - - @@ -193,57 +416,25 @@ Each unit is approx. 0.1 mm wide - - - - - 0 - 0 - + + + + If checked, system will attempt to automatically correct dimension references when the model changes. - - - 0 - 0 - + + - Edge Fuzz + Auto Correct Dimension Refs - - - - - - - 0 - 20 - - - - Maximum hatch line segments to use -when hatching a face with a PAT pattern - - - Qt::AlignRight - - - 1 - - - 1000000 - - - 100 - - - 10000 + + true - MaxSeg + AutoCorrectRefs - Mod/TechDraw/PAT + Mod/TechDraw/Dimensions @@ -275,277 +466,45 @@ can be a performance penalty in complex models. - - - - - 0 - 0 - - - - - 0 - 20 - - + + true - - Perform a fuse operation on input shape(s) before Section view processing - - Fuse Before Section - - - SectionFuseFirst - - - Mod/TechDraw/General + Overlap Edges Scrub Passes - - - - - 0 - 0 - - - - Mark Fuzz - - - - - - - - 0 - 0 - - - - - 174 - 0 - - - - - 0 - 0 - - - - Size of selection area around edges -Each unit is approx. 0.1 mm wide - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 10.000000000000000 - - - EdgeFuzz - - - Mod/TechDraw/General - - - - - - - - 0 - 0 - - - - - 0 - 20 - - - - Dump intermediate results during Detail view processing - - - Debug Detail - - - debugDetail - - - Mod/TechDraw/debug - - - - - - - - 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 - - - - + Max PAT Hatch Segments - - + + - If checked, system will attempt to automatically correct dimension references when the model changes. + 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 + + - - 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 - - - - - - - - 0 - 0 - - - - Include edges with unexpected geometry (zero length etc.) in results - - - Allow Crazy Edges - - - allowCrazyEdge - - - Mod/TechDraw/debug - - - - - - - Max SVG Hatch Tiles - - - - - - - Shape of line end caps. -Only change unless you know what you are doing! - - - EdgeCapStyle + ScrubCount Mod/TechDraw/General - - - Round - - - - - Square - - - - - Flat - - @@ -598,11 +557,6 @@ Only change unless you know what you are doing! QCheckBox
Gui/PrefWidgets.h
- - Gui::PrefComboBox - QComboBox -
Gui/PrefWidgets.h
-
Gui::PrefDoubleSpinBox QDoubleSpinBox