Skip to content
Snippets Groups Projects
Commit e90e40fa authored by Jacob Wahlman's avatar Jacob Wahlman :ok_hand:
Browse files

Merge branch '90-show-pc-in-gui' into 'develop'

Resolve "Show PC in GUI"

See merge request PUM_TDDD96/B-ASIC!55
parents 9eef1a36 e6e1cf0f
No related branches found
No related tags found
3 merge requests!67WIP: B-ASIC version 1.0.0 hotfix,!65B-ASIC version 1.0.0,!55Resolve "Show PC in GUI"
Pipeline #15710 passed
......@@ -241,6 +241,8 @@ class Ui_main_window(object):
self.actionRedo.setObjectName("actionRedo")
self.actionSimulateSFG = QtWidgets.QAction(main_window)
self.actionSimulateSFG.setObjectName("actionSimulateSFG")
self.actionShowPC = QtWidgets.QAction(main_window)
self.actionShowPC.setObjectName("actionShowPC")
self.aboutBASIC = QtWidgets.QAction(main_window)
self.aboutBASIC.setObjectName("aboutBASIC")
self.faqBASIC = QtWidgets.QAction(main_window)
......@@ -256,6 +258,7 @@ class Ui_main_window(object):
self.edit_menu.addAction(self.actionUndo)
self.edit_menu.addAction(self.actionRedo)
self.view_menu.addAction(self.actionToolbar)
self.run_menu.addAction(self.actionShowPC)
self.run_menu.addAction(self.actionSimulateSFG)
self.help_menu.addAction(self.aboutBASIC)
self.help_menu.addAction(self.faqBASIC)
......@@ -288,6 +291,7 @@ class Ui_main_window(object):
self.edit_menu.setTitle(_translate("main_window", "Edit"))
self.view_menu.setTitle(_translate("main_window", "View"))
self.run_menu.setTitle(_translate("main_window", "Run"))
self.actionShowPC.setText(_translate("main_window", "Show PC"))
self.help_menu.setTitle(_translate("main_window", "Help"))
self.actionSimulateSFG.setText(_translate("main_window", "Simulate SFG"))
self.aboutBASIC.setText(_translate("main_window", "About B-ASIC"))
......
......@@ -14,6 +14,7 @@ from drag_button import DragButton
from gui_interface import Ui_main_window
from arrow import Arrow
from port_button import PortButton
from show_pc_window import ShowPCWindow
from b_asic import Operation, SFG, InputPort, OutputPort
from b_asic.simulation import Simulation
......@@ -54,7 +55,6 @@ class MainWindow(QMainWindow):
self.signalPortDict = dict()
self.pressed_ports = []
self.sfg_list = []
self.source = None
self._window = self
self.logger = logging.getLogger(__name__)
self.init_ui()
......@@ -76,6 +76,7 @@ class MainWindow(QMainWindow):
self.check_show_names.setChecked(1)
self.ui.view_menu.addAction(self.check_show_names)
self.ui.actionShowPC.triggered.connect(self.show_precedence_chart)
self.ui.actionSimulateSFG.triggered.connect(self.simulate_sfg)
self.ui.faqBASIC.triggered.connect(self.display_faq_page)
self.ui.aboutBASIC.triggered.connect(self.display_about_page)
......@@ -97,7 +98,7 @@ class MainWindow(QMainWindow):
self.scene = QGraphicsScene(self)
self.graphic_view = QGraphicsView(self.scene, self)
self.graphic_view.setRenderHint(QPainter.Antialiasing)
self.graphic_view.setGeometry(self.ui.operation_box.width(), 0, self.width(), self.height())
self.graphic_view.setGeometry(self.ui.operation_box.width(), 20, self.width(), self.height())
self.graphic_view.setDragMode(QGraphicsView.RubberBandDrag)
def create_toolbar_view(self):
......@@ -106,7 +107,7 @@ class MainWindow(QMainWindow):
def resizeEvent(self, event):
self.ui.operation_box.setGeometry(10, 10, self.ui.operation_box.width(), self.height())
self.graphic_view.setGeometry(self.ui.operation_box.width() + 20, 0, self.width() - self.ui.operation_box.width() - 20, self.height())
self.graphic_view.setGeometry(self.ui.operation_box.width() + 20, 30, self.width() - self.ui.operation_box.width() - 20, self.height()-30)
super(MainWindow, self).resizeEvent(event)
def wheelEvent(self, event):
......@@ -149,6 +150,11 @@ class MainWindow(QMainWindow):
op.setToolTip(sfg.name)
self.sfg_list.append(sfg)
def show_precedence_chart(self):
self.dialog = ShowPCWindow(self)
self.dialog.add_sfg_to_dialog()
self.dialog.show()
def _determine_port_distance(self, length, ports):
"""Determine the distance between each port on the side of an operation.
The method returns the distance that each port should have from 0.
......@@ -242,6 +248,7 @@ class MainWindow(QMainWindow):
for pressed_op in self.pressed_operations:
pressed_op.remove()
self.move_button_index -= 1
self.pressed_operations.clear()
super().keyPressEvent(event)
def connectButton(self, button):
......
from PySide2.QtWidgets import QDialog, QPushButton, QVBoxLayout, QCheckBox,\
QFrame, QFormLayout
from PySide2.QtCore import Qt, Signal
from b_asic import SFG
class ShowPCWindow(QDialog):
pc = Signal()
def __init__(self, window):
super(ShowPCWindow, self).__init__()
self._window = window
self.check_box_list = []
self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
self.setWindowTitle("Show PC")
self.dialog_layout = QVBoxLayout()
self.pc_btn = QPushButton("Show PC")
self.pc_btn.clicked.connect(self.show_precedence_graph)
self.dialog_layout.addWidget(self.pc_btn)
self.setLayout(self.dialog_layout)
def add_sfg_to_dialog(self):
sfg_layout = QVBoxLayout()
options_layout = QFormLayout()
for sfg in self._window.sfg_list:
check_box = QCheckBox()
options_layout.addRow(sfg.name, check_box)
self.check_box_list.append(check_box)
sfg_layout.addLayout(options_layout)
frame = QFrame()
frame.setFrameShape(QFrame.HLine)
frame.setFrameShadow(QFrame.Sunken)
self.dialog_layout.addWidget(frame)
self.dialog_layout.addLayout(sfg_layout)
def show_precedence_graph(self):
for i, check_box in enumerate(self.check_box_list):
if check_box.isChecked():
self._window.logger.info("Creating a precedence chart from " + self._window.sfg_list[i].name)
self._window.sfg_list[i].show_precedence_graph()
break
self.accept()
self.pc.emit()
\ No newline at end of file
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