Skip to content

Commit

Permalink
Merge pull request #2605 from alicevision/fix/nodeSelectionPerfs
Browse files Browse the repository at this point in the history
Refactor Node selection for better UX and performance
  • Loading branch information
fabiencastan authored Dec 9, 2024
2 parents df4ad22 + 944ff15 commit 2d56016
Show file tree
Hide file tree
Showing 11 changed files with 656 additions and 499 deletions.
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

0 comments on commit 2d56016

Please sign in to comment.