From bd406ac5be272e634b8d6cf1b0380eaab3c72358 Mon Sep 17 00:00:00 2001 From: t0mpr1c3 Date: Wed, 18 Oct 2023 13:15:28 -0400 Subject: [PATCH 1/2] change colour of progress bar from black to transparent grey --- src/main/python/ayab/scene.py | 49 ++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/src/main/python/ayab/scene.py b/src/main/python/ayab/scene.py index 6391efdf..ed84af9d 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 @@ -37,7 +37,6 @@ class Scene(QGraphicsView): """ BAR_HEIGHT = 5.0 - LIMIT_BAR_WIDTH = 0.5 def __init__(self, parent): super().__init__(parent.ui.graphics_splitter) @@ -80,12 +79,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, + -self.BAR_HEIGHT - 0.5, + machine_width / 2 + 0.5, + self.BAR_HEIGHT) rect_orange.setBrush(QBrush(QColor("orange"))) rect_green = QGraphicsRectItem( - 0, -self.BAR_HEIGHT, - machine_width / 2 + self.LIMIT_BAR_WIDTH, self.BAR_HEIGHT) + 0, + -self.BAR_HEIGHT - 0.5, + machine_width / 2 + 0.5, + self.BAR_HEIGHT) rect_green.setBrush(QBrush(QColor("green"))) qscene.addItem(rect_orange) @@ -94,22 +97,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, + -self.BAR_HEIGHT - 0.5, + 0, + pixmap.height() + self.BAR_HEIGHT + 0.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, + -self.BAR_HEIGHT - 0.5, + 0, + pixmap.height() + self.BAR_HEIGHT + 0.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) From 747ddb6abe5ef7d0bacd848297e0d54e9606d779 Mon Sep 17 00:00:00 2001 From: t0mpr1c3 Date: Sat, 28 Oct 2023 03:31:55 -0400 Subject: [PATCH 2/2] remove BAR_HEIGHT parameter --- src/main/python/ayab/scene.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/python/ayab/scene.py b/src/main/python/ayab/scene.py index ed84af9d..9c553a33 100644 --- a/src/main/python/ayab/scene.py +++ b/src/main/python/ayab/scene.py @@ -36,8 +36,6 @@ class Scene(QGraphicsView): @date June 2020 """ - BAR_HEIGHT = 5.0 - def __init__(self, parent): super().__init__(parent.ui.graphics_splitter) self.setGeometry(QRect(0, 0, 700, 686)) @@ -80,15 +78,15 @@ def refresh(self): # draw "machine" rect_orange = QGraphicsRectItem( -machine_width / 2 - 0.5, - -self.BAR_HEIGHT - 0.5, + -5.5, machine_width / 2 + 0.5, - self.BAR_HEIGHT) + 5) rect_orange.setBrush(QBrush(QColor("orange"))) rect_green = QGraphicsRectItem( 0, - -self.BAR_HEIGHT - 0.5, + -5.5, machine_width / 2 + 0.5, - self.BAR_HEIGHT) + 5) rect_green.setBrush(QBrush(QColor("green"))) qscene.addItem(rect_orange) @@ -98,15 +96,15 @@ def refresh(self): qscene.addItem( QGraphicsRectItem( self.__start_needle - machine_width / 2 - 0.5, - -self.BAR_HEIGHT - 0.5, + -5.5, 0, - pixmap.height() + self.BAR_HEIGHT + 0.5)) + pixmap.height() + 5.5)) qscene.addItem( QGraphicsRectItem( self.__stop_needle - machine_width / 2 + 1.5, - -self.BAR_HEIGHT - 0.5, + -5.5, 0, - pixmap.height() + self.BAR_HEIGHT + 0.5)) + pixmap.height() + 5.5)) qscene.addItem( QGraphicsRectItem( self.__start_needle - machine_width / 2 - 1,