diff --git a/b_asic/scheduler-gui/graphics_scene.py b/b_asic/scheduler-gui/graphics_scene.py index 096b69ee90bb916a455472213f4e75c592553c2a..b2f03672f5eb654abf0d666cb9ebc4737cf61e53 100644 --- a/b_asic/scheduler-gui/graphics_scene.py +++ b/b_asic/scheduler-gui/graphics_scene.py @@ -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): diff --git a/b_asic/scheduler-gui/main_window.py b/b_asic/scheduler-gui/main_window.py index 65a098eb94c4246684fd15d6e1d11aef7b1cc47a..3b44c09bf2e46bf7c5d2c94a9284dd573883b901 100644 --- a/b_asic/scheduler-gui/main_window.py +++ b/b_asic/scheduler-gui/main_window.py @@ -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 diff --git a/b_asic/scheduler-gui/main_window.ui b/b_asic/scheduler-gui/main_window.ui index 9e16f773907dc07a642f064e33c2dcc366c42677..262a09f3caf1ebdd502f71ac877a33dde6996bc3 100644 --- a/b_asic/scheduler-gui/main_window.ui +++ b/b_asic/scheduler-gui/main_window.ui @@ -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>&Node Info</string>