From 28a6ca7ce22d78c61200d57bdd0dbe70570d707b Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sun, 2 Mar 2025 08:06:46 -0500 Subject: [PATCH 1/3] [TD]use correct property type for directions --- src/Mod/TechDraw/App/DrawViewPart.cpp | 28 +++++++++++++++++++++++++++ src/Mod/TechDraw/App/DrawViewPart.h | 7 ++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 987f37b84a..c03fcca040 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -1042,6 +1042,7 @@ bool DrawViewPart::hasGeometry() const const std::vector& verts = getVertexGeometry(); const std::vector& edges = getEdgeGeometry(); + return !(verts.empty() && edges.empty()); } @@ -1477,6 +1478,33 @@ void DrawViewPart::resetReferenceVerts() addReferencesToGeom(); } +void DrawViewPart::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop) +{ + if (prop == &Direction) { + // Direction was PropertyVector but is now PropertyDirection + App::PropertyVector tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + Direction.setValue(tmpValue); + } + return; + } + + if (prop == &XDirection) { + // XDirection was PropertyFloat but is now PropertyLength + App::PropertyVector tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + XDirection.setValue(tmpValue); + } + return; + } +} + // debugging ---------------------------------------------------------------------------- void DrawViewPart::dumpVerts(std::string text) diff --git a/src/Mod/TechDraw/App/DrawViewPart.h b/src/Mod/TechDraw/App/DrawViewPart.h index e5d772097e..6265c2544c 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.h +++ b/src/Mod/TechDraw/App/DrawViewPart.h @@ -90,9 +90,8 @@ public: App::PropertyLinkList Source; App::PropertyXLinkList XSource; - App::PropertyVector - Direction;//TODO: Rename to YAxisDirection or whatever this actually is (ProjectionDirection) - App::PropertyVector XDirection; + App::PropertyDirection Direction; // the projection direction + App::PropertyDirection XDirection; App::PropertyBool Perspective; App::PropertyDistance Focus; @@ -115,6 +114,8 @@ public: App::DocumentObjectExecReturn* execute() override; const char* getViewProviderName() const override { return "TechDrawGui::ViewProviderViewPart"; } PyObject* getPyObject() override; + void handleChangedPropertyType( + Base::XMLReader &reader, const char * TypeName, App::Property * prop) override; static TopoDS_Shape centerScaleRotate(const DrawViewPart* dvp, TopoDS_Shape& inOutShape, Base::Vector3d centroid); From d616b229e77257dd85dd5004f5e65a94b2ba31ba Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sun, 2 Mar 2025 08:24:52 -0500 Subject: [PATCH 2/3] [TD]use correct property types and spinboxes for Section --- src/Mod/TechDraw/App/DrawViewSection.cpp | 54 +++++- src/Mod/TechDraw/App/DrawViewSection.h | 6 +- src/Mod/TechDraw/Gui/TaskSectionView.cpp | 2 +- src/Mod/TechDraw/Gui/TaskSectionView.ui | 154 +++++++++--------- .../TechDraw/Gui/Widgets/CompassWidget.cpp | 11 +- src/Mod/TechDraw/Gui/Widgets/CompassWidget.h | 6 +- 6 files changed, 139 insertions(+), 94 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 615a350e91..b9d41f5551 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -66,7 +66,6 @@ #include #include #include -#include #include #include #include @@ -735,7 +734,7 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap -m_shapeSize, m_shapeSize); BRepTools::Write(mkFace.Face(), "DVSSectionPlane.brep");// debug - BRepTools::Write(shape, "DVSShapeToIntersect.brep)"); + BRepTools::Write(shape, "DVSShapeToIntersect.brep"); } BRep_Builder builder; TopoDS_Compound result; @@ -759,10 +758,6 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap // move section faces to line up with cut shape TopoDS_Compound DrawViewSection::alignSectionFaces(TopoDS_Shape faceIntersections) { - // Base::Console().Message("DVS::alignSectionFaces() - %s - - // faceIntersection.isnull: %d\n", - // getNameInDocument(), - // faceIntersections.IsNull()); TopoDS_Compound sectionFaces; TopoDS_Shape centeredShape = ShapeUtils::moveShape(faceIntersections, getOriginalCentroid() * -1.0); @@ -773,6 +768,10 @@ TopoDS_Compound DrawViewSection::alignSectionFaces(TopoDS_Shape faceIntersection ShapeUtils::rotateShape(scaledSection, getProjectionCS(), Rotation.getValue()); } + if (debugSection()) { + BRepTools::Write(scaledSection, "DVSScaledSectionFaces.brep"); + } + return mapToPage(scaledSection); } @@ -796,12 +795,23 @@ TopoDS_Compound DrawViewSection::mapToPage(TopoDS_Shape& shapeToAlign) TopExp_Explorer expFace(shapeToAlign, TopAbs_FACE); for (int iFace = 1; expFace.More(); expFace.Next(), iFace++) { const TopoDS_Face& face = TopoDS::Face(expFace.Current()); + if (debugSection()) { + std::stringstream ss; + ss << "DVSFace" << iFace << ".brep"; + BRepTools::Write(face, ss.str().c_str());// debug + } + + std::vector faceWires; TopExp_Explorer expWires(face, TopAbs_WIRE); for (; expWires.More(); expWires.Next()) { const TopoDS_Wire& wire = TopoDS::Wire(expWires.Current()); - TopoDS_Shape projectedShape = - GeometryObject::projectSimpleShape(wire, getProjectionCS()); + TopoDS_Shape projectedShape = GeometryObject::projectSimpleShape(wire, getProjectionCS()); + if (debugSection()) { + std::stringstream ss; + ss << "DVSProjectedWire" << iFace << ".brep"; + BRepTools::Write(projectedShape, ss.str().c_str());// debug + } std::vector wireEdges; // projectedShape is just a bunch of edges. we have to rebuild the wire. TopExp_Explorer expEdges(projectedShape, TopAbs_EDGE); @@ -809,6 +819,7 @@ TopoDS_Compound DrawViewSection::mapToPage(TopoDS_Shape& shapeToAlign) const TopoDS_Edge& edge = TopoDS::Edge(expEdges.Current()); wireEdges.push_back(edge); } + TopoDS_Wire cleanWire = EdgeWalker::makeCleanWire(wireEdges, 2.0 * EWTOLERANCE); faceWires.push_back(cleanWire); } @@ -1225,6 +1236,33 @@ void DrawViewSection::setupObject() DrawViewPart::setupObject(); } +void DrawViewSection::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop) +{ + if (prop == &SectionOrigin) { + // SectionOrigin was PropertyVector but is now PropertyPosition + App::PropertyVector tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + SectionOrigin.setValue(tmpValue); + } + return; + } + + if (prop == &SectionNormal) { + // Radius was PropertyVector but is now PropertyDirection + App::PropertyVector tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + SectionNormal.setValue(tmpValue); + } + return; + } +} + // hatch file routines // create geometric hatch lines diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 95a0919d93..d1c816c0c2 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -84,8 +84,8 @@ public: ~DrawViewSection() override; App::PropertyLink BaseView; - App::PropertyVector SectionNormal; - App::PropertyVector SectionOrigin; + App::PropertyDirection SectionNormal; + App::PropertyPosition SectionOrigin; App::PropertyString SectionSymbol; @@ -118,6 +118,8 @@ public: } void unsetupObject() override; short mustExecute() const override; + void handleChangedPropertyType( + Base::XMLReader &reader, const char * TypeName, App::Property * prop) override; void sectionExec(TopoDS_Shape& s); virtual void makeSectionCut(const TopoDS_Shape& baseShape); diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.cpp b/src/Mod/TechDraw/Gui/TaskSectionView.cpp index 1ddebae4d1..8cceb4eea7 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.cpp +++ b/src/Mod/TechDraw/Gui/TaskSectionView.cpp @@ -171,7 +171,7 @@ void TaskSectionView::setUiEdit() ui->sbScale->setEnabled(false); } - Base::Vector3d origin = m_section->SectionOrigin.getValue(); + auto origin = m_section->SectionOrigin.getValue(); setUiCommon(origin); // convert section normal to view angle diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.ui b/src/Mod/TechDraw/Gui/TaskSectionView.ui index e2a9f77931..2fd045bbf6 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.ui +++ b/src/Mod/TechDraw/Gui/TaskSectionView.ui @@ -6,8 +6,8 @@ 0 0 - 370 - 508 + 442 + 528 @@ -50,7 +50,7 @@ 0 - 22 + 24 @@ -67,7 +67,7 @@ 0 - 22 + 24 @@ -87,7 +87,7 @@ 0 - 22 + 24 @@ -299,7 +299,48 @@ - + + + + + + 0 + 0 + + + + + 150 + 24 + + + + false + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Z + + + @@ -319,20 +360,20 @@ - - + + - Qt::Horizontal + Qt::Vertical - 40 - 20 + 20 + 40 - + @@ -343,7 +384,7 @@ 150 - 22 + 24 @@ -354,7 +395,29 @@ - + + + + + 0 + 0 + + + + + 150 + 24 + + + + false + + + + + + + @@ -373,69 +436,6 @@ - - - - - 0 - 0 - - - - - 150 - 22 - - - - false - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Z - - - - - - - - 0 - 0 - - - - - 150 - 22 - - - - false - - - - - - diff --git a/src/Mod/TechDraw/Gui/Widgets/CompassWidget.cpp b/src/Mod/TechDraw/Gui/Widgets/CompassWidget.cpp index ecafa696e0..74e4357c6e 100644 --- a/src/Mod/TechDraw/Gui/Widgets/CompassWidget.cpp +++ b/src/Mod/TechDraw/Gui/Widgets/CompassWidget.cpp @@ -37,6 +37,8 @@ #include +#include + #include #include @@ -68,13 +70,13 @@ bool CompassWidget::eventFilter(QObject* target, QEvent* event) QKeyEvent* keyEvent = static_cast(event); if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) { dsbAngle->interpretText(); - slotSpinBoxEnter(dsbAngle->value()); + slotSpinBoxEnter(dsbAngle->rawValue()); return true; } } else if (event->type() == QEvent::FocusOut) { dsbAngle->interpretText(); - slotSpinBoxEnter(dsbAngle->value()); + slotSpinBoxEnter(dsbAngle->rawValue()); return true; } } @@ -128,9 +130,9 @@ void CompassWidget::buildWidget() compassControlLabel->setSizePolicy(sizePolicy2); compassControlLayout->addWidget(compassControlLabel); - - dsbAngle = new QDoubleSpinBox(this); + dsbAngle = new Gui::QuantitySpinBox(this); dsbAngle->setObjectName(QStringLiteral("dsbAngle")); + dsbAngle->setUnit(Base::Unit::Angle); sizePolicy2.setHeightForWidth(dsbAngle->sizePolicy().hasHeightForWidth()); dsbAngle->setSizePolicy(sizePolicy2); dsbAngle->setMinimumSize(QSize(75, 26)); @@ -138,7 +140,6 @@ void CompassWidget::buildWidget() dsbAngle->setFocusPolicy(Qt::ClickFocus); dsbAngle->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); dsbAngle->setKeyboardTracking(false); - dsbAngle->setSuffix(QStringLiteral("\302\260")); dsbAngle->setMaximum(360.000000000000000); dsbAngle->setMinimum(-360.000000000000000); diff --git a/src/Mod/TechDraw/Gui/Widgets/CompassWidget.h b/src/Mod/TechDraw/Gui/Widgets/CompassWidget.h index fff82ace91..b29f31a130 100644 --- a/src/Mod/TechDraw/Gui/Widgets/CompassWidget.h +++ b/src/Mod/TechDraw/Gui/Widgets/CompassWidget.h @@ -35,6 +35,10 @@ class QPushButton; class QVBoxLayout; QT_END_NAMESPACE +namespace Gui { +class QuantitySpinBox; +} + namespace TechDrawGui { @@ -94,7 +98,7 @@ private: CompassDialWidget* compassDial; // DoubleSpinBoxNoEnter* dsbAngle; - QDoubleSpinBox* dsbAngle; + Gui::QuantitySpinBox* dsbAngle; QLabel* compassControlLabel; QPushButton* pbCWAdvance; QPushButton* pbCCWAdvance; From b343e3cc59b868614651b722c47f8f10275dd30f Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sun, 2 Mar 2025 09:03:56 -0500 Subject: [PATCH 3/3] [TD]Property types and spinboxes for Detail --- src/Mod/TechDraw/App/DrawViewDetail.cpp | 31 ++- src/Mod/TechDraw/App/DrawViewDetail.h | 6 +- src/Mod/TechDraw/Gui/TaskDetail.ui | 260 +++++++++++++----------- 3 files changed, 171 insertions(+), 126 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 6a31f6efd9..9473c7fbd6 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -139,7 +139,6 @@ void DrawViewDetail::onChanged(const App::Property* prop) App::DocumentObjectExecReturn* DrawViewDetail::execute() { - // Base::Console().Message("DVD::execute() - %s\n", getNameInDocument()); if (!keepUpdated()) { return DrawView::execute(); } @@ -254,6 +253,7 @@ void DrawViewDetail::makeDetailShape(const TopoDS_Shape& shape3d, DrawViewPart* TopoDS_Face extrusionFace; Base::Vector3d extrudeVec = dirDetail * extrudeLength; + gp_Vec extrudeDir(extrudeVec.x, extrudeVec.y, extrudeVec.z); TopoDS_Shape tool; if (Preferences::mattingStyle()) { @@ -381,7 +381,6 @@ void DrawViewDetail::makeDetailShape(const TopoDS_Shape& shape3d, DrawViewPart* void DrawViewDetail::postHlrTasks(void) { - // Base::Console().Message("DVD::postHlrTasks()\n"); DrawViewPart::postHlrTasks(); geometryObject->pruneVertexGeom(Base::Vector3d(0.0, 0.0, 0.0), @@ -465,9 +464,35 @@ bool DrawViewDetail::debugDetail() const return Preferences::getPreferenceGroup("debug")->GetBool("debugDetail", false); } +void DrawViewDetail::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop) +{ + if (prop == &AnchorPoint) { + // AnchorPoint was PropertyVector but is now PropertyPosition + App::PropertyVector tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + AnchorPoint.setValue(tmpValue); + } + return; + } + + if (prop == &Radius) { + // Radius was PropertyFloat but is now PropertyLength + App::PropertyLength tmp; + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { + tmp.setContainer(this); + tmp.Restore(reader); + auto tmpValue = tmp.getValue(); + Radius.setValue(tmpValue); + } + return; + } +} + void DrawViewDetail::unsetupObject() { - // Base::Console().Message("DVD::unsetupObject()\n"); App::DocumentObject* baseObj = BaseView.getValue(); DrawView* base = dynamic_cast(baseObj); if (base) { diff --git a/src/Mod/TechDraw/App/DrawViewDetail.h b/src/Mod/TechDraw/App/DrawViewDetail.h index 70375b6f56..8c79e85344 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.h +++ b/src/Mod/TechDraw/App/DrawViewDetail.h @@ -57,8 +57,8 @@ public: ~DrawViewDetail() override; App::PropertyLink BaseView; - App::PropertyVector AnchorPoint; - App::PropertyFloat Radius; + App::PropertyPosition AnchorPoint; + App::PropertyLength Radius; App::PropertyString Reference; App::PropertyBool ShowMatting; @@ -71,6 +71,8 @@ public: return "TechDrawGui::ViewProviderViewPart"; } void unsetupObject() override; + void handleChangedPropertyType( + Base::XMLReader &reader, const char * TypeName, App::Property * prop) override; void detailExec(TopoDS_Shape& s, diff --git a/src/Mod/TechDraw/Gui/TaskDetail.ui b/src/Mod/TechDraw/Gui/TaskDetail.ui index 9d506516c0..5877379998 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.ui +++ b/src/Mod/TechDraw/Gui/TaskDetail.ui @@ -6,10 +6,16 @@ 0 0 - 300 - 264 + 497 + 367 + + + 0 + 0 + + Detail Anchor @@ -107,95 +113,7 @@ - - - - - X - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - x position of detail highlight within view - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - 0.000000000000000 - - - - - - - Y - - - - - - - y position of detail highlight within view - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - - - Radius - - - - - - - size of detail view - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - 10.000000000000000 - - - + @@ -203,35 +121,13 @@ - - + + - Page: scale factor of page is used -Automatic: if the detail view is larger than the page, - it will be scaled down to fit into the page -Custom: custom scale factor is used + reference label - - - Page - - - - - Automatic - - - - - Custom - - - - - - - - Scale Factor + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -260,6 +156,60 @@ Custom: custom scale factor is used + + + + + 0 + 0 + + + + y position of detail highlight within view + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + + + Scale Factor + + + + + + + + 0 + 0 + + + + size of detail view + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + 10.000000000000000 + + + @@ -267,16 +217,84 @@ Custom: custom scale factor is used - - + + + + + 0 + 0 + + - reference label + x position of detail highlight within view Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Radius + + + + + + + X + + + + + + + Page: scale factor of page is used +Automatic: if the detail view is larger than the page, + it will be scaled down to fit into the page +Custom: custom scale factor is used + + + + Page + + + + + Automatic + + + + + Custom + + + + + + + + Y + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + +