Skip to content
Snippets Groups Projects
Commit 897299d0 authored by Andreas Bolin's avatar Andreas Bolin
Browse files

workspace dump

parent 029b3a68
No related branches found
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #73420 passed
......@@ -69,7 +69,7 @@ class GraphicsAxesItem(QGraphicsItemGroup):
width_padding: Optional[float] = 0.6, height_padding: Optional[float] = 0.5,
parent: Optional[QGraphicsItem] = None):
"""Constructs a GraphicsAxesItem. 'parent' is passed to QGraphicsItemGroup's constructor."""
super().__init__(parent)
super().__init__(parent=parent)
assert width >= 0, f"'width' greater or equal to 0 expected, got: {width}."
assert height >= 0, f"'height' greater or equal to 0 expected, got: {height}."
......
......@@ -56,7 +56,7 @@ class GraphicsComponentItem(QGraphicsItemGroup):
def __init__(self, op_id: str, latency_offsets: Dict[str, int], execution_time: Optional[int] = None, height: float = 0.75, parent: Optional[QGraphicsItem] = None):
"""Constructs a GraphicsComponentItem. 'parent' is passed to QGraphicsItemGroup's constructor."""
super().__init__(parent)
super().__init__(parent=parent)
self._op_id = op_id
self._height = height
self._ports = {k:{'latency':float(v)} for k,v in latency_offsets.items()}
......
......@@ -45,7 +45,7 @@ from graphics_timeline_item import GraphicsTimelineItem
# sys.settrace
# class GraphicsGraphEvent(QGraphicsItemGroup, QObject): # PySide2
class GraphicsGraphEvent(): # PyQt5
class GraphicsGraphEvent: # PyQt5
"""Event filter and handlers for GraphicsGraphItem"""
class Signals(QObject): # PyQt5
"""A class respresenting signals."""
......@@ -55,7 +55,7 @@ class GraphicsGraphEvent(): # PyQt5
_axes: GraphicsAxesItem
_current_pos: QPointF
_delta_time: int
signals: Signals # PyQt5
_signals: Signals # PyQt5
# component_selected = Signal(str) # PySide2
# schedule_time_changed = Signal() # PySide2
......@@ -74,8 +74,8 @@ class GraphicsGraphEvent(): # PyQt5
def __init__(self, parent: Optional[QGraphicsItem] = None): # PyQt5
# QGraphicsItemGroup.__init__(self, parent)
# QObject.__init__(self)
super().__init__()
self.signals = self.Signals()
super().__init__(parent=parent)
self._signals = self.Signals()
#################
#### Filters ####
......@@ -196,7 +196,7 @@ class GraphicsGraphEvent(): # PyQt5
by default be accepted, and this item is then the mouse grabber. This
allows the item to receive future move, release and double-click events."""
item: GraphicsComponentItem = self.scene().mouseGrabberItem()
self.signals.component_selected.emit(item.op_id)
self._signals.component_selected.emit(item.op_id)
# self.component_selected.emit(item.op_id)
self._current_pos = item.mapToParent(event.pos())
item.setCursor(QCursor(Qt.ClosedHandCursor))
......@@ -258,4 +258,4 @@ class GraphicsGraphEvent(): # PyQt5
item.hide_label()
if self._delta_time != 0:
self.set_schedule_time(self._delta_time)
self.signals.schedule_time_changed.emit()
self._signals.schedule_time_changed.emit()
......@@ -47,8 +47,8 @@ from graphics_axes_item import GraphicsAxesItem
from graphics_graph_event import GraphicsGraphEvent
# class GraphicsGraphItem(GraphicsGraphEvent, QGraphicsItemGroup): # PySide2 / PyQt5
class GraphicsGraphItem(QGraphicsItemGroup, GraphicsGraphEvent): # PyQt5
class GraphicsGraphItem(GraphicsGraphEvent, QGraphicsItemGroup): # PySide2 / PyQt5
# class GraphicsGraphItem(QGraphicsItemGroup, GraphicsGraphEvent): # PyQt5
"""A class to represent a graph in a QGraphicsScene. This class is a
subclass of QGraphicsItemGroup and contains the objects, axes from
GraphicsAxesItem, as well as components from GraphicsComponentItem. It
......@@ -64,8 +64,13 @@ class GraphicsGraphItem(QGraphicsItemGroup, GraphicsGraphEvent): # PyQt5
def __init__(self, schedule: Schedule, parent: Optional[QGraphicsItem] = None):
"""Constructs a GraphicsGraphItem. 'parent' is passed to QGraphicsItemGroup's constructor."""
# super().__init__(parent)
super().__init__()
# QGraphicsItemGroup.__init__(self, self)
# GraphicsGraphEvent.__init__(self)
super().__init__(parent=parent)
# if isinstance(parent, QGraphicsItem):
# super().__init__(parent=parent)
# else:
# super().__init__(parent=self)
self._schedule = schedule
self._axes = None
self._components = []
......@@ -162,3 +167,5 @@ class GraphicsGraphItem(QGraphicsItemGroup, GraphicsGraphEvent): # PyQt5
for component in self._components:
self.addToGroup(component)
# self.addToGroup(self._components)
pprint(GraphicsGraphItem.__mro__)
\ No newline at end of file
......@@ -51,12 +51,12 @@ class GraphicsTimelineItem(QGraphicsLineItem):
QGraphicsLineItem's constructor."""
...
@overload
def __init__(self, parent:Optional[QGraphicsItem] = None) -> None:
def __init__(self, parent: Optional[QGraphicsItem] = None) -> None:
"""Constructs a GraphicsTimelineItem. 'parent' is passed to
QGraphicsLineItem's constructor."""
...
@overload
def __init__(self, x1: float, y1: float, x2: float, y2: float, parent:Optional[QGraphicsItem] = None) -> None:
def __init__(self, x1: float, y1: float, x2: float, y2: float, parent: Optional[QGraphicsItem] = None) -> None:
"""Constructs a GraphicsTimelineItem from (x1, y1) to (x2, y2). 'parent' is
passed to QGraphicsLineItem's constructor."""
...
......
......@@ -247,8 +247,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
"""SLOT() for SIGNAL(menu_close_schedule.triggered)
Closes current schedule."""
if self._graph:
self._graph.signals.component_selected.disconnect(self.info_table_update_component)
self._graph.signals.schedule_time_changed.disconnect(self.info_table_update_schedule)
self._graph._signals.component_selected.disconnect(self.info_table_update_component)
self._graph._signals.schedule_time_changed.disconnect(self.info_table_update_schedule)
self._graph.removeSceneEventFilters(self._graph.event_items)
self._scene.removeItem(self._graph)
self.menu_close_schedule.setEnabled(False)
......@@ -316,7 +316,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
@Slot(str)
def info_table_update_component(self, op_id: str) -> None:
"""SLOT(str) for SIGNAL(_graph.signals.component_selected)
"""SLOT(str) for SIGNAL(_graph._signals.component_selected)
Taked in an operator-id, first clears the 'Operator' part of the info
table and then fill in the table with new values from the operator
associated with 'op_id'."""
......@@ -325,7 +325,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
@Slot()
def info_table_update_schedule(self) -> None:
"""SLOT() for SIGNAL(_graph.signals.schedule_time_changed)
"""SLOT() for SIGNAL(_graph._signals.schedule_time_changed)
Updates the 'Schedule' part of the info table."""
self.info_table.item(1, 1).setText(str(self.schedule.schedule_time))
......@@ -395,8 +395,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.menu_close_schedule.setEnabled(True)
self._scene.addItem(self._graph)
self._graph.installSceneEventFilters(self._graph.event_items)
self._graph.signals.component_selected.connect(self.info_table_update_component)
self._graph.signals.schedule_time_changed.connect(self.info_table_update_schedule)
self._graph._signals.component_selected.connect(self.info_table_update_component)
self._graph._signals.schedule_time_changed.connect(self.info_table_update_schedule)
self.info_table_fill_schedule(self.schedule)
self.update_statusbar(self.tr('Schedule loaded successfully'))
......
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