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

workspace dump

parent aec7f034
No related branches found
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #72856 passed
# This Python file uses the following encoding: utf-8
"""B-ASIC Scheduler-gui GraphicsScene Module.
Contains the GraphicsScene class for drawing items on.
"""
import os
import sys
from typing import Any
from pprint import pprint
from typing import Any, AnyStr, Generic, Protocol, TypeVar, Union, Optional, overload
from typing_extensions import Self, Final, Literal, LiteralString, TypeAlias, final
import qtpy
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
# QGraphics and QPainter imports
from qtpy.QtCore import (
QObject, QRect, QRectF, QPoint, QSize, QByteArray)
from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon, QIcon, QPixmap,
QLinearGradient)
from qtpy.QtWidgets import (
QGraphicsView, QGraphicsScene, QGraphicsWidget,
QGraphicsLayout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsLayoutItem, QGraphicsAnchorLayout,
QGraphicsItem, QGraphicsItemGroup)
# B-ASIC
import logger
from b_asic.schedule import Schedule
@final
class GraphicsScene(QGraphicsScene):
"""GraphicsScene subclass of QGraphicsScene acts as a scene to place items on"""
_id: Final[int]
_schedule: Final[Schedule]
# @overload
# def __init__(self, parent:Optional[QObject]=...) -> None:
# ...
# @overload
# def __init__(self, sceneRect:QRectF, parent:Optional[QObject]=...) -> None:
# ...
# @overload
# def __init__(self, x:float, y:float, width:float, height:float, parent:Optional[QObject]=...) -> None:
# ...
# @overload
# def __init__(self, parent: QObject, id: int, schedule: Optional[Schedule] = None, *args, **kwargs) -> None: ...
# @overload
# def __init__(self, id: int, schedule: Optional[Schedule] = None, *args, **kwargs) -> None:
# super(Self, self).__init__(parent, *args, **kwargs)
# self._id = id
# @overload
# def __init__(self, parent: QObject, id: int, *args, **kwargs):
# super(GraphicsScene, self).__init__(parent, *args, **kwargs)
# self.__init__(id, *args, **kwargs)
# def __init__(self, id: int, schedule: Schedule = None, parent: Optional[QObject]):
# super(GraphicsScene, self).__init__(parent)
# self._id = id
# self._schedule
def __init__(self, id: int, schedule: Optional["Schedule"] = None, parent: Optional["QObject"] = None):
# def __init__(self, id: int[, schedule: Schedule]):# = None, parent: Optional[QObject] = None):
super(GraphicsScene, self).__init__(parent)
self._id = id
self._schedule = schedule
print()
print('parent:', parent)
print('type(parent):', type(parent))
print()
print('schedule:', schedule)
print('type(schedule):', type(schedule))
print('self._schedule:', self._schedule)
print('type(self._schedule):', type(self._schedule))
# def __init__(self, id: int):
# super(GraphicsScene, self).__init__()
# self._id = id
@property
def id(self):
return self._id
@property
def schedule(self):
return self._schedule
@schedule.setter
def schedule(self, schedule: Schedule):
self._schedule = schedule
print('GraphicsScene.__mro__:')
pprint(GraphicsScene.__mro__)
......@@ -19,31 +19,30 @@ from pprint import pprint
#from diagram import *
from importlib.machinery import SourceFileLoader
import inspect
from numpy import uint
# Qt/qtpy
import qtpy
from qtpy import uic, QtCore, QtGui, QtWidgets
from qtpy.QtCore import QCoreApplication, Qt, Slot, QSettings, QStandardPaths
#QtCore QSize, QPoint
from qtpy.QtGui import QCloseEvent
from qtpy.QtWidgets import (
QApplication, QMainWindow, QMessageBox, QFileDialog, QInputDialog, QCheckBox, QAbstractButton)
# QGraphics and QPainter imports
from qtpy.QtCore import (
QRect, QPoint, QSize, QByteArray)
from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon, QIcon, QPixmap,
QLinearGradient)
from qtpy.QtWidgets import (
QGraphicsView, QGraphicsScene, QGraphicsWidget,
QGraphicsLayout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsLayoutItem, QGraphicsAnchorLayout,
QGraphicsItem, QGraphicsItemGroup)
from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon, QIcon, QPixmap,
QLinearGradient)
from qtpy.QtCore import (
QRect, QPoint, QSize, QByteArray)
# B-ASIC
import logger
from b_asic.schedule import Schedule
from graphics_scene import GraphicsScene
log = logger.getLogger()
......@@ -103,7 +102,6 @@ QCoreApplication.setApplicationName('B-ASIC Scheduler')
class MainWindow(QMainWindow, Ui_MainWindow):
"""Schedule of an SFG with scheduled Operations."""
_schedules: dict
_schedule_id: int
......@@ -151,12 +149,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def _init_graphics_view(self) -> None:
"""Initialize the QGraphics framework"""
self.graphic_scene = QGraphicsScene(self)
self.graphic_scene = GraphicsScene(0, parent=self)
self.graphic_view.setScene(self.graphic_scene)
self.graphic_view.setRenderHint(QPainter.Antialiasing)
self.graphic_view.setGeometry(20, 20, self.width(), self.height())
self.graphic_view.setDragMode(QGraphicsView.RubberBandDrag)
###############
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment