-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreference_item.py
More file actions
43 lines (27 loc) · 1.3 KB
/
reference_item.py
File metadata and controls
43 lines (27 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from PyQt6.QtGui import QPixmap, QMouseEvent
from PyQt6.QtCore import Qt, QRectF, QMarginsF
from graphics_widget import GraphicsWidget
from drop_shadow_mixin import DropShadowMixin
from styling import *
class ReferenceItem(GraphicsWidget, DropShadowMixin):
def __init__(self, project):
GraphicsWidget.__init__(self)
DropShadowMixin.__init__(self)
self.setZValue(-100)
self.project = project
self.setAcceptHoverEvents(True)
self.setFlag(GraphicsWidget.GraphicsItemFlag.ItemSendsGeometryChanges)
# self.setGeometry(self.boundingRect())
def mouseMoveEvent(self, event: QMouseEvent):
""" Pan the view when dragging with Alt key pressed."""
print("--------")
def boundingRect(self):
"""Return the bounding rectangle for the item."""
return QRectF(QPointF(), self.project.reference_image.size().toSizeF())
def paint(self, painter, option, widget=None):
"""Override the paint method for customization."""
if self.project.reference_image:
painter.drawPixmap(0, 0, QPixmap.fromImage(self.project.reference_image))
painter.setBrush(Qt.BrushStyle.NoBrush)
painter.setPen(get_item_pen(self))
painter.drawRect(self.rect())