diff --git a/src/main/python/ayab/scene.py b/src/main/python/ayab/scene.py index 6391efdf..9c553a33 100644 --- a/src/main/python/ayab/scene.py +++ b/src/main/python/ayab/scene.py @@ -21,7 +21,7 @@ import logging from PyQt5.QtCore import QRect -from PyQt5.QtGui import QImage, QPixmap, QBrush, QColor +from PyQt5.QtGui import QImage, QPixmap, QPen, QBrush, QColor from PyQt5.QtWidgets import QGraphicsScene, QGraphicsRectItem, QGraphicsView from .image import AyabImage @@ -36,9 +36,6 @@ class Scene(QGraphicsView): @date June 2020 """ - BAR_HEIGHT = 5.0 - LIMIT_BAR_WIDTH = 0.5 - def __init__(self, parent): super().__init__(parent.ui.graphics_splitter) self.setGeometry(QRect(0, 0, 700, 686)) @@ -80,12 +77,16 @@ def refresh(self): # draw "machine" rect_orange = QGraphicsRectItem( - -machine_width / 2 - self.LIMIT_BAR_WIDTH, -self.BAR_HEIGHT, - machine_width / 2 + self.LIMIT_BAR_WIDTH, self.BAR_HEIGHT) + -machine_width / 2 - 0.5, + -5.5, + machine_width / 2 + 0.5, + 5) rect_orange.setBrush(QBrush(QColor("orange"))) rect_green = QGraphicsRectItem( - 0, -self.BAR_HEIGHT, - machine_width / 2 + self.LIMIT_BAR_WIDTH, self.BAR_HEIGHT) + 0, + -5.5, + machine_width / 2 + 0.5, + 5) rect_green.setBrush(QBrush(QColor("green"))) qscene.addItem(rect_orange) @@ -94,22 +95,32 @@ def refresh(self): # draw limiting lines (start/stop needle) qscene.addItem( QGraphicsRectItem( - self.__start_needle - machine_width / 2 - self.LIMIT_BAR_WIDTH, - -self.BAR_HEIGHT, self.LIMIT_BAR_WIDTH, - pixmap.height() + self.BAR_HEIGHT)) + self.__start_needle - machine_width / 2 - 0.5, + -5.5, + 0, + pixmap.height() + 5.5)) qscene.addItem( QGraphicsRectItem( - self.__stop_needle + 1 - machine_width / 2, - -self.BAR_HEIGHT, self.LIMIT_BAR_WIDTH, - pixmap.height() + self.BAR_HEIGHT)) - - # Draw knitting progress + self.__stop_needle - machine_width / 2 + 1.5, + -5.5, + 0, + pixmap.height() + 5.5)) qscene.addItem( QGraphicsRectItem( - -machine_width / 2 - self.LIMIT_BAR_WIDTH, - pixmap.height() - self.__row_progress + self.LIMIT_BAR_WIDTH, - machine_width + 2 * self.LIMIT_BAR_WIDTH, - self.LIMIT_BAR_WIDTH)) + self.__start_needle - machine_width / 2 - 1, + pixmap.height() + 0.5, + self.__stop_needle - self.__start_needle + 3, + 0)) + + # Draw knitting progress + grey = QGraphicsRectItem( + self.__start_needle - machine_width / 2, + pixmap.height(), + self.__stop_needle - self.__start_needle + 1, + -self.__row_progress) + grey.setPen(QPen(QColor(127, 127, 127, 127), 0)) + grey.setBrush(QBrush(QColor(127, 127, 127, 127))) + qscene.addItem(grey) self.resetTransform() self.scale(self.zoom, self.zoom)