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

workspace dump

parent adb9740d
No related branches found
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #73095 passed
...@@ -30,29 +30,30 @@ from qtpy.QtCore import ( ...@@ -30,29 +30,30 @@ from qtpy.QtCore import (
# B-ASIC # B-ASIC
import logger import logger
from graphics_graph_event import GraphicsGraphEvent
class GraphicsAxis(QGraphicsItemGroup): class GraphicsAxisItem(QGraphicsItemGroup, GraphicsGraphEvent):
_scale: float = 1.0 _scale: float = 1.0 # static, changed from MainWindow
_width: float _width: float
_height: float _height: float
_x_indent: float _dy_height: float
_axis: dict[str: Any] _x_indent: float
Type: int _axis: dict[str, QGraphicsItemGroup|QGraphicsLineItem]
def __init__(self, width: float = 10.0, height: float = 10.0, x_indent: float = 2.0, parent: QGraphicsItem = None): def __init__(self, width: float = 10.0, height: float = 10.0, x_indent: float = 2.0, parent: QGraphicsItem = None):
super().__init__(parent) super().__init__(parent)
self._dy_height = 5/self._scale
self._axis = {} self._axis = {}
self.Type = 10 # QGraphicsItemGroup.Type == 10 self.setFlag(QGraphicsItem.ItemIsMovable)
self.setFlag(QGraphicsItem.ItemIsSelectable)
self.setAcceptHoverEvents(True)
self.update(width, height, x_indent) self.update(width, height, x_indent)
def type(self) -> int:
return self.Type
@property @property
def width(self) -> float: def width(self) -> float:
...@@ -89,7 +90,12 @@ class GraphicsAxis(QGraphicsItemGroup): ...@@ -89,7 +90,12 @@ class GraphicsAxis(QGraphicsItemGroup):
self._axis[key].setParentItem(None) self._axis[key].setParentItem(None)
del self._axis[key] del self._axis[key]
pen = QPen(Qt.SolidPattern, 2/self._scale, j = Qt.MiterJoin) # define pencils
pen = QPen()
pen.setWidthF(2/self._scale)
pen.setJoinStyle(Qt.MiterJoin)
ledger_pen = QPen(Qt.lightGray)
ledger_pen.setWidthF(0) # 0 = cosmetic pen 1px width
# x-axis # x-axis
self._axis['x'] = QGraphicsItemGroup() self._axis['x'] = QGraphicsItemGroup()
...@@ -104,15 +110,17 @@ class GraphicsAxis(QGraphicsItemGroup): ...@@ -104,15 +110,17 @@ class GraphicsAxis(QGraphicsItemGroup):
polygon = QPolygonF([p0, p1, p2]) polygon = QPolygonF([p0, p1, p2])
arrow = QGraphicsPolygonItem(polygon) arrow = QGraphicsPolygonItem(polygon)
arrow.setPen(pen) arrow.setPen(pen)
arrow.setBrush(Qt.SolidPattern) arrow.setBrush(QBrush(Qt.SolidPattern))
arrow.setPos(self._width, 0) arrow.setPos(self._width, 0)
self._axis['x'].addToGroup(arrow) self._axis['x'].addToGroup(arrow)
# x-axis scale # x-axis scale
x_scale = [] x_scale = []
x_scale_labels = [] x_scale_labels = []
x_ledger = []
self._axis['x_ledger'] = QGraphicsItemGroup()
for i in range(int(self._width/10) + 1): for i in range(int(self._width/10) + 1):
# vertical x-scale # vertical x-scale
x_scale.append(QGraphicsLineItem(0, -0.5, 0, 0.5)) x_scale.append(QGraphicsLineItem(0, 0, 0, 0.5))
x_scale[i].setPen(pen) x_scale[i].setPen(pen)
x_scale[i].setPos(self._x_indent + i*10, 0) x_scale[i].setPos(self._x_indent + i*10, 0)
self._axis['x'].addToGroup(x_scale[i]) self._axis['x'].addToGroup(x_scale[i])
...@@ -122,6 +130,15 @@ class GraphicsAxis(QGraphicsItemGroup): ...@@ -122,6 +130,15 @@ class GraphicsAxis(QGraphicsItemGroup):
half_width = x_scale_labels[i].boundingRect().width()/(2*self._scale) half_width = x_scale_labels[i].boundingRect().width()/(2*self._scale)
x_scale_labels[i].setPos(self._x_indent + i*10 - half_width, 0.8) x_scale_labels[i].setPos(self._x_indent + i*10 - half_width, 0.8)
self._axis['x'].addToGroup(x_scale_labels[i]) self._axis['x'].addToGroup(x_scale_labels[i])
# vertical x-ledger
x_ledger.append(QGraphicsLineItem(0, 0, 0, self._height))
if i == int(self._width/10):
ledger_pen.setWidthF(2/self._scale)
ledger_pen.setStyle(Qt.DashLine)
ledger_pen.setColor(Qt.black)
x_ledger[i].setPen(ledger_pen)
x_ledger[i].setPos(self._x_indent + i*10, 0)
self._axis['x_ledger'].addToGroup(x_ledger[i])
# x-axis label # x-axis label
label = QGraphicsSimpleTextItem('time') label = QGraphicsSimpleTextItem('time')
label.setScale(label.scale() / self._scale) label.setScale(label.scale() / self._scale)
...@@ -130,13 +147,15 @@ class GraphicsAxis(QGraphicsItemGroup): ...@@ -130,13 +147,15 @@ class GraphicsAxis(QGraphicsItemGroup):
label.setPos(self._width - half_width + arrow_half_width, 0.8) label.setPos(self._width - half_width + arrow_half_width, 0.8)
self._axis['x'].addToGroup(label) self._axis['x'].addToGroup(label)
self._axis['x'].boundingRect() self._axis['x'].boundingRect()
# add x-axis
self._axis['x'].setPos(0, self._height)
self.addToGroup(self._axis['x'])
# y-axis # y-axis
self._axis['y'] = QGraphicsLineItem(0, 0, 0, self._height) self._axis['y'] = QGraphicsLineItem(0, 0, 0, self._height + self._dy_height)
self._axis['y'].setPen(pen) self._axis['y'].setPen(pen)
# add y-axis
# put it all together
self._axis['x'].setPos(0, self._height + self._dy_height)
self._axis['x_ledger'].setPos(0, self._dy_height)
self.addToGroup(self._axis['x_ledger'])
self.addToGroup(self._axis['x'])
self.addToGroup(self._axis['y']) self.addToGroup(self._axis['y'])
\ No newline at end of file
"""TODO"""
import os
import sys
from typing import Any, Optional
from pprint import pprint
from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union, Optional, overload, Final, final
# from typing_extensions import Self, Final, Literal, LiteralString, TypeAlias, final
import numpy as np
from copy import deepcopy
from itertools import combinations
import qtpy
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
# QGraphics and QPainter imports
from qtpy.QtCore import (
Qt, QObject, QRect, QRectF, QPoint, QSize, QSizeF, QByteArray, Slot)
from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon, QIcon, QPixmap,
QLinearGradient, QTransform, QCursor)
from qtpy.QtWidgets import (
QGraphicsView, QGraphicsScene, QGraphicsWidget,
QGraphicsLayout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsLayoutItem, QGraphicsAnchorLayout,
QGraphicsItem, QGraphicsItemGroup, QGraphicsPathItem, QGraphicsLineItem, QGraphicsRectItem,
QStyleOptionGraphicsItem, QWidget,
QGraphicsObject, QGraphicsSceneMouseEvent, QGraphicsSceneHoverEvent, QGraphicsSceneContextMenuEvent)
from qtpy.QtCore import (
QPoint, QPointF)
class GraphicsComponentEvent(QGraphicsObject):
"""Event handler for GraphicsComponentItem"""
def __init__(self, parent):
super().__init__()
# self.setAcceptedMouseButtons(Qt.LeftButton)
self.setFlag(QGraphicsItem.ItemIsMovable)
self.setFlag(QGraphicsItem.ItemIsSelectable)
self.setAcceptHoverEvents(True)
# self.setFlag(QGraphicsItem.ItemSendsGeometryChanges)
def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent) -> None:
"""Set the position of the graphical element in the graphic scene,
translate coordinates of the cursor within the graphic element
in the coordinate system of the graphic scenes"""
print('GraphicsComponentEvent.mouseMoveEvent()')
# Qt.DragMoveCursor
self.setPos(self.mapToScene(event.pos()))
def mousePressEvent(self, event: QGraphicsSceneMouseEvent) -> None:
"""Changes the cursor to ClosedHandCursor when grabbing an object"""
print('GraphicsComponentEvent.mousePressEvent()')
self.setCursor(QCursor(Qt.ClosedHandCursor))
event.accept()
def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent) -> None:
"""Changes the cursor to OpenHandCursor when releasing an object"""
print('GraphicsComponentEvent.mouseReleaseEvent()')
self.setCursor(QCursor(Qt.OpenHandCursor))
event.accept()
def hoverEnterEvent(self, event: QGraphicsSceneHoverEvent) -> None:
"""Changes the cursor to OpenHandCursor when hovering an object"""
print('GraphicsComponentEvent.hoverEnterEvent()')
self.setCursor(QCursor(Qt.OpenHandCursor))
# def hoverMoveEvent(event: QGraphicsSceneHoverEvent) -> None: ...
# def contextMenuEvent(event: QGraphicsSceneContextMenuEvent) -> None: ...
def hoverLeaveEvent(self, event: QGraphicsSceneHoverEvent) -> None:
"""Changes the cursor to ArrowCursor when leaving an object"""
print('GraphicsComponentEvent.hoverLeaveEvent()')
self.setCursor(QCursor(Qt.ArrowCursor))
# # https://www.qtcentre.org/threads/25486-QGraphicsItem-Horizontal-Vertical-move-only
# QVariant Component::itemChange(GraphicsItemChange change, const QVariant &value)
# {
# if (change == ItemPositionChange && scene()) {
# // value is the new position.
# QPointF newPos = value.toPointF();
# QRectF rect = scene()->sceneRect();
# if (!rect.contains(newPos)) {
# // Keep the item inside the scene rect.
# newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
# newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
# return newPos;
# }
# }
# return QGraphicsItem::itemChange(change, value);
# }
\ No newline at end of file
...@@ -16,27 +16,28 @@ from qtpy.QtCore import ( ...@@ -16,27 +16,28 @@ from qtpy.QtCore import (
Qt, QObject, QRect, QRectF, QPoint, QSize, QSizeF, QByteArray, Slot) Qt, QObject, QRect, QRectF, QPoint, QSize, QSizeF, QByteArray, Slot)
from qtpy.QtGui import ( from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon, QIcon, QPixmap, QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon, QIcon, QPixmap,
QLinearGradient, QTransform, QMatrix) QLinearGradient, QTransform)
from qtpy.QtWidgets import ( from qtpy.QtWidgets import (
QGraphicsView, QGraphicsScene, QGraphicsWidget, QGraphicsView, QGraphicsScene, QGraphicsWidget,
QGraphicsLayout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsLayoutItem, QGraphicsAnchorLayout, QGraphicsLayout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsLayoutItem, QGraphicsAnchorLayout,
QGraphicsItem, QGraphicsItemGroup, QGraphicsPathItem, QGraphicsRectItem, QGraphicsItem, QGraphicsItemGroup, QGraphicsPathItem, QGraphicsRectItem,
QStyleOptionGraphicsItem, QWidget) QStyleOptionGraphicsItem, QWidget, QGraphicsObject)
from qtpy.QtCore import ( from qtpy.QtCore import (
QPoint, QPointF) QPoint, QPointF)
# B-ASIC # B-ASIC
import logger import logger
from b_asic.schedule import Schedule from b_asic.schedule import Schedule
from graphics_component_event import GraphicsComponentEvent
class ComponentItem(QGraphicsItemGroup): class GraphicsComponentItem(QGraphicsItemGroup, GraphicsComponentEvent, QGraphicsObject):
_scale: float = 1.0 _scale: float = 1.0 # static, changed from MainWindow
_height: float _height: float
_component_item: QGraphicsPathItem _component_item: QGraphicsPathItem
_execution_time_item: QGraphicsPathItem _execution_time_item: QGraphicsPathItem
_item_group: QGraphicsItemGroup _item_group: QGraphicsItemGroup
def __init__(self, height: float = 10.0, parent: QGraphicsItem = None): def __init__(self, height: float = 10.0, parent: QGraphicsItem = None):
...@@ -48,7 +49,7 @@ class ComponentItem(QGraphicsItemGroup): ...@@ -48,7 +49,7 @@ class ComponentItem(QGraphicsItemGroup):
self.setFlag(QGraphicsItem.ItemIsMovable) self.setFlag(QGraphicsItem.ItemIsMovable)
self.setFlag(QGraphicsItem.ItemIsSelectable) self.setFlag(QGraphicsItem.ItemIsSelectable)
# self.setHandlesChildEvents(False) self.setAcceptHoverEvents(True)
self._populate() self._populate()
...@@ -59,8 +60,8 @@ class ComponentItem(QGraphicsItemGroup): ...@@ -59,8 +60,8 @@ class ComponentItem(QGraphicsItemGroup):
def _populate(self) -> None: def _populate(self) -> None:
brush = QBrush(Qt.lightGray) brush = QBrush(Qt.lightGray)
pen = QPen(Qt.SolidPattern, 2/self._scale) pen = QPen(Qt.darkGray)
pen.setBrush(Qt.darkGray) pen.setWidthF(2/self._scale)
# pen.setCapStyle(Qt.RoundCap) # Qt.FlatCap, Qt.SquareCap (default), Qt.RoundCap # pen.setCapStyle(Qt.RoundCap) # Qt.FlatCap, Qt.SquareCap (default), Qt.RoundCap
pen.setJoinStyle(Qt.RoundJoin) # Qt.MiterJoin, Qt.BevelJoin (default), Qt.RoundJoin, Qt.SvgMiterJoin pen.setJoinStyle(Qt.RoundJoin) # Qt.MiterJoin, Qt.BevelJoin (default), Qt.RoundJoin, Qt.SvgMiterJoin
......
"""TODO"""
import os
import sys
from typing import Any, Optional
from pprint import pprint
from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union, Optional, overload, Final, final
# from typing_extensions import Self, Final, Literal, LiteralString, TypeAlias, final
import numpy as np
from copy import deepcopy
from itertools import combinations
import qtpy
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
# QGraphics and QPainter imports
from qtpy.QtCore import (
Qt, QObject, QRect, QRectF, QPoint, QSize, QSizeF, QByteArray, Slot)
from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon, QIcon, QPixmap,
QLinearGradient, QTransform, QCursor)
from qtpy.QtWidgets import (
QGraphicsView, QGraphicsScene, QGraphicsWidget,
QGraphicsLayout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsLayoutItem, QGraphicsAnchorLayout,
QGraphicsItem, QGraphicsItemGroup, QGraphicsPathItem, QGraphicsLineItem, QGraphicsRectItem,
QStyleOptionGraphicsItem, QWidget,
QGraphicsObject, QGraphicsSceneMouseEvent, QGraphicsSceneHoverEvent, QGraphicsSceneContextMenuEvent)
from qtpy.QtCore import (
QPoint, QPointF)
class GraphicsGraphEvent(QGraphicsObject):
"""Event handler for GraphicsComponentItem"""
def __init__(self, parent):
super().__init__()
# self.setAcceptedMouseButtons(Qt.LeftButton)
self.setFlag(QGraphicsItem.ItemIsMovable)
self.setFlag(QGraphicsItem.ItemIsSelectable)
self.setAcceptHoverEvents(True)
# self.setFlag(QGraphicsItem.ItemSendsGeometryChanges)
def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent) -> None:
"""Set the position of the graphical element in the graphic scene,
translate coordinates of the cursor within the graphic element
in the coordinate system of the graphic scenes"""
print('GraphicsGraphEvent.mouseMoveEvent()')
# Qt.DragMoveCursor
# self.setPos(self.mapToScene(event.pos()))
super().mouseMoveEvent(event)
def mousePressEvent(self, event: QGraphicsSceneMouseEvent) -> None:
"""Changes the cursor to ClosedHandCursor when grabbing an object"""
print('GraphicsGraphEvent.mousePressEvent()')
super().mousePressEvent(event)
# self.setCursor(QCursor(Qt.ClosedHandCursor))
# event.accept()
def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent) -> None:
"""Changes the cursor to OpenHandCursor when releasing an object"""
print('GraphicsGraphEvent.mouseReleaseEvent()')
super().mouseReleaseEvent(event)
# self.setCursor(QCursor(Qt.OpenHandCursor))
# event.accept()
def hoverEnterEvent(self, event: QGraphicsSceneHoverEvent) -> None:
"""Changes the cursor to OpenHandCursor when hovering an object"""
print('GraphicsGraphEvent.hoverEnterEvent()')
super().hoverEnterEvent(event)
# self.setCursor(QCursor(Qt.OpenHandCursor))
# def hoverMoveEvent(event: QGraphicsSceneHoverEvent) -> None: ...
# def contextMenuEvent(event: QGraphicsSceneContextMenuEvent) -> None: ...
def hoverLeaveEvent(self, event: QGraphicsSceneHoverEvent) -> None:
"""Changes the cursor to ArrowCursor when leaving an object"""
print('GraphicsGraphEvent.hoverLeaveEvent()')
super().hoverLeaveEvent(event)
# self.setCursor(QCursor(Qt.ArrowCursor))
...@@ -29,55 +29,55 @@ from qtpy.QtCore import ( ...@@ -29,55 +29,55 @@ from qtpy.QtCore import (
# B-ASIC # B-ASIC
import logger import logger
from b_asic.schedule import Schedule from b_asic.schedule import Schedule
from component_item import ComponentItem from graphics_component_item import GraphicsComponentItem
from graphics_axis import GraphicsAxis from graphics_axis_item import GraphicsAxisItem
class GraphicsGraph(QGraphicsItemGroup): class GraphicsGraphItem(QGraphicsItemGroup, QGraphicsObject):
_schedule: Schedule
_axis: GraphicsAxis
_component_group: QGraphicsItemGroup
_axis_group: QGraphicsItemGroup
_schedule: Schedule
_axis: GraphicsAxisItem
_component_group: QGraphicsItemGroup
_components_height: float _components_height: float
_x_axis_indent: float _x_axis_indent: float
def __init__(self, schedule: Schedule, parent: QGraphicsItem = None): def __init__(self, schedule: Schedule, parent: QGraphicsItem = None):
super().__init__(parent) super().__init__(parent)
self.setHandlesChildEvents(False) self.setFlag(QGraphicsItem.ItemIsMovable)
self.setFlag(QGraphicsItem.ItemIsSelectable)
self.setAcceptHoverEvents(True)
self._schedule = deepcopy(schedule) self._schedule = deepcopy(schedule)
self._axis = None self._axis = None
self._component_group = QGraphicsItemGroup() self._component_group = QGraphicsItemGroup()
self._axis_group = QGraphicsItemGroup()
# add components
self._x_axis_indent = 2.0
self._components_height = 0.0 self._components_height = 0.0
self._x_axis_indent = 2.0
# build components
spacing = 2.0
for i in range(5): for i in range(5):
component = ComponentItem() component = GraphicsComponentItem()
component.setPos(0, self._components_height) component.setPos(0, self._components_height)
self._component_group.addToGroup(component) self._component_group.addToGroup(component)
self._components_height += component.height + 2 self._components_height += component.height + spacing
self._component_group.setPos(self._x_axis_indent, spacing)
self._components_height += spacing
# build axis
self._axis = GraphicsAxisItem(50 + 6, self._components_height, self._x_axis_indent)
self._component_group.setPos(self._x_axis_indent, 1) # add axis and components
self.addToGroup(self._component_group)
self._components_height += 1.5
# add axis
self._axis = GraphicsAxis(50 + 6, self._components_height, self._x_axis_indent)
self.addToGroup(self._axis) self.addToGroup(self._axis)
self.addToGroup(self._component_group)
def update(self) -> None: def update(self) -> None:
# self.prepareGeometryChange() # self.prepareGeometryChange()
self.removeFromGroup(self._axis) # self.removeFromGroup(self._axis)
self._axis.update(40 + 6, self._components_height, self._x_axis_indent) self._axis.update(40 + 6, self._components_height, self._x_axis_indent)
self.addToGroup(self._axis) # self.addToGroup(self._axis)
...@@ -93,11 +93,11 @@ class GraphicsGraph(QGraphicsItemGroup): ...@@ -93,11 +93,11 @@ class GraphicsGraph(QGraphicsItemGroup):
# @staticmethod # @staticmethod
@property @property
def axis(self) -> GraphicsAxis: def axis(self) -> GraphicsAxisItem:
return self._axis return self._axis
@property @property
def items(self) -> list[ComponentItem]: def items(self) -> list[GraphicsComponentItem]:
return self._component_group.childItems() return self._component_group.childItems()
\ No newline at end of file
...@@ -44,10 +44,10 @@ from qtpy.QtWidgets import ( ...@@ -44,10 +44,10 @@ from qtpy.QtWidgets import (
# B-ASIC # B-ASIC
import logger import logger
from b_asic.schedule import Schedule from b_asic.schedule import Schedule
from graphics_graph import GraphicsGraph from graphics_graph_item import GraphicsGraphItem
from graphics_axis import GraphicsAxis from graphics_axis_item import GraphicsAxisItem
from component_item import ComponentItem from graphics_component_item import GraphicsComponentItem
log = logger.getLogger() log = logger.getLogger()
...@@ -56,6 +56,7 @@ log = logger.getLogger() ...@@ -56,6 +56,7 @@ log = logger.getLogger()
if __debug__: if __debug__:
log.setLevel('DEBUG') log.setLevel('DEBUG')
if __debug__: if __debug__:
# Print some system version information # Print some system version information
QT_API = os.environ.get('QT_API') QT_API = os.environ.get('QT_API')
...@@ -109,12 +110,8 @@ QCoreApplication.setApplicationName('B-ASIC Scheduler') ...@@ -109,12 +110,8 @@ QCoreApplication.setApplicationName('B-ASIC Scheduler')
class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QMainWindow, Ui_MainWindow):
"""Schedule of an SFG with scheduled Operations.""" """Schedule of an SFG with scheduled Operations."""
# _schedules: dict
# _scenes: dict[str, GraphicsScene]
_scene: QGraphicsScene _scene: QGraphicsScene
_graphs: dict[str, QGraphicsWidget] _graph: GraphicsGraphItem
_graph_count: int
_scene_count: int
_open_file_dialog_opened: bool _open_file_dialog_opened: bool
_scale: float _scale: float
_debug_rects: QGraphicsItemGroup _debug_rects: QGraphicsItemGroup
...@@ -123,10 +120,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -123,10 +120,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self): def __init__(self):
"""Initialize Schedule-gui.""" """Initialize Schedule-gui."""
super().__init__() super().__init__()
self._scenes = {} self._graph = None
self._graphs = {}
self._scene_count = 0
self._graph_count = 0
self._open_file_dialog_opened = False self._open_file_dialog_opened = False
self._scale = 10.0 self._scale = 10.0
self._debug_rects = None self._debug_rects = None
...@@ -184,8 +178,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -184,8 +178,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.graphics_view.setDragMode(QGraphicsView.RubberBandDrag) self.graphics_view.setDragMode(QGraphicsView.RubberBandDrag)
self.graphics_view.setScene(self._scene) self.graphics_view.setScene(self._scene)
self.graphics_view.scale(self._scale, self._scale) self.graphics_view.scale(self._scale, self._scale)
ComponentItem._scale = self._scale GraphicsComponentItem._scale = self._scale
GraphicsAxis._scale = self._scale GraphicsAxisItem._scale = self._scale
...@@ -195,13 +189,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -195,13 +189,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
############### ###############
@Slot() @Slot()
def actionTbtn(self) -> None: def actionTbtn(self) -> None:
# print('_scene_count:', self._scene_count) sched = self._graph.schedule
scene = self._scenes[self._scene_count - 1] sched.plot_schedule()
sched = scene.schedule
print('From MainWindow:\t\t\t', end='')
pprint(sched)
# print('')
self._scenes[self._scene_count - 1].plot_schedule()
# self.printButtonPressed('callback_pushButton()') # self.printButtonPressed('callback_pushButton()')
@Slot() @Slot()
...@@ -258,26 +247,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -258,26 +247,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
#@Slot() #@Slot()
def open(self, schedule: Schedule) -> None: def open(self, schedule: Schedule) -> None:
"""Takes in an Schedule and place it in the schedule list.""" """Takes in an Schedule and place it in the schedule list."""
#TODO: all
#TODO: Unique hash keys self._graph = GraphicsGraphItem(schedule)
#TODO: self.open(schedule_obj_list[ret_tuple[0]) self._scene.addItem(self._graph)
# scene = GraphicsScene(self._scene_count, schedule, self.graphics_view)
# #scene = QGraphicsScene()
# self._scenes[self._scene_count] = scene
# self.graphics_view.setScene(scene)
# self.graphics_view.setRenderHint(QPainter.Antialiasing)
# # self.graphics_view.setGeometry(20, 20, self.width(), self.height())
# self.graphics_view.setDragMode(QGraphicsView.RubberBandDrag)
# # self.graphics_view.scale(10.0, 10.0)
# self._scene_count += 1
graph = GraphicsGraph(schedule)
self._scene.addItem(graph)
# graph.prepareGeometryChange() # graph.prepareGeometryChange()
# graph.setPos(200, 20) # graph.setPos(200, 20)
...@@ -299,15 +271,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -299,15 +271,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# self._scene.addRect(axis.mapRectToScene(axis.boundingRect() - m), pen) # self._scene.addRect(axis.mapRectToScene(axis.boundingRect() - m), pen)
# pen.setColor(Qt.green) # pen.setColor(Qt.green)
# # self._scene.addRect(self._scene.itemsBoundingRect() - m, pen) # # self._scene.addRect(self._scene.itemsBoundingRect() - m, pen)
# self._scene.setSceneRect(self._scene.itemsBoundingRect()) # self._scene.setSceneRect(self._scene.itemsBoundingRect())
self._graphs[self._graph_count] = graph
self._graph_count += 1
self.update_statusbar(self.tr('Schedule loaded successfully')) self.update_statusbar(self.tr('Schedule loaded successfully'))
@Slot() @Slot()
......
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