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
abe9e211
Commit
abe9e211
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
And the new GraphicsSignal class
parent
6504e635
No related branches found
Branches containing commit
No related tags found
1 merge request
!78
Add scheduler GUI
Pipeline
#74662
failed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/scheduler-gui/graphics_signal.py
+54
-0
54 additions, 0 deletions
b_asic/scheduler-gui/graphics_signal.py
with
54 additions
and
0 deletions
b_asic/scheduler-gui/graphics_signal.py
0 → 100644
+
54
−
0
View file @
abe9e211
from
typing
import
Optional
from
qtpy.QtWidgets
import
QGraphicsItem
,
QGraphicsPathItem
from
qtpy.QtGui
import
QPainterPath
,
QPen
from
qtpy.QtCore
import
Qt
,
QPointF
# B-ASIC
from
b_asic.signal
import
Signal
from
graphics_component_item
import
GraphicsComponentItem
class
GraphicsSignal
(
QGraphicsPathItem
):
_path
:
Optional
[
QPainterPath
]
=
None
_src_operation
:
GraphicsComponentItem
_dest_operation
:
GraphicsComponentItem
_signal
:
Signal
def
__init__
(
self
,
src_operation
:
GraphicsComponentItem
,
dest_operation
:
GraphicsComponentItem
,
signal
:
Signal
,
pen
:
Optional
[
QPen
]
=
None
,
parent
:
Optional
[
QGraphicsItem
]
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
_src_operation
=
src_operation
self
.
_dest_operation
=
dest_operation
self
.
_signal
=
signal
if
pen
is
None
:
pen
=
QPen
(
Qt
.
black
)
pen
.
setWidthF
(
0.03
)
self
.
setPen
(
pen
)
self
.
update_path
()
def
update_path
(
self
):
"""
Create a new path after moving connected operations.
"""
source_point
=
self
.
_src_operation
.
get_port_location
(
f
"
out
{
self
.
_signal
.
source
.
index
}
"
)
dest_point
=
self
.
_dest_operation
.
get_port_location
(
f
"
in
{
self
.
_signal
.
destination
.
index
}
"
)
path
=
QPainterPath
()
path
.
moveTo
(
source_point
)
source_x
=
source_point
.
x
()
source_y
=
source_point
.
y
()
dest_x
=
dest_point
.
x
()
dest_y
=
dest_point
.
y
()
if
abs
(
source_x
-
dest_x
)
<=
0.1
:
ctrl_point1
=
QPointF
(
source_x
+
0.5
,
source_y
)
ctrl_point2
=
QPointF
(
source_x
-
0.5
,
dest_y
)
else
:
mid_x
=
(
source_x
+
dest_x
)
/
2
ctrl_point1
=
QPointF
(
mid_x
,
source_y
)
ctrl_point2
=
QPointF
(
mid_x
,
dest_y
)
path
.
cubicTo
(
ctrl_point1
,
ctrl_point2
,
dest_point
)
self
.
setPath
(
path
)
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