diff --git a/GUI/main_window.py b/GUI/main_window.py deleted file mode 100644 index 53dacce61b5acbfe9de9607a2499c57e0a386eae..0000000000000000000000000000000000000000 --- a/GUI/main_window.py +++ /dev/null @@ -1,200 +0,0 @@ -"""@package docstring -B-ASIC GUI Module. -This python file is an example of how a GUI can be implemented -using buttons and textboxes. -""" - -import sys - -from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QLabel, QAction,\ -QStatusBar, QMenuBar, QLineEdit, QPushButton -from PyQt5.QtCore import Qt -from PyQt5.QtGui import QIcon, QFont, QPainter, QPen - - -class DragButton(QPushButton): - """How to create a dragbutton""" - def mousePressEvent(self, event): - self._mouse_press_pos = None - self._mouse_move_pos = None - if event.button() == Qt.LeftButton: - self._mouse_press_pos = event.globalPos() - self._mouse_move_pos = event.globalPos() - - super(DragButton, self).mousePressEvent(event) - - def mouseMoveEvent(self, event): - if event.buttons() == Qt.LeftButton: - cur_pos = self.mapToGlobal(self.pos()) - global_pos = event.globalPos() - diff = global_pos - self._mouse_move_pos - new_pos = self.mapFromGlobal(cur_pos + diff) - self.move(new_pos) - - self._mouse_move_pos = global_pos - - super(DragButton, self).mouseMoveEvent(event) - - def mouseReleaseEvent(self, event): - if self._mouse_press_pos is not None: - moved = event.globalPos() - self._mouse_press_pos - if moved.manhattanLength() > 3: - event.ignore() - return - - super(DragButton, self).mouseReleaseEvent(event) - -class SubWindow(QWidget): - """Creates a sub window """ - def create_window(self, window_width, window_height): - """Creates a window - """ - parent = None - super(SubWindow, self).__init__(parent) - self.setWindowFlags(Qt.WindowStaysOnTopHint) - self.resize(window_width, window_height) - -class MainWindow(QMainWindow): - """Main window for the program""" - def __init__(self, *args, **kwargs): - super(MainWindow, self).__init__(*args, **kwargs) - - self.setWindowTitle(" ") - self.setWindowIcon(QIcon('small_logo.png')) - - # Menu buttons - test_button = QAction("Test", self) - - exit_button = QAction("Exit", self) - exit_button.setShortcut("Ctrl+Q") - exit_button.triggered.connect(self.exit_app) - - edit_button = QAction("Edit", self) - edit_button.setStatusTip("Open edit menu") - edit_button.triggered.connect(self.on_edit_button_click) - - view_button = QAction("View", self) - view_button.setStatusTip("Open view menu") - view_button.triggered.connect(self.on_view_button_click) - - menu_bar = QMenuBar() - menu_bar.setStyleSheet("background-color:rgb(222, 222, 222)") - self.setMenuBar(menu_bar) - - file_menu = menu_bar.addMenu("&File") - file_menu.addAction(exit_button) - file_menu.addSeparator() - file_menu.addAction(test_button) - - edit_menu = menu_bar.addMenu("&Edit") - edit_menu.addAction(edit_button) - - edit_menu.addSeparator() - - view_menu = menu_bar.addMenu("&View") - view_menu.addAction(view_button) - - self.setStatusBar(QStatusBar(self)) - - def on_file_button_click(self): - print("File") - - def on_edit_button_click(self): - print("Edit") - - def on_view_button_click(self): - print("View") - - def exit_app(self, checked): - QApplication.quit() - - def clicked(self): - print("Drag button clicked") - - def add_drag_buttons(self): - """Adds draggable buttons""" - addition_button = DragButton("Addition", self) - addition_button.move(10, 130) - addition_button.setFixedSize(70, 20) - addition_button.clicked.connect(self.create_sub_window) - - addition_button2 = DragButton("Addition", self) - addition_button2.move(10, 130) - addition_button2.setFixedSize(70, 20) - addition_button2.clicked.connect(self.create_sub_window) - - subtraction_button = DragButton("Subtraction", self) - subtraction_button.move(10, 170) - subtraction_button.setFixedSize(70, 20) - subtraction_button.clicked.connect(self.create_sub_window) - - subtraction_button2 = DragButton("Subtraction", self) - subtraction_button2.move(10, 170) - subtraction_button2.setFixedSize(70, 20) - subtraction_button2.clicked.connect(self.create_sub_window) - - multiplication_button = DragButton("Multiplication", self) - multiplication_button.move(10, 210) - multiplication_button.setFixedSize(70, 20) - multiplication_button.clicked.connect(self.create_sub_window) - - multiplication_button2 = DragButton("Multiplication", self) - multiplication_button2.move(10, 210) - multiplication_button2.setFixedSize(70, 20) - multiplication_button2.clicked.connect(self.create_sub_window) - - def paintEvent(self, e): - # Temporary black box for operations - painter = QPainter(self) - painter.setPen(QPen(Qt.black, 5, Qt.SolidLine)) - painter.drawRect(0, 110, 100, 400) - - # Temporary arrow resembling a signal - painter.setRenderHint(QPainter.Antialiasing) - painter.setPen(Qt.black) - painter.setBrush(Qt.white) - painter.drawLine(300, 200, 400, 200) - painter.drawLine(400, 200, 395, 195) - painter.drawLine(400, 200, 395, 205) - - def create_sub_window(self): - """ Example of how to create a sub window - """ - self.sub_window = SubWindow() - self.sub_window.create_window(400, 300) - self.sub_window.setWindowTitle("Properties") - - self.sub_window.properties_label = QLabel(self.sub_window) - self.sub_window.properties_label.setText('Properties') - self.sub_window.properties_label.setFixedWidth(400) - self.sub_window.properties_label.setFont(QFont('SansSerif', 14, QFont.Bold)) - self.sub_window.properties_label.setAlignment(Qt.AlignCenter) - - self.sub_window.name_label = QLabel(self.sub_window) - self.sub_window.name_label.setText('Name:') - self.sub_window.name_label.move(20, 40) - - self.sub_window.name_line = QLineEdit(self.sub_window) - self.sub_window.name_line.setPlaceholderText("Write a name here") - self.sub_window.name_line.move(70, 40) - self.sub_window.name_line.resize(100, 20) - - self.sub_window.id_label = QLabel(self.sub_window) - self.sub_window.id_label.setText('Id:') - self.sub_window.id_label.move(20, 70) - - self.sub_window.id_line = QLineEdit(self.sub_window) - self.sub_window.id_line.setPlaceholderText("Write an id here") - self.sub_window.id_line.move(70, 70) - self.sub_window.id_line.resize(100, 20) - - self.sub_window.show() - - -if __name__ == "__main__": - app = QApplication(sys.argv) - window = MainWindow() - window.add_drag_buttons() - window.resize(960, 720) - window.show() - app.exec_() diff --git a/b_asic/GUI/__init__.py b/b_asic/GUI/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..16dd0253b1690cef57efa5a25f5adf28f53646f7 --- /dev/null +++ b/b_asic/GUI/__init__.py @@ -0,0 +1,4 @@ +"""TODO""" +from drag_button import * +from improved_main_window import * +from gui_interface import * diff --git a/b_asic/GUI/arrow.py b/b_asic/GUI/arrow.py new file mode 100644 index 0000000000000000000000000000000000000000..4014c78a4397f2d27823a2d570d1229d214f6393 --- /dev/null +++ b/b_asic/GUI/arrow.py @@ -0,0 +1,32 @@ +from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QLabel, QAction,\ +QStatusBar, QMenuBar, QLineEdit, QPushButton, QSlider, QScrollArea, QVBoxLayout,\ +QHBoxLayout, QDockWidget, QToolBar, QMenu, QLayout, QSizePolicy, QListWidget, QListWidgetItem,\ +QGraphicsLineItem, QGraphicsWidget +from PyQt5.QtCore import Qt, QSize, QLineF, QPoint, QRectF +from PyQt5.QtGui import QIcon, QFont, QPainter, QPen + + +class Arrow(QGraphicsLineItem): + + def __init__(self, source, destination, window, parent=None): + super(Arrow, self).__init__(parent) + self.source = source + self.destination = destination + self._window = window + self.moveLine() + self.source.moved.connect(self.moveLine) + self.destination.moved.connect(self.moveLine) + + def contextMenuEvent(self, event): + menu = QMenu() + menu.addAction("Delete", self.remove) + menu.exec_(self.cursor().pos()) + + def remove(self): + self._window.scene.removeItem(self) + self._window.signalList.remove(self) + + def moveLine(self): + self.setPen(QPen(Qt.black, 3)) + self.setLine(QLineF(self.source.x()+50, self.source.y()+25,\ + self.destination.x(), self.destination.y()+25)) \ No newline at end of file diff --git a/b_asic/GUI/drag_button.py b/b_asic/GUI/drag_button.py new file mode 100644 index 0000000000000000000000000000000000000000..9f2f26e439dff2706dc1ec13fb2b3224c6f8bf6f --- /dev/null +++ b/b_asic/GUI/drag_button.py @@ -0,0 +1,87 @@ +"""@package docstring +Drag button class. +This class creates a dragbutton which can be clicked, dragged and dropped. +""" + + +import os.path + +from PyQt5.QtWidgets import QPushButton, QMenu +from PyQt5.QtCore import Qt, QSize, pyqtSignal, QMimeData +from PyQt5.QtGui import QIcon + + +class DragButton(QPushButton): + connectionRequested = pyqtSignal(QPushButton) + moved = pyqtSignal() + def __init__(self, name, operation, operation_path_name, window, parent = None): + self.name = name + self.__window = window + self.operation = operation + self.operation_path_name = operation_path_name + self.clicked = 0 + self.pressed = False + super(DragButton, self).__init__(self.__window) + + def contextMenuEvent(self, event): + menu = QMenu() + menu.addAction("Connect", lambda: self.connectionRequested.emit(self)) + menu.exec_(self.cursor().pos()) + + def mousePressEvent(self, event): + self._mouse_press_pos = None + self._mouse_move_pos = None + + if event.button() == Qt.LeftButton: + self._mouse_press_pos = event.globalPos() + self._mouse_move_pos = event.globalPos() + + for signal in self.__window.signalList: + signal.update() + + self.clicked += 1 + if self.clicked == 1: + self.pressed = True + self.setStyleSheet("background-color: grey; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + path_to_image = os.path.join('operation_icons', self.operation_path_name + '_grey.png') + self.setIcon(QIcon(path_to_image)) + self.setIconSize(QSize(50, 50)) + self.__window.pressed_button.append(self) + + elif self.clicked == 2: + self.clicked = 0 + self.pressed = False + self.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + path_to_image = os.path.join('operation_icons', self.operation_path_name + '.png') + self.setIcon(QIcon(path_to_image)) + self.setIconSize(QSize(50, 50)) + self.__window.pressed_button.remove(self) + + super(DragButton, self).mousePressEvent(event) + + def mouseMoveEvent(self, event): + if event.buttons() == Qt.LeftButton: + cur_pos = self.mapToGlobal(self.pos()) + global_pos = event.globalPos() + diff = global_pos - self._mouse_move_pos + new_pos = self.mapFromGlobal(cur_pos + diff) + self.move(new_pos) + + self._mouse_move_pos = global_pos + + self.__window.update() + super(DragButton, self).mouseMoveEvent(event) + + def mouseReleaseEvent(self, event): + if self._mouse_press_pos is not None: + moved = event.globalPos() - self._mouse_press_pos + if moved.manhattanLength() > 3: + event.ignore() + return + + super(DragButton, self).mouseReleaseEvent(event) + + def remove(self): + self.deleteLater() \ No newline at end of file diff --git a/b_asic/GUI/gui_interface.py b/b_asic/GUI/gui_interface.py new file mode 100644 index 0000000000000000000000000000000000000000..6c384aacd131ac7bf570aa0f75ed8d8d04730b99 --- /dev/null +++ b/b_asic/GUI/gui_interface.py @@ -0,0 +1,351 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'gui_interface.ui' +# +# Created by: PyQt5 UI code generator 5.14.2 +# +# WARNING! All changes made in this file will be lost! + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_main_window(object): + def setupUi(self, main_window): + main_window.setObjectName("main_window") + main_window.setEnabled(True) + main_window.resize(897, 633) + self.centralwidget = QtWidgets.QWidget(main_window) + self.centralwidget.setObjectName("centralwidget") + self.operation_box = QtWidgets.QGroupBox(self.centralwidget) + self.operation_box.setGeometry(QtCore.QRect(10, 10, 201, 531)) + self.operation_box.setLayoutDirection(QtCore.Qt.LeftToRight) + self.operation_box.setAutoFillBackground(False) + self.operation_box.setStyleSheet("QGroupBox { \n" +" border: 2px solid gray; \n" +" border-radius: 3px;\n" +" margin-top: 0.5em; \n" +" } \n" +"\n" +"QGroupBox::title {\n" +" subcontrol-origin: margin;\n" +" left: 10px;\n" +" padding: 0 3px 0 3px;\n" +"}") + self.operation_box.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) + self.operation_box.setFlat(False) + self.operation_box.setCheckable(False) + self.operation_box.setObjectName("operation_box") + self.operation_list = QtWidgets.QToolBox(self.operation_box) + self.operation_list.setGeometry(QtCore.QRect(10, 20, 171, 271)) + self.operation_list.setAutoFillBackground(False) + self.operation_list.setObjectName("operation_list") + self.core_operations_page = QtWidgets.QWidget() + self.core_operations_page.setGeometry(QtCore.QRect(0, 0, 171, 217)) + self.core_operations_page.setObjectName("core_operations_page") + self.core_operations_list = QtWidgets.QListWidget(self.core_operations_page) + self.core_operations_list.setGeometry(QtCore.QRect(10, 0, 141, 211)) + self.core_operations_list.setMinimumSize(QtCore.QSize(141, 0)) + self.core_operations_list.setEditTriggers(QtWidgets.QAbstractItemView.DoubleClicked|QtWidgets.QAbstractItemView.EditKeyPressed) + self.core_operations_list.setDragEnabled(False) + self.core_operations_list.setDragDropMode(QtWidgets.QAbstractItemView.NoDragDrop) + self.core_operations_list.setMovement(QtWidgets.QListView.Static) + self.core_operations_list.setFlow(QtWidgets.QListView.TopToBottom) + self.core_operations_list.setProperty("isWrapping", False) + self.core_operations_list.setResizeMode(QtWidgets.QListView.Adjust) + self.core_operations_list.setLayoutMode(QtWidgets.QListView.SinglePass) + self.core_operations_list.setViewMode(QtWidgets.QListView.ListMode) + self.core_operations_list.setUniformItemSizes(False) + self.core_operations_list.setWordWrap(False) + self.core_operations_list.setSelectionRectVisible(False) + self.core_operations_list.setObjectName("core_operations_list") + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.core_operations_list.addItem(item) + self.operation_list.addItem(self.core_operations_page, "") + self.special_operations_page = QtWidgets.QWidget() + self.special_operations_page.setGeometry(QtCore.QRect(0, 0, 171, 217)) + self.special_operations_page.setObjectName("special_operations_page") + self.special_operations_list = QtWidgets.QListWidget(self.special_operations_page) + self.special_operations_list.setGeometry(QtCore.QRect(10, 0, 141, 81)) + self.special_operations_list.setObjectName("special_operations_list") + item = QtWidgets.QListWidgetItem() + self.special_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.special_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.special_operations_list.addItem(item) + item = QtWidgets.QListWidgetItem() + self.special_operations_list.addItem(item) + self.operation_list.addItem(self.special_operations_page, "") + main_window.setCentralWidget(self.centralwidget) + self.menu_bar = QtWidgets.QMenuBar(main_window) + self.menu_bar.setGeometry(QtCore.QRect(0, 0, 897, 21)) + palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 255, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(170, 170, 170)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.PlaceholderText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 255, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(170, 170, 170)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.PlaceholderText, brush) + brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 255, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(170, 170, 170)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.PlaceholderText, brush) + self.menu_bar.setPalette(palette) + self.menu_bar.setObjectName("menu_bar") + self.file_menu = QtWidgets.QMenu(self.menu_bar) + self.file_menu.setObjectName("file_menu") + self.edit_menu = QtWidgets.QMenu(self.menu_bar) + self.edit_menu.setObjectName("edit_menu") + self.view_menu = QtWidgets.QMenu(self.menu_bar) + self.view_menu.setObjectName("view_menu") + main_window.setMenuBar(self.menu_bar) + self.status_bar = QtWidgets.QStatusBar(main_window) + self.status_bar.setObjectName("status_bar") + main_window.setStatusBar(self.status_bar) + self.save_menu = QtWidgets.QAction(main_window) + self.save_menu.setObjectName("save_menu") + self.exit_menu = QtWidgets.QAction(main_window) + self.exit_menu.setObjectName("exit_menu") + self.actionUndo = QtWidgets.QAction(main_window) + self.actionUndo.setObjectName("actionUndo") + self.actionRedo = QtWidgets.QAction(main_window) + self.actionRedo.setObjectName("actionRedo") + self.actionToolbar = QtWidgets.QAction(main_window) + self.actionToolbar.setCheckable(True) + self.actionToolbar.setObjectName("actionToolbar") + self.file_menu.addAction(self.save_menu) + self.file_menu.addSeparator() + self.file_menu.addAction(self.exit_menu) + self.edit_menu.addAction(self.actionUndo) + self.edit_menu.addAction(self.actionRedo) + self.view_menu.addAction(self.actionToolbar) + self.menu_bar.addAction(self.file_menu.menuAction()) + self.menu_bar.addAction(self.edit_menu.menuAction()) + self.menu_bar.addAction(self.view_menu.menuAction()) + + self.retranslateUi(main_window) + self.operation_list.setCurrentIndex(1) + self.core_operations_list.setCurrentRow(-1) + QtCore.QMetaObject.connectSlotsByName(main_window) + + def retranslateUi(self, main_window): + _translate = QtCore.QCoreApplication.translate + main_window.setWindowTitle(_translate("main_window", "MainWindow")) + self.operation_box.setTitle(_translate("main_window", "Operations")) + self.core_operations_list.setSortingEnabled(False) + __sortingEnabled = self.core_operations_list.isSortingEnabled() + self.core_operations_list.setSortingEnabled(False) + item = self.core_operations_list.item(0) + item.setText(_translate("main_window", "Addition")) + item = self.core_operations_list.item(1) + item.setText(_translate("main_window", "Subtraction")) + item = self.core_operations_list.item(2) + item.setText(_translate("main_window", "Multiplication")) + item = self.core_operations_list.item(3) + item.setText(_translate("main_window", "Division")) + item = self.core_operations_list.item(4) + item.setText(_translate("main_window", "Constant")) + item = self.core_operations_list.item(5) + item.setText(_translate("main_window", "Constant multiplication")) + item = self.core_operations_list.item(6) + item.setText(_translate("main_window", "Square root")) + item = self.core_operations_list.item(7) + item.setText(_translate("main_window", "Complex conjugate")) + item = self.core_operations_list.item(8) + item.setText(_translate("main_window", "Absolute")) + item = self.core_operations_list.item(9) + item.setText(_translate("main_window", "Max")) + item = self.core_operations_list.item(10) + item.setText(_translate("main_window", "Min")) + item = self.core_operations_list.item(11) + item.setText(_translate("main_window", "Butterfly")) + self.core_operations_list.setSortingEnabled(__sortingEnabled) + self.operation_list.setItemText(self.operation_list.indexOf(self.core_operations_page), _translate("main_window", "Core operations")) + __sortingEnabled = self.special_operations_list.isSortingEnabled() + self.special_operations_list.setSortingEnabled(False) + item = self.special_operations_list.item(0) + item.setText(_translate("main_window", "Input")) + item = self.special_operations_list.item(1) + item.setText(_translate("main_window", "Output")) + item = self.special_operations_list.item(2) + item.setText(_translate("main_window", "Register")) + item = self.special_operations_list.item(3) + item.setText(_translate("main_window", "Custom")) + self.special_operations_list.setSortingEnabled(__sortingEnabled) + self.operation_list.setItemText(self.operation_list.indexOf(self.special_operations_page), _translate("main_window", "Special operations")) + self.file_menu.setTitle(_translate("main_window", "File")) + self.edit_menu.setTitle(_translate("main_window", "Edit")) + self.view_menu.setTitle(_translate("main_window", "View")) + self.save_menu.setText(_translate("main_window", "Save")) + self.exit_menu.setText(_translate("main_window", "Exit")) + self.exit_menu.setShortcut(_translate("main_window", "Ctrl+Q")) + self.actionUndo.setText(_translate("main_window", "Undo")) + self.actionRedo.setText(_translate("main_window", "Redo")) + self.actionToolbar.setText(_translate("main_window", "Toolbar")) + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + main_window = QtWidgets.QMainWindow() + ui = Ui_main_window() + ui.setupUi(main_window) + main_window.show() + sys.exit(app.exec_()) diff --git a/b_asic/GUI/gui_interface.ui b/b_asic/GUI/gui_interface.ui new file mode 100644 index 0000000000000000000000000000000000000000..c441048a8b6ceff93cf926060696a107bfdda9fb --- /dev/null +++ b/b_asic/GUI/gui_interface.ui @@ -0,0 +1,763 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>main_window</class> + <widget class="QMainWindow" name="main_window"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>897</width> + <height>633</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <widget class="QGroupBox" name="operation_box"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>201</width> + <height>531</height> + </rect> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="styleSheet"> + <string notr="true">QGroupBox { + border: 2px solid gray; + border-radius: 3px; + margin-top: 0.5em; + } + +QGroupBox::title { + subcontrol-origin: margin; + left: 10px; + padding: 0 3px 0 3px; +}</string> + </property> + <property name="title"> + <string>Operations</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="flat"> + <bool>false</bool> + </property> + <property name="checkable"> + <bool>false</bool> + </property> + <widget class="QToolBox" name="operation_list"> + <property name="geometry"> + <rect> + <x>10</x> + <y>20</y> + <width>171</width> + <height>271</height> + </rect> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="currentIndex"> + <number>1</number> + </property> + <widget class="QWidget" name="core_operations_page"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>171</width> + <height>217</height> + </rect> + </property> + <attribute name="label"> + <string>Core operations</string> + </attribute> + <widget class="QListWidget" name="core_operations_list"> + <property name="geometry"> + <rect> + <x>10</x> + <y>0</y> + <width>141</width> + <height>211</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>141</width> + <height>0</height> + </size> + </property> + <property name="editTriggers"> + <set>QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set> + </property> + <property name="dragEnabled"> + <bool>false</bool> + </property> + <property name="dragDropMode"> + <enum>QAbstractItemView::NoDragDrop</enum> + </property> + <property name="movement"> + <enum>QListView::Static</enum> + </property> + <property name="flow"> + <enum>QListView::TopToBottom</enum> + </property> + <property name="isWrapping" stdset="0"> + <bool>false</bool> + </property> + <property name="resizeMode"> + <enum>QListView::Adjust</enum> + </property> + <property name="layoutMode"> + <enum>QListView::SinglePass</enum> + </property> + <property name="viewMode"> + <enum>QListView::ListMode</enum> + </property> + <property name="uniformItemSizes"> + <bool>false</bool> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="selectionRectVisible"> + <bool>false</bool> + </property> + <property name="currentRow"> + <number>-1</number> + </property> + <property name="sortingEnabled"> + <bool>false</bool> + </property> + <item> + <property name="text"> + <string>Addition</string> + </property> + </item> + <item> + <property name="text"> + <string>Subtraction</string> + </property> + </item> + <item> + <property name="text"> + <string>Multiplication</string> + </property> + </item> + <item> + <property name="text"> + <string>Division</string> + </property> + </item> + <item> + <property name="text"> + <string>Constant</string> + </property> + </item> + <item> + <property name="text"> + <string>Constant multiplication</string> + </property> + </item> + <item> + <property name="text"> + <string>Square root</string> + </property> + </item> + <item> + <property name="text"> + <string>Complex conjugate</string> + </property> + </item> + <item> + <property name="text"> + <string>Absolute</string> + </property> + </item> + <item> + <property name="text"> + <string>Max</string> + </property> + </item> + <item> + <property name="text"> + <string>Min</string> + </property> + </item> + <item> + <property name="text"> + <string>Butterfly</string> + </property> + </item> + </widget> + </widget> + <widget class="QWidget" name="special_operations_page"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>171</width> + <height>217</height> + </rect> + </property> + <attribute name="label"> + <string>Special operations</string> + </attribute> + <widget class="QListWidget" name="special_operations_list"> + <property name="geometry"> + <rect> + <x>10</x> + <y>0</y> + <width>141</width> + <height>81</height> + </rect> + </property> + <item> + <property name="text"> + <string>Input</string> + </property> + </item> + <item> + <property name="text"> + <string>Output</string> + </property> + </item> + <item> + <property name="text"> + <string>Register</string> + </property> + </item> + <item> + <property name="text"> + <string>Custom</string> + </property> + </item> + </widget> + </widget> + </widget> + </widget> + </widget> + <widget class="QMenuBar" name="menu_bar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>897</width> + <height>21</height> + </rect> + </property> + <property name="palette"> + <palette> + <active> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Button"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>255</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Light"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Midlight"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Dark"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>127</red> + <green>127</green> + <blue>127</blue> + </color> + </brush> + </colorrole> + <colorrole role="Mid"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + <colorrole role="Text"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="BrightText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="ButtonText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Shadow"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="AlternateBase"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="ToolTipBase"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>220</blue> + </color> + </brush> + </colorrole> + <colorrole role="ToolTipText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="PlaceholderText"> + <brush brushstyle="SolidPattern"> + <color alpha="128"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + </active> + <inactive> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Button"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>255</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Light"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Midlight"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Dark"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>127</red> + <green>127</green> + <blue>127</blue> + </color> + </brush> + </colorrole> + <colorrole role="Mid"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + <colorrole role="Text"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="BrightText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="ButtonText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Shadow"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="AlternateBase"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="ToolTipBase"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>220</blue> + </color> + </brush> + </colorrole> + <colorrole role="ToolTipText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="PlaceholderText"> + <brush brushstyle="SolidPattern"> + <color alpha="128"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + </inactive> + <disabled> + <colorrole role="WindowText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>127</red> + <green>127</green> + <blue>127</blue> + </color> + </brush> + </colorrole> + <colorrole role="Button"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>255</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="Light"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Midlight"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Dark"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>127</red> + <green>127</green> + <blue>127</blue> + </color> + </brush> + </colorrole> + <colorrole role="Mid"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>170</red> + <green>170</green> + <blue>170</blue> + </color> + </brush> + </colorrole> + <colorrole role="Text"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>127</red> + <green>127</green> + <blue>127</blue> + </color> + </brush> + </colorrole> + <colorrole role="BrightText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="ButtonText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>127</red> + <green>127</green> + <blue>127</blue> + </color> + </brush> + </colorrole> + <colorrole role="Base"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Window"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="Shadow"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="AlternateBase"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </brush> + </colorrole> + <colorrole role="ToolTipBase"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>255</red> + <green>255</green> + <blue>220</blue> + </color> + </brush> + </colorrole> + <colorrole role="ToolTipText"> + <brush brushstyle="SolidPattern"> + <color alpha="255"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + <colorrole role="PlaceholderText"> + <brush brushstyle="SolidPattern"> + <color alpha="128"> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </brush> + </colorrole> + </disabled> + </palette> + </property> + <widget class="QMenu" name="file_menu"> + <property name="title"> + <string>File</string> + </property> + <addaction name="save_menu"/> + <addaction name="separator"/> + <addaction name="exit_menu"/> + </widget> + <widget class="QMenu" name="edit_menu"> + <property name="title"> + <string>Edit</string> + </property> + <addaction name="actionUndo"/> + <addaction name="actionRedo"/> + </widget> + <widget class="QMenu" name="view_menu"> + <property name="title"> + <string>View</string> + </property> + <addaction name="actionToolbar"/> + </widget> + <addaction name="file_menu"/> + <addaction name="edit_menu"/> + <addaction name="view_menu"/> + </widget> + <widget class="QStatusBar" name="status_bar"/> + <action name="save_menu"> + <property name="text"> + <string>Save</string> + </property> + </action> + <action name="exit_menu"> + <property name="text"> + <string>Exit</string> + </property> + <property name="shortcut"> + <string>Ctrl+Q</string> + </property> + </action> + <action name="actionUndo"> + <property name="text"> + <string>Undo</string> + </property> + </action> + <action name="actionRedo"> + <property name="text"> + <string>Redo</string> + </property> + </action> + <action name="actionToolbar"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="text"> + <string>Toolbar</string> + </property> + </action> + </widget> + <resources/> + <connections/> +</ui> diff --git a/b_asic/GUI/improved_main_window.py b/b_asic/GUI/improved_main_window.py new file mode 100644 index 0000000000000000000000000000000000000000..5f81b8fc2516866b159baed0c5b8ef8ab5f0d8f9 --- /dev/null +++ b/b_asic/GUI/improved_main_window.py @@ -0,0 +1,440 @@ +"""@package docstring +B-ASIC GUI Module. +This python file is the main window of the GUI for B-ASIC. +""" + +from os import getcwd +import sys + +from drag_button import DragButton +from gui_interface import Ui_main_window +from arrow import Arrow + +from b_asic import Constant, Addition, Subtraction, Absolute,\ +Multiplication, Division, ConstantMultiplication, SquareRoot, ComplexConjugate,\ +Max, Min, Butterfly +from b_asic import Input, Output, Register + +from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QLabel, QAction,\ +QStatusBar, QMenuBar, QLineEdit, QPushButton, QSlider, QScrollArea, QVBoxLayout,\ +QHBoxLayout, QDockWidget, QToolBar, QMenu, QLayout, QSizePolicy, QListWidget,\ +QListWidgetItem, QGraphicsView, QGraphicsScene +from PyQt5.QtCore import Qt, QSize +from PyQt5.QtGui import QIcon, QFont, QPainter, QPen, QBrush + + +class MainWindow(QMainWindow): + def __init__(self): + super(MainWindow, self).__init__() + self.ui = Ui_main_window() + self.ui.setupUi(self) + self.setWindowTitle(" ") + self.setWindowIcon(QIcon('small_logo.png')) + self.scene = None + self.init_ui() + + self.add_counter = 0 + self.sub_counter = 0 + self.mul_counter = 0 + self.div_counter = 0 + self.const_counter = 0 + self.cmul_counter = 0 + self.sqr_counter = 0 + self.cc_counter = 0 + self.abs_counter = 0 + self.max_counter = 0 + self.min_counter = 0 + self.butterfly_counter = 0 + self.input_counter = 0 + self.output_counter = 0 + self.reg_counter = 0 + + self.operationList = [] + self.signalList = [] + self.pressed_button = [] + + self.source = None + + def init_ui(self): + self.ui.core_operations_list.itemClicked.connect(self.on_list_widget_item_clicked) + self.ui.special_operations_list.itemClicked.connect(self.on_list_widget_item_clicked) + self.ui.exit_menu.triggered.connect(self.exit_app) + self.create_graphics_view() + + def create_graphics_view(self): + self.scene = QGraphicsScene() + graphic_view = QGraphicsView(self.scene, self) + graphic_view.setRenderHint(QPainter.Antialiasing) + graphic_view.setGeometry(250, 40, 600, 520) + + def exit_app(self, checked): + QApplication.quit() + + def add_ports(self, operation): + if operation.operation.input_count == 2: + self.input_port_1 = QPushButton(">", operation) + self.input_port_1.setStyleSheet("background-color: white") + self.input_port_1.clicked.connect(self.print_input_port_1) + self.input_port_1.show() + self.input_port_2 = QPushButton(">", operation) + self.input_port_2.setStyleSheet("background-color: white") + self.input_port_2.move(0, 33) + self.input_port_2.clicked.connect(self.print_input_port_2) + self.input_port_2.show() + else: + self.input_port_1 = QPushButton(">", operation) + self.input_port_1.setStyleSheet("background-color: white") + self.input_port_1.move(0, 16) + self.input_port_1.clicked.connect(self.print_input_port_1) + self.input_port_1.show() + if operation.operation.output_count == 2: + self.output_port = QPushButton(">", operation) + self.output_port.setStyleSheet("background-color: white") + self.output_port.move(38, 0) + self.output_port.clicked.connect(self.print_output_port_1) + self.output_port.show() + self.output_port2 = QPushButton(">", operation) + self.output_port2.setStyleSheet("background-color: white") + self.output_port2.move(38, 33) + self.output_port2.clicked.connect(self.print_output_port_2) + self.output_port2.show() + else: + self.output_port = QPushButton(">", operation) + self.output_port.setStyleSheet("background-color: white") + self.output_port.move(38, 16) + self.output_port.clicked.connect(self.print_output_port_1) + self.output_port.show() + + def create_addition_operation(self): + self.add_counter += 1 + addition_object = Addition() + self.addition_operation = DragButton("Add" + str(self.add_counter),\ + addition_object, "addition", self) + self.addition_operation.move(250, 100) + self.addition_operation.setFixedSize(50, 50) + self.addition_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.addition_operation.setIcon(QIcon(r"operation_icons\addition.png")) + self.addition_operation.setIconSize(QSize(50, 50)) + self.addition_operation.setParent(None) + self.scene.addWidget(self.addition_operation) + self.operationList.append(self.addition_operation) + self.addition_operation.connectionRequested.connect(self.connectButton) + + self.operationList.append(self.addition_operation) + self.add_ports(self.addition_operation) + + def print_input_port_1(self): + print("Input port 1") + + def print_input_port_2(self): + print("Input port 2") + + def print_output_port_1(self): + print("Output port 1") + + def print_output_port_2(self): + print("Output port 2") + + def create_subtraction_operation(self): + self.sub_counter += 1 + subtraction_object = Subtraction() + self.subtraction_operation = DragButton("Subb" + str(self.sub_counter),\ + subtraction_object, "subtraction", self) + self.subtraction_operation.move(250, 100) + self.subtraction_operation.setFixedSize(50, 50) + self.subtraction_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.subtraction_operation.setIcon(QIcon(r"operation_icons\subtraction.png")) + self.subtraction_operation.setIconSize(QSize(50, 50)) + self.subtraction_operation.setParent(None) + self.scene.addWidget(self.subtraction_operation) + self.operationList.append(self.subtraction_operation) + self.add_ports(self.subtraction_operation) + + def create_multiplication_operation(self): + self.mul_counter += 1 + multiplication_object = Multiplication() + self.multiplication_operation = DragButton("Mul" + str(self.mul_counter),\ + multiplication_object, "multiplication", self) + self.multiplication_operation.move(250, 100) + self.multiplication_operation.setFixedSize(50, 50) + self.multiplication_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.multiplication_operation.setIcon(QIcon\ + (r"operation_icons\multiplication.png")) + self.multiplication_operation.setIconSize(QSize(50, 50)) + self.multiplication_operation.setParent(None) + self.scene.addWidget(self.multiplication_operation) + self.operationList.append(self.multiplication_operation) + self.add_ports(self.multiplication_operation) + + def create_division_operation(self): + self.div_counter += 1 + division_object = Division() + self.division_operation = DragButton("Div" + str(self.div_counter),\ + division_object, "division", self) + self.division_operation.move(250, 100) + self.division_operation.setFixedSize(50, 50) + self.division_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.division_operation.setIcon(QIcon(r"operation_icons\division.png")) + self.division_operation.setIconSize(QSize(50, 50)) + self.division_operation.setParent(None) + self.scene.addWidget(self.division_operation) + self.operationList.append(self.division_operation) + self.add_ports(self.division_operation) + + def create_constant_operation(self): + self.const_counter += 1 + constant_object = Constant() + self.constant_operation = DragButton("Const" + str(self.const_counter),\ + constant_object, "constant", self) + self.constant_operation.move(250, 100) + self.constant_operation.setFixedSize(50, 50) + self.constant_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.constant_operation.setIcon(QIcon(r"operation_icons\constant.png")) + self.constant_operation.setIconSize(QSize(50, 50)) + self.constant_operation.setParent(None) + self.scene.addWidget(self.constant_operation) + self.operationList.append(self.constant_operation) + self.add_ports(self.constant_operation) + + def create_constant_multiplication_operation(self): + self.cmul_counter += 1 + constant_multiplication_object = ConstantMultiplication() + self.constant_multiplication_operation = DragButton("Cmul" + str(self.cmul_counter),\ + constant_multiplication_object, "constant_multiplication", self) + self.constant_multiplication_operation.move(250, 100) + self.constant_multiplication_operation.setFixedSize(50, 50) + self.constant_multiplication_operation.setStyleSheet("background-color: white; \ + border-style: solid; border-color: black; border-width: 2px; border-radius: 10px") + self.constant_multiplication_operation.setIcon(QIcon\ + (r"operation_icons\constant_multiplication.png")) + self.constant_multiplication_operation.setIconSize(QSize(50, 50)) + self.constant_multiplication_operation.setParent(None) + self.scene.addWidget(self.constant_multiplication_operation) + self.operationList.append(self.constant_multiplication_operation) + self.add_ports(self.constant_multiplication_operation) + + def create_square_root_operation(self): + self.sqr_counter += 1 + square_root_object = SquareRoot() + self.square_root_operation = DragButton("Sqr" + str(self.sqr_counter),\ + square_root_object, "square_root", self) + self.square_root_operation.move(250, 100) + self.square_root_operation.setFixedSize(50, 50) + self.square_root_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.square_root_operation.setIcon(QIcon(r"operation_icons\square_root.png")) + self.square_root_operation.setIconSize(QSize(50, 50)) + self.square_root_operation.setParent(None) + self.scene.addWidget(self.square_root_operation) + self.operationList.append(self.square_root_operation) + self.add_ports(self.square_root_operation) + + def create_complex_conjugate_operation(self): + self.cc_counter += 1 + complex_conjugate_object = ComplexConjugate() + self.complex_conjugate_operation = DragButton("Cc" + str(self.cc_counter),\ + complex_conjugate_object, "complex_conjugate", self) + self.complex_conjugate_operation.move(250, 100) + self.complex_conjugate_operation.setFixedSize(50, 50) + self.complex_conjugate_operation.setStyleSheet("background-color: white;\ + border-style: solid; border-color: black; border-width: 2px; border-radius: 10px") + self.complex_conjugate_operation.setIcon(QIcon\ + (r"operation_icons\complex_conjugate.png")) + self.complex_conjugate_operation.setIconSize(QSize(50, 50)) + self.complex_conjugate_operation.setParent(None) + self.scene.addWidget(self.complex_conjugate_operation) + self.operationList.append(self.complex_conjugate_operation) + self.add_ports(self.complex_conjugate_operation) + + def create_absolute_operation(self): + self.abs_counter += 1 + absolute_object = Absolute() + self.absolute_operation = DragButton("Abs" + str(self.abs_counter),\ + absolute_object, "absolute", self) + self.absolute_operation.move(250, 100) + self.absolute_operation.setFixedSize(50, 50) + self.absolute_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.absolute_operation.setIcon(QIcon(r"operation_icons\absolute.png")) + self.absolute_operation.setIconSize(QSize(50, 50)) + self.absolute_operation.setParent(None) + self.scene.addWidget(self.absolute_operation) + self.operationList.append(self.absolute_operation) + self.add_ports(self.absolute_operation) + + def create_max_operation(self): + self.max_counter += 1 + max_object = Max() + self.max_operation = DragButton("Max" + str(self.max_counter),\ + max_object, "max", self) + self.max_operation.move(250, 100) + self.max_operation.setFixedSize(50, 50) + self.max_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.max_operation.setIcon(QIcon(r"operation_icons\max.png")) + self.max_operation.setIconSize(QSize(50, 50)) + self.max_operation.setParent(None) + self.scene.addWidget(self.max_operation) + self.operationList.append(self.max_operation) + self.add_ports(self.max_operation) + + def create_min_operation(self): + self.min_counter += 1 + min_object = Min() + self.min_operation = DragButton("Min" + str(self.min_counter),\ + min_object, "min", self) + self.min_operation.move(250, 100) + self.min_operation.setFixedSize(50, 50) + self.min_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.min_operation.setIcon(QIcon(r"operation_icons\min.png")) + self.min_operation.setIconSize(QSize(50, 50)) + self.min_operation.setParent(None) + self.scene.addWidget(self.min_operation) + self.operationList.append(self.min_operation) + self.add_ports(self.min_operation) + + def create_butterfly_operation(self): + self.butterfly_counter += 1 + butterfly_object = Butterfly() + self.butterfly_operation = DragButton("Butterfly" + str(self.butterfly_counter),\ + butterfly_object, "butterfly", self) + self.butterfly_operation.move(250, 100) + self.butterfly_operation.setFixedSize(50, 50) + self.butterfly_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.butterfly_operation.setIcon(QIcon(r"operation_icons\butterfly.png")) + self.butterfly_operation.setIconSize(QSize(50, 50)) + self.butterfly_operation.setParent(None) + self.scene.addWidget(self.butterfly_operation) + self.operationList.append(self.butterfly_operation) + self.add_ports(self.butterfly_operation) + + def create_input_operation(self): + self.input_counter += 1 + input_object = Input() + self.input_operation = DragButton("In" + str(self.input_counter),\ + input_object, "input", self) + self.input_operation.move(250, 100) + self.input_operation.setFixedSize(50, 50) + self.input_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.input_operation.setIcon(QIcon(r"operation_icons\input.png")) + self.input_operation.setIconSize(QSize(50, 50)) + self.input_operation.setParent(None) + self.scene.addWidget(self.input_operation) + self.operationList.append(self.input_operation) + self.add_ports(self.input_operation) + + def create_output_operation(self): + self.output_counter += 1 + output_object = Output() + self.output_operation = DragButton("Out" + str(self.output_counter),\ + output_object, "output", self) + self.output_operation.move(250, 100) + self.output_operation.setFixedSize(50, 50) + self.output_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.output_operation.setIcon(QIcon(r"operation_icons\output.png")) + self.output_operation.setIconSize(QSize(50, 50)) + self.output_operation.setParent(None) + self.scene.addWidget(self.output_operation) + self.operationList.append(self.output_operation) + self.add_ports(self.output_operation) + + def create_register_operation(self): + self.reg_counter += 1 + register_object = Register() + self.register_operation = DragButton("Reg" + str(self.reg_counter),\ + register_object, "register", self) + self.register_operation.move(250, 100) + self.register_operation.setFixedSize(50, 50) + self.register_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.register_operation.setIcon(QIcon(r"operation_icons\register.png")) + self.register_operation.setIconSize(QSize(50, 50)) + self.register_operation.setParent(None) + self.scene.addWidget(self.register_operation) + self.operationList.append(self.register_operation) + self.add_ports(self.register_operation) + + def create_custom_operation(self): + self.custom_operation = DragButton(self) + self.custom_operation.move(250, 100) + self.custom_operation.setFixedSize(50, 50) + self.custom_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.custom_operation.setIcon(QIcon(r"operation_icons\custom_operation.png")) + self.custom_operation.setIconSize(QSize(50, 50)) + self.custom_operation.show() + + def on_list_widget_item_clicked(self, item): + if item.text() == "Addition": + self.create_addition_operation() + elif item.text() == "Subtraction": + self.create_subtraction_operation() + elif item.text() == "Multiplication": + self.create_multiplication_operation() + elif item.text() == "Division": + self.create_division_operation() + elif item.text() == "Constant": + self.create_constant_operation() + elif item.text() == "Constant multiplication": + self.create_constant_multiplication_operation() + elif item.text() == "Square root": + self.create_square_root_operation() + elif item.text() == "Complex conjugate": + self.create_complex_conjugate_operation() + elif item.text() == "Max": + self.create_max_operation() + elif item.text() == "Min": + self.create_min_operation() + elif item.text() == "Absolute": + self.create_absolute_operation() + elif item.text() == "Butterfly": + self.create_butterfly_operation() + elif item.text() == "Input": + self.create_input_operation() + elif item.text() == "Output": + self.create_output_operation() + elif item.text() == "Register": + self.create_register_operation() + else: + print("Block for this operation is not implemented yet.") + + def keyPressEvent(self, event): + pressed_buttons = [] + for op in self.operationList: + if op.pressed: + pressed_buttons.append(op) + if event.key() == Qt.Key_Delete: + for pressed_op in pressed_buttons: + self.operationList.remove(pressed_op) + pressed_op.remove() + super().keyPressEvent(event) + + def connectButton(self, button): + if len(self.pressed_button) < 2: + return + + for i in range(len(self.pressed_button) - 1): + line = Arrow(self.pressed_button[i], self.pressed_button[i + 1], self) + self.scene.addItem(line) + self.signalList.append(line) + + self.update() + + def paintEvent(self, event): + for signal in self.signalList: + signal.moveLine() + +if __name__ == "__main__": + app = QApplication(sys.argv) + window = MainWindow() + window.show() + sys.exit(app.exec_()) diff --git a/b_asic/GUI/main_window.py b/b_asic/GUI/main_window.py new file mode 100644 index 0000000000000000000000000000000000000000..b65a118438b64ee9b6540bac5177b77cc9c2cf44 --- /dev/null +++ b/b_asic/GUI/main_window.py @@ -0,0 +1,414 @@ +"""@package docstring +B-ASIC GUI Module. +This python file is an example of how a GUI can be implemented +using buttons and textboxes. +""" + +import sys + +from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QLabel, QAction,\ +QStatusBar, QMenuBar, QLineEdit, QPushButton, QSlider, QScrollArea, QVBoxLayout,\ +QHBoxLayout, QDockWidget, QToolBar, QMenu +from PyQt5.QtCore import Qt, QSize, pyqtSlot +from PyQt5.QtGui import QIcon, QFont, QPainter, QPen, QColor + +from b_asic.core_operations import Addition + + +class DragButton(QPushButton): + def __init__(self, name, window, parent = None): + self.name = name + self.__menu = None + self.__window = window + self.counter = 0 + self.clicked = 0 + self.pressed = False + print("Constructor" + self.name) + super(DragButton, self).__init__(self.__window) + + self.__window.setContextMenuPolicy(Qt.CustomContextMenu) + self.__window.customContextMenuRequested.connect(self.create_menu) + + + @pyqtSlot(QAction) + def actionClicked(self, action): + print("Triggern "+ self.name, self.__menu.name) + #self.__window.check_for_remove_op(self.name) + + #def show_context_menu(self, point): + # show context menu + + + def create_menu(self, point): + self.counter += 1 + # create context menu + popMenu = MyMenu('Menu' + str(self.counter)) + popMenu.addAction(QAction('Add a signal', self)) + popMenu.addAction(QAction('Remove a signal', self)) + #action = QAction('Remove operation', self) + popMenu.addAction('Remove operation', lambda:self.removeAction(self)) + popMenu.addSeparator() + popMenu.addAction(QAction('Remove all signals', self)) + self.__window.menuList.append(popMenu) + #self.__window.actionList.append(action) + self.__menu = popMenu + self.pressed = False + self.__menu.exec_(self.__window.sender().mapToGlobal(point)) + self.__menu.triggered.connect(self.actionClicked) + + + def removeAction(self, op): + print(op.__menu.name, op.name) + op.remove() + + """This class is made to create a draggable button""" + + def mousePressEvent(self, event): + self._mouse_press_pos = None + self._mouse_move_pos = None + self.clicked += 1 + if self.clicked == 1: + self.pressed = True + self.setStyleSheet("background-color: grey; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + elif self.clicked == 2: + self.clicked = 0 + self.presseed = False + self.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + + if event.button() == Qt.LeftButton: + self._mouse_press_pos = event.globalPos() + self._mouse_move_pos = event.globalPos() + + super(DragButton, self).mousePressEvent(event) + + def mouseMoveEvent(self, event): + if event.buttons() == Qt.LeftButton: + cur_pos = self.mapToGlobal(self.pos()) + global_pos = event.globalPos() + diff = global_pos - self._mouse_move_pos + new_pos = self.mapFromGlobal(cur_pos + diff) + self.move(new_pos) + self.pressed = False + + self._mouse_move_pos = global_pos + + super(DragButton, self).mouseMoveEvent(event) + + def mouseReleaseEvent(self, event): + if self._mouse_press_pos is not None: + moved = event.globalPos() - self._mouse_press_pos + if moved.manhattanLength() > 3: + event.ignore() + return + + super(DragButton, self).mouseReleaseEvent(event) + + def remove(self): + self.deleteLater() + +class SubWindow(QWidget): + """Creates a sub window """ + def create_window(self, window_width, window_height): + """Creates a window + """ + parent = None + super(SubWindow, self).__init__(parent) + self.setWindowFlags(Qt.WindowStaysOnTopHint) + self.resize(window_width, window_height) + + +class MyMenu(QMenu): + def __init__(self, name, parent = None): + self.name = name + super(MyMenu, self).__init__() + + +class MainWindow(QMainWindow): + """Main window for the program""" + # pylint: disable=too-many-instance-attributes + # Eight is reasonable in this case. + def __init__(self, *args, **kwargs): + super(MainWindow, self).__init__(*args, **kwargs) + self.init_ui() + self.counter = 0 + self.operations = [] + self.menuList = [] + self.actionList = [] + + def init_ui(self): + self.setWindowTitle(" ") + self.setWindowIcon(QIcon('small_logo.png')) + self.create_operation_menu() + self.create_menu_bar() + self.setStatusBar(QStatusBar(self)) + + def create_operation_menu(self): + self.operation_box = QDockWidget("Operation Box", self) + self.operation_box.setAllowedAreas(Qt.LeftDockWidgetArea) + self.test = QToolBar(self) + self.operation_list = QMenuBar(self) + self.test.addWidget(self.operation_list) + self.test.setOrientation(Qt.Vertical) + self.operation_list.setStyleSheet("background-color:rgb(222,222,222); vertical") + basic_operations = self.operation_list.addMenu('Basic operations') + special_operations = self.operation_list.addMenu('Special operations') + + self.addition_menu_item = QAction('&Addition', self) + self.addition_menu_item.setStatusTip("Add addition operation to workspace") + self.addition_menu_item.triggered.connect(self.create_addition_operation) + basic_operations.addAction(self.addition_menu_item) + + self.subtraction_menu_item = QAction('&Subtraction', self) + self.subtraction_menu_item.setStatusTip("Add subtraction operation to workspace") + self.subtraction_menu_item.triggered.connect(self.create_subtraction_operation) + basic_operations.addAction(self.subtraction_menu_item) + + self.multiplication_menu_item = QAction('&Multiplication', self) + self.multiplication_menu_item.setStatusTip("Add multiplication operation to workspace") + self.multiplication_menu_item.triggered.connect(self.create_multiplication_operation) + basic_operations.addAction(self.multiplication_menu_item) + + self.division_menu_item = QAction('&Division', self) + self.division_menu_item.setStatusTip("Add division operation to workspace") + #self.division_menu_item.triggered.connect(self.create_division_operation) + basic_operations.addAction(self.division_menu_item) + + self.constant_menu_item = QAction('&Constant', self) + self.constant_menu_item.setStatusTip("Add constant operation to workspace") + #self.constant_menu_item.triggered.connect(self.create_constant_operation) + basic_operations.addAction(self.constant_menu_item) + + self.square_root_menu_item = QAction('&Square root', self) + self.square_root_menu_item.setStatusTip("Add square root operation to workspace") + #self.square_root_menu_item.triggered.connect(self.create_square_root_operation) + basic_operations.addAction(self.square_root_menu_item) + + self.complex_conjugate_menu_item = QAction('&Complex conjugate', self) + self.complex_conjugate_menu_item.setStatusTip("Add complex conjugate operation to workspace") + #self.complex_conjugate_menu_item.triggered.connect(self.create_complex_conjugate_operation) + basic_operations.addAction(self.complex_conjugate_menu_item) + + self.max_menu_item = QAction('&Max', self) + self.max_menu_item.setStatusTip("Add max operation to workspace") + #self.max_menu_item.triggered.connect(self.create_max_operation) + basic_operations.addAction(self.max_menu_item) + + self.min_menu_item = QAction('&Min', self) + self.min_menu_item.setStatusTip("Add min operation to workspace") + #self.min_menu_item.triggered.connect(self.create_min_operation) + basic_operations.addAction(self.min_menu_item) + + self.absolute_menu_item = QAction('&Absolute', self) + self.absolute_menu_item.setStatusTip("Add absolute operation to workspace") + #self.absolute_menu_item.triggered.connect(self.create_absolute_operation) + basic_operations.addAction(self.absolute_menu_item) + + self.constant_addition_menu_item = QAction('&Constant addition', self) + self.constant_addition_menu_item.setStatusTip("Add constant addition operation to workspace") + #self.constant_addition_menu_item.triggered.connect(self.create_constant_addition_operation) + basic_operations.addAction(self.constant_addition_menu_item) + + self.constant_subtraction_menu_item = QAction('&Constant subtraction', self) + self.constant_subtraction_menu_item.setStatusTip("Add constant subtraction operation to workspace") + #self.constant_subtraction_menu_item.triggered.connect(self.create_constant_subtraction_operation) + basic_operations.addAction(self.constant_subtraction_menu_item) + + self.constant_multiplication_menu_item = QAction('&Constant multiplication', self) + self.constant_multiplication_menu_item.setStatusTip("Add constant multiplication operation to workspace") + #self.constant_multiplication_menu_item.triggered.connect(self.create_constant_multiplication_operation) + basic_operations.addAction(self.constant_multiplication_menu_item) + + self.constant_division_menu_item = QAction('&Constant division', self) + self.constant_division_menu_item.setStatusTip("Add constant division operation to workspace") + #self.constant_division_menu_item.triggered.connect(self.create_constant_division_operation) + basic_operations.addAction(self.constant_division_menu_item) + + self.butterfly_menu_item = QAction('&Butterfly', self) + self.butterfly_menu_item.setStatusTip("Add butterfly operation to workspace") + #self.butterfly_menu_item.triggered.connect(self.create_butterfly_operation) + basic_operations.addAction(self.butterfly_menu_item) + + self.operation_box.setWidget(self.operation_list) + self.operation_box.setMaximumSize(240, 400) + self.operation_box.setFeatures(QDockWidget.NoDockWidgetFeatures) + self.operation_box.setFixedSize(300, 500) + self.operation_box.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px") + self.addDockWidget(Qt.LeftDockWidgetArea, self.operation_box) + + def create_addition_operation(self): + self.counter += 1 + + # Create drag button + addition_operation = DragButton("OP" + str(self.counter), self) + addition_operation.move(250, 100) + addition_operation.setFixedSize(50, 50) + addition_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + addition_operation.clicked.connect(self.create_sub_window) + #self.addition_operation.setIcon(QIcon("GUI'\'operation_icons'\'plus.png")) + addition_operation.setText("OP" + str(self.counter)) + addition_operation.setIconSize(QSize(50, 50)) + addition_operation.show() + self.operations.append(addition_operation) + + # set context menu policies + #self.addition_operation.setContextMenuPolicy(Qt.CustomContextMenu) + #self.addition_operation.customContextMenuRequested.connect(self.show_context_menu) + + #self.action.triggered.connect(lambda checked: self.remove(self.addition_operation.name)) + + def check_for_remove_op(self, name): + self.remove(name) + + + def remove(self, name): + for op in self.operations: + print(name, op.name) + if op.name == name: + self.operations.remove(op) + op.remove() + + def create_subtraction_operation(self): + self.subtraction_operation = DragButton("sub" + str(self.counter), self) + self.subtraction_operation.move(250, 100) + self.subtraction_operation.setFixedSize(50, 50) + self.subtraction_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.subtraction_operation.setIcon(QIcon("GUI'\'operation_icons'\'minus.png")) + self.subtraction_operation.setIconSize(QSize(50, 50)) + self.subtraction_operation.clicked.connect(self.create_sub_window) + self.subtraction_operation.show() + + # set context menu policies + self.subtraction_operation.setContextMenuPolicy(Qt.CustomContextMenu) + self.subtraction_operation.customContextMenuRequested.connect(self.show_context_menu) + + # create context menu + self.button_context_menu = QMenu(self) + self.button_context_menu.addAction(QAction('Add a signal', self)) + self.button_context_menu.addAction(QAction('Remove a signal', self)) + self.button_context_menu.addSeparator() + self.button_context_menu.addAction(QAction('Remove all signals', self)) + + def create_multiplication_operation(self): + self.multiplication_operation = DragButton(self) + self.multiplication_operation.move(250, 100) + self.multiplication_operation.setFixedSize(50, 50) + self.multiplication_operation.setStyleSheet("background-color: white; border-style: solid;\ + border-color: black; border-width: 2px; border-radius: 10px") + self.multiplication_operation.clicked.connect(self.create_sub_window) + self.multiplication_operation.setIcon(QIcon(r"GUI\operation_icons\plus.png")) + self.multiplication_operation.setIconSize(QSize(50, 50)) + self.multiplication_operation.show() + + # set context menu policies + self.multiplication_operation.setContextMenuPolicy(Qt.CustomContextMenu) + self.multiplication_operation.customContextMenuRequested.connect(self.show_context_menu) + + # create context menu + self.button_context_menu = QMenu(self) + self.button_context_menu.addAction(QAction('Add a signal', self)) + self.button_context_menu.addAction(QAction('Remove a signal', self)) + self.button_context_menu.addSeparator() + self.button_context_menu.addAction(QAction('Remove all signals', self)) + + + def create_menu_bar(self): + # Menu buttons + load_button = QAction("Load", self) + save_button = QAction("Save", self) + + exit_button = QAction("Exit", self) + exit_button.setShortcut("Ctrl+Q") + exit_button.triggered.connect(self.exit_app) + + edit_button = QAction("Edit", self) + edit_button.setStatusTip("Open edit menu") + edit_button.triggered.connect(self.on_edit_button_click) + + view_button = QAction("View", self) + view_button.setStatusTip("Open view menu") + view_button.triggered.connect(self.on_view_button_click) + + menu_bar = QMenuBar() + menu_bar.setStyleSheet("background-color:rgb(222, 222, 222)") + self.setMenuBar(menu_bar) + + file_menu = menu_bar.addMenu("&File") + file_menu.addAction(save_button) + file_menu.addSeparator() + file_menu.addAction(exit_button) + + edit_menu = menu_bar.addMenu("&Edit") + edit_menu.addAction(edit_button) + + edit_menu.addSeparator() + + view_menu = menu_bar.addMenu("&View") + view_menu.addAction(view_button) + + + def create_sub_window(self): + """ Example of how to create a sub window + """ + self.sub_window = SubWindow() + self.sub_window.create_window(400, 300) + self.sub_window.setWindowTitle("Properties") + + self.sub_window.properties_label = QLabel(self.sub_window) + self.sub_window.properties_label.setText('Properties') + self.sub_window.properties_label.setFixedWidth(400) + self.sub_window.properties_label.setFont(QFont('SansSerif', 14, QFont.Bold)) + self.sub_window.properties_label.setAlignment(Qt.AlignCenter) + + self.sub_window.name_label = QLabel(self.sub_window) + self.sub_window.name_label.setText('Name:') + self.sub_window.name_label.move(20, 40) + + self.sub_window.name_line = QLineEdit(self.sub_window) + self.sub_window.name_line.setPlaceholderText("Write a name here") + self.sub_window.name_line.move(70, 40) + self.sub_window.name_line.resize(100, 20) + + self.sub_window.id_label = QLabel(self.sub_window) + self.sub_window.id_label.setText('Id:') + self.sub_window.id_label.move(20, 70) + + self.sub_window.id_line = QLineEdit(self.sub_window) + self.sub_window.id_line.setPlaceholderText("Write an id here") + self.sub_window.id_line.move(70, 70) + self.sub_window.id_line.resize(100, 20) + + self.sub_window.show() + + def keyPressEvent(self, event): + for op in self.operations: + if event.key() == Qt.Key_Delete and op.pressed: + self.operations.remove(op) + op.remove() + + def on_file_button_click(self): + print("File") + + def on_edit_button_click(self): + print("Edit") + + def on_view_button_click(self): + print("View") + + def exit_app(self, checked): + QApplication.quit() + + def clicked(self): + print("Drag button clicked") + + +if __name__ == "__main__": + app = QApplication(sys.argv) + window = MainWindow() + window.resize(960, 720) + window.show() + app.exec_() diff --git a/b_asic/GUI/operation_icons/absolute.png b/b_asic/GUI/operation_icons/absolute.png new file mode 100644 index 0000000000000000000000000000000000000000..6573d4d96928d32a3a59641e877108ab60d38c19 Binary files /dev/null and b/b_asic/GUI/operation_icons/absolute.png differ diff --git a/b_asic/GUI/operation_icons/absolute_grey.png b/b_asic/GUI/operation_icons/absolute_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..4e16da3110d3497c7dab55b9cd9edf22aef4c097 Binary files /dev/null and b/b_asic/GUI/operation_icons/absolute_grey.png differ diff --git a/b_asic/GUI/operation_icons/addition.png b/b_asic/GUI/operation_icons/addition.png new file mode 100644 index 0000000000000000000000000000000000000000..504e641e4642d9c03deeea9911927bbe714f053e Binary files /dev/null and b/b_asic/GUI/operation_icons/addition.png differ diff --git a/b_asic/GUI/operation_icons/addition_grey.png b/b_asic/GUI/operation_icons/addition_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..a7620d2b56c8a5d06b2c04ff994eb334777008f4 Binary files /dev/null and b/b_asic/GUI/operation_icons/addition_grey.png differ diff --git a/b_asic/GUI/operation_icons/butterfly.png b/b_asic/GUI/operation_icons/butterfly.png new file mode 100644 index 0000000000000000000000000000000000000000..9948a964d353e7325c696ae7f12e1ded09cdc13f Binary files /dev/null and b/b_asic/GUI/operation_icons/butterfly.png differ diff --git a/b_asic/GUI/operation_icons/butterfly_grey.png b/b_asic/GUI/operation_icons/butterfly_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..cc282efe67637dda8b5e76b0f4c35015b19ddd93 Binary files /dev/null and b/b_asic/GUI/operation_icons/butterfly_grey.png differ diff --git a/b_asic/GUI/operation_icons/complex_conjugate.png b/b_asic/GUI/operation_icons/complex_conjugate.png new file mode 100644 index 0000000000000000000000000000000000000000..c74c9de7f45c16b972ddc072e5e0203dcb902f1b Binary files /dev/null and b/b_asic/GUI/operation_icons/complex_conjugate.png differ diff --git a/b_asic/GUI/operation_icons/complex_conjugate_grey.png b/b_asic/GUI/operation_icons/complex_conjugate_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..33f1e60e686cb711644a875341c34a12b8dfe4c9 Binary files /dev/null and b/b_asic/GUI/operation_icons/complex_conjugate_grey.png differ diff --git a/b_asic/GUI/operation_icons/constant.png b/b_asic/GUI/operation_icons/constant.png new file mode 100644 index 0000000000000000000000000000000000000000..0068adae8130f7b384f7fd70277fb8f87d9dbf94 Binary files /dev/null and b/b_asic/GUI/operation_icons/constant.png differ diff --git a/b_asic/GUI/operation_icons/constant_grey.png b/b_asic/GUI/operation_icons/constant_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..d7d3e585e21e70aa8b89b85008e5306184ccff8c Binary files /dev/null and b/b_asic/GUI/operation_icons/constant_grey.png differ diff --git a/b_asic/GUI/operation_icons/constant_multiplication.png b/b_asic/GUI/operation_icons/constant_multiplication.png new file mode 100644 index 0000000000000000000000000000000000000000..7e7ff82b3aa577886da6686f62df936e8aa3572e Binary files /dev/null and b/b_asic/GUI/operation_icons/constant_multiplication.png differ diff --git a/b_asic/GUI/operation_icons/constant_multiplication_grey.png b/b_asic/GUI/operation_icons/constant_multiplication_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..8fe92d2606b8bc1c2bce98ed45cccb6236e36476 Binary files /dev/null and b/b_asic/GUI/operation_icons/constant_multiplication_grey.png differ diff --git a/b_asic/GUI/operation_icons/custom_operation.png b/b_asic/GUI/operation_icons/custom_operation.png new file mode 100644 index 0000000000000000000000000000000000000000..a598abaaf05934222c457fc8b141431ca04f91be Binary files /dev/null and b/b_asic/GUI/operation_icons/custom_operation.png differ diff --git a/b_asic/GUI/operation_icons/custom_operation_grey.png b/b_asic/GUI/operation_icons/custom_operation_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..a1d72e3b7f67fb78acccf8f5fb417be62cbc2b2a Binary files /dev/null and b/b_asic/GUI/operation_icons/custom_operation_grey.png differ diff --git a/b_asic/GUI/operation_icons/division.png b/b_asic/GUI/operation_icons/division.png new file mode 100644 index 0000000000000000000000000000000000000000..d7bf8908ed0acae344dc04adf6a96ae8448bb9d4 Binary files /dev/null and b/b_asic/GUI/operation_icons/division.png differ diff --git a/b_asic/GUI/operation_icons/division_grey.png b/b_asic/GUI/operation_icons/division_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..de3a82c369dde1b6a28ea93e5362e6eb8879fe68 Binary files /dev/null and b/b_asic/GUI/operation_icons/division_grey.png differ diff --git a/b_asic/GUI/operation_icons/input.png b/b_asic/GUI/operation_icons/input.png new file mode 100644 index 0000000000000000000000000000000000000000..ebfd1a23e5723496e69f02bebc959d68e3c2f986 Binary files /dev/null and b/b_asic/GUI/operation_icons/input.png differ diff --git a/b_asic/GUI/operation_icons/input_grey.png b/b_asic/GUI/operation_icons/input_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..07d3362f93039ca65966bc04d0ea481840072559 Binary files /dev/null and b/b_asic/GUI/operation_icons/input_grey.png differ diff --git a/b_asic/GUI/operation_icons/max.png b/b_asic/GUI/operation_icons/max.png new file mode 100644 index 0000000000000000000000000000000000000000..1f759155f632e090a5dea49644f8dbc5dff7b4f4 Binary files /dev/null and b/b_asic/GUI/operation_icons/max.png differ diff --git a/b_asic/GUI/operation_icons/max_grey.png b/b_asic/GUI/operation_icons/max_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..8179fb2e812cc617a012a1fb3d338e1c99e07aa7 Binary files /dev/null and b/b_asic/GUI/operation_icons/max_grey.png differ diff --git a/b_asic/GUI/operation_icons/min.png b/b_asic/GUI/operation_icons/min.png new file mode 100644 index 0000000000000000000000000000000000000000..5365002a74b91d91e40c95091ab8c052cfe3f3c5 Binary files /dev/null and b/b_asic/GUI/operation_icons/min.png differ diff --git a/b_asic/GUI/operation_icons/min_grey.png b/b_asic/GUI/operation_icons/min_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..6978cd91288a9d5705903efb017e2dc3b42b1af1 Binary files /dev/null and b/b_asic/GUI/operation_icons/min_grey.png differ diff --git a/b_asic/GUI/operation_icons/multiplication.png b/b_asic/GUI/operation_icons/multiplication.png new file mode 100644 index 0000000000000000000000000000000000000000..2042dd16781e64ea97ed5323b79f4f310f760009 Binary files /dev/null and b/b_asic/GUI/operation_icons/multiplication.png differ diff --git a/b_asic/GUI/operation_icons/multiplication_grey.png b/b_asic/GUI/operation_icons/multiplication_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..00e2304b634e02810d6a17aa2850c9afe4922eb9 Binary files /dev/null and b/b_asic/GUI/operation_icons/multiplication_grey.png differ diff --git a/b_asic/GUI/operation_icons/output.png b/b_asic/GUI/operation_icons/output.png new file mode 100644 index 0000000000000000000000000000000000000000..e7da51bbe3640b03b9f7d89f9dd90543c3022273 Binary files /dev/null and b/b_asic/GUI/operation_icons/output.png differ diff --git a/b_asic/GUI/operation_icons/output_grey.png b/b_asic/GUI/operation_icons/output_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..2cde317beecf019db5c4eac2a35baa8ef8e99f5e Binary files /dev/null and b/b_asic/GUI/operation_icons/output_grey.png differ diff --git a/b_asic/GUI/operation_icons/register.png b/b_asic/GUI/operation_icons/register.png new file mode 100644 index 0000000000000000000000000000000000000000..f294072fc6d3b3567d8252aee881d035aa4913eb Binary files /dev/null and b/b_asic/GUI/operation_icons/register.png differ diff --git a/b_asic/GUI/operation_icons/register_grey.png b/b_asic/GUI/operation_icons/register_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..88af5760169b161fdd7aa5dce7c61cdb13b69231 Binary files /dev/null and b/b_asic/GUI/operation_icons/register_grey.png differ diff --git a/b_asic/GUI/operation_icons/square_root.png b/b_asic/GUI/operation_icons/square_root.png new file mode 100644 index 0000000000000000000000000000000000000000..8160862b675680bb5fc2f31a0a5f870b73352bbb Binary files /dev/null and b/b_asic/GUI/operation_icons/square_root.png differ diff --git a/b_asic/GUI/operation_icons/square_root_grey.png b/b_asic/GUI/operation_icons/square_root_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..4353217de9c38d665f1364a7f7c501c444232abc Binary files /dev/null and b/b_asic/GUI/operation_icons/square_root_grey.png differ diff --git a/b_asic/GUI/operation_icons/subtraction.png b/b_asic/GUI/operation_icons/subtraction.png new file mode 100644 index 0000000000000000000000000000000000000000..73db57daf9984fd1c1eb0775a1e0535b786396a8 Binary files /dev/null and b/b_asic/GUI/operation_icons/subtraction.png differ diff --git a/b_asic/GUI/operation_icons/subtraction_grey.png b/b_asic/GUI/operation_icons/subtraction_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..8b32557a56f08e27adcd028f080d517f6ce5bdf2 Binary files /dev/null and b/b_asic/GUI/operation_icons/subtraction_grey.png differ