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
Merge requests
!108
Drawing of ports in scheduling GUI use helper functions
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Drawing of ports in scheduling GUI use helper functions
latencydrawing2
into
master
Overview
0
Commits
1
Pipelines
1
Changes
1
Merged
Oscar Gustafsson
requested to merge
latencydrawing2
into
master
2 years ago
Overview
0
Commits
1
Pipelines
1
Changes
1
Expand
Closes
#122 (closed)
Probably should test a few more complicated ones...
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
bb0e23b9
1 commit,
2 years ago
1 file
+
44
−
68
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
b_asic/scheduler_gui/graphics_component_item.py
+
44
−
68
Options
@@ -139,49 +139,40 @@ class GraphicsComponentItem(QGraphicsItemGroup):
def
_make_component
(
self
)
->
None
:
"""
Makes a new component out of the stored attributes.
"""
pen1
=
QPen
(
Qt
.
GlobalColor
.
black
)
# used by component outline
pen1
.
setWidthF
(
2
/
self
.
_scale
)
# pen1.setCapStyle(Qt.RoundCap) # Qt.FlatCap, Qt.SquareCap (default), Qt.RoundCap
pen1
.
setJoinStyle
(
latency_outline_pen
=
QPen
(
Qt
.
GlobalColor
.
black
)
# used by component outline
latency_outline_pen
.
setWidthF
(
2
/
self
.
_scale
)
# latency_outline_pen.setCapStyle(Qt.RoundCap) # Qt.FlatCap, Qt.SquareCap (default), Qt.RoundCap
latency_outline_pen
.
setJoinStyle
(
Qt
.
RoundJoin
)
# Qt.MiterJoin, Qt.BevelJoin (default), Qt.RoundJoin, Qt.SvgMiterJoin
brush2
=
QBrush
(
Qt
.
GlobalColor
.
black
)
# used by port filling
pen2
=
QPen
(
Qt
.
GlobalColor
.
black
)
# used by port outline
pen2
.
setWidthF
(
0
)
# pen2.setCosmetic(True)
port_filling_brush
=
QBrush
(
Qt
.
GlobalColor
.
black
)
# used by port filling
port_outline_pen
=
QPen
(
Qt
.
GlobalColor
.
black
)
# used by port outline
port_outline_pen
.
setWidthF
(
0
)
# port_outline_pen.setCosmetic(True)
port_size
=
7
/
self
.
_scale
# the diameter of a port
execution_time
=
QColor
(
OPERATION_EXECUTION_TIME_INACTIVE
)
execution_time
.
setAlpha
(
200
)
# 0-255
pen3
=
QPen
()
# used by execution time outline
pen3
.
setColor
(
execution_time
)
pen3
.
setWidthF
(
3
/
self
.
_scale
)
# make lists of sorted keys. reverse output port list.
input_keys
=
[
key
for
key
in
self
.
_ports
.
keys
()
if
key
.
lower
().
startswith
(
"
in
"
)
]
input_keys
=
sorted
(
input_keys
)
output_keys
=
[
key
for
key
in
self
.
_ports
.
keys
()
if
key
.
lower
().
startswith
(
"
out
"
)
]
output_keys
=
sorted
(
output_keys
,
reverse
=
True
)
execution_time_color
=
QColor
(
OPERATION_EXECUTION_TIME_INACTIVE
)
execution_time_color
.
setAlpha
(
200
)
# 0-255
execution_time_pen
=
QPen
()
# used by execution time outline
execution_time_pen
.
setColor
(
execution_time_color
)
execution_time_pen
.
setWidthF
(
3
/
self
.
_scale
)
# Set the starting position
x
=
old_x
=
self
.
_ports
[
input_keys
[
0
]][
"
latency
"
]
if
input_keys
else
0
y
=
old_y
=
0
latency
,
execution_time
=
self
.
_operation
.
get_plot_coordinates
()
latency_path
=
QPainterPath
(
QPointF
(
x
+
latency
[
0
][
0
],
y
+
latency
[
0
][
1
]
*
self
.
_height
)
QPointF
(
latency
[
0
][
0
],
latency
[
0
][
1
]
*
self
.
_height
)
)
# starting point
for
_x
,
_y
in
latency
[
1
:]:
latency_path
.
lineTo
(
x
+
_x
,
y
+
_y
*
self
.
_height
)
latency_path
.
lineTo
(
_x
,
_y
*
self
.
_height
)
latency_path
.
closeSubpath
()
self
.
_latency_item
=
QGraphicsPathItem
(
latency_path
)
self
.
_latency_item
.
setPen
(
pen
1
)
self
.
_latency_item
.
setPen
(
latency_outline_
pen
)
if
execution_time
:
execution_time_path
=
QPainterPath
(
@@ -193,52 +184,37 @@ class GraphicsComponentItem(QGraphicsItemGroup):
execution_time_path
.
lineTo
(
_x
,
_y
*
self
.
_height
)
execution_time_path
.
closeSubpath
()
self
.
_execution_time_item
=
QGraphicsPathItem
(
execution_time_path
)
self
.
_execution_time_item
.
setPen
(
pen3
)
# component path
def
draw_component_path
(
keys
:
List
[
str
],
reversed
:
bool
)
->
None
:
"""
Draws component path and also register port positions in self._ports dictionary.
"""
nonlocal
y
nonlocal
old_x
nonlocal
old_y
neg
=
-
1
if
reversed
else
1
for
key
in
keys
:
# draw 1 or 2 lines
x
=
self
.
_ports
[
key
][
"
latency
"
]
y
=
old_y
+
neg
*
(
self
.
_height
/
len
(
keys
))
# register the port pos in dictionary
port_x
=
x
# Port coordinates is at the center
port_y
=
(
y
-
neg
*
abs
(
y
-
old_y
)
/
2
)
# of previous vertical line.
self
.
_ports
[
key
][
"
pos
"
]
=
QPointF
(
port_x
,
port_y
)
# update last pos
old_x
=
x
old_y
=
y
# draw the path
if
input_keys
:
draw_component_path
(
input_keys
,
False
)
# draw input side
else
:
y
=
old_y
=
self
.
_height
draw_component_path
(
output_keys
,
True
)
# draw output side
self
.
_execution_time_item
.
setPen
(
execution_time_pen
)
# component item
self
.
_set_background
(
Qt
.
GlobalColor
.
lightGray
OPERATION_LATENCY_INACTIVE
)
# used by component filling
# ports item
for
port_dict
in
self
.
_ports
.
values
():
port_pos
=
self
.
mapToParent
(
port_dict
[
"
pos
"
])
inputs
,
outputs
=
self
.
_operation
.
get_io_coordinates
()
for
i
,
(
x
,
y
)
in
enumerate
(
inputs
):
pos
=
QPointF
(
x
,
y
*
self
.
_height
)
key
=
f
"
in
{
i
}
"
self
.
_ports
[
key
][
"
pos
"
]
=
pos
port_pos
=
self
.
mapToParent
(
pos
)
port
=
QGraphicsEllipseItem
(
-
port_size
/
2
,
-
port_size
/
2
,
port_size
,
port_size
)
port
.
setPen
(
port_outline_pen
)
port
.
setBrush
(
port_filling_brush
)
port
.
setPos
(
port_pos
.
x
(),
port_pos
.
y
())
self
.
_port_items
.
append
(
port
)
for
i
,
(
x
,
y
)
in
enumerate
(
outputs
):
pos
=
QPointF
(
x
,
y
*
self
.
_height
)
key
=
f
"
out
{
i
}
"
self
.
_ports
[
key
][
"
pos
"
]
=
pos
port_pos
=
self
.
mapToParent
(
pos
)
port
=
QGraphicsEllipseItem
(
-
port_size
/
2
,
-
port_size
/
2
,
port_size
,
port_size
)
# center of circle is in origo
port
.
setPen
(
pen
2
)
port
.
setBrush
(
brush
2
)
)
port
.
setPen
(
port_outline_
pen
)
port
.
setBrush
(
port_filling_
brush
)
port
.
setPos
(
port_pos
.
x
(),
port_pos
.
y
())
self
.
_port_items
.
append
(
port
)
Loading