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
e77b3d1f
Commit
e77b3d1f
authored
2 years ago
by
Petter Källström
Browse files
Options
Downloads
Patches
Plain Diff
Changed to 'all'/'none' buttons. Added minimize/maximize
parent
5a527216
No related branches found
No related tags found
1 merge request
!203
Simulation window
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/GUI/plot_window.py
+37
-22
37 additions, 22 deletions
b_asic/GUI/plot_window.py
with
37 additions
and
22 deletions
b_asic/GUI/plot_window.py
+
37
−
22
View file @
e77b3d1f
# TODO's:
# TODO's:
# * Solve the legend update. That isn't working at all.
# * Solve the legend update. That isn't working at all.
# * Change labels "All" and "None" into buttons.
# * Make it work with the main_window
# * Make it work with the main_window
import
re
import
re
...
@@ -15,13 +14,12 @@ from qtpy.QtCore import Qt
...
@@ -15,13 +14,12 @@ from qtpy.QtCore import Qt
from
qtpy.QtGui
import
QKeySequence
from
qtpy.QtGui
import
QKeySequence
# Intereme imports for the Plot class:
# Intereme imports for the Plot class:
from
qtpy.QtWidgets
import
(
# QFrame,; QScrollArea,; QLineEdit,; QSizePolicy,
from
qtpy.QtWidgets
import
(
# QFrame,; QScrollArea,; QLineEdit,; QSizePolicy,
; QLabel,
QApplication
,
QApplication
,
QCheckBox
,
QCheckBox
,
QDialog
,
QDialog
,
QFileDialog
,
QFileDialog
,
QHBoxLayout
,
QHBoxLayout
,
QLabel
,
QListWidget
,
QListWidget
,
QListWidgetItem
,
QListWidgetItem
,
QPushButton
,
QPushButton
,
...
@@ -38,7 +36,7 @@ class PlotCanvas(FigureCanvas):
...
@@ -38,7 +36,7 @@ class PlotCanvas(FigureCanvas):
super
().
__init__
(
fig
)
super
().
__init__
(
fig
)
self
.
axes
=
fig
.
add_subplot
(
111
)
self
.
axes
=
fig
.
add_subplot
(
111
)
self
.
axes
.
xaxis
.
set_major_locator
(
MaxNLocator
(
integer
=
True
))
self
.
axes
.
xaxis
.
set_major_locator
(
MaxNLocator
(
integer
=
True
))
self
.
legend
=
self
.
axes
.
legend
()
self
.
legend
=
None
self
.
logger
=
logger
self
.
logger
=
logger
FigureCanvas
.
updateGeometry
(
self
)
FigureCanvas
.
updateGeometry
(
self
)
...
@@ -76,7 +74,13 @@ class PlotWindow(QDialog):
...
@@ -76,7 +74,13 @@ class PlotWindow(QDialog):
):
):
super
().
__init__
()
super
().
__init__
()
self
.
_window
=
window
self
.
_window
=
window
self
.
setWindowFlags
(
Qt
.
WindowTitleHint
|
Qt
.
WindowCloseButtonHint
)
self
.
setWindowFlags
(
Qt
.
WindowTitleHint
|
Qt
.
WindowCloseButtonHint
|
Qt
.
WindowMinimizeButtonHint
|
Qt
.
WindowMaximizeButtonHint
|
Qt
.
WindowStaysOnTopHint
)
self
.
setWindowTitle
(
"
Simulation result
"
)
self
.
setWindowTitle
(
"
Simulation result
"
)
self
.
sim_result
=
sim_result
self
.
sim_result
=
sim_result
self
.
_auto_redraw
=
False
self
.
_auto_redraw
=
False
...
@@ -124,17 +128,18 @@ class PlotWindow(QDialog):
...
@@ -124,17 +128,18 @@ class PlotWindow(QDialog):
sim_result
[
key
],
visible
=
False
,
label
=
key
sim_result
[
key
],
visible
=
False
,
label
=
key
)
)
self
.
_lines
[
key
]
=
line
self
.
_lines
[
key
]
=
line
self
.
plotcanvas
.
legend
=
self
.
plotcanvas
.
axes
.
legend
()
########### List layout: ##############
########### List layout: ##############
# Add two
label
s for selecting all/none:
# Add two
button
s for selecting all/none:
hlayout
=
QHBoxLayout
()
hlayout
=
QHBoxLayout
()
labelAll
=
QLabel
(
"
All
"
)
button_all
=
QPushButton
(
"
&
All
"
)
labelAll
.
mousePressEvent
=
self
.
_label
_all_click
button_all
.
clicked
.
connect
(
self
.
_button
_all_click
)
la
belNone
=
QLabel
(
"
None
"
)
h
la
yout
.
addWidget
(
button_all
)
labelNone
.
mousePressEvent
=
self
.
_label_none_click
button_none
=
QPushButton
(
"
&None
"
)
hlayout
.
addWidget
(
labelAll
)
button_none
.
clicked
.
connect
(
self
.
_button_none_click
)
hlayout
.
addWidget
(
labelN
one
)
hlayout
.
addWidget
(
button_n
one
)
listlayout
.
addLayout
(
hlayout
)
listlayout
.
addLayout
(
hlayout
)
# Add the entire list
# Add the entire list
...
@@ -155,11 +160,15 @@ class PlotWindow(QDialog):
...
@@ -155,11 +160,15 @@ class PlotWindow(QDialog):
self
.
checklist
.
setFixedWidth
(
150
)
self
.
checklist
.
setFixedWidth
(
150
)
listlayout
.
addWidget
(
self
.
checklist
)
listlayout
.
addWidget
(
self
.
checklist
)
# Add a
"legend" checkbox, connected to the plot.
# Add a
dditional checkboxes
self
.
legend_checkbox
=
QCheckBox
(
"
&Legend
"
)
self
.
legend_checkbox
=
QCheckBox
(
"
&Legend
"
)
self
.
legend_checkbox
.
stateChanged
.
connect
(
self
.
_legend_checkbox_change
)
self
.
legend_checkbox
.
stateChanged
.
connect
(
self
.
_legend_checkbox_change
)
self
.
legend_checkbox
.
setCheckState
(
Qt
.
CheckState
.
Checked
)
self
.
legend_checkbox
.
setCheckState
(
Qt
.
CheckState
.
Checked
)
listlayout
.
addWidget
(
self
.
legend_checkbox
)
listlayout
.
addWidget
(
self
.
legend_checkbox
)
# self.ontop_checkbox = QCheckBox("&On top")
# self.ontop_checkbox.stateChanged.connect(self._ontop_checkbox_change)
# self.ontop_checkbox.setCheckState(Qt.CheckState.Unchecked)
# listlayout.addWidget(self.ontop_checkbox)
# Add "Close" buttons
# Add "Close" buttons
buttonClose
=
QPushButton
(
"
&Close
"
,
self
)
buttonClose
=
QPushButton
(
"
&Close
"
,
self
)
...
@@ -178,19 +187,27 @@ class PlotWindow(QDialog):
...
@@ -178,19 +187,27 @@ class PlotWindow(QDialog):
if
checkState
==
Qt
.
CheckState
.
Checked
:
if
checkState
==
Qt
.
CheckState
.
Checked
:
self
.
plotcanvas
.
legend
=
self
.
plotcanvas
.
axes
.
legend
()
self
.
plotcanvas
.
legend
=
self
.
plotcanvas
.
axes
.
legend
()
self
.
plotcanvas
.
draw
()
self
.
plotcanvas
.
draw
()
# self.plotcanvas.legend
# if checkState == Qt.CheckState.Checked:
# print('legend on')
# else:
# print('legend off')
def
_label_all_click
(
self
,
event
):
# def _ontop_checkbox_change(self, checkState):
# Bugg: It seems the window closes if you change the WindowStaysOnTopHint.
# (Nothing happens if "changing" from False to False or True to True)
# self.setWindowFlag(Qt.WindowStaysOnTopHint, on = (checkState == Qt.CheckState.Checked))
# self.setWindowFlag(Qt.WindowStaysOnTopHint, on = True)
# print("_ontop_checkbox_change")
def
_button_all_click
(
self
,
event
):
self
.
_auto_redraw
=
False
for
x
in
range
(
self
.
checklist
.
count
()):
for
x
in
range
(
self
.
checklist
.
count
()):
self
.
checklist
.
item
(
x
).
setCheckState
(
Qt
.
CheckState
.
Checked
)
self
.
checklist
.
item
(
x
).
setCheckState
(
Qt
.
CheckState
.
Checked
)
self
.
_auto_redraw
=
True
self
.
plotcanvas
.
draw
()
def
_label_none_click
(
self
,
event
):
def
_button_none_click
(
self
,
event
):
self
.
_auto_redraw
=
False
for
x
in
range
(
self
.
checklist
.
count
()):
for
x
in
range
(
self
.
checklist
.
count
()):
self
.
checklist
.
item
(
x
).
setCheckState
(
Qt
.
CheckState
.
Unchecked
)
self
.
checklist
.
item
(
x
).
setCheckState
(
Qt
.
CheckState
.
Unchecked
)
self
.
_auto_redraw
=
True
self
.
plotcanvas
.
draw
()
def
_item_change
(
self
,
listitem
):
def
_item_change
(
self
,
listitem
):
key
=
listitem
.
text
()
key
=
listitem
.
text
()
...
@@ -201,8 +218,6 @@ class PlotWindow(QDialog):
...
@@ -201,8 +218,6 @@ class PlotWindow(QDialog):
if
self
.
legend_checkbox
.
checkState
==
Qt
.
CheckState
.
Checked
:
if
self
.
legend_checkbox
.
checkState
==
Qt
.
CheckState
.
Checked
:
self
.
plotcanvas
.
legend
=
self
.
plotcanvas
.
axes
.
legend
()
self
.
plotcanvas
.
legend
=
self
.
plotcanvas
.
axes
.
legend
()
self
.
plotcanvas
.
draw
()
self
.
plotcanvas
.
draw
()
# print(f"lines[{key}].set(visible={listitem.checkState() == Qt.CheckState.Checked}). autodraw={self._auto_redraw}")
# print("Arg:", listitem)
# Simple test of the dialog
# Simple test of the dialog
...
...
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