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
7185d1dd
Commit
7185d1dd
authored
2 years ago
by
Petter Källström
Committed by
Oscar Gustafsson
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
PlotWindow: Added NavigationToolbar. Still the same canvas
parent
705153cc
No related branches found
No related tags found
1 merge request
!228
Update plot window
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/gui_utils/plot_window.py
+20
-24
20 additions, 24 deletions
b_asic/gui_utils/plot_window.py
with
20 additions
and
24 deletions
b_asic/
GUI
/plot_window.py
→
b_asic/
gui_utils
/plot_window.py
+
20
−
24
View file @
7185d1dd
"""
PlotWindow is a window in which simulation results are plotted.
"""
# TODO's:
# * Solve the legend update. That isn't working at all.
# * Zoom etc. Might need to change FigureCanvas. Or just something very little.
...
...
@@ -5,9 +7,8 @@
import
re
import
sys
from
matplotlib.backends.backend_qt5agg
import
(
FigureCanvasQTAgg
as
FigureCanvas
,
)
from
matplotlib.backends.backend_qt5agg
import
FigureCanvasQTAgg
as
FigureCanvas
from
matplotlib.backends.backend_qt5agg
import
NavigationToolbar2QT
as
NavigationToolbar
from
matplotlib.figure
import
Figure
from
matplotlib.ticker
import
MaxNLocator
from
qtpy.QtCore
import
Qt
...
...
@@ -46,9 +47,7 @@ class PlotCanvas(FigureCanvas):
def
_save_plot_figure
(
self
):
self
.
logger
.
info
(
f
"
Saving plot of figure:
{
self
.
sfg
.
name
}
.
"
)
file_choices
=
"
PNG (*.png)|*.png
"
path
,
ext
=
QFileDialog
.
getSaveFileName
(
self
,
"
Save file
"
,
""
,
file_choices
)
path
,
ext
=
QFileDialog
.
getSaveFileName
(
self
,
"
Save file
"
,
""
,
file_choices
)
path
=
path
.
encode
(
"
utf-8
"
)
if
not
path
[
-
4
:]
==
file_choices
[
-
4
:].
encode
(
"
utf-8
"
):
path
+=
file_choices
[
-
4
:].
encode
(
"
utf-8
"
)
...
...
@@ -79,10 +78,10 @@ class PlotWindow(QDialog):
|
Qt
.
WindowCloseButtonHint
|
Qt
.
WindowMinimizeButtonHint
|
Qt
.
WindowMaximizeButtonHint
|
Qt
.
WindowStaysOnTopHint
#
| Qt.WindowStaysOnTopHint
)
self
.
setWindowTitle
(
"
Simulation result
"
)
self
.
sim_result
=
sim_result
#
self.sim_result = sim_result
self
.
_auto_redraw
=
False
# Categorise sim_results into inputs, outputs, delays, others
...
...
@@ -110,26 +109,27 @@ class PlotWindow(QDialog):
self
.
setLayout
(
self
.
dialog_layout
)
listlayout
=
QVBoxLayout
()
self
.
plotcanvas
=
PlotCanvas
(
logger
=
logger
,
parent
=
self
,
width
=
5
,
height
=
4
,
dpi
=
100
)
plotlayout
=
QVBoxLayout
()
self
.
dialog_layout
.
addLayout
(
listlayout
)
self
.
dialog_layout
.
add
Widget
(
self
.
plotcanvas
)
self
.
dialog_layout
.
add
Layout
(
plotlayout
)
########### Plot: ##############
# Do this before the list layout, as the list layout will re/set visibility
# Note: The order is of importens. Interesting lines last, to be on top.
self
.
plotcanvas
=
PlotCanvas
(
logger
=
logger
,
parent
=
self
,
width
=
5
,
height
=
4
,
dpi
=
100
)
self
.
_lines
=
{}
for
key
in
(
sim_res_others
|
sim_res_delays
|
sim_res_ins
|
sim_res_outs
):
line
=
self
.
plotcanvas
.
axes
.
plot
(
sim_result
[
key
],
visible
=
False
,
label
=
key
)
for
key
in
sim_res_others
|
sim_res_delays
|
sim_res_ins
|
sim_res_outs
:
line
=
self
.
plotcanvas
.
axes
.
plot
(
sim_result
[
key
],
visible
=
False
,
label
=
key
)
self
.
_lines
[
key
]
=
line
self
.
plotcanvas
.
legend
=
self
.
plotcanvas
.
axes
.
legend
()
plotlayout
.
addWidget
(
NavigationToolbar
(
self
.
plotcanvas
,
self
))
plotlayout
.
addWidget
(
self
.
plotcanvas
)
########### List layout: ##############
# Add two buttons for selecting all/none:
...
...
@@ -146,9 +146,7 @@ class PlotWindow(QDialog):
self
.
checklist
=
QListWidget
()
self
.
checklist
.
itemChanged
.
connect
(
self
.
_item_change
)
listitems
=
{}
for
key
in
(
sim_res_ins
|
sim_res_outs
|
sim_res_delays
|
sim_res_others
):
for
key
in
sim_res_ins
|
sim_res_outs
|
sim_res_delays
|
sim_res_others
:
listitem
=
QListWidgetItem
(
key
)
listitems
[
key
]
=
listitem
self
.
checklist
.
addItem
(
listitem
)
...
...
@@ -180,9 +178,7 @@ class PlotWindow(QDialog):
self
.
_auto_redraw
=
True
def
_legend_checkbox_change
(
self
,
checkState
):
self
.
plotcanvas
.
legend
.
set
(
visible
=
(
checkState
==
Qt
.
CheckState
.
Checked
)
)
self
.
plotcanvas
.
legend
.
set
(
visible
=
(
checkState
==
Qt
.
CheckState
.
Checked
))
if
self
.
_auto_redraw
:
if
checkState
==
Qt
.
CheckState
.
Checked
:
self
.
plotcanvas
.
legend
=
self
.
plotcanvas
.
axes
.
legend
()
...
...
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