Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • da/B-ASIC
  • lukja239/B-ASIC
  • robal695/B-ASIC
3 results
Show changes
Commits on Source (115)
Showing
with 1444 additions and 36 deletions
.vs/
.vscode/
build*/
bin*/
logs/
dist/
CMakeLists.txt.user*
*.autosave
*.creator
*.creator.user*
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
*~
.fuse_hudden*
.directory
.Trash-*
.nfs*
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
$RECYCLE.BIN/
*.stackdump
[Dd]esktop.ini
*.egg-info
__pycache__/
env/
.vs/
.vscode/
build*/
bin*/
logs/
dist/
CMakeLists.txt.user*
*.autosave
*.creator
*.creator.user*
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
*~
.fuse_hudden*
.directory
.Trash-*
.nfs*
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
$RECYCLE.BIN/
*.stackdump
[Dd]esktop.ini
*.egg-info
__pycache__/
env/
venv/
\ No newline at end of file
......@@ -8,16 +8,26 @@ How to build and debug the library during development.
### Prerequisites
The following packages are required in order to build the library:
* cmake 3.8+
* C++:
* cmake 3.8+
* gcc 7+/clang 7+/msvc 16+
* fmtlib 5.2.1+
* pybind11 2.3.0+
* python 3.6+
* Python:
* python 3.6+
* setuptools
* wheel
* pybind11
* numpy
* pyside2/pyqt5
* pyside2
To build a binary distribution, the following additional packages are required:
* Python:
* wheel
To run the test suite, the following additional packages are required:
* Python:
* pytest
* pytest-cov (for testing with coverage)
### Using CMake directly
How to build using CMake.
......
"""TODO"""
from drag_button import *
from improved_main_window import *
from gui_interface import *
from PySide2.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 PySide2.QtCore import Qt, QSize, QLineF, QPoint, QRectF
from PySide2.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.operation.x()+self.source.x()+14,\
self.source.operation.y()+self.source.y()+7.5,\
self.destination.operation.x()+self.destination.x(),\
self.destination.operation.y()+self.destination.y()+7.5))
"""@package docstring
Drag button class.
This class creates a dragbutton which can be clicked, dragged and dropped.
"""
import os.path
from properties_window import PropertiesWindow
from PySide2.QtWidgets import QPushButton, QMenu, QAction
from PySide2.QtCore import Qt, QSize, Signal
from PySide2.QtGui import QIcon
from utils import decorate_class, handle_error
@decorate_class(handle_error)
class DragButton(QPushButton):
connectionRequested = Signal(QPushButton)
moved = Signal()
def __init__(self, name, operation, operation_path_name, is_show_name, window, parent = None):
self.name = name
self.is_show_name = is_show_name
self._window = window
self.operation = operation
self.operation_path_name = operation_path_name
self.clicked = 0
self.pressed = False
self._mouse_press_pos = None
self._mouse_move_pos = None
super(DragButton, self).__init__(self._window)
def contextMenuEvent(self, event):
menu = QMenu()
properties = QAction("Properties")
menu.addAction(properties)
properties.triggered.connect(self.show_properties_window)
menu.exec_(self.cursor().pos())
def show_properties_window(self, event):
self.properties_window = PropertiesWindow(self, self._window)
self.properties_window.show()
def add_label(self, label):
self.label = label
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self._mouse_press_pos = event.pos()
self._mouse_move_pos = event.pos()
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")
path_to_image = os.path.join('operation_icons', self.operation_path_name + '_grey.png')
self.setIcon(QIcon(path_to_image))
self.setIconSize(QSize(55, 55))
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")
path_to_image = os.path.join('operation_icons', self.operation_path_name + '.png')
self.setIcon(QIcon(path_to_image))
self.setIconSize(QSize(55, 55))
self._window.pressed_button.remove(self)
super(DragButton, self).mousePressEvent(event)
def mouseMoveEvent(self, event):
if event.buttons() == Qt.LeftButton:
self.move(self.mapToParent(event.pos() - self._mouse_press_pos))
self._window.update()
super(DragButton, self).mouseMoveEvent(event)
def mouseReleaseEvent(self, event):
if self._mouse_press_pos is not None:
moved = event.pos() - 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
# -*- 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 PySide2 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")
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")
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)
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)
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_())
<?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>
"""@package docstring
B-ASIC GUI Module.
This python file is the main window of the GUI for B-ASIC.
"""
from os import getcwd, path
import sys
from drag_button import DragButton
from gui_interface import Ui_main_window
from arrow import Arrow
from port_button import PortButton
from b_asic import Operation
import b_asic.core_operations as c_oper
import b_asic.special_operations as s_oper
from utils import decorate_class, handle_error
from numpy import linspace
from PySide2.QtWidgets import QApplication, QWidget, QMainWindow, QLabel, QAction,\
QStatusBar, QMenuBar, QLineEdit, QPushButton, QSlider, QScrollArea, QVBoxLayout,\
QHBoxLayout, QDockWidget, QToolBar, QMenu, QLayout, QSizePolicy, QListWidget,\
QListWidgetItem, QGraphicsView, QGraphicsScene, QShortcut, QGraphicsTextItem,\
QGraphicsProxyWidget
from PySide2.QtCore import Qt, QSize
from PySide2.QtGui import QIcon, QFont, QPainter, QPen, QBrush, QKeySequence
MIN_WIDTH_SCENE = 600
MIN_HEIGHT_SCENE = 520
@decorate_class(handle_error)
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._operations_from_name = dict()
self.zoom = 1
self.operationList = []
self.signalList = []
self.pressed_button = []
self.portList = []
self.pressed_ports = []
self.source = None
self._window = self
self.init_ui()
self.add_operations_from_namespace(c_oper, self.ui.core_operations_list)
self.add_operations_from_namespace(s_oper, self.ui.special_operations_list)
self.shortcut_core = QShortcut(QKeySequence("Ctrl+R"), self.ui.operation_box)
self.shortcut_core.activated.connect(self._refresh_operations_list_from_namespace)
self.move_button_index = 0
self.is_show_names = True
self.check_show_names = QAction("Show operation names")
self.check_show_names.triggered.connect(self.view_operation_names)
self.check_show_names.setCheckable(True)
self.check_show_names.setChecked(1)
self.ui.view_menu.addAction(self.check_show_names)
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(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.setDragMode(QGraphicsView.ScrollHandDrag)
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())
super(MainWindow, self).resizeEvent(event)
def wheelEvent(self, event):
if event.modifiers() == Qt.ControlModifier:
old_zoom = self.zoom
self.zoom += event.angleDelta().y()/2500
self.graphic_view.scale(self.zoom, self.zoom)
self.zoom = old_zoom
def view_operation_names(self, event):
if self.check_show_names.isChecked():
self.is_show_names = True
else:
self.is_show_names = False
for operation in self.operationList:
operation.label.setOpacity(self.is_show_names)
operation.is_show_name = self.is_show_names
def exit_app(self, checked):
QApplication.quit()
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.
"""
return [length / 2] if ports == 1 else linspace(0, length, ports)
def _create_port(self, operation, output_port=True):
text = ">" if output_port else "<"
button = PortButton(text, operation, self)
button.setStyleSheet("background-color: white")
button.connectionRequested.connect(self.connectButton)
return button
def add_ports(self, operation):
_output_ports_dist = self._determine_port_distance(55 - 17, operation.operation.output_count)
_input_ports_dist = self._determine_port_distance(55 - 17, operation.operation.input_count)
for dist in _input_ports_dist:
port = self._create_port(operation)
port.move(0, dist)
port.show()
for dist in _output_ports_dist:
port = self._create_port(operation)
port.move(55 - 12, dist)
port.show()
def get_operations_from_namespace(self, namespace):
return [comp for comp in dir(namespace) if hasattr(getattr(namespace, comp), "type_name")]
def add_operations_from_namespace(self, namespace, _list):
for attr_name in self.get_operations_from_namespace(namespace):
attr = getattr(namespace, attr_name)
try:
attr.type_name()
item = QListWidgetItem(attr_name)
_list.addItem(item)
self._operations_from_name[attr_name] = attr
except NotImplementedError:
pass
def _create_operation(self, item):
try:
attr_oper = self._operations_from_name[item.text()]()
attr_button = DragButton(attr_oper.graph_id, attr_oper, attr_oper.type_name().lower(), True, self)
attr_button.move(250, 100)
attr_button.setFixedSize(55, 55)
attr_button.setStyleSheet("background-color: white; border-style: solid;\
border-color: black; border-width: 2px")
self.add_ports(attr_button)
icon_path = path.join("operation_icons", f"{attr_oper.type_name().lower()}.png")
if not path.exists(icon_path):
icon_path = path.join("operation_icons", f"custom_operation.png")
attr_button.setIcon(QIcon(icon_path))
attr_button.setIconSize(QSize(55, 55))
attr_button.setParent(None)
attr_button_scene = self.scene.addWidget(attr_button)
attr_button_scene.moveBy(self.move_button_index * 100, 0)
self.move_button_index += 1
operation_label = QGraphicsTextItem(attr_oper.type_name(), attr_button_scene)
if not self.is_show_names:
operation_label.setOpacity(0)
operation_label.setTransformOriginPoint(operation_label.boundingRect().center())
operation_label.moveBy(10, -20)
attr_button.add_label(operation_label)
self.operationList.append(attr_button)
except Exception as e:
print("Unexpected error occured: ", e)
def _refresh_operations_list_from_namespace(self):
self.ui.core_operations_list.clear()
self.ui.special_operations_list.clear()
self.add_operations_from_namespace(c_oper, self.ui.core_operations_list)
self.add_operations_from_namespace(s_oper, self.ui.special_operations_list)
def on_list_widget_item_clicked(self, item):
self._create_operation(item)
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()
self.move_button_index -= 1
super().keyPressEvent(event)
def connectButton(self, button):
if len(self.pressed_ports) < 2:
return
for i in range(len(self.pressed_ports) - 1):
line = Arrow(self.pressed_ports[i], self.pressed_ports[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_())
b_asic/GUI/operation_icons/abs.png

1.22 KiB

b_asic/GUI/operation_icons/abs_grey.png

1.34 KiB

b_asic/GUI/operation_icons/add.png

1.18 KiB

b_asic/GUI/operation_icons/add_grey.png

1.27 KiB

b_asic/GUI/operation_icons/bfly.png

5.23 KiB

b_asic/GUI/operation_icons/bfly_grey.png

5.02 KiB

b_asic/GUI/operation_icons/c.png

5.08 KiB

b_asic/GUI/operation_icons/c_grey.png

4.9 KiB

b_asic/GUI/operation_icons/cmul.png

3.52 KiB

b_asic/GUI/operation_icons/cmul_grey.png

3.76 KiB

b_asic/GUI/operation_icons/conj.png

3.9 KiB

b_asic/GUI/operation_icons/conj_grey.png

3.8 KiB