Skip to content
Snippets Groups Projects
Commit dcfcac9f authored by Adam Jakobsson's avatar Adam Jakobsson
Browse files

visualize creating sgf by hover over an operation to se which sfg it's...

visualize creating sgf by hover over an operation to se which sfg it's containing or if it's belongs to a sfg
parent 3612b8b1
Branches operationspc2
No related tags found
1 merge request!52Resolve "Create SFG in GUI"
Pipeline #15448 passed
......@@ -39,6 +39,8 @@ class DragButton(QPushButton):
self.pressed = True
self.setStyleSheet("background-color: grey; border-style: solid;\
border-color: black; border-width: 2px; border-radius: 10px")
self.setStyleSheet(""" QToolTip { background-color: white;
color: black }""")
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))
......@@ -49,6 +51,8 @@ class DragButton(QPushButton):
self.pressed = False
self.setStyleSheet("background-color: white; border-style: solid;\
border-color: black; border-width: 2px; border-radius: 10px")
self.setStyleSheet(""" QToolTip { background-color: white;
color: black}""")
path_to_image = os.path.join('operation_icons', self.operation_path_name + '.png')
self.setIcon(QIcon(path_to_image))
self.setIconSize(QSize(50, 50))
......
......@@ -24,8 +24,8 @@ from numpy import linspace
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, QShortcut, QGraphicsRectItem
from PyQt5.QtCore import Qt, QSize, QRectF, QPoint
QListWidgetItem, QGraphicsView, QGraphicsScene, QShortcut, QToolTip
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QIcon, QFont, QPainter, QPen, QBrush, QKeySequence
......@@ -40,13 +40,13 @@ class MainWindow(QMainWindow):
self.scene = None
self._operations_from_name = dict()
self.zoom = 1
self.sfg_name_i = 0
self.operationList = []
self.signalList = []
self.pressed_operations = []
self.portList = []
self.pressed_ports = []
self.sfg_list = []
self.rect_list = []
self.source = None
self._window = self
......@@ -92,32 +92,13 @@ class MainWindow(QMainWindow):
inputs.append(op.operation)
elif isinstance(op.operation, s_oper.Output):
outputs.append(op.operation)
sfg = SFG(inputs=inputs, outputs=outputs)
self.create_rect()
self.sfg_name_i += 1
sfg = SFG(inputs=inputs, outputs=outputs, name="sfg" + str(self.sfg_name_i))
for op in self.pressed_operations:
op.setToolTip(sfg.name)
self.sfg_list.append(sfg)
def create_rect(self):
x_min = math.inf
y_min = math.inf
x_max = 0
y_max = 0
for op in self.pressed_operations:
if op.x() <= x_min:
x_min = op.x()
if op.y() <= y_min:
y_min = op.y()
if op.x() >= x_max:
x_max = op.x()
if op.y() >= y_max:
y_max = op.y()
point1 = QPoint(x_min-10, y_min-10)
point2 = QPoint(x_max+60, y_max+60)
rect = QRectF(point1, point2)
rect_item = QGraphicsRectItem(rect)
self.scene.addItem(rect_item)
self.rect_list.append(rect_item)
def _determine_port_distance(self, length, ports):
"""Determine the distance between each port on the side of an operation.
......@@ -176,6 +157,11 @@ class MainWindow(QMainWindow):
attr_button.setIcon(QIcon(icon_path))
attr_button.setIconSize(QSize(50, 50))
attr_button.setToolTip("No sfg")
attr_button.setStyleSheet(""" QToolTip { background-color: white;
color: black }""")
attr_button.setParent(None)
self.scene.addWidget(attr_button)
self.operationList.append(attr_button)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment