From 23290b805051e2c7e7636ffdc17b51a40f1ed5b9 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sun, 2 Nov 2025 19:29:35 -0500 Subject: [PATCH 01/13] [TD]add preference methods for center marks --- src/Mod/TechDraw/App/Preferences.cpp | 10 ++++++++++ src/Mod/TechDraw/App/Preferences.h | 3 +++ src/Mod/TechDraw/Gui/PagePrinter.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp | 3 +-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Mod/TechDraw/App/Preferences.cpp b/src/Mod/TechDraw/App/Preferences.cpp index 7b87739711..f97c9ed9e9 100644 --- a/src/Mod/TechDraw/App/Preferences.cpp +++ b/src/Mod/TechDraw/App/Preferences.cpp @@ -709,3 +709,13 @@ double Preferences::detailSnapRadius() return getPreferenceGroup("General")->GetFloat("DetailSnapRadius", 0.6); } + +bool Preferences::showCenterMarks() +{ + return getPreferenceGroup("Decorations")->GetBool("ShowCenterMarks", false); +} + +bool Preferences::printCenterMarks() +{ + return getPreferenceGroup("Decorations")->GetBool("PrintCenterMarks", false); +} diff --git a/src/Mod/TechDraw/App/Preferences.h b/src/Mod/TechDraw/App/Preferences.h index 1eb0afa6e9..7fe50c9bb5 100644 --- a/src/Mod/TechDraw/App/Preferences.h +++ b/src/Mod/TechDraw/App/Preferences.h @@ -166,6 +166,9 @@ public: static bool snapDetailHighlights(); static double detailSnapRadius(); + static bool showCenterMarks(); + static bool printCenterMarks(); + }; diff --git a/src/Mod/TechDraw/Gui/PagePrinter.cpp b/src/Mod/TechDraw/Gui/PagePrinter.cpp index c0f33c026a..49b0411741 100644 --- a/src/Mod/TechDraw/Gui/PagePrinter.cpp +++ b/src/Mod/TechDraw/Gui/PagePrinter.cpp @@ -240,7 +240,7 @@ void PagePrinter::printAllPdf(QPrinter* printer, App::Document* doc) renderPage(vpp, painter, sourceRect, targetRect); dPage->redrawCommand(); - ourScene->setExportingPdf(true); + ourScene->setExportingPdf(false); } ourDoc->setModified(docModifiedState); diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index bb20e943c0..2ff8ce7781 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -102,12 +102,11 @@ ViewProviderViewPart::ViewProviderViewPart() ADD_PROPERTY_TYPE(ExtraWidth, (weight), group, App::Prop_None, "The thickness of LineGroup Extra lines, if enabled"); double defScale = Preferences::getPreferenceGroup("Decorations")->GetFloat("CenterMarkScale", 0.50); - bool defShowCenters = Preferences::getPreferenceGroup("Decorations")->GetBool("ShowCenterMarks", false); //decorations ADD_PROPERTY_TYPE(HorizCenterLine ,(false), dgroup, App::Prop_None, "Show a horizontal centerline through view"); ADD_PROPERTY_TYPE(VertCenterLine ,(false), dgroup, App::Prop_None, "Show a vertical centerline through view"); - ADD_PROPERTY_TYPE(ArcCenterMarks ,(defShowCenters), dgroup, App::Prop_None, "Center marks on/off"); + ADD_PROPERTY_TYPE(ArcCenterMarks ,(Preferences::showCenterMarks()), dgroup, App::Prop_None, "Center marks on/off"); ADD_PROPERTY_TYPE(CenterScale, (defScale), dgroup, App::Prop_None, "Center mark size adjustment, if enabled"); //properties that affect Section Line From 4bb8f7e8ebbaac494338617d288ffe44852c7aaf Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sun, 2 Nov 2025 19:33:58 -0500 Subject: [PATCH 02/13] [TD]add getExportingAny() --- src/Mod/TechDraw/Gui/QGSPage.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/QGSPage.h b/src/Mod/TechDraw/Gui/QGSPage.h index 294fd8431d..d5d0fbdacd 100644 --- a/src/Mod/TechDraw/Gui/QGSPage.h +++ b/src/Mod/TechDraw/Gui/QGSPage.h @@ -136,10 +136,11 @@ public: TechDraw::DrawPage* getDrawPage(); void setExportingSvg(bool enable); - bool getExportingSvg() { return m_exportingSvg; } + bool getExportingSvg() const { return m_exportingSvg; } void setExportingPdf(bool enable) { m_exportingPdf = enable; }; bool getExportingPdf() const { return m_exportingPdf; } + bool getExportingAny() const { return getExportingPdf() || getExportingSvg(); } virtual void refreshViews(); From d2bbd78c671cd704b24a256c56bf6338b1acf803 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 3 Nov 2025 15:53:58 -0500 Subject: [PATCH 03/13] [TD]clear selection affects vertex display - clearing the selection here causes the new vertex to not be displayed --- src/Mod/TechDraw/Gui/CommandAnnotate.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp index 10a97eb9bc..010ef98ada 100644 --- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp +++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp @@ -231,7 +231,6 @@ void CmdTechDrawCosmeticVertexGroup::activated(int iMsg) Base::Console().message("CMD::CVGrp - invalid iMsg: %d\n", iMsg); }; updateActive(); - Gui::Selection().clearSelection(); } Gui::Action * CmdTechDrawCosmeticVertexGroup::createAction() From b918cac67aca5c3e971ddf991b08e72a6c5c18ef Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 3 Nov 2025 16:43:53 -0500 Subject: [PATCH 04/13] [TD]fix giant vertex from tracker --- src/Mod/TechDraw/Gui/QGTracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/QGTracker.cpp b/src/Mod/TechDraw/Gui/QGTracker.cpp index 8d47127a68..a2406ae0fd 100644 --- a/src/Mod/TechDraw/Gui/QGTracker.cpp +++ b/src/Mod/TechDraw/Gui/QGTracker.cpp @@ -400,7 +400,7 @@ void QGTracker::setPoint(std::vector pts) auto point = new QGIVertex(-1); point->setParentItem(this); point->setPos(pts.front()); - point->setRadius(static_cast(m_qgParent)->getVertexSize()); + point->setRadius(Rez::guiX(getTrackerWeight())); point->setNormalColor(Qt::blue); point->setFillColor(Qt::blue); point->setPrettyNormal(); From f0da095cf8df2162950e495578da286e00ceb63a Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 3 Nov 2025 16:44:51 -0500 Subject: [PATCH 05/13] [TD]fix center marks not shown --- src/Mod/TechDraw/Gui/QGIViewPart.cpp | 153 +++++++++++++++++++-------- src/Mod/TechDraw/Gui/QGIViewPart.h | 10 +- 2 files changed, 115 insertions(+), 48 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index b2d4c0b904..bc21ebce44 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -63,6 +63,7 @@ #include "ZVALUE.h" #include "PathBuilder.h" #include "QGIBreakLine.h" +#include "QGSPage.h" using namespace TechDraw; using namespace TechDrawGui; @@ -101,8 +102,15 @@ QVariant QGIViewPart::itemChange(GraphicsItemChange change, const QVariant& valu bool selectState = value.toBool(); if (!selectState && !isUnderMouse()) { // hide everything + bool hideCenters = hideCenterMarks(); for (auto& child : childItems()) { - if (child->type() == UserType::QGIVertex || child->type() == UserType::QGICMark) { + if (child->type() == UserType::QGIVertex) { + child->hide(); + continue; + } + + if (child->type() == UserType::QGICMark && + hideCenters) { child->hide(); } } @@ -116,15 +124,21 @@ QVariant QGIViewPart::itemChange(GraphicsItemChange change, const QVariant& valu } else if (change == QGraphicsItem::ItemSceneHasChanged) { if (scene()) { + // added to scene m_selectionChangedConnection = connect(scene(), &QGraphicsScene::selectionChanged, this, [this]() { // When selection changes, if the mouse is not over the view, // hide any non-selected vertices. if (!isUnderMouse()) { + bool hideCenters = hideCenterMarks(); for (auto* child : childItems()) { - if ((child->type() == UserType::QGIVertex || child->type() == UserType::QGICMark) && + if (child->type() == UserType::QGIVertex && !child->isSelected()) { child->hide(); } + if (child->type() == UserType::QGICMark && + hideCenters) { + child->hide(); + } } update(); } @@ -159,7 +173,6 @@ bool QGIViewPart::sceneEventFilter(QGraphicsItem *watched, QEvent *event) //! selected, remove it from the view. bool QGIViewPart::removeSelectedCosmetic() const { - // Base::Console().message("QGIVP::removeSelectedCosmetic()\n"); auto dvp(dynamic_cast(getViewObject())); if (!dvp) { throw Base::RuntimeError("Graphic has no feature!"); @@ -458,7 +471,8 @@ void QGIViewPart::drawAllVertexes() QColor vertexColor = PreferencesGui::getAccessibleQColor(PreferencesGui::vertexQColor()); const std::vector& verts = dvp->getVertexGeometry(); - std::vector::const_iterator vert = verts.begin(); + auto vert = verts.begin(); + bool hideCenters = hideCenterMarks(); for (int i = 0; vert != verts.end(); ++vert, i++) { if ((*vert)->isCenter()) { if (showCenterMarks()) { @@ -469,7 +483,7 @@ void QGIViewPart::drawAllVertexes() cmItem->setSize(getVertexSize() * vp->CenterScale.getValue()); cmItem->setPrettyNormal(); cmItem->setZValue(ZVALUE::VERTEX); - cmItem->setVisible(m_isHovered); + cmItem->setVisible(!hideCenters); } } else { //regular Vertex @@ -482,7 +496,7 @@ void QGIViewPart::drawAllVertexes() item->setRadius(getVertexSize()); item->setPrettyNormal(); item->setZValue(ZVALUE::VERTEX); - item->setVisible(m_isHovered); + item->setVisible(m_isHovered || isSelected()); } } } @@ -513,39 +527,6 @@ bool QGIViewPart::showThisEdge(BaseGeomPtr geom) return false; } -// returns true if vertex dots should be shown -bool QGIViewPart::showVertices() -{ - // dvp and vp already validated - auto dvp(static_cast(getViewObject())); - - if (dvp->CoarseView.getValue()) { - // never show vertices in CoarseView - return false; - } - return true; -} - - -// returns true if arc center marks should be shown -bool QGIViewPart::showCenterMarks() -{ - // dvp and vp already validated - auto dvp(static_cast(getViewObject())); - auto vp(static_cast(getViewProvider(dvp))); - - if (!vp->ArcCenterMarks.getValue()) { - // no center marks if view property is false - return false; - } - if (prefPrintCenters()) { - // frames are off, view property is true and Print Center Marks is true - return true; - } - - return true; -} - bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item) { @@ -1202,11 +1183,6 @@ bool QGIViewPart::prefFaceEdges() return result; } -bool QGIViewPart::prefPrintCenters() -{ - bool printCenters = Preferences::getPreferenceGroup("Decorations")->GetBool("PrintCenterMarks", false);//true matches v0.18 behaviour - return printCenters; -} Base::Color QGIViewPart::prefBreaklineColor() { @@ -1330,11 +1306,98 @@ void QGIViewPart::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { QGIView::hoverLeaveEvent(event); + if (isSelected()) { + // if the view is selected, we should leave things alone. + return; + } + + bool hideCenters = hideCenterMarks(); + for (auto& child : childItems()) { - if ((child->type() == UserType::QGIVertex || child->type() == UserType::QGICMark) && + if (child->type() == UserType::QGIVertex && !child->isSelected()) { child->hide(); + continue; + } + + if (child->type() == UserType::QGICMark) { + if (child->isSelected()) { + continue; + } + + if (hideCenters) { + child->hide(); + } } } update(); } + + +bool QGIViewPart::isExporting() const +{ + // dvp already validated + auto viewPart {freecad_cast(getViewObject())}; + auto vpPage = getViewProviderPage(viewPart); + + QGSPage* scenePage = vpPage->getQGSPage(); + if (!scenePage) { + return false; + } + + return scenePage->getExportingAny(); +} + + +// returns true if vertex dots should be shown +bool QGIViewPart::showVertices() const +{ + // dvp already validated + auto dvp(static_cast(getViewObject())); + + if (dvp->CoarseView.getValue()) { + // never show vertices in CoarseView + return false; + } + + // if (isSelected()) { + // return true; + // } + + // if we have selected verts? + + return true; +} + + +// returns true if arc center marks should be shown +bool QGIViewPart::showCenterMarks() const +{ + // dvp and vp already validated + auto dvp(static_cast(getViewObject())); + auto vp(static_cast(getViewProvider(dvp))); + + if (isExporting() && Preferences::printCenterMarks()) { + return true; + } + + return vp->ArcCenterMarks.getValue(); +} + +//! true if center marks (type of vertex) should be hidden +bool QGIViewPart::hideCenterMarks() const +{ + // printing + if (isExporting() && + Preferences::printCenterMarks()) { + return false; + } + + // on screen + if (showCenterMarks()) { + return false; + } + + return true; +} + diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.h b/src/Mod/TechDraw/Gui/QGIViewPart.h index b762e425e5..dcf1201eb6 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.h +++ b/src/Mod/TechDraw/Gui/QGIViewPart.h @@ -126,6 +126,11 @@ public: virtual double getLineWidth(); virtual double getVertexSize(); + bool isExporting() const; + bool hideCenterMarks() const; + + + protected: bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override; QPainterPath drawPainterPath(TechDraw::BaseGeomPtr baseGeom) const; @@ -142,14 +147,13 @@ protected: void removePrimitives(); void removeDecorations(); bool prefFaceEdges(); - bool prefPrintCenters(); Base::Color prefBreaklineColor(); bool formatGeomFromCosmetic(std::string cTag, QGIEdge* item); bool formatGeomFromCenterLine(std::string cTag, QGIEdge* item); - bool showCenterMarks(); - bool showVertices(); + bool showCenterMarks() const; + bool showVertices() const; private: QList deleteItems; From 73e4b296b12fdf3667ac96d8dbdcc1b52b7de91a Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 3 Nov 2025 22:25:01 -0500 Subject: [PATCH 06/13] [TD]fix fail to create vertex outside frame --- src/Mod/TechDraw/Gui/QGTracker.cpp | 8 ++++++-- src/Mod/TechDraw/Gui/QGTracker.h | 2 ++ src/Mod/TechDraw/Gui/TaskCosVertex.cpp | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGTracker.cpp b/src/Mod/TechDraw/Gui/QGTracker.cpp index a2406ae0fd..c155811a31 100644 --- a/src/Mod/TechDraw/Gui/QGTracker.cpp +++ b/src/Mod/TechDraw/Gui/QGTracker.cpp @@ -273,6 +273,10 @@ void QGTracker::onDoubleClick(QPointF pos) void QGTracker::getPickedQGIV(QPointF pos) { + if (m_qgParent) { + return; + } + setVisible(false); m_qgParent = nullptr; QList views = scene()->views(); @@ -284,13 +288,12 @@ void QGTracker::getPickedQGIV(QPointF pos) if (topItem != pickedItem) { pickedItem = topItem; } //pickedItem sb a QGIV - QGIView* qgParent = dynamic_cast(pickedItem); + auto* qgParent = dynamic_cast(pickedItem); if (qgParent) { m_qgParent = qgParent; } } setVisible(true); - return; } QRectF QGTracker::boundingRect() const @@ -420,6 +423,7 @@ std::vector QGTracker::convertPoints() void QGTracker::terminateDrawing() { setCursor(Qt::ArrowCursor); + // should we care if m_qgParent is null? Q_EMIT drawingFinished(m_points, m_qgParent); } diff --git a/src/Mod/TechDraw/Gui/QGTracker.h b/src/Mod/TechDraw/Gui/QGTracker.h index 30d805a108..67368484b1 100644 --- a/src/Mod/TechDraw/Gui/QGTracker.h +++ b/src/Mod/TechDraw/Gui/QGTracker.h @@ -95,6 +95,8 @@ public: void setTrackerMode(TrackerMode m) { m_trackerMode = m; } QPointF snapToAngle(QPointF pt); + void setOwnerQView(QGIView* owner) { m_qgParent = owner; } + Q_SIGNALS: void drawingFinished(std::vector pts, TechDrawGui::QGIView* qgParent); void qViewPicked(QPointF pos, TechDrawGui::QGIView* qgParent); diff --git a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp index 47d02fb841..2830a6d08c 100644 --- a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp +++ b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp @@ -185,6 +185,9 @@ void TaskCosVertex::startTracker() if (!m_tracker) { m_tracker = new QGTracker(m_vpp->getQGSPage(), m_trackerMode); + std::string parentName = m_baseFeat->getNameInDocument(); + QGIView* parentView = m_vpp->getQGSPage()->getQGIVByName(parentName); + m_tracker->setOwnerQView(parentView); QObject::connect( m_tracker, &QGTracker::drawingFinished, this, &TaskCosVertex::onTrackerFinished From 2161e3132803bef45c73e7e68a67472e0fb31542 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Wed, 5 Nov 2025 16:17:35 -0500 Subject: [PATCH 07/13] [TD]fix fail to clear frame on selection change --- src/Mod/TechDraw/Gui/QGIView.cpp | 36 +++++++++++++++------------- src/Mod/TechDraw/Gui/QGIView.h | 2 ++ src/Mod/TechDraw/Gui/QGIViewPart.cpp | 3 +-- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp index 5d62918318..2f546f0e2d 100644 --- a/src/Mod/TechDraw/Gui/QGIView.cpp +++ b/src/Mod/TechDraw/Gui/QGIView.cpp @@ -168,7 +168,6 @@ void QGIView::alignTo(QGraphicsItem*item, const QString &alignment) QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value) { - // Base::Console().message("QGIV::itemChange(%d)\n", change); if(change == ItemPositionChange && scene()) { QPointF newPos = value.toPointF(); //position within parent! TechDraw::DrawView* viewObj = getViewObject(); @@ -196,13 +195,10 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value) return newPos; } + // wf: why scene()? because if our selected state has changed because we have been removed from + // the scene, we don't do anything except wait to be deleted. if (change == ItemSelectedHasChanged && scene()) { - std::vector currentSelection = Gui::Selection().getSelectionEx(); - bool isViewObjectSelected = Gui::Selection().isSelected(getViewObject()); - bool hasSelectedSubElements = - !DrawGuiUtil::getSubsForSelectedObject(currentSelection, getViewObject()).empty(); - - if (isViewObjectSelected || hasSelectedSubElements) { + if (isSelected() || hasSelectedChildren(this)) { m_colCurrent = getSelectColor(); m_border->show(); m_label->show(); @@ -220,7 +216,6 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value) } } drawBorder(); - update(); } return QGraphicsItemGroup::itemChange(change, value); @@ -537,7 +532,6 @@ void QGIView::hoverEnterEvent(QGraphicsSceneHoverEvent *event) m_lock->setVisible(getViewObject()->isLocked() && getViewObject()->showLock()); drawBorder(); - update(); } @@ -560,13 +554,11 @@ void QGIView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } drawBorder(); - update(); } //sets position in /Gui(graphics), not /App void QGIView::setPosition(qreal xPos, qreal yPos) { - // Base::Console().message("QGIV::setPosition(%.3f, %.3f) (gui)\n", x, y); double newX = xPos; double newY = -yPos; double oldX = pos().x(); @@ -595,8 +587,6 @@ QGIViewClip* QGIView::getClipGroup() void QGIView::updateView(bool forceUpdate) { - // Base::Console().message("QGIV::updateView() - %s\n", getViewObject()->getNameInDocument()); - //allow/prevent dragging if (getViewObject()->isLocked()) { setFlag(QGraphicsItem::ItemIsMovable, false); @@ -678,7 +668,6 @@ void QGIView::toggleCache(bool state) void QGIView::draw() { - // Base::Console().message("QGIV::draw()\n"); double xFeat, yFeat; if (getViewObject()) { xFeat = Rez::guiX(getViewObject()->X.getValue()); @@ -742,10 +731,10 @@ void QGIView::layoutDecorations(const QRectF& contentArea, void QGIView::drawBorder() { - // Base::Console().message("QGIV::drawBorder() - %s\n", getViewName()); auto feat = getViewObject(); - if (!feat) + if (!feat) { return; + } prepareCaption(); @@ -1060,6 +1049,20 @@ void QGIView::makeMark(double xPos, double yPos, QColor color) vItem->setZValue(ZVALUE::VERTEX); } +//! true if parent has any children which are selected +bool QGIView::hasSelectedChildren(QGIView* parent) +{ + QList children = parent->childItems(); + + auto itMatch = std::find_if(children.begin(), children.end(), + [&](QGraphicsItem* child) { + return child->isSelected(); + }); + + return itMatch != children.end(); +} + + void QGIView::makeMark(Base::Vector3d pos, QColor color) { makeMark(pos.x, pos.y, color); @@ -1070,6 +1073,7 @@ void QGIView::makeMark(QPointF pos, QColor color) makeMark(pos.x(), pos.y(), color); } + //! Retrieves objects of type T with given indexes template std::vector QGIView::getObjects(std::vector indexes) diff --git a/src/Mod/TechDraw/Gui/QGIView.h b/src/Mod/TechDraw/Gui/QGIView.h index d1a3cdb8c7..0a77c5f88b 100644 --- a/src/Mod/TechDraw/Gui/QGIView.h +++ b/src/Mod/TechDraw/Gui/QGIView.h @@ -174,6 +174,8 @@ public: bool pseudoEventFilter(QGraphicsItem *watched, QEvent *event) { return sceneEventFilter(watched, event); } + static bool hasSelectedChildren(QGIView* parent); + protected: QGIView* getQGIVByName(std::string name) const; diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index bc21ebce44..e632327b6d 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -116,7 +116,7 @@ QVariant QGIViewPart::itemChange(GraphicsItemChange change, const QVariant& valu } return QGIView::itemChange(change, value); } - // we are selected + // we are selected, don't change anything? } else if (change == ItemSceneChange && scene()) { // This means we are finished? @@ -140,7 +140,6 @@ QVariant QGIViewPart::itemChange(GraphicsItemChange change, const QVariant& valu child->hide(); } } - update(); } }); } From f6c75c7838c51ac8b148d5f6b6d2e52a1eb2af76 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 6 Nov 2025 10:02:37 -0500 Subject: [PATCH 08/13] [TD]fix no vertex select in front view of projection group --- src/Mod/TechDraw/Gui/QGIProjGroup.cpp | 49 ++++++++++++++++++++++----- src/Mod/TechDraw/Gui/QGIProjGroup.h | 2 ++ 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp index 0f67b84135..46f1a3f9b3 100644 --- a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp @@ -32,10 +32,13 @@ #include #include "QGIProjGroup.h" +#include "QGIViewDimension.h" +#include "QGIViewPart.h" #include "Rez.h" using namespace TechDrawGui; +using namespace TechDraw; QGIProjGroup::QGIProjGroup() { @@ -45,7 +48,6 @@ QGIProjGroup::QGIProjGroup() setFlag(ItemIsSelectable, false); setFlag(ItemIsMovable, true); setFiltersChildEvents(true); -// setFrameState(false); } TechDraw::DrawProjGroup * QGIProjGroup::getDrawView() const @@ -53,6 +55,7 @@ TechDraw::DrawProjGroup * QGIProjGroup::getDrawView() const App::DocumentObject *obj = getViewObject(); return dynamic_cast(obj); } + bool QGIProjGroup::autoDistributeEnabled() const { return getDrawView() && getDrawView()->AutoDistribute.getValue(); @@ -60,15 +63,28 @@ bool QGIProjGroup::autoDistributeEnabled() const bool QGIProjGroup::sceneEventFilter(QGraphicsItem* watched, QEvent *event) { + auto qvpart = dynamic_cast(watched); + std::vector outlist = getViewObject()->getOutList(); + if (!qvpart || + !isMember(qvpart->getViewObject())) { + // if qwatched is not in this projgroup, we ignore the event as none of our business + return false; + } + // i want to handle events before the child item that would ordinarily receive them if(event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseMove || event->type() == QEvent::GraphicsSceneMouseRelease) { - QGIView *qAnchor = getAnchorQItem(); - QGIView* qWatched = dynamic_cast(watched); + auto* qWatched = dynamic_cast(watched); + if (!qWatched) { + return false; + } + // If AutoDistribute is enabled, catch events and move the anchor directly - if(qAnchor && (watched == qAnchor || (autoDistributeEnabled() && qWatched != nullptr))) { + //? the anchor doesn't move?? + if(qAnchor && (watched == qAnchor || + (autoDistributeEnabled() && qWatched != nullptr))) { auto *mEvent = dynamic_cast(event); // Disable moves on the view to prevent double drag @@ -143,6 +159,9 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val void QGIProjGroup::mousePressEvent(QGraphicsSceneMouseEvent * event) { + // TODO: this bit is obsolete? you can click on any secondary view to drag now. + // test event location against each secondary or just use the PG's bounding rect (ie if we got the + // event, the click must have been within the BR). QGIView *qAnchor = getAnchorQItem(); if(qAnchor) { QPointF transPos = qAnchor->mapFromScene(event->scenePos()); @@ -150,31 +169,32 @@ void QGIProjGroup::mousePressEvent(QGraphicsSceneMouseEvent * event) mousePos = event->screenPos(); } } - event->accept(); } void QGIProjGroup::mouseMoveEvent(QGraphicsSceneMouseEvent * event) { QGIView *qAnchor = getAnchorQItem(); + // this is obsolete too? if(scene() && qAnchor && (qAnchor == scene()->mouseGrabberItem() || autoDistributeEnabled())) { if((mousePos - event->screenPos()).manhattanLength() > 5) { //if the mouse has moved more than 5, process the mouse event QGIViewCollection::mouseMoveEvent(event); } } - event->accept(); } void QGIProjGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { mouseReleaseEvent(getAnchorQItem(), event); } + + void QGIProjGroup::mouseReleaseEvent(QGIView* originator, QGraphicsSceneMouseEvent* event) { if(scene()) { + // this assumes we are dragging? if((mousePos - event->screenPos()).manhattanLength() < 5) { if(originator && originator->shape().contains(event->pos())) { - event->ignore(); - originator->mouseReleaseEvent(event); + return; } } else if(scene() && originator) { @@ -217,3 +237,16 @@ void QGIProjGroup::drawBorder() // Base::Console().message("TRACE - QGIProjGroup::drawBorder - doing nothing!!\n"); } + +//! true if dvpObj is a member of our projection group +bool QGIProjGroup::isMember(App::DocumentObject* dvpObj) const +{ + std::vector groupOutlist = getViewObject()->getOutList(); + auto itMatch = std::find_if(groupOutlist.begin(), groupOutlist.end(), + [dvpObj](App::DocumentObject* child) { + return child == dvpObj; + }); + return itMatch != groupOutlist.end(); +} + + diff --git a/src/Mod/TechDraw/Gui/QGIProjGroup.h b/src/Mod/TechDraw/Gui/QGIProjGroup.h index 4b67f25d2f..eb78b64258 100644 --- a/src/Mod/TechDraw/Gui/QGIProjGroup.h +++ b/src/Mod/TechDraw/Gui/QGIProjGroup.h @@ -59,6 +59,8 @@ public: void drawBorder() override; + bool isMember(App::DocumentObject* dvpObj) const; + protected: bool sceneEventFilter(QGraphicsItem* watched, QEvent *event) override; QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; From 66a2dd984ed3d7a214992287b18ac2f5f6695771 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 6 Nov 2025 11:17:42 -0500 Subject: [PATCH 09/13] [TD]fix cosmetic vertex outside frameRect is not selectable - attempting to select a vertex outside the frameRect/boundingRect triggers hoverLeave event which hides the vertex. --- src/Mod/TechDraw/Gui/QGIView.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp index 2f546f0e2d..0f3ca64fc1 100644 --- a/src/Mod/TechDraw/Gui/QGIView.cpp +++ b/src/Mod/TechDraw/Gui/QGIView.cpp @@ -799,6 +799,7 @@ QRectF QGIView::frameRect() const continue; } if ( + // we only want the area defined by the edges child->type() != UserType::QGIRichAnno && child->type() != UserType::QGEPath && child->type() != UserType::QGMText && @@ -834,7 +835,9 @@ QRectF QGIView::customChildrenBoundingRect() const child->type() != UserType::QGCustomBorder && child->type() != UserType::QGCustomLabel && child->type() != UserType::QGICaption && - child->type() != UserType::QGIVertex && + // we treat vertices as part of the boundingRect to allow loose vertices outside of the + // area defined by the edges as in frameRect() + // child->type() != UserType::QGIVertex && child->type() != UserType::QGICMark) { QRectF childRect = mapFromItem(child, child->boundingRect()).boundingRect(); result = result.united(childRect); From 110b4b0d95476cd4dc157704372c1f06ce0d39f0 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 10 Nov 2025 10:27:13 -0500 Subject: [PATCH 10/13] [TD]fix lost mouse event in Projection Group --- src/Mod/TechDraw/Gui/QGIProjGroup.cpp | 66 ++++++++++++--------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp index 46f1a3f9b3..a5023a67d8 100644 --- a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp @@ -61,59 +61,55 @@ bool QGIProjGroup::autoDistributeEnabled() const return getDrawView() && getDrawView()->AutoDistribute.getValue(); } + +// note that we are not actually handling any of these events (ie we don't return true, and we don't +// set the the event to ignore) here. bool QGIProjGroup::sceneEventFilter(QGraphicsItem* watched, QEvent *event) { auto qvpart = dynamic_cast(watched); - std::vector outlist = getViewObject()->getOutList(); if (!qvpart || !isMember(qvpart->getViewObject())) { // if qwatched is not in this projgroup, we ignore the event as none of our business return false; } -// i want to handle events before the child item that would ordinarily receive them + // i want to handle events before the child item that would ordinarily receive them if(event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseMove || event->type() == QEvent::GraphicsSceneMouseRelease) { - QGIView *qAnchor = getAnchorQItem(); auto* qWatched = dynamic_cast(watched); if (!qWatched) { return false; } - // If AutoDistribute is enabled, catch events and move the anchor directly - //? the anchor doesn't move?? - if(qAnchor && (watched == qAnchor || - (autoDistributeEnabled() && qWatched != nullptr))) { - auto *mEvent = dynamic_cast(event); + auto *mEvent = dynamic_cast(event); - // Disable moves on the view to prevent double drag - std::vector modifiedChildren; - for (auto* child : childItems()) { - if (child->isSelected() && (child->flags() & QGraphicsItem::ItemIsMovable)) { - child->setFlag(QGraphicsItem::ItemIsMovable, false); - modifiedChildren.push_back(child); - } + // Disable moves on the view to prevent double drag + std::vector modifiedChildren; + for (auto* child : childItems()) { + if (child->isSelected() && (child->flags() & QGraphicsItem::ItemIsMovable)) { + child->setFlag(QGraphicsItem::ItemIsMovable, false); + modifiedChildren.push_back(child); } - - switch (event->type()) { - case QEvent::GraphicsSceneMousePress: - mousePressEvent(mEvent); - break; - case QEvent::GraphicsSceneMouseMove: - mouseMoveEvent(mEvent); - break; - case QEvent::GraphicsSceneMouseRelease: - mouseReleaseEvent(qWatched, mEvent); - break; - default: - break; - } - for (auto* child : modifiedChildren) { - child->setFlag(QGraphicsItem::ItemIsMovable, true); - } - return true; } + + switch (event->type()) { + case QEvent::GraphicsSceneMousePress: + mousePressEvent(mEvent); + break; + case QEvent::GraphicsSceneMouseMove: + mouseMoveEvent(mEvent); + break; + case QEvent::GraphicsSceneMouseRelease: + mouseReleaseEvent(qWatched, mEvent); + break; + default: + break; + } + for (auto* child : modifiedChildren) { + child->setFlag(QGraphicsItem::ItemIsMovable, true); + } + return false; } return false; @@ -159,9 +155,7 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val void QGIProjGroup::mousePressEvent(QGraphicsSceneMouseEvent * event) { - // TODO: this bit is obsolete? you can click on any secondary view to drag now. - // test event location against each secondary or just use the PG's bounding rect (ie if we got the - // event, the click must have been within the BR). + // save the new mousePos, but don't do anything else. QGIView *qAnchor = getAnchorQItem(); if(qAnchor) { QPointF transPos = qAnchor->mapFromScene(event->scenePos()); From cf656ba77e5de5890248366866c71c633502773f Mon Sep 17 00:00:00 2001 From: wandererfan Date: Tue, 11 Nov 2025 18:41:01 -0500 Subject: [PATCH 11/13] [TD]fix center mark preferences not honored --- src/Mod/TechDraw/Gui/QGIViewPart.cpp | 43 ++++++++++++---------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index e632327b6d..386dec846a 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -471,19 +471,19 @@ void QGIViewPart::drawAllVertexes() const std::vector& verts = dvp->getVertexGeometry(); auto vert = verts.begin(); - bool hideCenters = hideCenterMarks(); for (int i = 0; vert != verts.end(); ++vert, i++) { if ((*vert)->isCenter()) { - if (showCenterMarks()) { - auto* cmItem = new QGICMark(i); - addToGroup(cmItem); - cmItem->setPos(Rez::guiX((*vert)->x()), Rez::guiX((*vert)->y())); - cmItem->setThick(0.5F * getLineWidth());//need minimum? - cmItem->setSize(getVertexSize() * vp->CenterScale.getValue()); - cmItem->setPrettyNormal(); - cmItem->setZValue(ZVALUE::VERTEX); - cmItem->setVisible(!hideCenters); - } + auto* cmItem = new QGICMark(i); + addToGroup(cmItem); + cmItem->setPos(Rez::guiX((*vert)->x()), Rez::guiX((*vert)->y())); + cmItem->setThick(0.5F * getLineWidth()); //need minimum? + cmItem->setSize(getVertexSize() * vp->CenterScale.getValue()); + cmItem->setPrettyNormal(); + cmItem->setZValue(ZVALUE::VERTEX); + bool showMark = + ( (!isExporting() && vp->ArcCenterMarks.getValue()) || + (isExporting() && Preferences::printCenterMarks()) ); + cmItem->setVisible(showMark); } else { //regular Vertex if (showVertices()) { @@ -1295,7 +1295,13 @@ void QGIViewPart::hoverEnterEvent(QGraphicsSceneHoverEvent *event) for (auto& child : childItems()) { if (child->type() == UserType::QGIVertex || child->type() == UserType::QGICMark) { child->show(); + continue; } + if (child->type() == UserType::QGICMark && + !hideCenterMarks()) { + child->show(); + } + } update(); @@ -1349,23 +1355,12 @@ bool QGIViewPart::isExporting() const // returns true if vertex dots should be shown +// note this is only one of the "rules" around showing or hiding vertices. bool QGIViewPart::showVertices() const { // dvp already validated auto dvp(static_cast(getViewObject())); - - if (dvp->CoarseView.getValue()) { - // never show vertices in CoarseView - return false; - } - - // if (isSelected()) { - // return true; - // } - - // if we have selected verts? - - return true; + return !dvp->CoarseView.getValue(); } From 484c89818cbcb3d7ac47d617a66f13923cbee13a Mon Sep 17 00:00:00 2001 From: wandererfan Date: Fri, 14 Nov 2025 15:38:16 -0500 Subject: [PATCH 12/13] [TD]enforce center mark print rule on print preview --- src/Mod/TechDraw/Gui/MDIViewPage.cpp | 7 +++++-- src/Mod/TechDraw/Gui/MDIViewPage.h | 2 ++ src/Mod/TechDraw/Gui/PagePrinter.cpp | 5 +++-- src/Mod/TechDraw/Gui/PagePrinter.h | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp index 7a16b0c32f..a69c74f9c4 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp +++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp @@ -81,7 +81,8 @@ namespace sp = std::placeholders; TYPESYSTEM_SOURCE_ABSTRACT(TechDrawGui::MDIViewPage, Gui::MDIView) MDIViewPage::MDIViewPage(ViewProviderPage* pageVp, Gui::Document* doc, QWidget* parent) - : Gui::MDIView(doc, parent), m_vpPage(pageVp) + : Gui::MDIView(doc, parent), m_vpPage(pageVp), + m_previewState(false) { setMouseTracking(true); @@ -362,7 +363,9 @@ void MDIViewPage::printPreview() QPrintPreviewDialog dlg(&printer, this); connect(&dlg, &QPrintPreviewDialog::paintRequested, this, qOverload(&MDIViewPage::print)); + m_previewState = true; dlg.exec(); + m_previewState = false; } @@ -411,7 +414,7 @@ void MDIViewPage::print(QPrinter* printer) } } - PagePrinter::print(getViewProviderPage(), printer); + PagePrinter::print(getViewProviderPage(), printer, m_previewState); } // static routine to print all pages in a document. Used by PrintAll command in Command.cpp diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.h b/src/Mod/TechDraw/Gui/MDIViewPage.h index 64698d1c6d..c3fa868d65 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.h +++ b/src/Mod/TechDraw/Gui/MDIViewPage.h @@ -156,6 +156,8 @@ private: QList m_orderedSceneSelection; //items in selection order QString defaultFileName(); + + bool m_previewState{false}; }; class MDIViewPagePy : public Py::PythonExtension diff --git a/src/Mod/TechDraw/Gui/PagePrinter.cpp b/src/Mod/TechDraw/Gui/PagePrinter.cpp index 49b0411741..e8548f0258 100644 --- a/src/Mod/TechDraw/Gui/PagePrinter.cpp +++ b/src/Mod/TechDraw/Gui/PagePrinter.cpp @@ -305,7 +305,7 @@ void PagePrinter::renderPage(ViewProviderPage* vpp, QPainter& painter, QRectF& s /// print the Page associated with the view provider -void PagePrinter::print(ViewProviderPage* vpPage, QPrinter* printer) +void PagePrinter::print(ViewProviderPage* vpPage, QPrinter* printer, bool isPreview) { QPageLayout pageLayout = printer->pageLayout(); @@ -318,7 +318,8 @@ void PagePrinter::print(ViewProviderPage* vpPage, QPrinter* printer) QPainter painter(printer); auto ourScene = vpPage->getQGSPage(); - if (!printer->outputFileName().isEmpty()) { + if (!printer->outputFileName().isEmpty() || + isPreview) { ourScene->setExportingPdf(true); } auto ourDoc = Gui::Application::Instance->getDocument(dPage->getDocument()); diff --git a/src/Mod/TechDraw/Gui/PagePrinter.h b/src/Mod/TechDraw/Gui/PagePrinter.h index ea43e94090..19ff8a7288 100644 --- a/src/Mod/TechDraw/Gui/PagePrinter.h +++ b/src/Mod/TechDraw/Gui/PagePrinter.h @@ -105,7 +105,7 @@ public: static PaperAttributes getPaperAttributes(TechDraw::DrawPage* pageObject); static PaperAttributes getPaperAttributes(ViewProviderPage* vpPage); - static void print(ViewProviderPage* vpPage, QPrinter* printer); + static void print(ViewProviderPage* vpPage, QPrinter* printer, bool isPreview = false); static void printPdf(ViewProviderPage* vpPage, const std::string& file); static void printAll(QPrinter* printer, App::Document* doc); static void printAllPdf(QPrinter* printer, App::Document* doc); From 0f4be480b1e92581f386416b347d8233199b6251 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 04:30:03 +0000 Subject: [PATCH 13/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/Gui/ViewProviderGeometryObject.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Gui/ViewProviderGeometryObject.cpp b/src/Gui/ViewProviderGeometryObject.cpp index 1ef6938154..9a371ca6f2 100644 --- a/src/Gui/ViewProviderGeometryObject.cpp +++ b/src/Gui/ViewProviderGeometryObject.cpp @@ -196,8 +196,7 @@ void ViewProviderGeometryObject::updateData(const App::Property* prop) App::Material defaultMaterial; auto material = geometry->getMaterialAppearance(); if ((ShapeAppearance.getSize() == 1) - && (ShapeAppearance[0] == defaultMaterial - || ShapeAppearance[0] == materialAppearance) + && (ShapeAppearance[0] == defaultMaterial || ShapeAppearance[0] == materialAppearance) && (material != defaultMaterial)) { ShapeAppearance.setValue(material); }