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
827071b0
Commit
827071b0
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Enable connecting multiple ports in a logical manner
parent
7c94e73b
No related branches found
No related tags found
1 merge request
!187
Enable connecting multiple ports in a logical manner
Pipeline
#89660
passed
2 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/GUI/main_window.py
+39
-30
39 additions, 30 deletions
b_asic/GUI/main_window.py
test/test_gui.py
+2
-2
2 additions, 2 deletions
test/test_gui.py
with
41 additions
and
32 deletions
b_asic/GUI/main_window.py
+
39
−
30
View file @
827071b0
...
...
@@ -33,13 +33,14 @@ from b_asic.GUI._preferences import GAP, GRID, MINBUTTONSIZE, PORTHEIGHT
from
b_asic.GUI.arrow
import
Arrow
from
b_asic.GUI.drag_button
import
DragButton
from
b_asic.GUI.gui_interface
import
Ui_main_window
from
b_asic.GUI.port_button
import
PortButton
from
b_asic.GUI.select_sfg_window
import
SelectSFGWindow
from
b_asic.GUI.show_pc_window
import
ShowPCWindow
from
b_asic.GUI.simulate_sfg_window
import
Plot
,
SimulateSFGWindow
from
b_asic.GUI.util_dialogs
import
FaqWindow
,
KeybindsWindow
from
b_asic.GUI.utils
import
decorate_class
,
handle_error
from
b_asic.gui_utils.about_window
import
AboutWindow
from
b_asic.port
import
OutputPort
from
b_asic.port
import
InputPort
,
OutputPort
from
b_asic.save_load_structure
import
python_to_sfg
,
sfg_to_python
from
b_asic.signal_flow_graph
import
SFG
...
...
@@ -125,7 +126,7 @@ class MainWindow(QMainWindow):
self
.
shortcut_help
=
QShortcut
(
QKeySequence
(
"
Ctrl+?
"
),
self
)
self
.
shortcut_help
.
activated
.
connect
(
self
.
display_faq_page
)
self
.
shortcut_signal
=
QShortcut
(
QKeySequence
(
Qt
.
Key_Space
),
self
)
self
.
shortcut_signal
.
activated
.
connect
(
self
.
_connect_
button
)
self
.
shortcut_signal
.
activated
.
connect
(
self
.
_connect_
callback
)
self
.
logger
.
info
(
"
Finished setting up GUI
"
)
self
.
logger
.
info
(
...
...
@@ -288,7 +289,7 @@ class MainWindow(QMainWindow):
]
if
source
and
destination
:
self
.
connect_button
(
source
[
0
],
destination
[
0
])
self
.
_
connect_button
(
source
[
0
],
destination
[
0
])
for
port
in
self
.
pressed_ports
:
port
.
select_port
()
...
...
@@ -494,7 +495,7 @@ class MainWindow(QMainWindow):
namespace
,
self
.
ui
.
custom_operations_list
)
def
create_operation
(
self
,
op
,
position
=
None
,
is_flipped
=
False
):
def
create_operation
(
self
,
op
,
position
=
None
,
is_flipped
:
bool
=
False
):
try
:
if
op
in
self
.
operationDragDict
:
self
.
logger
.
warning
(
...
...
@@ -600,7 +601,7 @@ class MainWindow(QMainWindow):
self
.
pressed_operations
.
clear
()
super
().
keyPressEvent
(
event
)
def
_connect_
button
(
self
,
*
event
):
def
_connect_
callback
(
self
,
*
event
):
if
len
(
self
.
pressed_ports
)
<
2
:
self
.
logger
.
warning
(
"
Cannot connect less than two ports. Please select at least
"
...
...
@@ -608,37 +609,45 @@ class MainWindow(QMainWindow):
)
return
for
i
in
range
(
len
(
self
.
pressed_ports
)
-
1
):
source
=
(
self
.
pressed_ports
[
i
]
if
isinstance
(
self
.
pressed_ports
[
i
].
port
,
OutputPort
)
else
self
.
pressed_ports
[
i
+
1
]
)
destination
=
(
self
.
pressed_ports
[
i
+
1
]
if
source
is
not
self
.
pressed_ports
[
i
+
1
]
else
self
.
pressed_ports
[
i
]
)
if
source
.
port
.
operation
is
destination
.
port
.
operation
:
self
.
logger
.
warning
(
"
Cannot connect to the same port
"
)
continue
pressed_op_inports
=
[
pressed
for
pressed
in
self
.
pressed_ports
if
isinstance
(
pressed
.
port
,
InputPort
)
]
pressed_op_outports
=
[
pressed
for
pressed
in
self
.
pressed_ports
if
isinstance
(
pressed
.
port
,
OutputPort
)
]
if
isinstance
(
source
.
port
,
type
(
destination
.
port
)):
self
.
logger
.
warning
(
"
Cannot connect port of type: %s to port of type: %s.
"
%
(
type
(
source
.
port
).
__name__
,
type
(
destination
.
port
).
__name__
,
)
)
continue
if
len
(
pressed_op_outports
)
!=
1
:
raise
ValueError
(
"
Exactly one output port must be selected!
"
)
self
.
connect_button
(
source
,
destination
)
pressed_op_outport
=
pressed_op_outports
[
0
]
for
pressed_op_inport
in
pressed_op_inports
:
self
.
_connect_button
(
pressed_op_outport
,
pressed_op_inport
)
for
port
in
self
.
pressed_ports
:
port
.
select_port
()
def
connect_button
(
self
,
source
,
destination
):
def
_connect_button
(
self
,
source
:
PortButton
,
destination
:
PortButton
)
->
None
:
"""
Connect two PortButtons with an Arrow.
Parameters
----------
source : PortButton
The PortButton to start the signal at.
destination : PortButton
The PortButton to end the signal at.
Returns
-------
None.
"""
signal_exists
=
(
signal
for
signal
in
source
.
port
.
signals
...
...
This diff is collapsed.
Click to expand it.
test/test_gui.py
+
2
−
2
View file @
827071b0
...
...
@@ -225,7 +225,7 @@ def test_add_operation_and_create_sfg(qtbot, monkeypatch):
assert
len
(
widget
.
pressed_ports
)
==
2
# Connect ports
widget
.
_connect_
button
()
widget
.
_connect_
callback
()
# Not sure why this won't work
# qtbot.keyClick(widget, QtCore.Qt.Key.Key_Space, delay=10)
# Still one selected!?
...
...
@@ -245,7 +245,7 @@ def test_add_operation_and_create_sfg(qtbot, monkeypatch):
QtCore
.
Qt
.
KeyboardModifier
.
ControlModifier
,
)
# Connect
widget
.
_connect_
button
()
widget
.
_connect_
callback
()
assert
len
(
widget
.
signalList
)
==
2
# Select input op
...
...
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