Skip to content
Snippets Groups Projects
Commit 9f43681a authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Unify naming

parent bd9caefb
No related branches found
No related tags found
1 merge request!497Unify naming
Pipeline #158994 passed
...@@ -52,8 +52,8 @@ class AboutWindow(QDialog): ...@@ -52,8 +52,8 @@ class AboutWindow(QDialog):
" Toolbox__\n\n*Construct, simulate and analyze signal processing" " Toolbox__\n\n*Construct, simulate and analyze signal processing"
" algorithms aimed at implementation on an ASIC or" " algorithms aimed at implementation on an ASIC or"
" FPGA.*\n\nB-ASIC is developed by the <a" " FPGA.*\n\nB-ASIC is developed by the <a"
" href=\"https://liu.se/en/organisation/liu/isy/da\">Division of" " href=\"https://liu.se/en/organisation/liu/isy/elda\">Division of"
" Computer Engineering</a> at <a" " Electronics and Computer Engineering</a> at <a"
" href=\"https://liu.se/?l=en\">Linköping University</a>," " href=\"https://liu.se/?l=en\">Linköping University</a>,"
" Sweden.\n\nB-ASIC is released under the <a" " Sweden.\n\nB-ASIC is released under the <a"
" href=\"https://gitlab.liu.se/da/B-ASIC/-/blob/master/LICENSE\">" " href=\"https://gitlab.liu.se/da/B-ASIC/-/blob/master/LICENSE\">"
......
...@@ -36,23 +36,23 @@ class ColorDataType: ...@@ -36,23 +36,23 @@ class ColorDataType:
self.name = name self.name = name
Latency_Color = ColorDataType( LATENCY_COLOR_TYPE = ColorDataType(
current_color=OPERATION_LATENCY_INACTIVE, current_color=OPERATION_LATENCY_INACTIVE,
DEFAULT=OPERATION_LATENCY_INACTIVE, DEFAULT=OPERATION_LATENCY_INACTIVE,
name='Latency Color', name='Latency Color',
) )
Execution_Time_Color = ColorDataType( EXECUTION_TIME_COLOR_TYPE = ColorDataType(
current_color=OPERATION_EXECUTION_TIME_ACTIVE, current_color=OPERATION_EXECUTION_TIME_ACTIVE,
DEFAULT=OPERATION_EXECUTION_TIME_ACTIVE, DEFAULT=OPERATION_EXECUTION_TIME_ACTIVE,
name='Execution Time Color', name='Execution Time Color',
) )
Signal_Warning_Color = ColorDataType( SIGNAL_WARNING_COLOR_TYPE = ColorDataType(
current_color=SIGNAL_WARNING, DEFAULT=SIGNAL_WARNING, name='Warning Color' current_color=SIGNAL_WARNING, DEFAULT=SIGNAL_WARNING, name='Warning Color'
) )
Signal_Color = ColorDataType( SIGNAL_COLOR_TYPE = ColorDataType(
current_color=SIGNAL_INACTIVE, DEFAULT=SIGNAL_INACTIVE, name='Signal Color' current_color=SIGNAL_INACTIVE, DEFAULT=SIGNAL_INACTIVE, name='Signal Color'
) )
Active_Color = ColorDataType( ACTIVE_COLOR_TYPE = ColorDataType(
current_color=SIGNAL_ACTIVE, DEFAULT=SIGNAL_ACTIVE, name='Active Color' current_color=SIGNAL_ACTIVE, DEFAULT=SIGNAL_ACTIVE, name='Active Color'
) )
...@@ -79,6 +79,6 @@ class FontDataType: ...@@ -79,6 +79,6 @@ class FontDataType:
self.changed = changed self.changed = changed
Font = FontDataType( FONT = FontDataType(
current_font=DEFAULT_FONT, DEFAULT=DEFAULT_FONT, DEFAULT_COLOR=DEFAULT_FONT_COLOR current_font=DEFAULT_FONT, DEFAULT=DEFAULT_FONT, DEFAULT_COLOR=DEFAULT_FONT_COLOR
) )
...@@ -65,13 +65,13 @@ from b_asic.gui_utils.icons import get_icon ...@@ -65,13 +65,13 @@ from b_asic.gui_utils.icons import get_icon
from b_asic.gui_utils.mpl_window import MPLWindow from b_asic.gui_utils.mpl_window import MPLWindow
from b_asic.schedule import Schedule from b_asic.schedule import Schedule
from b_asic.scheduler_gui._preferences import ( from b_asic.scheduler_gui._preferences import (
Active_Color, ACTIVE_COLOR_TYPE,
EXECUTION_TIME_COLOR_TYPE,
FONT,
LATENCY_COLOR_TYPE,
SIGNAL_COLOR_TYPE,
SIGNAL_WARNING_COLOR_TYPE,
ColorDataType, ColorDataType,
Execution_Time_Color,
Font,
Latency_Color,
Signal_Color,
Signal_Warning_Color,
) )
from b_asic.scheduler_gui.axes_item import AxesItem from b_asic.scheduler_gui.axes_item import AxesItem
from b_asic.scheduler_gui.operation_item import OperationItem from b_asic.scheduler_gui.operation_item import OperationItem
...@@ -742,28 +742,39 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -742,28 +742,39 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
settings.setValue("scheduler/splitter/pos", self.splitter.sizes()[1]) settings.setValue("scheduler/splitter/pos", self.splitter.sizes()[1])
settings.beginGroup("scheduler/preferences") settings.beginGroup("scheduler/preferences")
settings.setValue("font", Font.current_font.toString()) settings.setValue("font", FONT.current_font.toString())
settings.setValue("fontSize", Font.size) settings.setValue("fontSize", FONT.size)
settings.setValue("fontColor", Font.color) settings.setValue("fontColor", FONT.color)
settings.setValue("fontBold", Font.current_font.bold()) settings.setValue("fontBold", FONT.current_font.bold())
settings.setValue("fontItalic", Font.current_font.italic()) settings.setValue("fontItalic", FONT.current_font.italic())
settings.setValue("fontChanged", Font.changed) settings.setValue("fontChanged", FONT.changed)
settings.setValue(Signal_Color.name, Signal_Color.current_color.name()) settings.setValue(
settings.setValue(Active_Color.name, Active_Color.current_color.name()) SIGNAL_COLOR_TYPE.name, SIGNAL_COLOR_TYPE.current_color.name()
)
settings.setValue( settings.setValue(
Signal_Warning_Color.name, Signal_Warning_Color.current_color.name() ACTIVE_COLOR_TYPE.name, ACTIVE_COLOR_TYPE.current_color.name()
) )
settings.setValue( settings.setValue(
Execution_Time_Color.name, Execution_Time_Color.current_color.name() SIGNAL_WARNING_COLOR_TYPE.name,
SIGNAL_WARNING_COLOR_TYPE.current_color.name(),
)
settings.setValue(
EXECUTION_TIME_COLOR_TYPE.name,
EXECUTION_TIME_COLOR_TYPE.current_color.name(),
) )
settings.setValue(f"{Signal_Color.name}_changed", Signal_Color.changed)
settings.setValue(f"{Active_Color.name}_changed", Active_Color.changed)
settings.setValue( settings.setValue(
f"{Signal_Warning_Color.name}_changed", Signal_Warning_Color.changed f"{SIGNAL_COLOR_TYPE.name}_changed", SIGNAL_COLOR_TYPE.changed
)
settings.setValue(
f"{ACTIVE_COLOR_TYPE.name}_changed", ACTIVE_COLOR_TYPE.changed
) )
self.Save_colortype() settings.setValue(
f"{SIGNAL_WARNING_COLOR_TYPE.name}_changed",
SIGNAL_WARNING_COLOR_TYPE.changed,
)
self.save_colortype()
settings.sync() settings.sync()
if settings.isWritable(): if settings.isWritable():
...@@ -792,68 +803,70 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -792,68 +803,70 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
) )
settings.beginGroup("scheduler/preferences") settings.beginGroup("scheduler/preferences")
Font.current_font = QFont( FONT.current_font = QFont(
settings.value("font", defaultValue=Font.DEFAULT.toString(), type=str) settings.value("font", defaultValue=FONT.DEFAULT.toString(), type=str)
) )
Font.size = settings.value( FONT.size = settings.value(
"fontSize", defaultValue=Font.DEFAULT.pointSizeF(), type=int "fontSize", defaultValue=FONT.DEFAULT.pointSizeF(), type=int
) )
Font.color = QColor( FONT.color = QColor(
settings.value("fontColor", defaultValue=Font.DEFAULT_COLOR, type=str) settings.value("fontColor", defaultValue=FONT.DEFAULT_COLOR, type=str)
) )
Font.bold = settings.value( FONT.bold = settings.value(
"fontBold", defaultValue=Font.DEFAULT.bold(), type=bool "fontBold", defaultValue=FONT.DEFAULT.bold(), type=bool
) )
Font.italic = settings.value( FONT.italic = settings.value(
"fontItalic", defaultValue=Font.DEFAULT.italic(), type=bool "fontItalic", defaultValue=FONT.DEFAULT.italic(), type=bool
) )
Font.changed = settings.value("fontChanged", Font.changed, bool) FONT.changed = settings.value("fontChanged", FONT.changed, bool)
Signal_Color.current_color = QColor( SIGNAL_COLOR_TYPE.current_color = QColor(
settings.value( settings.value(
"Signal Color", defaultValue=Signal_Color.DEFAULT.name(), type=str "Signal Color", defaultValue=SIGNAL_COLOR_TYPE.DEFAULT.name(), type=str
) )
) )
Active_Color.current_color = QColor( ACTIVE_COLOR_TYPE.current_color = QColor(
settings.value( settings.value(
"Active Color", defaultValue=Active_Color.DEFAULT.name(), type=str "Active Color", defaultValue=ACTIVE_COLOR_TYPE.DEFAULT.name(), type=str
) )
) )
Signal_Warning_Color.current_color = QColor( SIGNAL_WARNING_COLOR_TYPE.current_color = QColor(
settings.value( settings.value(
"Warning Color", "Warning Color",
defaultValue=Signal_Warning_Color.DEFAULT.name(), defaultValue=SIGNAL_WARNING_COLOR_TYPE.DEFAULT.name(),
type=str, type=str,
) )
) )
Latency_Color.current_color = QColor( LATENCY_COLOR_TYPE.current_color = QColor(
settings.value( settings.value(
"Latency Color", defaultValue=Latency_Color.DEFAULT.name(), type=str "Latency Color",
defaultValue=LATENCY_COLOR_TYPE.DEFAULT.name(),
type=str,
) )
) )
Execution_Time_Color.current_color = QColor( EXECUTION_TIME_COLOR_TYPE.current_color = QColor(
settings.value( settings.value(
"Execution Time Color", "Execution Time Color",
defaultValue=Execution_Time_Color.DEFAULT.name(), defaultValue=EXECUTION_TIME_COLOR_TYPE.DEFAULT.name(),
type=str, type=str,
) )
) )
Signal_Color.changed = settings.value( SIGNAL_COLOR_TYPE.changed = settings.value(
f"{Signal_Color.name}_changed", False, bool f"{SIGNAL_COLOR_TYPE.name}_changed", False, bool
) )
Active_Color.changed = settings.value( ACTIVE_COLOR_TYPE.changed = settings.value(
f"{Active_Color.name}_changed", False, bool f"{ACTIVE_COLOR_TYPE.name}_changed", False, bool
) )
Signal_Warning_Color.changed = settings.value( SIGNAL_WARNING_COLOR_TYPE.changed = settings.value(
f"{Signal_Warning_Color.name}_changed", f"{SIGNAL_WARNING_COLOR_TYPE.name}_changed",
False, False,
bool, bool,
) )
Latency_Color.changed = settings.value( LATENCY_COLOR_TYPE.changed = settings.value(
f"{Latency_Color.name}_changed", False, bool f"{LATENCY_COLOR_TYPE.name}_changed", False, bool
) )
Execution_Time_Color.changed = settings.value( EXECUTION_TIME_COLOR_TYPE.changed = settings.value(
f"{Execution_Time_Color.name}_changed", f"{EXECUTION_TIME_COLOR_TYPE.name}_changed",
False, False,
bool, bool,
) )
...@@ -1003,12 +1016,12 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1003,12 +1016,12 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
layout.addWidget(label) layout.addWidget(label)
Hlayout.setSpacing(20) Hlayout.setSpacing(20)
Hlayout.addWidget(self.creat_color_button(Execution_Time_Color)) Hlayout.addWidget(self.create_color_button(EXECUTION_TIME_COLOR_TYPE))
Hlayout.addWidget(self.creat_color_button(Latency_Color)) Hlayout.addWidget(self.create_color_button(LATENCY_COLOR_TYPE))
Hlayout.addWidget( Hlayout.addWidget(
self.creat_color_button( self.create_color_button(
ColorDataType( ColorDataType(
current_color=Latency_Color.DEFAULT, current_color=LATENCY_COLOR_TYPE.DEFAULT,
DEFAULT=QColor('skyblue'), DEFAULT=QColor('skyblue'),
name="Latency Color per Type", name="Latency Color per Type",
) )
...@@ -1024,14 +1037,14 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1024,14 +1037,14 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
Hlayout = QHBoxLayout() Hlayout = QHBoxLayout()
Hlayout.setSpacing(20) Hlayout.setSpacing(20)
Signal_button = self.creat_color_button(Signal_Color) Signal_button = self.create_color_button(SIGNAL_COLOR_TYPE)
Signal_button.setStyleSheet( Signal_button.setStyleSheet(
f"color: {QColor(255,255,255,0).name()}; background-color: {Signal_Color.DEFAULT.name()}" f"color: {QColor(255,255,255,0).name()}; background-color: {SIGNAL_COLOR_TYPE.DEFAULT.name()}"
) )
Hlayout.addWidget(Signal_button) Hlayout.addWidget(Signal_button)
Hlayout.addWidget(self.creat_color_button(Signal_Warning_Color)) Hlayout.addWidget(self.create_color_button(SIGNAL_WARNING_COLOR_TYPE))
Hlayout.addWidget(self.creat_color_button(Active_Color)) Hlayout.addWidget(self.create_color_button(ACTIVE_COLOR_TYPE))
groupbox.setLayout(Hlayout) groupbox.setLayout(Hlayout)
layout.addWidget(groupbox) layout.addWidget(groupbox)
...@@ -1063,19 +1076,19 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1063,19 +1076,19 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
icon = QIcon.fromTheme("format-text-italic") icon = QIcon.fromTheme("format-text-italic")
Italicbutton = ( Italicbutton = (
ColorButton(QColor('silver')) ColorButton(QColor('silver'))
if Font.italic if FONT.italic
else ColorButton(QColor('snow')) else ColorButton(QColor('snow'))
) )
Italicbutton.setIcon(icon) Italicbutton.setIcon(icon)
Italicbutton.pressed.connect(lambda: self.Italic_font_clicked(Italicbutton)) Italicbutton.pressed.connect(lambda: self.italic_font_clicked(Italicbutton))
Hlayout2.addWidget(Italicbutton) Hlayout2.addWidget(Italicbutton)
icon = QIcon.fromTheme("format-text-bold") icon = QIcon.fromTheme("format-text-bold")
Boldbutton = ( Boldbutton = (
ColorButton(QColor('silver')) if Font.bold else ColorButton(QColor('snow')) ColorButton(QColor('silver')) if FONT.bold else ColorButton(QColor('snow'))
) )
Boldbutton.setIcon(icon) Boldbutton.setIcon(icon)
Boldbutton.pressed.connect(lambda: self.Bold_font_clicked(Boldbutton)) Boldbutton.pressed.connect(lambda: self.bold_font_clicked(Boldbutton))
Hlayout2.addWidget(Boldbutton) Hlayout2.addWidget(Boldbutton)
groupbox2.setLayout(Hlayout2) groupbox2.setLayout(Hlayout2)
...@@ -1091,26 +1104,30 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1091,26 +1104,30 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
icon = QIcon.fromTheme("list-add") icon = QIcon.fromTheme("list-add")
Incr_button = ColorButton(QColor('smoke')) Incr_button = ColorButton(QColor('smoke'))
Incr_button.setIcon(icon) Incr_button.setIcon(icon)
Incr_button.pressed.connect(lambda: self.Incr_font_clicked(Font_Size_input)) Incr_button.pressed.connect(
lambda: self.increase_font_size_clicked(Font_Size_input)
)
Incr_button.setShortcut(QCoreApplication.translate("MainWindow", "Ctrl++")) Incr_button.setShortcut(QCoreApplication.translate("MainWindow", "Ctrl++"))
Hlayout2.addWidget(Incr_button) Hlayout2.addWidget(Incr_button)
Font_Size_input.setPlaceholderText('Font Size') Font_Size_input.setPlaceholderText('Font Size')
Font_Size_input.setText(f'Font Size: {Font.size}') Font_Size_input.setText(f'Font Size: {FONT.size}')
Font_Size_input.setValidator(QIntValidator(0, 99)) Font_Size_input.setValidator(QIntValidator(0, 99))
Font_Size_input.setAlignment(Qt.AlignCenter) Font_Size_input.setAlignment(Qt.AlignCenter)
Font_Size_input.textChanged.connect( Font_Size_input.textChanged.connect(
lambda: self.set_fontSize_clicked(Font_Size_input.text()) lambda: self.set_font_size_clicked(Font_Size_input.text())
) )
Font_Size_input.textChanged.connect( Font_Size_input.textChanged.connect(
lambda: self.set_fontSize_clicked(Font_Size_input.text()) lambda: self.set_font_size_clicked(Font_Size_input.text())
) )
Hlayout2.addWidget(Font_Size_input) Hlayout2.addWidget(Font_Size_input)
icon = QIcon.fromTheme("list-remove") icon = QIcon.fromTheme("list-remove")
Decr_button = ColorButton(QColor('smoke')) Decr_button = ColorButton(QColor('smoke'))
Decr_button.setIcon(icon) Decr_button.setIcon(icon)
Decr_button.pressed.connect(lambda: self.Decr_font_clicked(Font_Size_input)) Decr_button.pressed.connect(
lambda: self.decrease_font_size_clicked(Font_Size_input)
)
Decr_button.setShortcut(QCoreApplication.translate("MainWindow", "Ctrl+-")) Decr_button.setShortcut(QCoreApplication.translate("MainWindow", "Ctrl+-"))
Hlayout2.addWidget(Decr_button) Hlayout2.addWidget(Decr_button)
...@@ -1147,10 +1164,13 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1147,10 +1164,13 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
dialog.exec_() dialog.exec_()
def creat_color_button(self, color: ColorDataType) -> ColorButton: def create_color_button(self, color: ColorDataType) -> ColorButton:
"""Create a colored button to be used to modify a certain color """Create a colored button to be used to modify a certain color
color_type: ColorDataType
The color_type assigned to the butten to be created. Parameters
----------
color : ColorDataType
The ColorDataType assigned to the butten to be created.
""" """
button = ColorButton(color.DEFAULT) button = ColorButton(color.DEFAULT)
button.setText(color.name) button.setText(color.name)
...@@ -1163,7 +1183,7 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1163,7 +1183,7 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
lambda: self.set_latency_color_by_type_name(all=False) lambda: self.set_latency_color_by_type_name(all=False)
) )
else: else:
button.pressed.connect(lambda: self.Color_button_clicked(color)) button.pressed.connect(lambda: self.color_button_clicked(color))
return button return button
def set_latency_color_by_type_name(self, all: bool): def set_latency_color_by_type_name(self, all: bool):
...@@ -1171,16 +1191,16 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1171,16 +1191,16 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
all: bool all: bool
Indicates if the color of all type names to be modified. Indicates if the color of all type names to be modified.
""" """
if Latency_Color.changed: if LATENCY_COLOR_TYPE.changed:
current_color = Latency_Color.current_color current_color = LATENCY_COLOR_TYPE.current_color
else: else:
current_color = Latency_Color.DEFAULT current_color = LATENCY_COLOR_TYPE.DEFAULT
# Prompt user to select operation type if not setting color for all types # Prompt user to select operation type if not setting color for all types
if not all: if not all:
used_types = self._schedule.get_used_type_names() used_types = self._schedule.get_used_type_names()
type, ok = QInputDialog.getItem( type, ok = QInputDialog.getItem(
self, "Select Operation Type", "Type", used_types, editable=False self, "Select operation type", "Type", used_types, editable=False
) )
else: else:
type = "all operations" type = "all operations"
...@@ -1195,62 +1215,67 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1195,62 +1215,67 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
# If a valid color is selected, update color settings and graph # If a valid color is selected, update color settings and graph
if color.isValid(): if color.isValid():
if all: if all:
Latency_Color.changed = True LATENCY_COLOR_TYPE.changed = True
self._color_changed_perType = False self._color_changed_perType = False
self.changed_operation_colors.clear() self.changed_operation_colors.clear()
Latency_Color.current_color = color LATENCY_COLOR_TYPE.current_color = color
# Save color settings for each operation type # Save color settings for each operation type
else: else:
self._color_changed_perType = True self._color_changed_perType = True
self.changed_operation_colors[type] = color self.changed_operation_colors[type] = color
self.color_pref_update() self.color_pref_update()
self.update_statusbar("Preferences Updated") self.update_statusbar("Preferences updated")
def color_pref_update(self): def color_pref_update(self):
"""Update preferences of Latency color per type""" """Update preferences of Latency color per type"""
for type in self._schedule.get_used_type_names(): for type in self._schedule.get_used_type_names():
if Latency_Color.changed and not self._color_changed_perType: if LATENCY_COLOR_TYPE.changed and not self._color_changed_perType:
self._color_per_type[type] = Latency_Color.current_color self._color_per_type[type] = LATENCY_COLOR_TYPE.current_color
elif not Latency_Color.changed and not self._color_changed_perType: elif not LATENCY_COLOR_TYPE.changed and not self._color_changed_perType:
self._color_per_type[type] = Latency_Color.DEFAULT self._color_per_type[type] = LATENCY_COLOR_TYPE.DEFAULT
elif not Latency_Color.changed and self._color_changed_perType: elif not LATENCY_COLOR_TYPE.changed and self._color_changed_perType:
if type in self.changed_operation_colors.keys(): if type in self.changed_operation_colors.keys():
self._color_per_type[type] = self.changed_operation_colors[type] self._color_per_type[type] = self.changed_operation_colors[type]
else: else:
self._color_per_type[type] = Latency_Color.DEFAULT self._color_per_type[type] = LATENCY_COLOR_TYPE.DEFAULT
else: else:
if type in self.changed_operation_colors.keys(): if type in self.changed_operation_colors.keys():
self._color_per_type[type] = self.changed_operation_colors[type] self._color_per_type[type] = self.changed_operation_colors[type]
else: else:
self._color_per_type[type] = Latency_Color.current_color self._color_per_type[type] = LATENCY_COLOR_TYPE.current_color
self.Save_colortype() self.save_colortype()
def Save_colortype(self): def save_colortype(self):
"""Save preferences of Latency color per type in settings""" """Save preferences of Latency color per type in settings"""
settings = QSettings() settings = QSettings()
for key, color in self._color_per_type.items(): for key, color in self._color_per_type.items():
self._graph._color_change(color, key) self._graph._color_change(color, key)
self.converted_colorPerType[key] = color.name() self.converted_colorPerType[key] = color.name()
settings.setValue( settings.setValue(
f"scheduler/preferences/{Latency_Color.name}", f"scheduler/preferences/{LATENCY_COLOR_TYPE.name}",
Latency_Color.current_color, LATENCY_COLOR_TYPE.current_color,
) )
settings.setValue( settings.setValue(
f"scheduler/preferences/{Latency_Color.name}_changed", Latency_Color.changed f"scheduler/preferences/{LATENCY_COLOR_TYPE.name}_changed",
LATENCY_COLOR_TYPE.changed,
) )
settings.setValue( settings.setValue(
f"scheduler/preferences/{Latency_Color.name}/perType", f"scheduler/preferences/{LATENCY_COLOR_TYPE.name}/perType",
self.converted_colorPerType, self.converted_colorPerType,
) )
settings.setValue( settings.setValue(
f"scheduler/preferences/{Latency_Color.name}/perType_changed", f"scheduler/preferences/{LATENCY_COLOR_TYPE.name}/perType_changed",
self._color_changed_perType, self._color_changed_perType,
) )
def Color_button_clicked(self, color_type: ColorDataType): def color_button_clicked(self, color_type: ColorDataType) -> None:
"""Open a color dialog to select a color based on the specified color type """
color_type: ColorDataType Open a color dialog to select a color based on the specified color type
The color_type to be changed.
Parameters
----------
color_type : ColorDataType
The ColorDataType to be changed.
""" """
settings = QSettings() settings = QSettings()
if color_type.changed: if color_type.changed:
...@@ -1273,70 +1298,76 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1273,70 +1298,76 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
self.update_statusbar("Preferences Updated") self.update_statusbar("Preferences Updated")
def font_clicked( def font_clicked(
self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton self, line: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton
): ):
"""Open a font dialog to select a font and update the current font """
Sizeline: QLineEdit Open a font dialog to select a font and update the current font.
Parameters
----------
line : QLineEdit
The line displaying the text size to be matched with the chosen font. The line displaying the text size to be matched with the chosen font.
italicbutton: ColorButton italicbutton : ColorButton
The button displaying the italic state to be matched with the chosen font. The button displaying the italic state to be matched with the chosen font.
boldbutton: ColorButton boldbutton : ColorButton
The button displaying the bold state to be matched with the chosen font. The button displaying the bold state to be matched with the chosen font.
""" """
if Font.changed: if FONT.changed:
current_font = Font.current_font current_font = FONT.current_font
else: else:
current_font = Font.DEFAULT current_font = FONT.DEFAULT
(ok, font) = QFontDialog.getFont(current_font, self) (ok, font) = QFontDialog.getFont(current_font, self)
if ok: if ok:
Font.current_font = font FONT.current_font = font
Font.size = int(font.pointSizeF()) FONT.size = int(font.pointSizeF())
Font.bold = font.bold() FONT.bold = font.bold()
Font.italic = font.italic() FONT.italic = font.italic()
self.Update_font() self.update_font()
self.Match_Dialog_Font(Sizeline, italicbutton, boldbutton) self.match_dialog_font(line, italicbutton, boldbutton)
self.update_statusbar("Preferences Updated") self.update_statusbar("Preferences Updated")
def Update_font(self): def update_font(self):
"""Update font preferences based on current Font settings""" """Update font preferences based on current Font settings"""
settings = QSettings() settings = QSettings()
Font.changed = ( FONT.changed = (
False False
if ( if (
Font.current_font == Font.DEFAULT FONT.current_font == FONT.DEFAULT
and Font.size == int(Font.DEFAULT.pointSizeF()) and FONT.size == int(FONT.DEFAULT.pointSizeF())
and Font.italic == Font.DEFAULT.italic() and FONT.italic == FONT.DEFAULT.italic()
and Font.bold == Font.DEFAULT.bold() and FONT.bold == FONT.DEFAULT.bold()
) )
else True else True
) )
settings.setValue("scheduler/preferences/font", Font.current_font.toString()) settings.setValue("scheduler/preferences/font", FONT.current_font.toString())
settings.setValue("scheduler/preferences/fontSize", Font.size) settings.setValue("scheduler/preferences/fontSize", FONT.size)
settings.setValue("scheduler/preferences/fontBold", Font.bold) settings.setValue("scheduler/preferences/fontBold", FONT.bold)
settings.setValue("scheduler/preferences/fontItalic", Font.italic) settings.setValue("scheduler/preferences/fontItalic", FONT.italic)
settings.sync() settings.sync()
self.load_preferences() self.load_preferences()
def load_preferences(self): def load_preferences(self):
"Load the last saved preferences from settings" "Load the last saved preferences from settings"
settings = QSettings() settings = QSettings()
Latency_Color.current_color = QColor( LATENCY_COLOR_TYPE.current_color = QColor(
settings.value( settings.value(
f"scheduler/preferences/{Latency_Color.name}", f"scheduler/preferences/{LATENCY_COLOR_TYPE.name}",
defaultValue=Latency_Color.DEFAULT, defaultValue=LATENCY_COLOR_TYPE.DEFAULT,
type=str, type=str,
) )
) )
Latency_Color.changed = settings.value( LATENCY_COLOR_TYPE.changed = settings.value(
f"scheduler/preferences/{Latency_Color.name}_changed", False, bool f"scheduler/preferences/{LATENCY_COLOR_TYPE.name}_changed", False, bool
) )
self.converted_colorPerType = settings.value( self.converted_colorPerType = settings.value(
f"scheduler/preferences/{Latency_Color.name}/perType", f"scheduler/preferences/{LATENCY_COLOR_TYPE.name}/perType",
self.converted_colorPerType, self.converted_colorPerType,
) )
self._color_changed_perType = settings.value( self._color_changed_perType = settings.value(
f"scheduler/preferences/{Latency_Color.name}/perType_changed", False, bool f"scheduler/preferences/{LATENCY_COLOR_TYPE.name}/perType_changed",
False,
bool,
) )
settings.sync() settings.sync()
...@@ -1344,175 +1375,191 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1344,175 +1375,191 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
color = QColor(color_str) color = QColor(color_str)
self._color_per_type[key] = color self._color_per_type[key] = color
Match = ( Match = (
(color == Latency_Color.current_color) (color == LATENCY_COLOR_TYPE.current_color)
if Latency_Color.changed if LATENCY_COLOR_TYPE.changed
else (color == Latency_Color.DEFAULT) else (color == LATENCY_COLOR_TYPE.DEFAULT)
) )
if self._color_changed_perType and not Match: if self._color_changed_perType and not Match:
self.changed_operation_colors[key] = color self.changed_operation_colors[key] = color
self.color_pref_update() self.color_pref_update()
if Font.changed: if FONT.changed:
Font.current_font.setPointSizeF(Font.size) FONT.current_font.setPointSizeF(FONT.size)
Font.current_font.setItalic(Font.italic) FONT.current_font.setItalic(FONT.italic)
Font.current_font.setBold(Font.bold) FONT.current_font.setBold(FONT.bold)
self._graph._font_change(Font.current_font) self._graph._font_change(FONT.current_font)
self._graph._font_color_change(Font.color) self._graph._font_color_change(FONT.color)
else: else:
self._graph._font_change(Font.DEFAULT) self._graph._font_change(FONT.DEFAULT)
self._graph._font_color_change(Font.DEFAULT_COLOR) self._graph._font_color_change(FONT.DEFAULT_COLOR)
self.update_statusbar("Saved Preferences Loaded") self.update_statusbar("Saved Preferences Loaded")
def font_color_clicked(self): def font_color_clicked(self):
"""Select a font color and update preferences""" """Select a font color and update preferences"""
settings = QSettings() settings = QSettings()
color = QColorDialog.getColor(Font.color, self, "Select Font Color") color = QColorDialog.getColor(FONT.color, self, "Select Font Color")
if color.isValid(): if color.isValid():
Font.color = color FONT.color = color
Font.changed = True FONT.changed = True
settings.setValue("scheduler/preferences/fontColor", Font.color.name()) settings.setValue("scheduler/preferences/fontColor", FONT.color.name())
settings.sync() settings.sync()
self._graph._font_color_change(Font.color) self._graph._font_color_change(FONT.color)
def set_fontSize_clicked(self, size): def set_font_size_clicked(self, size):
"""Set the font size to the specified size and update the font """Set the font size to the specified size and update the font
size size
The font size to be set. The font size to be set.
""" """
Font.size = int(size) if (not size == "") else 6 FONT.size = int(size) if (not size == "") else 6
Font.current_font.setPointSizeF(Font.size) FONT.current_font.setPointSizeF(FONT.size)
self.Update_font() self.update_font()
def Italic_font_clicked(self, button: ColorButton): def italic_font_clicked(self, button: ColorButton):
"""Toggle the font style to italic if not already italic, otherwise remove italic """Toggle the font style to italic if not already italic, otherwise remove italic
button: ColorButton button: ColorButton
The clicked button. Used to indicate state on/off. The clicked button. Used to indicate state on/off.
""" """
Font.italic = not Font.italic FONT.italic = not FONT.italic
Font.current_font.setItalic(Font.italic) FONT.current_font.setItalic(FONT.italic)
( (
button.set_color(QColor('silver')) button.set_color(QColor('silver'))
if Font.italic if FONT.italic
else button.set_color(QColor('snow')) else button.set_color(QColor('snow'))
) )
self.Update_font() self.update_font()
def Bold_font_clicked(self, button: ColorButton): def bold_font_clicked(self, button: ColorButton):
"""Toggle the font style to bold if not already bold, otherwise unbold """
button: ColorButton Toggle the font style to bold if not already bold, otherwise unbold.
Parameters
----------
button : ColorButton
The clicked button. Used to indicate state on/off. The clicked button. Used to indicate state on/off.
""" """
Font.bold = not Font.bold FONT.bold = not FONT.bold
Font.current_font.setBold(Font.bold) FONT.current_font.setBold(FONT.bold)
Font.current_font.setWeight(50) FONT.current_font.setWeight(50)
( (
button.set_color(QColor('silver')) button.set_color(QColor('silver'))
if Font.bold if FONT.bold
else button.set_color(QColor('snow')) else button.set_color(QColor('snow'))
) )
self.Update_font() self.update_font()
def Incr_font_clicked(self, line: QLineEdit): def increase_font_size_clicked(self, line: QLineEdit) -> None:
""" """
Increase the font size by 1. Increase the font size by 1.
line: QLineEdit
Parameters
----------
line : QLineEdit
The line displaying the text size to be matched. The line displaying the text size to be matched.
""" """
( if FONT.size <= 71:
line.setText(str(Font.size + 1)) line.setText(str(FONT.size + 1))
if Font.size <= 71 else:
else line.setText(str(Font.size)) line.setText(str(FONT.size))
)
def Decr_font_clicked(self, line: QLineEdit): def decrease_font_size_clicked(self, line: QLineEdit) -> None:
""" """
Decrease the font size by 1. Decrease the font size by 1.
line: QLineEdit
Parameters
----------
line : QLineEdit
The line displaying the text size to be matched. The line displaying the text size to be matched.
""" """
( if FONT.size >= 7:
line.setText(str(Font.size - 1)) line.setText(str(FONT.size - 1))
if Font.size >= 7 else:
else line.setText(str(Font.size)) line.setText(str(FONT.size))
)
def reset_color_clicked(self): def reset_color_clicked(self):
"""Reset the color settings""" """Reset the color settings"""
settings = QSettings() settings = QSettings()
Latency_Color.changed = False LATENCY_COLOR_TYPE.changed = False
Active_Color.changed = False ACTIVE_COLOR_TYPE.changed = False
Signal_Warning_Color.changed = False SIGNAL_WARNING_COLOR_TYPE.changed = False
Signal_Color.changed = False SIGNAL_COLOR_TYPE.changed = False
Execution_Time_Color.changed = False EXECUTION_TIME_COLOR_TYPE.changed = False
self._color_changed_perType = False self._color_changed_perType = False
self.color_pref_update() self.color_pref_update()
settings.beginGroup("scheduler/preferences") settings.beginGroup("scheduler/preferences")
settings.setValue(Latency_Color.name, Latency_Color.DEFAULT.name()) settings.setValue(LATENCY_COLOR_TYPE.name, LATENCY_COLOR_TYPE.DEFAULT.name())
settings.setValue(Signal_Color.name, Signal_Color.DEFAULT.name()) settings.setValue(SIGNAL_COLOR_TYPE.name, SIGNAL_COLOR_TYPE.DEFAULT.name())
settings.setValue(Active_Color.name, Active_Color.DEFAULT.name()) settings.setValue(ACTIVE_COLOR_TYPE.name, ACTIVE_COLOR_TYPE.DEFAULT.name())
settings.setValue( settings.setValue(
Signal_Warning_Color.name, Signal_Warning_Color.DEFAULT.name() SIGNAL_WARNING_COLOR_TYPE.name, SIGNAL_WARNING_COLOR_TYPE.DEFAULT.name()
) )
settings.setValue( settings.setValue(
Execution_Time_Color.name, Execution_Time_Color.DEFAULT.name() EXECUTION_TIME_COLOR_TYPE.name, EXECUTION_TIME_COLOR_TYPE.DEFAULT.name()
) )
settings.endGroup() settings.endGroup()
self._graph._color_change(Latency_Color.DEFAULT, "all operations") self._graph._color_change(LATENCY_COLOR_TYPE.DEFAULT, "all operations")
self._graph._signals.reopen.emit() self._graph._signals.reopen.emit()
self.load_preferences() self.load_preferences()
def reset_font_clicked( def reset_font_clicked(
self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton self, line: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton
): ):
"""Reset the font settings. """
Sizeline: QLineEdit Reset the font settings.
Parameters
----------
line : QLineEdit
The line displaying the text size to be matched with the chosen font. The line displaying the text size to be matched with the chosen font.
italicbutton: ColorButton italicbutton : ColorButton
The button displaying the italic state to be matched with the chosen font. The button displaying the italic state to be matched with the chosen font.
boldbutton: ColorButton boldbutton : ColorButton
The button displaying the bold state to be matched with the chosen font. The button displaying the bold state to be matched with the chosen font.
""" """
Font.current_font = QFont("Times", 12) FONT.current_font = QFont("Times", 12)
Font.changed = False FONT.changed = False
Font.color = Font.DEFAULT_COLOR FONT.color = FONT.DEFAULT_COLOR
Font.size = int(Font.DEFAULT.pointSizeF()) FONT.size = int(FONT.DEFAULT.pointSizeF())
Font.bold = Font.DEFAULT.bold() FONT.bold = FONT.DEFAULT.bold()
Font.italic = Font.DEFAULT.italic() FONT.italic = FONT.DEFAULT.italic()
self.Update_font() self.update_font()
self.load_preferences() self.load_preferences()
self.Match_Dialog_Font(Sizeline, italicbutton, boldbutton) self.match_dialog_font(line, italicbutton, boldbutton)
def reset_all_clicked( def reset_all_clicked(
self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton self, line: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton
): ):
"""Reset both the color and the font settings""" """Reset both the color and the font settings."""
self.reset_color_clicked() self.reset_color_clicked()
self.reset_font_clicked(Sizeline, italicbutton, boldbutton) self.reset_font_clicked(line, italicbutton, boldbutton)
def Match_Dialog_Font( def match_dialog_font(
self, Sizeline: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton self, line: QLineEdit, italicbutton: ColorButton, boldbutton: ColorButton
): ) -> None:
"""Update the widgets on the pref dialog to match the current font """
Sizeline: QLineEdit Update the widgets on the pref dialog to match the current font.
Parameters
----------
line : QLineEdit
The line displaying the text size to be matched with the current font. The line displaying the text size to be matched with the current font.
italicbutton: ColorButton italicbutton : ColorButton
The button displaying the italic state to be matched with the current font. The button displaying the italic state to be matched with the current font.
boldbutton: ColorButton boldbutton : ColorButton
The button displaying the bold state to be matched with the current font. The button displaying the bold state to be matched with the current font.
""" """
Sizeline.setText(str(Font.size)) line.setText(str(FONT.size))
( (
italicbutton.set_color(QColor('silver')) italicbutton.set_color(QColor('silver'))
if Font.italic if FONT.italic
else italicbutton.set_color(QColor('snow')) else italicbutton.set_color(QColor('snow'))
) )
( (
boldbutton.set_color(QColor('silver')) boldbutton.set_color(QColor('silver'))
if Font.bold if FONT.bold
else boldbutton.set_color(QColor('snow')) else boldbutton.set_color(QColor('snow'))
) )
......
...@@ -26,12 +26,12 @@ from b_asic.graph_component import GraphID ...@@ -26,12 +26,12 @@ from b_asic.graph_component import GraphID
from b_asic.gui_utils.icons import get_icon from b_asic.gui_utils.icons import get_icon
from b_asic.operation import Operation from b_asic.operation import Operation
from b_asic.scheduler_gui._preferences import ( from b_asic.scheduler_gui._preferences import (
ACTIVE_COLOR_TYPE,
EXECUTION_TIME_COLOR_TYPE,
LATENCY_COLOR_TYPE,
OPERATION_HEIGHT, OPERATION_HEIGHT,
Active_Color, SIGNAL_COLOR_TYPE,
Execution_Time_Color, SIGNAL_WARNING_COLOR_TYPE,
Latency_Color,
Signal_Color,
Signal_Warning_Color,
) )
if TYPE_CHECKING: if TYPE_CHECKING:
...@@ -63,7 +63,7 @@ class OperationItem(QGraphicsItemGroup): ...@@ -63,7 +63,7 @@ class OperationItem(QGraphicsItemGroup):
_label_item: QGraphicsSimpleTextItem _label_item: QGraphicsSimpleTextItem
_port_items: list[QGraphicsEllipseItem] _port_items: list[QGraphicsEllipseItem]
_port_number_items: list[QGraphicsSimpleTextItem] _port_number_items: list[QGraphicsSimpleTextItem]
_inactive_color: QColor = Latency_Color.DEFAULT _inactive_color: QColor = LATENCY_COLOR_TYPE.DEFAULT
def __init__( def __init__(
self, self,
...@@ -97,30 +97,32 @@ class OperationItem(QGraphicsItemGroup): ...@@ -97,30 +97,32 @@ class OperationItem(QGraphicsItemGroup):
QCursor(Qt.CursorShape.OpenHandCursor) QCursor(Qt.CursorShape.OpenHandCursor)
) # default cursor when hovering over object ) # default cursor when hovering over object
if Signal_Color.changed: if SIGNAL_COLOR_TYPE.changed:
self._port_filling_brush = QBrush(Signal_Color.current_color) self._port_filling_brush = QBrush(SIGNAL_COLOR_TYPE.current_color)
self._port_outline_pen = QPen(Signal_Color.current_color) self._port_outline_pen = QPen(SIGNAL_COLOR_TYPE.current_color)
else: else:
self._port_filling_brush = QBrush(Signal_Color.DEFAULT) self._port_filling_brush = QBrush(SIGNAL_COLOR_TYPE.DEFAULT)
self._port_outline_pen = QPen(Signal_Color.DEFAULT) self._port_outline_pen = QPen(SIGNAL_COLOR_TYPE.DEFAULT)
self._port_outline_pen.setWidthF(0) self._port_outline_pen.setWidthF(0)
if Active_Color.changed: if ACTIVE_COLOR_TYPE.changed:
self._port_filling_brush_active = QBrush(Active_Color.current_color) self._port_filling_brush_active = QBrush(ACTIVE_COLOR_TYPE.current_color)
self._port_outline_pen_active = QPen(Active_Color.current_color) self._port_outline_pen_active = QPen(ACTIVE_COLOR_TYPE.current_color)
else: else:
self._port_filling_brush_active = QBrush(Active_Color.DEFAULT) self._port_filling_brush_active = QBrush(ACTIVE_COLOR_TYPE.DEFAULT)
self._port_outline_pen_active = QPen(Active_Color.DEFAULT) self._port_outline_pen_active = QPen(ACTIVE_COLOR_TYPE.DEFAULT)
self._port_outline_pen_active.setWidthF(0) self._port_outline_pen_active.setWidthF(0)
if Signal_Warning_Color.changed: if SIGNAL_WARNING_COLOR_TYPE.changed:
self._port_filling_brush_warning = QBrush( self._port_filling_brush_warning = QBrush(
Signal_Warning_Color.current_color SIGNAL_WARNING_COLOR_TYPE.current_color
)
self._port_outline_pen_warning = QPen(
SIGNAL_WARNING_COLOR_TYPE.current_color
) )
self._port_outline_pen_warning = QPen(Signal_Warning_Color.current_color)
else: else:
self._port_filling_brush_warning = QBrush(Signal_Warning_Color.DEFAULT) self._port_filling_brush_warning = QBrush(SIGNAL_WARNING_COLOR_TYPE.DEFAULT)
self._port_outline_pen_warning = QPen(Signal_Warning_Color.DEFAULT) self._port_outline_pen_warning = QPen(SIGNAL_WARNING_COLOR_TYPE.DEFAULT)
self._port_outline_pen_warning.setWidthF(0) self._port_outline_pen_warning.setWidthF(0)
self._make_component() self._make_component()
...@@ -198,18 +200,18 @@ class OperationItem(QGraphicsItemGroup): ...@@ -198,18 +200,18 @@ class OperationItem(QGraphicsItemGroup):
def set_active(self) -> None: def set_active(self) -> None:
"""Set the item as active, i.e., draw it in special colors.""" """Set the item as active, i.e., draw it in special colors."""
if Active_Color.changed: if ACTIVE_COLOR_TYPE.changed:
self._set_background(Active_Color.current_color) self._set_background(ACTIVE_COLOR_TYPE.current_color)
else: else:
self._set_background(Active_Color.DEFAULT) self._set_background(ACTIVE_COLOR_TYPE.DEFAULT)
self.setCursor(QCursor(Qt.CursorShape.ClosedHandCursor)) self.setCursor(QCursor(Qt.CursorShape.ClosedHandCursor))
def set_inactive(self) -> None: def set_inactive(self) -> None:
"""Set the item as inactive, i.e., draw it in standard colors.""" """Set the item as inactive, i.e., draw it in standard colors."""
if Latency_Color.changed: if LATENCY_COLOR_TYPE.changed:
self._set_background(self._inactive_color) self._set_background(self._inactive_color)
else: else:
self._set_background(Latency_Color.DEFAULT) self._set_background(LATENCY_COLOR_TYPE.DEFAULT)
self.setCursor(QCursor(Qt.CursorShape.OpenHandCursor)) self.setCursor(QCursor(Qt.CursorShape.OpenHandCursor))
def Set_font(self, font: QFont) -> None: def Set_font(self, font: QFont) -> None:
...@@ -231,12 +233,12 @@ class OperationItem(QGraphicsItemGroup): ...@@ -231,12 +233,12 @@ class OperationItem(QGraphicsItemGroup):
def set_port_active(self, key: str): def set_port_active(self, key: str):
item = self._ports[key]["item"] item = self._ports[key]["item"]
if Active_Color.changed: if ACTIVE_COLOR_TYPE.changed:
self._port_filling_brush_active = QBrush(Active_Color.current_color) self._port_filling_brush_active = QBrush(ACTIVE_COLOR_TYPE.current_color)
self._port_outline_pen_active = QPen(Active_Color.current_color) self._port_outline_pen_active = QPen(ACTIVE_COLOR_TYPE.current_color)
else: else:
self._port_filling_brush_active = QBrush(Active_Color.DEFAULT) self._port_filling_brush_active = QBrush(ACTIVE_COLOR_TYPE.DEFAULT)
self._port_outline_pen_active = QPen(Active_Color.DEFAULT) self._port_outline_pen_active = QPen(ACTIVE_COLOR_TYPE.DEFAULT)
self._port_outline_pen_active.setWidthF(0) self._port_outline_pen_active.setWidthF(0)
item.setBrush(self._port_filling_brush_active) item.setBrush(self._port_filling_brush_active)
...@@ -267,10 +269,10 @@ class OperationItem(QGraphicsItemGroup): ...@@ -267,10 +269,10 @@ class OperationItem(QGraphicsItemGroup):
port_size = 7 / self._scale # the diameter of a port port_size = 7 / self._scale # the diameter of a port
if Execution_Time_Color.changed: if EXECUTION_TIME_COLOR_TYPE.changed:
execution_time_color = QColor(Execution_Time_Color.current_color) execution_time_color = QColor(EXECUTION_TIME_COLOR_TYPE.current_color)
else: else:
execution_time_color = QColor(Execution_Time_Color.DEFAULT) execution_time_color = QColor(EXECUTION_TIME_COLOR_TYPE.DEFAULT)
execution_time_color.setAlpha(200) # 0-255 execution_time_color.setAlpha(200) # 0-255
execution_time_pen = QPen() # used by execution time outline execution_time_pen = QPen() # used by execution time outline
execution_time_pen.setColor(execution_time_color) execution_time_pen.setColor(execution_time_color)
...@@ -298,7 +300,7 @@ class OperationItem(QGraphicsItemGroup): ...@@ -298,7 +300,7 @@ class OperationItem(QGraphicsItemGroup):
self._execution_time_item.setPen(execution_time_pen) self._execution_time_item.setPen(execution_time_pen)
# component item # component item
self._set_background(Latency_Color.DEFAULT) # used by component filling self._set_background(LATENCY_COLOR_TYPE.DEFAULT) # used by component filling
def create_ports(io_coordinates, prefix): def create_ports(io_coordinates, prefix):
for i, (x, y) in enumerate(io_coordinates): for i, (x, y) in enumerate(io_coordinates):
......
...@@ -13,13 +13,13 @@ from qtpy.QtWidgets import QGraphicsPathItem ...@@ -13,13 +13,13 @@ from qtpy.QtWidgets import QGraphicsPathItem
# B-ASIC # B-ASIC
from b_asic.scheduler_gui._preferences import ( from b_asic.scheduler_gui._preferences import (
ACTIVE_COLOR_TYPE,
SCHEDULE_INDENT, SCHEDULE_INDENT,
SIGNAL_COLOR_TYPE,
SIGNAL_WARNING_COLOR_TYPE,
SIGNAL_WIDTH, SIGNAL_WIDTH,
SIGNAL_WIDTH_ACTIVE, SIGNAL_WIDTH_ACTIVE,
SIGNAL_WIDTH_WARNING, SIGNAL_WIDTH_WARNING,
Active_Color,
Signal_Color,
Signal_Warning_Color,
) )
from b_asic.scheduler_gui.operation_item import OperationItem from b_asic.scheduler_gui.operation_item import OperationItem
from b_asic.signal import Signal from b_asic.signal import Signal
...@@ -100,24 +100,24 @@ class SignalItem(QGraphicsPathItem): ...@@ -100,24 +100,24 @@ class SignalItem(QGraphicsPathItem):
def _refresh_pens(self) -> None: def _refresh_pens(self) -> None:
"""Create pens.""" """Create pens."""
if Active_Color.changed: if ACTIVE_COLOR_TYPE.changed:
pen = QPen(Active_Color.current_color) pen = QPen(ACTIVE_COLOR_TYPE.current_color)
else: else:
pen = QPen(Active_Color.DEFAULT) pen = QPen(ACTIVE_COLOR_TYPE.DEFAULT)
pen.setWidthF(SIGNAL_WIDTH_ACTIVE) pen.setWidthF(SIGNAL_WIDTH_ACTIVE)
self._active_pen = pen self._active_pen = pen
if Signal_Color.changed: if SIGNAL_COLOR_TYPE.changed:
pen = QPen(Signal_Color.current_color) pen = QPen(SIGNAL_COLOR_TYPE.current_color)
else: else:
pen = QPen(Signal_Color.DEFAULT) pen = QPen(SIGNAL_COLOR_TYPE.DEFAULT)
pen.setWidthF(SIGNAL_WIDTH) pen.setWidthF(SIGNAL_WIDTH)
self._inactive_pen = pen self._inactive_pen = pen
if Signal_Warning_Color.changed: if SIGNAL_WARNING_COLOR_TYPE.changed:
pen = QPen(Signal_Warning_Color.current_color) pen = QPen(SIGNAL_WARNING_COLOR_TYPE.current_color)
else: else:
pen = QPen(Signal_Warning_Color.DEFAULT) pen = QPen(SIGNAL_WARNING_COLOR_TYPE.DEFAULT)
pen.setWidthF(SIGNAL_WIDTH_WARNING) pen.setWidthF(SIGNAL_WIDTH_WARNING)
self._warning_pen = pen self._warning_pen = pen
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment