From 5bcc55c19ffe3f809223791d735158a795aeb485 Mon Sep 17 00:00:00 2001 From: waaake Date: Mon, 3 Feb 2025 16:59:31 +0530 Subject: [PATCH 1/2] [ui] Edge: Added slot to fetch if a point exists on the path Removed mousePress and mouseReleased events Invoking custom Event or querying mouse buttons from the provided QMouseEvent crashes meshroom, this comes as first part of the workaround for querying when a point exists on the path --- meshroom/ui/components/edge.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/meshroom/ui/components/edge.py b/meshroom/ui/components/edge.py index da6f051ea1..63c4321572 100755 --- a/meshroom/ui/components/edge.py +++ b/meshroom/ui/components/edge.py @@ -1,4 +1,4 @@ -from PySide6.QtCore import Signal, Property, QPointF, Qt, QObject +from PySide6.QtCore import Signal, Slot, Property, QPointF, Qt, QObject from PySide6.QtGui import QPainterPath, QVector2D from PySide6.QtQuick import QQuickItem @@ -51,19 +51,6 @@ def geometryChange(self, newGeometry, oldGeometry): super(EdgeMouseArea, self).geometryChange(newGeometry, oldGeometry) self.updateShape() - def mousePressEvent(self, evt): - if not self.acceptedMouseButtons() & evt.button(): - evt.setAccepted(False) - return - e = MouseEvent(evt) - self.pressed.emit(e) - e.deleteLater() - - def mouseReleaseEvent(self, evt): - e = MouseEvent(evt) - self.released.emit(e) - e.deleteLater() - def updateShape(self): p1 = QPointF(0, 0) p2 = QPointF(self.width(), self.height()) @@ -110,6 +97,10 @@ def setContainsMouse(self, value): self._containsMouse = value self.containsMouseChanged.emit() + @Slot(QPointF, result=bool) + def containsPoint(self, point): + return self.contains(point) + thicknessChanged = Signal() thickness = Property(float, getThickness, setThickness, notify=thicknessChanged) curveScaleChanged = Signal() From efb13f1d7d9d615685afd72ad9a718ccda755d3b Mon Sep 17 00:00:00 2001 From: waaake Date: Mon, 3 Feb 2025 17:02:57 +0530 Subject: [PATCH 2/2] [ui] Edge: Added mouse area which checks clicks on edgeArea The workaround on edge crashing is to use the mouse area around the edge and query if the click exists in the edge to accept pressed or released signal --- meshroom/ui/qml/GraphEditor/Edge.qml | 29 +++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/meshroom/ui/qml/GraphEditor/Edge.qml b/meshroom/ui/qml/GraphEditor/Edge.qml index e6832edeec..503a0d738f 100644 --- a/meshroom/ui/qml/GraphEditor/Edge.qml +++ b/meshroom/ui/qml/GraphEditor/Edge.qml @@ -139,12 +139,35 @@ Item { acceptedButtons: Qt.LeftButton | Qt.RightButton thickness: root.thickness + 4 curveScale: cubic.ctrlPtDist / root.width // Normalize by width + } + + MouseArea { + x: Math.min(0, root.width) + y: Math.min(0, root.height) + height: Math.abs(root.height) + width: Math.abs(root.width) + acceptedButtons: Qt.LeftButton | Qt.RightButton + onPressed: function(event) { - root.pressed(event) + let xpos = root.width < 0 ? root.height + event.x : event.x; + let ypos = root.height < 0 ? root.height + event.y: event.y; + if (edgeArea.containsPoint(Qt.point(xpos, ypos))) { + root.pressed(event); + } + else { + event.accepted = false; + } } + onReleased: function(event) { - root.released(event) + let xpos = root.width < 0 ? root.height + event.x : event.x; + let ypos = root.height < 0 ? root.height + event.y: event.y; + if (edgeArea.containsPoint(Qt.point(xpos, ypos))) { + root.released(event); + } + else { + event.accepted = false; + } } - } }