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
29feb3be
Commit
29feb3be
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Initial GUI support for swapping IOs
parent
9220108b
No related branches found
No related tags found
1 merge request
!326
Swap
Pipeline
#96181
passed
2 years ago
Stage: test
Stage: deploy
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/GUI/drag_button.py
+1
-1
1 addition, 1 deletion
b_asic/GUI/drag_button.py
b_asic/scheduler_gui/operation_item.py
+20
-1
20 additions, 1 deletion
b_asic/scheduler_gui/operation_item.py
b_asic/scheduler_gui/scheduler_event.py
+14
-6
14 additions, 6 deletions
b_asic/scheduler_gui/scheduler_event.py
with
35 additions
and
8 deletions
b_asic/GUI/drag_button.py
+
1
−
1
View file @
29feb3be
...
@@ -47,7 +47,7 @@ class DragButton(QPushButton):
...
@@ -47,7 +47,7 @@ class DragButton(QPushButton):
self
,
self
,
operation
:
Operation
,
operation
:
Operation
,
show_name
:
bool
,
show_name
:
bool
,
window
,
window
:
"
SFGMainWindow
"
,
parent
=
None
,
parent
=
None
,
):
):
self
.
name
=
operation
.
name
or
operation
.
graph_id
self
.
name
=
operation
.
name
or
operation
.
graph_id
...
...
This diff is collapsed.
Click to expand it.
b_asic/scheduler_gui/operation_item.py
+
20
−
1
View file @
29feb3be
...
@@ -12,11 +12,13 @@ from typing import TYPE_CHECKING, Dict, List, Union, cast
...
@@ -12,11 +12,13 @@ from typing import TYPE_CHECKING, Dict, List, Union, cast
from
qtpy.QtCore
import
QPointF
,
Qt
from
qtpy.QtCore
import
QPointF
,
Qt
from
qtpy.QtGui
import
QBrush
,
QColor
,
QCursor
,
QPainterPath
,
QPen
from
qtpy.QtGui
import
QBrush
,
QColor
,
QCursor
,
QPainterPath
,
QPen
from
qtpy.QtWidgets
import
(
from
qtpy.QtWidgets
import
(
QAction
,
QGraphicsEllipseItem
,
QGraphicsEllipseItem
,
QGraphicsItem
,
QGraphicsItem
,
QGraphicsItemGroup
,
QGraphicsItemGroup
,
QGraphicsPathItem
,
QGraphicsPathItem
,
QGraphicsSimpleTextItem
,
QGraphicsSimpleTextItem
,
QMenu
,
)
)
# B-ASIC
# B-ASIC
...
@@ -81,12 +83,13 @@ class OperationItem(QGraphicsItemGroup):
...
@@ -81,12 +83,13 @@ class OperationItem(QGraphicsItemGroup):
self
.
setFlag
(
QGraphicsItem
.
ItemIsSelectable
)
# mouse move events
self
.
setFlag
(
QGraphicsItem
.
ItemIsSelectable
)
# mouse move events
# self.setAcceptHoverEvents(True) # mouse hover events
# self.setAcceptHoverEvents(True) # mouse hover events
self
.
setAcceptedMouseButtons
(
self
.
setAcceptedMouseButtons
(
Qt
.
MouseButton
.
LeftButton
Qt
.
MouseButton
.
LeftButton
|
Qt
.
MouseButton
.
RightButton
)
# accepted buttons for movements
)
# accepted buttons for movements
self
.
setCursor
(
self
.
setCursor
(
QCursor
(
Qt
.
CursorShape
.
OpenHandCursor
)
QCursor
(
Qt
.
CursorShape
.
OpenHandCursor
)
)
# default cursor when hovering over object
)
# default cursor when hovering over object
self
.
_context_menu
=
None
self
.
_make_component
()
self
.
_make_component
()
# def sceneEvent(self, event: QEvent) -> bool:
# def sceneEvent(self, event: QEvent) -> bool:
...
@@ -106,6 +109,11 @@ class OperationItem(QGraphicsItemGroup):
...
@@ -106,6 +109,11 @@ class OperationItem(QGraphicsItemGroup):
"""
The graph-id of the operation that the item corresponds to.
"""
"""
The graph-id of the operation that the item corresponds to.
"""
return
self
.
_operation
.
graph_id
return
self
.
_operation
.
graph_id
@property
def
name
(
self
)
->
str
:
"""
The name of the operation that the item corresponds to.
"""
return
self
.
_operation
.
name
@property
@property
def
operation
(
self
)
->
Operation
:
def
operation
(
self
)
->
Operation
:
"""
The operation that the item corresponds to.
"""
"""
The operation that the item corresponds to.
"""
...
@@ -247,3 +255,14 @@ class OperationItem(QGraphicsItemGroup):
...
@@ -247,3 +255,14 @@ class OperationItem(QGraphicsItemGroup):
self
.
addToGroup
(
self
.
_execution_time_item
)
self
.
addToGroup
(
self
.
_execution_time_item
)
self
.
set_inactive
()
self
.
set_inactive
()
def
_open_context_menu
(
self
):
menu
=
QMenu
()
swap
=
QAction
(
"
Swap
"
)
menu
.
addAction
(
swap
)
swap
.
setEnabled
(
self
.
_operation
.
is_swappable
)
swap
.
triggered
.
connect
(
self
.
_swap_io
)
menu
.
exec_
(
self
.
cursor
().
pos
())
def
_swap_io
(
self
,
event
=
None
)
->
None
:
self
.
_operation
.
swap_io
()
This diff is collapsed.
Click to expand it.
b_asic/scheduler_gui/scheduler_event.py
+
14
−
6
View file @
29feb3be
...
@@ -10,7 +10,7 @@ import math
...
@@ -10,7 +10,7 @@ import math
from
typing
import
List
,
Optional
,
overload
from
typing
import
List
,
Optional
,
overload
# QGraphics and QPainter imports
# QGraphics and QPainter imports
from
qtpy.QtCore
import
QEvent
,
QObject
,
QPointF
,
Signal
from
qtpy.QtCore
import
QEvent
,
QObject
,
QPointF
,
Qt
,
Signal
from
qtpy.QtWidgets
import
QGraphicsItem
,
QGraphicsSceneMouseEvent
from
qtpy.QtWidgets
import
QGraphicsItem
,
QGraphicsSceneMouseEvent
from
b_asic.schedule
import
Schedule
from
b_asic.schedule
import
Schedule
...
@@ -181,14 +181,22 @@ class SchedulerEvent: # PyQt5
...
@@ -181,14 +181,22 @@ class SchedulerEvent: # PyQt5
allows the item to receive future move, release and double-click events.
allows the item to receive future move, release and double-click events.
"""
"""
item
:
OperationItem
=
self
.
scene
().
mouseGrabberItem
()
item
:
OperationItem
=
self
.
scene
().
mouseGrabberItem
()
self
.
_old_op_position
=
self
.
_schedule
.
get_y_location
(
item
.
operation
.
graph_id
)
if
event
.
button
()
==
Qt
.
MouseButton
.
LeftButton
:
self
.
_signals
.
component_selected
.
emit
(
item
.
graph_id
)
self
.
_old_op_position
=
self
.
_schedule
.
get_y_location
(
self
.
_current_pos
=
item
.
mapToParent
(
event
.
pos
())
item
.
operation
.
graph_id
self
.
set_item_active
(
item
)
)
event
.
accept
()
self
.
_signals
.
component_selected
.
emit
(
item
.
graph_id
)
self
.
_current_pos
=
item
.
mapToParent
(
event
.
pos
())
self
.
set_item_active
(
item
)
event
.
accept
()
else
:
# Right-button
item
.
_open_context_menu
()
def
operation_mouseReleaseEvent
(
self
,
event
:
QGraphicsSceneMouseEvent
)
->
None
:
def
operation_mouseReleaseEvent
(
self
,
event
:
QGraphicsSceneMouseEvent
)
->
None
:
"""
Change the cursor to OpenHandCursor when releasing an object.
"""
"""
Change the cursor to OpenHandCursor when releasing an object.
"""
if
event
.
button
()
!=
Qt
.
MouseButton
.
LeftButton
:
return
item
:
OperationItem
=
self
.
scene
().
mouseGrabberItem
()
item
:
OperationItem
=
self
.
scene
().
mouseGrabberItem
()
self
.
set_item_inactive
(
item
)
self
.
set_item_inactive
(
item
)
self
.
set_new_start_time
(
item
)
self
.
set_new_start_time
(
item
)
...
...
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