Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change black progress bar to transparent grey block #594

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 31 additions & 20 deletions src/main/python/ayab/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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,
t0mpr1c3 marked this conversation as resolved.
Show resolved Hide resolved
-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)
Expand All @@ -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)
Expand Down
Loading