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
fb7e6f14
Commit
fb7e6f14
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Introduce GUI settings and scalable height operations
parent
d3e9250e
No related branches found
No related tags found
1 merge request
!100
Introduce GUI settings and scalable height operations
Pipeline
#88026
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/GUI/drag_button.py
+2
-1
2 additions, 1 deletion
b_asic/GUI/drag_button.py
b_asic/GUI/main_window.py
+18
-14
18 additions, 14 deletions
b_asic/GUI/main_window.py
with
20 additions
and
15 deletions
b_asic/GUI/drag_button.py
+
2
−
1
View file @
fb7e6f14
...
@@ -11,6 +11,7 @@ from qtpy.QtWidgets import QAction, QMenu, QPushButton
...
@@ -11,6 +11,7 @@ from qtpy.QtWidgets import QAction, QMenu, QPushButton
from
b_asic.GUI.properties_window
import
PropertiesWindow
from
b_asic.GUI.properties_window
import
PropertiesWindow
from
b_asic.GUI.utils
import
decorate_class
,
handle_error
from
b_asic.GUI.utils
import
decorate_class
,
handle_error
from
b_asic.GUI.settings
import
MINBUTTONSIZE
@decorate_class
(
handle_error
)
@decorate_class
(
handle_error
)
...
@@ -119,7 +120,7 @@ class DragButton(QPushButton):
...
@@ -119,7 +120,7 @@ class DragButton(QPushButton):
),
),
)
)
self
.
setIcon
(
QIcon
(
path_to_image
))
self
.
setIcon
(
QIcon
(
path_to_image
))
self
.
setIconSize
(
QSize
(
55
,
55
))
self
.
setIconSize
(
QSize
(
MINBUTTONSIZE
,
MINBUTTONSIZE
))
def
select_button
(
self
,
modifiers
=
None
):
def
select_button
(
self
,
modifiers
=
None
):
if
modifiers
!=
Qt
.
ControlModifier
:
if
modifiers
!=
Qt
.
ControlModifier
:
...
...
This diff is collapsed.
Click to expand it.
b_asic/GUI/main_window.py
+
18
−
14
View file @
fb7e6f14
...
@@ -35,6 +35,7 @@ from b_asic.GUI.drag_button import DragButton
...
@@ -35,6 +35,7 @@ from b_asic.GUI.drag_button import DragButton
from
b_asic.GUI.gui_interface
import
Ui_main_window
from
b_asic.GUI.gui_interface
import
Ui_main_window
from
b_asic.GUI.port_button
import
PortButton
from
b_asic.GUI.port_button
import
PortButton
from
b_asic.GUI.select_sfg_window
import
SelectSFGWindow
from
b_asic.GUI.select_sfg_window
import
SelectSFGWindow
from
b_asic.GUI.settings
import
GAP
,
MINBUTTONSIZE
,
PORTHEIGHT
,
PORTWIDTH
from
b_asic.GUI.show_pc_window
import
ShowPCWindow
from
b_asic.GUI.show_pc_window
import
ShowPCWindow
from
b_asic.GUI.simulate_sfg_window
import
Plot
,
SimulateSFGWindow
from
b_asic.GUI.simulate_sfg_window
import
Plot
,
SimulateSFGWindow
from
b_asic.GUI.utils
import
decorate_class
,
handle_error
from
b_asic.GUI.utils
import
decorate_class
,
handle_error
...
@@ -448,39 +449,38 @@ class MainWindow(QMainWindow):
...
@@ -448,39 +449,38 @@ class MainWindow(QMainWindow):
self
.
dialog
.
add_sfg_to_dialog
()
self
.
dialog
.
add_sfg_to_dialog
()
self
.
dialog
.
show
()
self
.
dialog
.
show
()
def
_determine_port_distance
(
self
,
length
,
ports
):
def
_determine_port_distance
(
self
,
height
,
ports
):
"""
Determine the distance between each port on the side of an operation.
"""
Determine the distance between each port on the side of an operation.
The method returns the distance that each port should have from 0.
The method returns the distance that each port should have from 0.
"""
"""
return
[
length
/
2
]
if
ports
==
1
else
np
.
linspace
(
0
,
length
,
ports
)
return
[
(
height
-
PORTHEIGHT
)
/
/
2
]
if
ports
==
1
else
[(
PORTHEIGHT
+
GAP
)
*
i
for
i
in
range
(
ports
)
]
def
add_ports
(
self
,
operation
):
def
add_ports
(
self
,
operation
):
op
=
operation
.
operation
height
=
self
.
_get_button_height
(
op
)
_output_ports_dist
=
self
.
_determine_port_distance
(
_output_ports_dist
=
self
.
_determine_port_distance
(
55
-
17
,
operation
.
operation
.
output_count
height
,
op
.
output_count
)
)
_input_ports_dist
=
self
.
_determine_port_distance
(
_input_ports_dist
=
self
.
_determine_port_distance
(
55
-
17
,
operation
.
operation
.
input_count
height
,
op
.
input_count
)
)
self
.
portDict
[
operation
]
=
[]
self
.
portDict
[
operation
]
=
[]
print
(
_output_ports_dist
)
print
(
_input_ports_dist
)
for
i
,
dist
in
enumerate
(
_input_ports_dist
):
for
i
,
dist
in
enumerate
(
_input_ports_dist
):
port
=
PortButton
(
port
=
PortButton
(
"
>
"
,
operation
,
op
eration
.
operation
.
input
(
i
),
self
"
>
"
,
operation
,
op
.
input
(
i
),
self
)
)
self
.
portDict
[
operation
].
append
(
port
)
self
.
portDict
[
operation
].
append
(
port
)
operation
.
ports
.
append
(
port
)
operation
.
ports
.
append
(
port
)
port
.
move
(
0
,
round
(
dist
)
)
port
.
move
(
0
,
dist
)
port
.
show
()
port
.
show
()
for
i
,
dist
in
enumerate
(
_output_ports_dist
):
for
i
,
dist
in
enumerate
(
_output_ports_dist
):
port
=
PortButton
(
port
=
PortButton
(
"
>
"
,
operation
,
op
eration
.
operation
.
output
(
i
),
self
"
>
"
,
operation
,
op
.
output
(
i
),
self
)
)
self
.
portDict
[
operation
].
append
(
port
)
self
.
portDict
[
operation
].
append
(
port
)
operation
.
ports
.
append
(
port
)
operation
.
ports
.
append
(
port
)
port
.
move
(
55
-
12
,
round
(
dist
)
)
port
.
move
(
MINBUTTONSIZE
-
PORTWIDTH
,
dist
)
port
.
show
()
port
.
show
()
def
get_operations_from_namespace
(
self
,
namespace
):
def
get_operations_from_namespace
(
self
,
namespace
):
...
@@ -523,6 +523,10 @@ class MainWindow(QMainWindow):
...
@@ -523,6 +523,10 @@ class MainWindow(QMainWindow):
namespace
,
self
.
ui
.
custom_operations_list
namespace
,
self
.
ui
.
custom_operations_list
)
)
def
_get_button_height
(
self
,
op
):
max_ports
=
max
(
op
.
input_count
,
op
.
output_count
)
return
max
(
MINBUTTONSIZE
,
max_ports
*
PORTHEIGHT
+
(
max_ports
-
1
)
*
GAP
)
def
create_operation
(
self
,
op
,
position
=
None
):
def
create_operation
(
self
,
op
,
position
=
None
):
try
:
try
:
attr_button
=
DragButton
(
attr_button
=
DragButton
(
...
@@ -533,7 +537,7 @@ class MainWindow(QMainWindow):
...
@@ -533,7 +537,7 @@ class MainWindow(QMainWindow):
else
:
else
:
attr_button
.
move
(
*
position
)
attr_button
.
move
(
*
position
)
attr_button
.
setFixedSize
(
55
,
55
)
attr_button
.
setFixedSize
(
MINBUTTONSIZE
,
self
.
_get_button_height
(
op
)
)
attr_button
.
setStyleSheet
(
attr_button
.
setStyleSheet
(
"
background-color: white; border-style: solid;
"
"
background-color: white; border-style: solid;
"
"
border-color: black; border-width: 2px
"
"
border-color: black; border-width: 2px
"
...
@@ -552,7 +556,7 @@ class MainWindow(QMainWindow):
...
@@ -552,7 +556,7 @@ class MainWindow(QMainWindow):
"
custom_operation.png
"
,
"
custom_operation.png
"
,
)
)
attr_button
.
setIcon
(
QIcon
(
icon_path
))
attr_button
.
setIcon
(
QIcon
(
icon_path
))
attr_button
.
setIconSize
(
QSize
(
55
,
55
))
attr_button
.
setIconSize
(
QSize
(
MINBUTTONSIZE
,
MINBUTTONSIZE
))
attr_button
.
setToolTip
(
"
No SFG
"
)
attr_button
.
setToolTip
(
"
No SFG
"
)
attr_button
.
setStyleSheet
(
attr_button
.
setStyleSheet
(
"""
QToolTip { background-color: white;
"""
QToolTip { background-color: white;
...
@@ -562,7 +566,7 @@ class MainWindow(QMainWindow):
...
@@ -562,7 +566,7 @@ class MainWindow(QMainWindow):
attr_button_scene
=
self
.
scene
.
addWidget
(
attr_button
)
attr_button_scene
=
self
.
scene
.
addWidget
(
attr_button
)
if
position
is
None
:
if
position
is
None
:
attr_button_scene
.
moveBy
(
attr_button_scene
.
moveBy
(
int
(
self
.
scene
.
width
()
/
2
),
int
(
self
.
scene
.
height
()
/
2
)
int
(
self
.
scene
.
width
()
/
4
),
int
(
self
.
scene
.
height
()
/
4
)
)
)
attr_button_scene
.
setFlag
(
attr_button_scene
.
ItemIsSelectable
,
True
)
attr_button_scene
.
setFlag
(
attr_button_scene
.
ItemIsSelectable
,
True
)
operation_label
=
QGraphicsTextItem
(
op
.
name
,
attr_button_scene
)
operation_label
=
QGraphicsTextItem
(
op
.
name
,
attr_button_scene
)
...
...
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