4
4
from abc import ABC
5
5
6
6
from graphics .canvas import Canvas
7
- from PyQt6 .QtWidgets import QAbstractGraphicsShapeItem
7
+ from PyQt6 .QtWidgets import QAbstractGraphicsShapeItem , QGraphicsLineItem , QGraphicsItem
8
8
from PyQt6 .QtGui import QPen , QPainter , QBrush , QColor , QFont , QPainterPath
9
9
from PyQt6 .QtCore import Qt
10
10
@@ -70,7 +70,7 @@ def reset_to_blank(self):
70
70
def set_track_area (self , track_area : TrackArea ):
71
71
self ._track_area = track_area
72
72
73
- def _get_current_scale (self ):
73
+ def _get_current_scale (self , width : int , height : int ):
74
74
min_x = self ._track_area .min_x
75
75
min_y = self ._track_area .min_y
76
76
max_x = self ._track_area .max_x
@@ -79,8 +79,8 @@ def _get_current_scale(self):
79
79
x_size = max_x - min_x
80
80
y_size = max_y - min_y
81
81
82
- x_scale = self . geometry (). width () / x_size
83
- y_scale = self . geometry (). height () / y_size
82
+ x_scale = width / x_size
83
+ y_scale = height / y_size
84
84
85
85
scale = min (x_scale , y_scale )
86
86
@@ -89,21 +89,22 @@ def _get_current_scale(self):
89
89
90
90
return Scale (min_x - x_border , max_y + y_border , scale )
91
91
92
- def _paint (self , painter : QPainter ):
93
- scale = self ._get_current_scale ()
92
+ def _paint (self , painter : QPainter , width : int , height : int ):
93
+ scale = self ._get_current_scale (width , height )
94
94
for f in self ._fixed_shapes :
95
95
f .paint (painter , scale )
96
96
97
- def _get_scene_items (self ) -> list [QAbstractGraphicsShapeItem ]:
98
- # rect = QGraphicsRectItem(0, 0, self._width / 20, self._height / 20)
99
- # rect.setPos(self._width / 10, self._height / 10)
100
- # brush = QBrush(Qt.GlobalColor.red)
101
- # rect.setBrush(brush)
97
+ def _get_scene_items (self ) -> list [QGraphicsItem ]:
102
98
# pen = QPen(Qt.GlobalColor.cyan)
103
- # pen.setWidth(10)
104
- # rect.setPen(pen)
99
+ # pen.setWidth(0)
100
+ # result = []
101
+ # for i in range(0, 200):
102
+ # line = QGraphicsLineItem(i * 2, 0, i * 2, 200)
103
+ # line.setPos(0, 0)
104
+ # line.setPen(pen)
105
+ # result.append(line)
105
106
#
106
- # return [rect]
107
+ # return result
107
108
return []
108
109
109
110
def add_fixed_shape (self , item : FixedShape ):
@@ -126,7 +127,7 @@ def paint(self, painter: QPainter, scale: Scale):
126
127
painter .setPen (self ._pen )
127
128
painter .setBrush (self ._brush )
128
129
radius = self ._diameter / 2
129
- if self ._diameter >= 3 :
130
+ if self ._diameter >= 2 :
130
131
painter .drawEllipse (round (x - radius ), round (y - radius ), self ._diameter , self ._diameter )
131
132
else :
132
133
painter .drawPoint (round (x ), round (y ))
0 commit comments