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

workspace dump

parent c759edd5
No related branches found
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #72967 passed
......@@ -19,14 +19,16 @@ from qtpy import QtWidgets
# QGraphics and QPainter imports
from qtpy.QtCore import (
QObject, QRect, QRectF, QPoint, QSize, QByteArray)
Qt, 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)
QGraphicsItem, QGraphicsItemGroup, QGraphicsPathItem)
from qtpy.QtCore import (
QPoint, QPointF)
# B-ASIC
import logger
......@@ -55,6 +57,59 @@ class GraphicsScene(QGraphicsScene):
print('From GraphicsScene/self._schedule:\t', end='')
pprint(self._schedule)
# print('')
scale = 10.0
brush = QBrush(Qt.lightGray, bs=Qt.SolidPattern)
# pen = QPen(brush, 10, s=Qt.SolidLine, c=Qt.SquareCap, j=Qt.BevelJoin)
pen = QPen(Qt.SolidLine)
pen.setWidthF(2/scale)
pen.setBrush(Qt.darkGray)
# pen.setCapStyle(Qt.RoundCap) # Qt.FlatCap, Qt.SquareCap (default), Qt.RoundCap
pen.setJoinStyle(Qt.RoundJoin) # Qt.MiterJoin, Qt.BevelJoin (default), Qt.RoundJoin, Qt.SvgMiterJoin
# the group consist of a time_item and a component_item
item_group = QGraphicsItemGroup()
item_group.setScale(scale)
component_path = QPainterPath(QPoint(0,0))
component_path.lineTo(0, 10)
component_path.lineTo(40, 10)
component_path.lineTo(40, 0)
# component_path.lineTo(0, 0)
component_path.closeSubpath()
# pen.setCosmetic(True) # Dont scale pen
component_item = QGraphicsPathItem(component_path, item_group)
component_item.setPen(pen)
component_item.setBrush(brush)
# item_group.addToGroup(component_item)
component_item.setPos(5,0) # in parent (item_group) coordinates
time_path = QPainterPath(QPoint(0,0))
time_path.lineTo(0, 10)
time_path.lineTo(10, 10)
time_path.lineTo(10, 0)
# time_path.lineTo(0, 0)
time_path.closeSubpath()
green_color = QColor(Qt.magenta)
green_color.setAlpha(200) # 0-255
pen.setColor(green_color)
# pen.setBrush(Qt.green)
time_item = QGraphicsPathItem(time_path, item_group)
time_item.setPen(pen)
# item_group.addToGroup(time_item)
# add the component group to scene
self.addItem(item_group)
def plot_schedule(self):
......
......@@ -144,15 +144,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# Setup event member functions
self.closeEvent = self._close_event
# Init info sidebar
# self.info_table.insertColumn(0)
# self.info_table.insertRow(0)
# Setup info table
self.info_table.setHorizontalHeaderLabels(['Property','Value'])
# test = '#b085b2'
# self.info_table.setStyleSheet('alternate-background-color: lightGray;background-color: white;');
self.info_table.setStyleSheet('alternate-background-color: #fadefb;background-color: #ebebeb;');
for i in range(10):
print(i)
self.info_table.insertRow(i)
item = QTableWidgetItem('this is a very very very very long string that says abolutly nothing')
self.info_table.setItem(i,0, QTableWidgetItem('property {}: '.format(i)))
......@@ -248,10 +245,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
scene = GraphicsScene(self._scene_count, schedule, self)
#scene = QGraphicsScene()
self._scenes[self._scene_count] = scene
self.graphic_view.setScene(scene)
self.graphic_view.setRenderHint(QPainter.Antialiasing)
# self.graphic_view.setGeometry(20, 20, self.width(), self.height())
self.graphic_view.setDragMode(QGraphicsView.RubberBandDrag)
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._scene_count += 1
......
......@@ -49,8 +49,10 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<layout class="QHBoxLayout" name="horizontalLayout_2"/>
<widget class="QGraphicsView" name="graphics_view">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
<widget class="QTableWidget" name="info_table">
<property name="editTriggers">
......@@ -68,6 +70,9 @@
<property name="columnCount">
<number>2</number>
</property>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
......@@ -87,7 +92,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......@@ -182,8 +187,8 @@
</property>
<property name="icon">
<iconset resource="icons/misc.qrc">
<normaloff>:/icons/misc/right_filled_panel.svg</normaloff>
<normalon>:/icons/misc/right_panel.svg</normalon>:/icons/misc/right_filled_panel.svg</iconset>
<normaloff>:/icons/misc/right_panel.svg</normaloff>
<normalon>:/icons/misc/right_filled_panel.svg</normalon>:/icons/misc/right_panel.svg</iconset>
</property>
<property name="text">
<string>&amp;Node Info</string>
......
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