Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
c0b5ff87
Commit
c0b5ff87
authored
2 years ago
by
Andreas Bolin
Browse files
Options
Downloads
Patches
Plain Diff
workspace dump
parent
5c07b468
No related branches found
No related tags found
1 merge request
!78
Add scheduler GUI
Pipeline
#73040
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/scheduler-gui/component_item.py
+52
-30
52 additions, 30 deletions
b_asic/scheduler-gui/component_item.py
b_asic/scheduler-gui/main_window.py
+31
-21
31 additions, 21 deletions
b_asic/scheduler-gui/main_window.py
with
83 additions
and
51 deletions
b_asic/scheduler-gui/component_item.py
+
52
−
30
View file @
c0b5ff87
...
@@ -31,7 +31,8 @@ from b_asic.schedule import Schedule
...
@@ -31,7 +31,8 @@ from b_asic.schedule import Schedule
# class ComponentItem(QGraphicsItemGroup, QGraphicsLayoutItem):
# class ComponentItem(QGraphicsItemGroup, QGraphicsLayoutItem):
class
ComponentItem
(
QGraphicsLayoutItem
,
QGraphicsItem
):
class
ComponentItem
(
QGraphicsItemGroup
,
QGraphicsLayoutItem
):
# class ComponentItem(QGraphicsLayoutItem, QGraphicsItemGroup):
# class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
# class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
_scale
:
float
_scale
:
float
...
@@ -40,48 +41,45 @@ class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
...
@@ -40,48 +41,45 @@ class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
_item_group
:
QGraphicsItemGroup
_item_group
:
QGraphicsItemGroup
# def __init__(self, scale: float, *args, **kwargs):
def
__init__
(
self
,
scale
:
float
,
parent
:
QGraphicsWidget
=
None
):
def
__init__
(
self
,
scale
:
float
,
*
args
,
**
kwargs
):
QGraphicsItemGroup
.
__init__
(
self
)
# def __init__(self, scale: float):
QGraphicsLayoutItem
.
__init__
(
self
,
parent
=
parent
)
super
().
__init__
(
*
args
,
**
kwargs
)
# QGraphicsLayoutItem.__init__()
# QGraphicsItem.__init__(parent = parent)
self
.
_scale
=
scale
self
.
setGraphicsItem
(
self
)
self
.
setGraphicsItem
(
self
)
print
(
'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'
)
self
.
_scale
=
scale
print
(
'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! A
'
)
self
.
_item_group
=
QGraphicsItemGroup
()
self
.
_item_group
=
QGraphicsItemGroup
()
# self._item_group.setParentItem(self)
print
(
'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! B
'
)
# print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
self
.
_populate
()
self
.
_populate
()
# print(self.boundingRect().size())
# print(self.boundingRect().size())
def
_populate
(
self
):
def
_populate
(
self
):
# brush = QBrush(Qt.lightGray, bs=Qt.SolidPattern)
# brush = QBrush(Qt.lightGray, bs=Qt.SolidPattern)
brush
=
QBrush
(
Qt
.
lightGray
)
brush
=
QBrush
(
Qt
.
lightGray
)
# brush.setStyle(Qt.SolidPattern)
pen
=
QPen
(
Qt
.
SolidLine
)
pen
=
QPen
(
Qt
.
SolidLine
)
pen
.
setWidthF
(
2
/
self
.
_scale
)
pen
.
setWidthF
(
1
/
self
.
_scale
)
pen
.
setBrush
(
Qt
.
darkGray
)
pen
.
setBrush
(
Qt
.
darkGray
)
# 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
# component path
# component path
component_path
=
QPainterPath
(
QPoint
(
0
,
0
))
component_path
=
QPainterPath
(
QPoint
(
0
,
0
))
component_path
.
lineTo
(
0
,
1
0
)
component_path
.
lineTo
(
0
,
1
)
component_path
.
lineTo
(
4
0
,
1
0
)
component_path
.
lineTo
(
4
,
1
)
component_path
.
lineTo
(
4
0
,
0
)
component_path
.
lineTo
(
4
,
0
)
component_path
.
closeSubpath
()
component_path
.
closeSubpath
()
# component item
# component item
self
.
_component_item
=
QGraphicsPathItem
(
component_path
)
self
.
_component_item
=
QGraphicsPathItem
(
component_path
)
self
.
_component_item
.
setPen
(
pen
)
self
.
_component_item
.
setPen
(
pen
)
self
.
_component_item
.
setBrush
(
brush
)
self
.
_component_item
.
setBrush
(
brush
)
self
.
_component_item
.
setPos
(
5
,
0
)
# in parent (i.e. item_group) coordinates
self
.
_component_item
.
setPos
(
0.
5
,
0
)
# in parent (i.e. item_group) coordinates
# execution time square
# execution time square
execution_time_path
=
QPainterPath
(
QPoint
(
0
,
0
))
execution_time_path
=
QPainterPath
(
QPoint
(
0
,
0
))
execution_time_path
.
addRect
(
0
,
0
,
1
0
.0
,
1
0
.0
)
execution_time_path
.
addRect
(
0
,
0
,
1.0
,
1.0
)
# execution time item
# execution time item
green_color
=
QColor
(
Qt
.
magenta
)
green_color
=
QColor
(
Qt
.
magenta
)
...
@@ -97,9 +95,16 @@ class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
...
@@ -97,9 +95,16 @@ class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
# print(graphics_item)
# print(graphics_item)
# self._item_group = graphics_item.childItems()[0]
# self._item_group = graphics_item.childItems()[0]
# print(self._item_group)
# print(self._item_group)
# item_group.setScale(self._scale)
# # item_group.setScale(self._scale)
self
.
_item_group
.
addToGroup
(
self
.
_component_item
)
# print('############################# 1')
self
.
_item_group
.
addToGroup
(
self
.
_execution_time_item
)
# self._item_group.addToGroup(self._component_item)
# print('############################# 2')
# self._item_group.addToGroup(self._execution_time_item)
print
(
'
############################# 1
'
)
self
.
addToGroup
(
self
.
_component_item
)
print
(
'
############################# 2
'
)
self
.
addToGroup
(
self
.
_execution_time_item
)
# self.setGraphicsItem(self)
# self.setGraphicsItem(self)
# QGraphicsItemGroup
# QGraphicsItemGroup
...
@@ -110,8 +115,15 @@ class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
...
@@ -110,8 +115,15 @@ class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
# reimplement QGraphicsLayoutItem virtual functions
# reimplement QGraphicsLayoutItem virtual functions
def
setGeometry
(
rect
):
def
updateGeometry
(
self
):
print
(
f
'
setGeometry(
{
rect
}
)
'
)
print
(
'
updateGeometry()
'
)
QGraphicsLayoutItem
.
updateGeometry
(
self
)
def
setGeometry
(
self
,
geom
:
QRectF
)
->
None
:
print
(
f
'
setGeometry(
{
geom
}
)
'
)
self
.
prepareGeometryChange
()
QGraphicsLayoutItem
.
setGeometry
(
self
,
geom
)
self
.
setPos
(
geom
.
topLeft
())
def
sizeHint
(
self
,
which
:
Qt
.
SizeHint
,
constraint
:
QSizeF
=
QSizeF
())
->
QSizeF
:
def
sizeHint
(
self
,
which
:
Qt
.
SizeHint
,
constraint
:
QSizeF
=
QSizeF
())
->
QSizeF
:
print
(
f
'
sizeHint(which=
{
which
}
, constraint=
{
constraint
}
'
)
print
(
f
'
sizeHint(which=
{
which
}
, constraint=
{
constraint
}
'
)
...
@@ -123,19 +135,29 @@ class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
...
@@ -123,19 +135,29 @@ class ComponentItem(QGraphicsLayoutItem, QGraphicsItem):
switch
=
{
switch
=
{
Qt
.
MinimumSize
:
self
.
boundingRect
().
size
(),
Qt
.
MinimumSize
:
self
.
boundingRect
().
size
(),
Qt
.
PreferredSize
:
self
.
boundingRect
().
size
(),
Qt
.
PreferredSize
:
self
.
boundingRect
().
size
(),
# Qt.MinimumSize: self.geometry().size(),
# Qt.PreferredSize: self.geometry().size(),
Qt
.
MaximumSize
:
QSizeF
(
float
(
"
inf
"
),
float
(
"
inf
"
))
Qt
.
MaximumSize
:
QSizeF
(
float
(
"
inf
"
),
float
(
"
inf
"
))
# Qt.MaximumSize: self.parentItem().boundingRect().size()
}
}
ret
=
switch
.
get
(
which
,
constraint
)
print
(
f
'
ret:
{
ret
}
'
)
return
switch
.
get
(
which
,
constraint
)
return
switch
.
get
(
which
,
constraint
)
def
minimumSize
(
self
):
print
(
'
minimumSize()
'
)
# reimplement QGraphicsItem virtual functions
# # reimplement QGraphicsItem virtual functions
def
boundingRect
(
self
)
->
QRectF
:
# def boundingRect(self) -> QRectF:
print
(
'
boundingRect()
'
)
# print('boundingRect()')
return
self
.
_item_group
.
boundingRect
()
# # return self._item_group.boundingRect()
# return QRectF(QPointF(0,0), self.geometry().size())
def
paint
(
self
,
painter
:
QPainter
,
option
:
QStyleOptionGraphicsItem
,
widget
:
Optional
[
QWidget
]
=
None
)
->
None
:
# def paint(self, painter: QPainter, option: QStyleOptionGraphicsItem, widget: Optional[QWidget]= None) -> None:
print
(
f
'
paint(painter=
{
painter
}
, option=
{
option
}
, widget=
{
widget
}
)
'
)
# print(f'paint(painter={painter}, option={option}, widget={widget})')
return
self
.
_item_group
.
paint
(
painter
,
option
,
widget
)
# painter.drawRoundedRect(-10, -10, 20, 20, 5, 5)
# # self._item_group.paint(painter, option, widget)
# print("MRO:")
# print("MRO:")
# pprint(ComponentItem.__mro__)
# pprint(ComponentItem.__mro__)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
b_asic/scheduler-gui/main_window.py
+
31
−
21
View file @
c0b5ff87
...
@@ -29,11 +29,11 @@ from qtpy.QtCore import QCoreApplication, Qt, Slot, QSettings, QStandardPaths
...
@@ -29,11 +29,11 @@ from qtpy.QtCore import QCoreApplication, Qt, Slot, QSettings, QStandardPaths
from
qtpy.QtGui
import
QCloseEvent
from
qtpy.QtGui
import
QCloseEvent
from
qtpy.QtWidgets
import
(
from
qtpy.QtWidgets
import
(
QApplication
,
QMainWindow
,
QMessageBox
,
QFileDialog
,
QInputDialog
,
QCheckBox
,
QAbstractButton
,
QApplication
,
QMainWindow
,
QMessageBox
,
QFileDialog
,
QInputDialog
,
QCheckBox
,
QAbstractButton
,
QTableWidgetItem
)
QTableWidgetItem
,
QSizePolicy
)
# QGraphics and QPainter imports
# QGraphics and QPainter imports
from
qtpy.QtCore
import
(
from
qtpy.QtCore
import
(
QRect
,
QPoint
,
QSize
,
QByteArray
)
QRect
,
QRectF
,
QPoint
,
QSize
,
QByteArray
)
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
)
QLinearGradient
)
...
@@ -125,13 +125,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -125,13 +125,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
_scene_count
=
0
self
.
_scene_count
=
0
self
.
_diagram_count
=
0
self
.
_diagram_count
=
0
self
.
_open_file_dialog_opened
=
False
self
.
_open_file_dialog_opened
=
False
self
.
_scale
=
10.0
self
.
_scale
=
10
0
.0
QIcon
.
setThemeName
(
'
breeze
'
)
QIcon
.
setThemeName
(
'
breeze
'
)
log
.
debug
(
'
themeName:
\'
{}
\'
'
.
format
(
QIcon
.
themeName
()))
log
.
debug
(
'
themeName:
\'
{}
\'
'
.
format
(
QIcon
.
themeName
()))
log
.
debug
(
'
themeSearchPaths: {}
'
.
format
(
QIcon
.
themeSearchPaths
()))
log
.
debug
(
'
themeSearchPaths: {}
'
.
format
(
QIcon
.
themeSearchPaths
()))
self
.
_init_ui
()
self
.
_init_ui
()
self
.
_init_graphics
_view
()
self
.
_init_graphics
()
self
.
_read_settings
()
self
.
_read_settings
()
...
@@ -170,13 +170,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -170,13 +170,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
splitter_center
.
setCollapsible
(
0
,
False
)
self
.
splitter_center
.
setCollapsible
(
0
,
False
)
self
.
splitter_center
.
setCollapsible
(
1
,
True
)
self
.
splitter_center
.
setCollapsible
(
1
,
True
)
def
_init_graphics
_view
(
self
)
->
None
:
def
_init_graphics
(
self
)
->
None
:
"""
Initialize the QGraphics framework
"""
"""
Initialize the QGraphics framework
"""
# scene = GraphicsScene(0, parent=self)
# scene = GraphicsScene(0, parent=self)
# self.graphic_view.setScene(scene)
# self.graphic_view.setScene(scene)
# self.graphic_view.setRenderHint(QPainter.Antialiasing)
# self.graphic_view.setRenderHint(QPainter.Antialiasing)
# self.graphic_view.setGeometry(20, 20, self.width(), self.height())
# self.graphic_view.setGeometry(20, 20, self.width(), self.height())
#
self.graphic_view.setDragMode(QGraphicsView.RubberBandDrag)
self
.
graphic
s
_view
.
setDragMode
(
QGraphicsView
.
RubberBandDrag
)
self
.
graphics_view
.
scale
(
self
.
_scale
,
self
.
_scale
)
self
.
graphics_view
.
scale
(
self
.
_scale
,
self
.
_scale
)
self
.
_scene
=
QGraphicsScene
()
self
.
_scene
=
QGraphicsScene
()
self
.
graphics_view
.
setScene
(
self
.
_scene
)
self
.
graphics_view
.
setScene
(
self
.
_scene
)
...
@@ -270,27 +270,37 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -270,27 +270,37 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# self._scene_count += 1
# self._scene_count += 1
windowLayout
=
QGraphicsLinearLayout
(
Qt
.
Vertical
)
# windowLayout = QGraphicsLinearLayout(Qt.Vertical)
# vertical = QGraphicsLinearLayout(Qt.Vertical)
vertical
=
QGraphicsLinearLayout
(
Qt
.
Vertical
)
linear1
=
QGraphicsLinearLayout
(
windowLayout
)
# linear1 = QGraphicsLinearLayout(windowLayout)
# linear1 = QGraphicsLinearLayout(Qt.Vertical)
linear1
=
QGraphicsLinearLayout
(
Qt
.
Horizontal
)
# linear2 = QGraphicsLinearLayout(Qt.Horizontal)
# linear1.setAlignment(Qt.AlignLeft| Qt.AlignTop)
linear2
=
QGraphicsLinearLayout
(
Qt
.
Horizontal
)
linear1
.
setMaximumSize
(
linear1
.
minimumSize
())
linear2
.
setMaximumSize
(
linear2
.
minimumSize
())
vertical
.
setMaximumSize
(
vertical
.
minimumSize
())
linear1
.
setSizePolicy
(
QSizePolicy
.
Preferred
,
QSizePolicy
.
Preferred
,
QSizePolicy
.
DefaultType
)
linear2
.
setSizePolicy
(
QSizePolicy
.
Preferred
,
QSizePolicy
.
Preferred
,
QSizePolicy
.
DefaultType
)
vertical
.
setSizePolicy
(
QSizePolicy
.
Preferred
,
QSizePolicy
.
Preferred
,
QSizePolicy
.
DefaultType
)
widget
=
QGraphicsWidget
()
widget
=
QGraphicsWidget
()
item1
=
ComponentItem
(
10.0
)
item1
=
ComponentItem
(
self
.
_scale
)
#
item2 = ComponentItem(
10.0
)
item2
=
ComponentItem
(
self
.
_scale
)
#
item3 = ComponentItem(
10.0
)
item3
=
ComponentItem
(
self
.
_scale
)
linear1
.
addItem
(
item1
)
linear1
.
addItem
(
item1
)
linear1
.
setStretchFactor
(
item1
,
1
)
linear1
.
setStretchFactor
(
item1
,
1
)
#
linear1.addItem(item2)
linear1
.
addItem
(
item2
)
#
linear2.addItem(item3)
linear2
.
addItem
(
item3
)
print
(
'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1
'
)
print
(
'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1
'
)
#
vertical.addItem(linear1)
vertical
.
addItem
(
linear1
)
#
vertical.addItem(linear2)
vertical
.
addItem
(
linear2
)
print
(
'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2
'
)
print
(
'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2
'
)
print
(
f
'
boundingRect:
{
item1
.
boundingRect
()
}
'
)
print
(
f
'
vertical.getContentsMargins():
{
vertical
.
getContentsMargins
()
}
'
)
print
(
f
'
linear1.getContentsMargins():
{
linear1
.
getContentsMargins
()
}
'
)
print
(
f
'
linear2.getContentsMargins():
{
linear2
.
getContentsMargins
()
}
'
)
# widget.setLayout(windowLayout)
widget
.
setLayout
(
windowLayout
)
widget
.
setLayout
(
vertical
)
# widget.setLayout(linear1)
widget
.
setWindowTitle
(
self
.
tr
(
"
Basic Graphics Layouts Example
"
))
widget
.
setWindowTitle
(
self
.
tr
(
"
Basic Graphics Layouts Example
"
))
print
(
'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3
'
)
print
(
'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 3
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment