Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
64288df2
Commit
64288df2
authored
May 29, 2021
by
Valentin Valls
Browse files
Insert scan at right place when it is loaded from history
parent
9ab47bf7
Changes
4
Hide whitespace changes
Inline
Side-by-side
bliss/flint/model/scan_model.py
View file @
64288df2
...
...
@@ -394,6 +394,10 @@ class Scan(qt.QObject, _Sealable):
raise
KeyError
(
"Version do not match"
)
return
result
[
1
]
def
startTime
(
self
):
scanInfo
=
self
.
scanInfo
()
return
scanInfo
.
get
(
"start_time"
,
None
)
class
ScanGroup
(
Scan
):
"""Scan group object.
...
...
bliss/flint/widgets/curve_plot.py
View file @
64288df2
...
...
@@ -555,6 +555,18 @@ class CurvePlotWidget(plot_helper.PlotWidget):
self
.
scanListUpdated
.
emit
(
self
.
__scans
)
self
.
__redrawAllScans
()
def
insertScan
(
self
,
scan
):
if
scan
is
None
:
return
if
scan
is
self
.
__scan
:
_logger
.
warning
(
"Removing the current scan is not available"
)
return
self
.
__scans
.
append
(
scan
)
self
.
__scans
=
list
(
reversed
(
sorted
(
self
.
__scans
,
key
=
lambda
s
:
s
.
startTime
())))
self
.
__syncStyleStrategy
()
self
.
scanListUpdated
.
emit
(
self
.
__scans
)
self
.
__redrawAllScans
()
def
setMaxStoredScans
(
self
,
maxScans
:
int
):
# FIXME: Must emit event
self
.
__maxStoredScans
=
maxScans
...
...
bliss/flint/widgets/curve_plot_property.py
View file @
64288df2
...
...
@@ -890,27 +890,32 @@ class CurvePlotPropertyWidget(qt.QWidget):
scan
=
scan_history
.
create_scan
(
nodeName
)
widget
=
self
.
__focusWidget
if
widget
is
not
None
:
plots
=
scan_info_helper
.
create_plot_model
(
scan
.
scanInfo
(),
scan
)
plots
=
[
p
for
p
in
plots
if
isinstance
(
p
,
plot_item_model
.
CurvePlot
)]
if
len
(
plots
)
==
0
:
_logger
.
warning
(
"No curve plot to display"
)
qt
.
QMessageBox
.
warning
(
None
,
"Warning"
,
"There was no curve plot in the selected scan"
)
return
plotModel
=
plots
[
0
]
previousWidgetPlot
=
self
.
__plotModel
# Reuse only available values
if
isinstance
(
previousWidgetPlot
,
plot_item_model
.
CurvePlot
):
model_helper
.
removeNotAvailableChannels
(
previousWidgetPlot
,
plotModel
,
scan
)
widget
.
setScan
(
scan
)
if
previousWidgetPlot
is
None
or
previousWidgetPlot
.
isEmpty
():
if
plotModel
.
styleStrategy
()
is
None
:
plotModel
.
setStyleStrategy
(
DefaultStyleStrategy
(
self
.
__flintModel
))
widget
.
setPlotModel
(
plotModel
)
if
widget
.
isPreviousScanStored
():
widget
.
insertScan
(
scan
)
else
:
plots
=
scan_info_helper
.
create_plot_model
(
scan
.
scanInfo
(),
scan
)
plots
=
[
p
for
p
in
plots
if
isinstance
(
p
,
plot_item_model
.
CurvePlot
)]
if
len
(
plots
)
==
0
:
_logger
.
warning
(
"No curve plot to display"
)
qt
.
QMessageBox
.
warning
(
None
,
"Warning"
,
"There was no curve plot in the selected scan"
)
return
plotModel
=
plots
[
0
]
previousWidgetPlot
=
self
.
__plotModel
# Reuse only available values
if
isinstance
(
previousWidgetPlot
,
plot_item_model
.
CurvePlot
):
model_helper
.
removeNotAvailableChannels
(
previousWidgetPlot
,
plotModel
,
scan
)
widget
.
setScan
(
scan
)
if
previousWidgetPlot
is
None
or
previousWidgetPlot
.
isEmpty
():
if
plotModel
.
styleStrategy
()
is
None
:
plotModel
.
setStyleStrategy
(
DefaultStyleStrategy
(
self
.
__flintModel
)
)
widget
.
setPlotModel
(
plotModel
)
def
__findItemFromPlotItem
(
self
,
requestedItem
:
plot_model
.
Item
...
...
bliss/flint/widgets/delegates.py
View file @
64288df2
...
...
@@ -378,8 +378,7 @@ class ScanStartTimeDelegate(qt.QStyledItemDelegate):
return
editor
def
__toStartTimeText
(
self
,
scan
:
scan_model
.
Scan
)
->
str
:
scanInfo
=
scan
.
scanInfo
()
value
=
scanInfo
.
get
(
"start_time"
,
None
)
value
=
scan
.
startTime
()
if
value
is
None
:
return
""
return
value
.
strftime
(
"%H:%M"
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment