Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Multi-cursor support
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacZhangzhuo committed Oct 3, 2023
1 parent aa61f32 commit 7e8f11d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/compas_view2/shapes/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@


class Text(Shape):
""" """
"""
A text is defined by a string of characters, a position, a height, and a font.
"""

def __init__(self, text, position=[0, 0, 0], height=50, font=None):
super().__init__()
Expand Down
11 changes: 8 additions & 3 deletions src/compas_view2/views/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from qtpy import QtCore
from qtpy import QtWidgets
from qtpy import QtGui


from compas_view2.scene import Camera
from compas_view2.scene import Mouse
Expand Down Expand Up @@ -35,9 +37,7 @@ class View(QtWidgets.QOpenGLWidget):
TOP = 3
PERSPECTIVE = 4

def __init__(
self, app, background_color=(1, 1, 1, 1), selection_color=(1.0, 1.0, 0.0), mode="shaded", show_grid=True
):
def __init__(self, app, background_color=(1, 1, 1, 1), selection_color=(1.0, 1.0, 0.0), mode="shaded", show_grid=True):
super().__init__()
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self._opacity = 1.0
Expand Down Expand Up @@ -237,6 +237,10 @@ def mousePressEvent(self, event):
# if right button
elif event.buttons() & QtCore.Qt.RightButton:
self.mouse.buttons["right"] = True
if self.keys["shift"]:
QtGui.QGuiApplication.setOverrideCursor(QtCore.Qt.OpenHandCursor)
else:
QtGui.QGuiApplication.setOverrideCursor(QtCore.Qt.SizeAllCursor)
# recod mouse position
self.mouse.last_pos = event.pos()
self.update()
Expand All @@ -258,6 +262,7 @@ def mouseReleaseEvent(self, event):
# if right button
elif event.button() == QtCore.Qt.MouseButton.RightButton:
self.mouse.buttons["right"] = False
QtGui.QGuiApplication.restoreOverrideCursor()
self.update()

def wheelEvent(self, event):
Expand Down

0 comments on commit 7e8f11d

Please sign in to comment.