Skip to content

Commit

Permalink
Merge branch 'middle-colors-twice'
Browse files Browse the repository at this point in the history
  • Loading branch information
dl1com committed Dec 28, 2018
2 parents 0539b20 + ceb04c1 commit b70a689
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 109 deletions.
31 changes: 23 additions & 8 deletions src/main/python/ayab/ayab.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class GuiMain(QMainWindow):
GuiMain inherits from QMainWindow and instanciates a window with the form components form ayab_gui.UiForm.
"""

signalUpdateProgress = pyqtSignal(int, int)
signalUpdateProgress = pyqtSignal(int, int, int)
signalUpdateColor = pyqtSignal('QString')
signalUpdateStatus = pyqtSignal(int, int, 'QString', int)
signalUpdateNotification = pyqtSignal('QString')
signalDisplayPopUp = pyqtSignal('QString', 'QString')
Expand Down Expand Up @@ -99,19 +100,32 @@ def __init__(self, app_context):
self.showMaximized()
self.setupBehaviour()

def updateProgress(self, row, total=0):
self.ui.label_notifications.setText("")
self.ui.label_current_line.setText("")
self.ui.label_current_color.setText("")

def update_progress(self, row, total=0, repeats=0):
'''Updates the Progress Bar.'''
#Store to local variable
self.var_progress = row
self.refresh_scene()

# Update label and progress bar
# Update label
if total != 0:
self.ui.notification_label.setText("{0}/{1}".format(row, total))
text = "Line {0}/{1}".format(row, total)
if repeats != 0:
text += " ({0} repeats completed)".format(repeats)
else:
text = ""
self.ui.label_current_line.setText(text)

options_ui = self.enabled_plugin.options_ui
options_ui.label_progress.setText("{0}/{1}".format(row, total))


def update_color(self, color):
'''Updates the current color.'''
self.ui.label_current_color.setText("Color: " + color)

def updateStatus(self, hall_l, hall_r, carriage_type, carriage_position):
options_ui = self.enabled_plugin.options_ui
options_ui.progress_hall_l.setValue(hall_l)
Expand All @@ -129,7 +143,7 @@ def update_file_selected_text_field(self, route):
def slotUpdateNotification(self, text):
'''Updates the Notification field'''
logging.info("Notification: " + text)
self.ui.notification_label.setText(text)
self.ui.label_notifications.setText(text)

def slotUpdateNeedles(self, start_needle, stop_needle):
'''Updates the position of the start/stop needle visualisation'''
Expand Down Expand Up @@ -188,7 +202,8 @@ def setupBehaviour(self):
self.ui.actionLoad_AYAB_Firmware.triggered.connect(self.generate_firmware_ui)
self.ui.image_pattern_view.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)
# Connecting Signals.
self.signalUpdateProgress.connect(self.updateProgress)
self.signalUpdateProgress.connect(self.update_progress)
self.signalUpdateColor.connect(self.update_color)
self.signalUpdateStatus.connect(self.updateStatus)
self.signalUpdateNotification.connect(self.slotUpdateNotification)
self.signalDisplayPopUp.connect(self.display_blocking_pop_up)
Expand Down Expand Up @@ -307,7 +322,7 @@ def refresh_scene(self):

def set_dimensions_on_gui(self, width, height):
text = "{} - {}".format(width, height)
self.ui.notification_label.setText("Image Dimensions: " + text)
self.ui.label_notifications.setText("Image Dimensions: " + text)

def display_blocking_pop_up(self, message="", message_type="info"):
logging.debug("MessageBox {}: '{}'".format(message_type, message))
Expand Down
54 changes: 40 additions & 14 deletions src/main/python/ayab/ayab_gui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'ayab/ayab_gui.ui'
# Form implementation generated from reading ui file 'src/main/python/ayab/ayab_gui.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
Expand All @@ -16,6 +16,41 @@ def setupUi(self, MainWindow):
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.image_side_panel = QtWidgets.QVBoxLayout()
self.image_side_panel.setSpacing(6)
self.image_side_panel.setObjectName("image_side_panel")
self.image_pattern_view = QtWidgets.QGraphicsView(self.centralwidget)
self.image_pattern_view.setObjectName("image_pattern_view")
self.image_side_panel.addWidget(self.image_pattern_view)
self.progressLayout = QtWidgets.QHBoxLayout()
self.progressLayout.setSpacing(2)
self.progressLayout.setObjectName("progressLayout")
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label_current_color = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
font.setKerning(True)
self.label_current_color.setFont(font)
self.label_current_color.setObjectName("label_current_color")
self.horizontalLayout.addWidget(self.label_current_color, 0, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.progressLayout.addLayout(self.horizontalLayout)
self.label_current_line = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.label_current_line.setFont(font)
self.label_current_line.setObjectName("label_current_line")
self.progressLayout.addWidget(self.label_current_line, 0, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.image_side_panel.addLayout(self.progressLayout)
self.label_notifications = QtWidgets.QLabel(self.centralwidget)
self.label_notifications.setAlignment(QtCore.Qt.AlignCenter)
self.label_notifications.setObjectName("label_notifications")
self.image_side_panel.addWidget(self.label_notifications)
self.gridLayout.addLayout(self.image_side_panel, 0, 0, 3, 1)
self.assistant_dock = QtWidgets.QScrollArea(self.centralwidget)
self.assistant_dock.setEnabled(True)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
Expand Down Expand Up @@ -119,21 +154,9 @@ def setupUi(self, MainWindow):
self.verticalLayout_5.addWidget(self.widget_knitcontrol, 0, QtCore.Qt.AlignHCenter)
self.assistant_dock.setWidget(self.dockWidgetContents)
self.gridLayout.addWidget(self.assistant_dock, 0, 1, 3, 1)
self.image_side_panel = QtWidgets.QVBoxLayout()
self.image_side_panel.setSpacing(6)
self.image_side_panel.setObjectName("image_side_panel")
self.image_pattern_view = QtWidgets.QGraphicsView(self.centralwidget)
self.image_pattern_view.setObjectName("image_pattern_view")
self.image_side_panel.addWidget(self.image_pattern_view)
self.notification_label = QtWidgets.QLabel(self.centralwidget)
self.notification_label.setText("")
self.notification_label.setAlignment(QtCore.Qt.AlignCenter)
self.notification_label.setObjectName("notification_label")
self.image_side_panel.addWidget(self.notification_label)
self.gridLayout.addLayout(self.image_side_panel, 0, 0, 3, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1008, 20))
self.menubar.setGeometry(QtCore.QRect(0, 0, 1008, 22))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
Expand Down Expand Up @@ -195,6 +218,9 @@ def setupUi(self, MainWindow):
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "All Yarns Are Beautiful"))
self.label_current_color.setText(_translate("MainWindow", "label_current_color"))
self.label_current_line.setText(_translate("MainWindow", "label_current_line"))
self.label_notifications.setText(_translate("MainWindow", "label_notifications"))
self.assistant_dock.setWindowTitle(_translate("MainWindow", "Asistant"))
self.load_file_button.setText(_translate("MainWindow", "1. Load Image File"))
self.load_file_button.setShortcut(_translate("MainWindow", "Ctrl+O"))
Expand Down
82 changes: 61 additions & 21 deletions src/main/python/ayab/ayab_gui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,66 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="3">
<layout class="QVBoxLayout" name="image_side_panel">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QGraphicsView" name="image_pattern_view"/>
</item>
<item>
<layout class="QHBoxLayout" name="progressLayout">
<property name="spacing">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<widget class="QLabel" name="label_current_color">
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>label_current_color</string>
</property>
</widget>
</item>
</layout>
</item>
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<widget class="QLabel" name="label_current_line">
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>label_current_line</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_notifications">
<property name="text">
<string>label_notifications</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1" rowspan="3">
<widget class="QScrollArea" name="assistant_dock">
<property name="enabled">
Expand Down Expand Up @@ -232,26 +292,6 @@
</widget>
</widget>
</item>
<item row="0" column="0" rowspan="3">
<layout class="QVBoxLayout" name="image_side_panel">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QGraphicsView" name="image_pattern_view"/>
</item>
<item>
<widget class="QLabel" name="notification_label">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
Expand All @@ -260,7 +300,7 @@
<x>0</x>
<y>0</y>
<width>1008</width>
<height>20</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down
Loading

0 comments on commit b70a689

Please sign in to comment.