Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Edge: Workaround on the Crash due to Edge Connections #2663

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions meshroom/ui/components/edge.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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()
Expand Down
29 changes: 26 additions & 3 deletions meshroom/ui/qml/GraphEditor/Edge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

}
}