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

Refactor Node selection for better UX and performance #2605

Merged
merged 19 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# [GraphEditor] Indentation fix
87c0cef605e4ef2b359d7e678155e79b65b2e762
# [qt6][qml] Clean-up code and harmonize comments
5a0b1c0c9547b0d00f3f10fae6994d6d8ea0b45e
# [nodes] Linting: Clean-up files
Expand Down
9 changes: 9 additions & 0 deletions meshroom/common/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ def _referenceItem(self, item):

self._objectByKey[key] = item

@QtCore.Slot(int, result=QtCore.QModelIndex)
def index(self, row: int, column: int = 0, parent=QtCore.QModelIndex()):
""" Returns the model index for the given row, column and parent index. """
if parent.isValid() or column != 0:
return QtCore.QModelIndex()
if row < 0 or row >= self.size():
return QtCore.QModelIndex()
return self.createIndex(row, column, self._objects[row])

def _dereferenceItem(self, item):
# Ask for object deletion if parented to the model
if shiboken6.isValid(item) and item.parent() == self:
Expand Down
5 changes: 4 additions & 1 deletion meshroom/ui/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

def registerTypes():
from PySide6.QtQml import qmlRegisterType
from PySide6.QtQml import qmlRegisterType, qmlRegisterSingletonType
from meshroom.ui.components.clipboard import ClipboardHelper
from meshroom.ui.components.edge import EdgeMouseArea
from meshroom.ui.components.filepath import FilepathHelper
from meshroom.ui.components.scene3D import Scene3DHelper, TrackballController, Transformations3DHelper
from meshroom.ui.components.csvData import CsvData
from meshroom.ui.components.geom2D import Geom2D

qmlRegisterType(EdgeMouseArea, "GraphEditor", 1, 0, "EdgeMouseArea")
qmlRegisterType(ClipboardHelper, "Meshroom.Helpers", 1, 0, "ClipboardHelper") # TODO: uncreatable
Expand All @@ -14,3 +15,5 @@ def registerTypes():
qmlRegisterType(Transformations3DHelper, "Meshroom.Helpers", 1, 0, "Transformations3DHelper") # TODO: uncreatable
qmlRegisterType(TrackballController, "Meshroom.Helpers", 1, 0, "TrackballController")
qmlRegisterType(CsvData, "DataObjects", 1, 0, "CsvData")

qmlRegisterSingletonType(Geom2D, "Meshroom.Helpers", 1, 0, "Geom2D")
8 changes: 8 additions & 0 deletions meshroom/ui/components/geom2D.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from PySide6.QtCore import QObject, Slot, QRectF


class Geom2D(QObject):
@Slot(QRectF, QRectF, result=bool)
def rectRectIntersect(self, rect1: QRectF, rect2: QRectF) -> bool:
"""Check if two rectangles intersect."""
return rect1.intersects(rect2)
Loading
Loading