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

Updated casing etc of GUI

parent 8a4e239e
No related branches found
No related tags found
1 merge request!75Updated casing etc of GUI
Pipeline #31123 passed
...@@ -35,7 +35,7 @@ class Arrow(QGraphicsLineItem): ...@@ -35,7 +35,7 @@ class Arrow(QGraphicsLineItem):
for port1, port2 in self._window.signalPortDict[self]: for port1, port2 in self._window.signalPortDict[self]:
for operation, operation_ports in self._window.portDict.items(): for operation, operation_ports in self._window.portDict.items():
if (port1 in operation_ports or port2 in operation_ports) and operation in self._window.opToSFG: if (port1 in operation_ports or port2 in operation_ports) and operation in self._window.opToSFG:
self._window.logger.info(f"Operation detected in existing sfg, removing sfg with name: {self._window.opToSFG[operation].name}.") self._window.logger.info(f"Operation detected in existing SFG, removing SFG with name: {self._window.opToSFG[operation].name}.")
del self._window.sfg_dict[self._window.opToSFG[operation].name] del self._window.sfg_dict[self._window.opToSFG[operation].name]
self._window.opToSFG = {op: self._window.opToSFG[op] for op in self._window.opToSFG if self._window.opToSFG[op] is not self._window.opToSFG[operation]} self._window.opToSFG = {op: self._window.opToSFG[op] for op in self._window.opToSFG if self._window.opToSFG[op] is not self._window.opToSFG[operation]}
......
...@@ -140,7 +140,7 @@ class DragButton(QPushButton): ...@@ -140,7 +140,7 @@ class DragButton(QPushButton):
if self in self._window.opToSFG: if self in self._window.opToSFG:
self._window.logger.info( self._window.logger.info(
f"Operation detected in existing sfg, removing sfg with name: {self._window.opToSFG[self].name}.") f"Operation detected in existing SFG, removing SFG with name: {self._window.opToSFG[self].name}.")
del self._window.sfg_dict[self._window.opToSFG[self].name] del self._window.sfg_dict[self._window.opToSFG[self].name]
self._window.opToSFG = { self._window.opToSFG = {
op: self._window.opToSFG[op] for op in self._window.opToSFG if self._window.opToSFG[op] is not self._window.opToSFG[self]} op: self._window.opToSFG[op] for op in self._window.opToSFG if self._window.opToSFG[op] is not self._window.opToSFG[self]}
......
...@@ -302,7 +302,7 @@ class Ui_main_window(object): ...@@ -302,7 +302,7 @@ class Ui_main_window(object):
self.edit_menu.setTitle(_translate("main_window", "Edit")) self.edit_menu.setTitle(_translate("main_window", "Edit"))
self.view_menu.setTitle(_translate("main_window", "View")) self.view_menu.setTitle(_translate("main_window", "View"))
self.run_menu.setTitle(_translate("main_window", "Run")) self.run_menu.setTitle(_translate("main_window", "Run"))
self.actionShowPC.setText(_translate("main_window", "Show PC")) self.actionShowPC.setText(_translate("main_window", "Show PG"))
self.help_menu.setTitle(_translate("main_window", "Help")) self.help_menu.setTitle(_translate("main_window", "Help"))
self.actionSimulateSFG.setText(_translate("main_window", "Simulate SFG")) self.actionSimulateSFG.setText(_translate("main_window", "Simulate SFG"))
self.aboutBASIC.setText(_translate("main_window", "About B-ASIC")) self.aboutBASIC.setText(_translate("main_window", "About B-ASIC"))
...@@ -310,7 +310,7 @@ class Ui_main_window(object): ...@@ -310,7 +310,7 @@ class Ui_main_window(object):
self.keybindsBASIC.setText(_translate("main_window", "Keybinds")) self.keybindsBASIC.setText(_translate("main_window", "Keybinds"))
self.load_menu.setText(_translate("main_window", "Load SFG")) self.load_menu.setText(_translate("main_window", "Load SFG"))
self.save_menu.setText(_translate("main_window", "Save SFG")) self.save_menu.setText(_translate("main_window", "Save SFG"))
self.load_operations.setText(_translate("main_window", "Load Operations")) self.load_operations.setText(_translate("main_window", "Load operations"))
self.exit_menu.setText(_translate("main_window", "Exit")) self.exit_menu.setText(_translate("main_window", "Exit"))
self.exit_menu.setShortcut(_translate("main_window", "Ctrl+Q")) self.exit_menu.setShortcut(_translate("main_window", "Ctrl+Q"))
self.actionToolbar.setText(_translate("main_window", "Toolbar")) self.actionToolbar.setText(_translate("main_window", "Toolbar"))
......
...@@ -133,7 +133,7 @@ class MainWindow(QMainWindow): ...@@ -133,7 +133,7 @@ class MainWindow(QMainWindow):
def create_toolbar_view(self): def create_toolbar_view(self):
self.toolbar = self.addToolBar("Toolbar") self.toolbar = self.addToolBar("Toolbar")
self.toolbar.addAction("Create SFG", self.create_SFG_from_toolbar) self.toolbar.addAction("Create SFG", self.create_SFG_from_toolbar)
self.toolbar.addAction("Clear Workspace", self.clear_workspace) self.toolbar.addAction("Clear workspace", self.clear_workspace)
def resizeEvent(self, event): def resizeEvent(self, event):
self.ui.operation_box.setGeometry( self.ui.operation_box.setGeometry(
...@@ -167,7 +167,7 @@ class MainWindow(QMainWindow): ...@@ -167,7 +167,7 @@ class MainWindow(QMainWindow):
if not accepted: if not accepted:
return return
self.logger.info(f"Saving sfg to path: {module}.") self.logger.info(f"Saving SFG to path: {module}.")
operation_positions = dict() operation_positions = dict()
for operation_drag, operation_scene in self.dragOperationSceneDict.items(): for operation_drag, operation_scene in self.dragOperationSceneDict.items():
operation_positions[operation_drag.operation.graph_id] = ( operation_positions[operation_drag.operation.graph_id] = (
...@@ -179,10 +179,10 @@ class MainWindow(QMainWindow): ...@@ -179,10 +179,10 @@ class MainWindow(QMainWindow):
sfg, suffix=f"positions = {str(operation_positions)}")) sfg, suffix=f"positions = {str(operation_positions)}"))
except Exception as e: except Exception as e:
self.logger.error( self.logger.error(
f"Failed to save sfg to path: {module}, with error: {e}.") f"Failed to save SFG to path: {module}, with error: {e}.")
return return
self.logger.info(f"Saved sfg to path: {module}.") self.logger.info(f"Saved SFG to path: {module}.")
def save_work(self): def save_work(self):
self.sfg_widget = SelectSFGWindow(self) self.sfg_widget = SelectSFGWindow(self)
...@@ -196,7 +196,7 @@ class MainWindow(QMainWindow): ...@@ -196,7 +196,7 @@ class MainWindow(QMainWindow):
if not accepted: if not accepted:
return return
self.logger.info(f"Loading sfg from path: {module}.") self.logger.info(f"Loading SFG from path: {module}.")
try: try:
sfg, positions = python_to_sfg(module) sfg, positions = python_to_sfg(module)
except ImportError as e: except ImportError as e:
...@@ -206,7 +206,7 @@ class MainWindow(QMainWindow): ...@@ -206,7 +206,7 @@ class MainWindow(QMainWindow):
while sfg.name in self.sfg_dict: while sfg.name in self.sfg_dict:
self.logger.warning( self.logger.warning(
f"Duplicate sfg with name: {sfg.name} detected. Please choose a new name.") f"Duplicate SFG with name: {sfg.name} detected. Please choose a new name.")
name, accepted = QInputDialog.getText( name, accepted = QInputDialog.getText(
self, "Change SFG Name", "Name: ", QLineEdit.Normal) self, "Change SFG Name", "Name: ", QLineEdit.Normal)
if not accepted: if not accepted:
...@@ -240,7 +240,7 @@ class MainWindow(QMainWindow): ...@@ -240,7 +240,7 @@ class MainWindow(QMainWindow):
self.opToSFG[self.operationDragDict[op]] = sfg self.opToSFG[self.operationDragDict[op]] = sfg
self.sfg_dict[sfg.name] = sfg self.sfg_dict[sfg.name] = sfg
self.logger.info(f"Loaded sfg from path: {module}.") self.logger.info(f"Loaded SFG from path: {module}.")
self.update() self.update()
def exit_app(self): def exit_app(self):
...@@ -248,7 +248,7 @@ class MainWindow(QMainWindow): ...@@ -248,7 +248,7 @@ class MainWindow(QMainWindow):
QApplication.quit() QApplication.quit()
def clear_workspace(self): def clear_workspace(self):
self.logger.info("Clearing workspace from operations and sfgs.") self.logger.info("Clearing workspace from operations and SFGs.")
self.pressed_operations.clear() self.pressed_operations.clear()
self.pressed_ports.clear() self.pressed_ports.clear()
self.operationItemSceneList.clear() self.operationItemSceneList.clear()
...@@ -433,7 +433,7 @@ class MainWindow(QMainWindow): ...@@ -433,7 +433,7 @@ class MainWindow(QMainWindow):
__file__), "operation_icons", f"custom_operation.png") __file__), "operation_icons", f"custom_operation.png")
attr_button.setIcon(QIcon(icon_path)) attr_button.setIcon(QIcon(icon_path))
attr_button.setIconSize(QSize(55, 55)) attr_button.setIconSize(QSize(55, 55))
attr_button.setToolTip("No sfg") attr_button.setToolTip("No SFG")
attr_button.setStyleSheet(""" QToolTip { background-color: white; attr_button.setStyleSheet(""" QToolTip { background-color: white;
color: black }""") color: black }""")
attr_button.setParent(None) attr_button.setParent(None)
...@@ -489,7 +489,7 @@ class MainWindow(QMainWindow): ...@@ -489,7 +489,7 @@ class MainWindow(QMainWindow):
def _connect_button(self, *event): def _connect_button(self, *event):
if len(self.pressed_ports) < 2: if len(self.pressed_ports) < 2:
self.logger.warning( self.logger.warning(
"Can't connect less than two ports. Please select more.") "Cannot connect less than two ports. Please select at least two.")
return return
for i in range(len(self.pressed_ports) - 1): for i in range(len(self.pressed_ports) - 1):
...@@ -498,12 +498,12 @@ class MainWindow(QMainWindow): ...@@ -498,12 +498,12 @@ class MainWindow(QMainWindow):
destination = self.pressed_ports[i + destination = self.pressed_ports[i +
1] if source is not self.pressed_ports[i + 1] else self.pressed_ports[i] 1] if source is not self.pressed_ports[i + 1] else self.pressed_ports[i]
if source.port.operation is destination.port.operation: if source.port.operation is destination.port.operation:
self.logger.warning("Can't connect to the same port") self.logger.warning("Cannot connect to the same port")
continue continue
if type(source.port) == type(destination.port): if type(source.port) == type(destination.port):
self.logger.warning( self.logger.warning(
f"Can't connect port of type: {type(source.port).__name__} to port of type: {type(destination.port).__name__}.") f"Cannot connect port of type: {type(source.port).__name__} to port of type: {type(destination.port).__name__}.")
continue continue
self.connect_button(source, destination) self.connect_button(source, destination)
...@@ -547,7 +547,7 @@ class MainWindow(QMainWindow): ...@@ -547,7 +547,7 @@ class MainWindow(QMainWindow):
def _simulate_sfg(self): def _simulate_sfg(self):
for sfg, properties in self.dialog.properties.items(): for sfg, properties in self.dialog.properties.items():
self.logger.info(f"Simulating sfg with name: {sfg.name}.") self.logger.info(f"Simulating SFG with name: {sfg.name}.")
simulation = FastSimulation( simulation = FastSimulation(
sfg, input_providers=properties["input_values"]) sfg, input_providers=properties["input_values"])
l_result = simulation.run_for( l_result = simulation.run_for(
...@@ -560,7 +560,7 @@ class MainWindow(QMainWindow): ...@@ -560,7 +560,7 @@ class MainWindow(QMainWindow):
if properties["show_plot"]: if properties["show_plot"]:
self.logger.info( self.logger.info(
f"Opening plot for sfg with name: {sfg.name}.") f"Opening plot for SFG with name: {sfg.name}.")
self.logger.info( self.logger.info(
"To save the plot press 'Ctrl+S' when the plot is focused.") "To save the plot press 'Ctrl+S' when the plot is focused.")
self.plot = Plot(simulation, sfg, self) self.plot = Plot(simulation, sfg, self)
......
...@@ -51,7 +51,7 @@ class PropertiesWindow(QDialog): ...@@ -51,7 +51,7 @@ class PropertiesWindow(QDialog):
if self.operation.operation.input_count > 0: if self.operation.operation.input_count > 0:
self.latency_layout = QHBoxLayout() self.latency_layout = QHBoxLayout()
self.latency_label = QLabel("Set Latency For Input Ports (-1 for None):") self.latency_label = QLabel("Set latency for input ports (-1 for None):")
self.latency_layout.addWidget(self.latency_label) self.latency_layout.addWidget(self.latency_label)
self.vertical_layout.addLayout(self.latency_layout) self.vertical_layout.addLayout(self.latency_layout)
...@@ -86,7 +86,7 @@ class PropertiesWindow(QDialog): ...@@ -86,7 +86,7 @@ class PropertiesWindow(QDialog):
if self.operation.operation.output_count > 0: if self.operation.operation.output_count > 0:
self.latency_layout = QHBoxLayout() self.latency_layout = QHBoxLayout()
self.latency_label = QLabel("Set Latency For Output Ports (-1 for None):") self.latency_label = QLabel("Set latency for output ports (-1 for None):")
self.latency_layout.addWidget(self.latency_label) self.latency_layout.addWidget(self.latency_label)
self.vertical_layout.addLayout(self.latency_layout) self.vertical_layout.addLayout(self.latency_layout)
......
...@@ -13,10 +13,10 @@ class ShowPCWindow(QDialog): ...@@ -13,10 +13,10 @@ class ShowPCWindow(QDialog):
self._window = window self._window = window
self.check_box_dict = dict() self.check_box_dict = dict()
self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint) self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
self.setWindowTitle("Show PC") self.setWindowTitle("Show precedence graph")
self.dialog_layout = QVBoxLayout() self.dialog_layout = QVBoxLayout()
self.pc_btn = QPushButton("Show PC") self.pc_btn = QPushButton("Show PG")
self.pc_btn.clicked.connect(self.show_precedence_graph) self.pc_btn.clicked.connect(self.show_precedence_graph)
self.dialog_layout.addWidget(self.pc_btn) self.dialog_layout.addWidget(self.pc_btn)
self.setLayout(self.dialog_layout) self.setLayout(self.dialog_layout)
...@@ -42,7 +42,7 @@ class ShowPCWindow(QDialog): ...@@ -42,7 +42,7 @@ class ShowPCWindow(QDialog):
def show_precedence_graph(self): def show_precedence_graph(self):
for check_box, sfg in self.check_box_dict.items(): for check_box, sfg in self.check_box_dict.items():
if check_box.isChecked(): if check_box.isChecked():
self._window.logger.info(f"Creating a precedence chart from sfg with name: {sfg}.") self._window.logger.info(f"Creating a precedence graph from SFG with name: {sfg}.")
self._window.sfg_dict[sfg].show_precedence_graph() self._window.sfg_dict[sfg].show_precedence_graph()
self.accept() self.accept()
......
...@@ -35,13 +35,13 @@ class SimulateSFGWindow(QDialog): ...@@ -35,13 +35,13 @@ class SimulateSFGWindow(QDialog):
spin_box = QSpinBox() spin_box = QSpinBox()
spin_box.setRange(0, 2147483647) spin_box.setRange(0, 2147483647)
options_layout.addRow("Iteration Count: ", spin_box) options_layout.addRow("Iteration count: ", spin_box)
check_box_plot = QCheckBox() check_box_plot = QCheckBox()
options_layout.addRow("Plot Results: ", check_box_plot) options_layout.addRow("Plot results: ", check_box_plot)
check_box_all = QCheckBox() check_box_all = QCheckBox()
options_layout.addRow("Get All Results: ", check_box_all) options_layout.addRow("Get all results: ", check_box_all)
sfg_layout.addLayout(options_layout) sfg_layout.addLayout(options_layout)
...@@ -54,7 +54,7 @@ class SimulateSFGWindow(QDialog): ...@@ -54,7 +54,7 @@ class SimulateSFGWindow(QDialog):
if sfg.input_count > 0: if sfg.input_count > 0:
input_label = QHBoxLayout() input_label = QHBoxLayout()
input_label = QLabel("Input Values:") input_label = QLabel("Input values:")
options_layout.addRow(input_label) options_layout.addRow(input_label)
input_grid = QGridLayout() input_grid = QGridLayout()
...@@ -123,13 +123,13 @@ class SimulateSFGWindow(QDialog): ...@@ -123,13 +123,13 @@ class SimulateSFGWindow(QDialog):
"input_values": input_values "input_values": input_values
} }
# If we plot we should also print the entire data, since you can't really interact with the graph. # If we plot we should also print the entire data, since you cannot really interact with the graph.
if self.properties[sfg]["show_plot"]: if self.properties[sfg]["show_plot"]:
self.properties[sfg]["all_results"] = True self.properties[sfg]["all_results"] = True
continue continue
self._window.logger.info(f"Skipping simulation of sfg with name: {sfg.name}, due to previous errors.") self._window.logger.info(f"Skipping simulation of SFG with name: {sfg.name}, due to previous errors.")
self.accept() self.accept()
self.simulate.emit() self.simulate.emit()
......
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