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
9d6437b8
Commit
9d6437b8
authored
May 21, 2021
by
Valentin Valls
Browse files
Test the ROI selection behavior
parent
c3723876
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/qt/flint/manager/test_manager.py
View file @
9d6437b8
"""Testing manager module."""
import
copy
from
bliss.flint.manager.manager
import
ManageMainBehaviours
from
bliss.flint.model
import
flint_model
from
bliss.flint.model
import
plot_item_model
from
bliss.flint.widgets.curve_plot
import
CurvePlotWidget
from
bliss.flint.helper
import
scan_info_helper
SCAN_INFO_LIMA_ROIS
=
{
"acquisition_chain"
:
{
"timer"
:
{
"devices"
:
[
"timer"
,
"beamviewer"
,
"beamviewer:roi_counters"
]}
},
"devices"
:
{
"timer"
:
{
"channels"
:
[
"timer:elapsed_time"
,
"timer:epoch"
],
"triggered_devices"
:
[
"beamviewer"
],
},
"beamviewer"
:
{
"type"
:
"lima"
,
"triggered_devices"
:
[
"beamviewer:roi_counters"
],
"channels"
:
[
"beamviewer:image"
],
},
"beamviewer:roi_counters"
:
{
"channels"
:
[
"beamviewer:roi_counters:roi1_sum"
,
"beamviewer:roi_counters:roi2_sum"
,
],
"roi1"
:
{
"kind"
:
"rect"
,
"x"
:
190
,
"y"
:
110
,
"width"
:
600
,
"height"
:
230
},
"roi2"
:
{
"kind"
:
"arc"
,
"cx"
:
487.0
,
"cy"
:
513.0
,
"r1"
:
137.0
,
"r2"
:
198.0
,
"a1"
:
-
172.0
,
"a2"
:
-
300.0
,
},
},
},
"channels"
:
{
"timer:elapsed_time"
:
{
"dim"
:
0
},
"timer:epoch"
:
{
"dim"
:
0
},
"beamviewer:roi_counters:roi1_sum"
:
{
"dim"
:
0
},
"beamviewer:roi_counters:roi2_sum"
:
{
"dim"
:
0
},
"beamviewer:image"
:
{
"dim"
:
2
},
},
}
def
_create_ascan_scan_info
(
master_name
,
extra_name
=
None
):
result
=
{
"type"
:
"ascan"
,
...
...
@@ -35,6 +78,16 @@ def _create_ascan_scan_info(master_name, extra_name=None):
return
result
def
_create_lima_scan_info
(
include_roi2
):
"""
Simulate a scan containing a lima detector with ROIs.
"""
result
=
copy
.
deepcopy
(
SCAN_INFO_LIMA_ROIS
)
if
not
include_roi2
:
del
result
[
"devices"
][
"beamviewer:roi_counters"
][
"roi2"
]
return
result
def
test_consecutive_scans__loopscan_ascan
(
local_flint
):
"""
Test plot state with consecutive scans
...
...
@@ -114,3 +167,47 @@ def test_consecutive_scans__ascan_ascan(local_flint):
model
=
widget
.
plotModel
()
item
=
model
.
items
()[
0
]
assert
item
.
xChannel
().
name
()
==
"axis:sy"
def
test_plot_with_new_roi
(
local_flint
):
"""Test the resulted image plot when a new ROI is part of the scan.
We expect:
- The previous ROI to still use the same config
- The new ROI to be displayed.
"""
flint
=
flint_model
.
FlintState
()
workspace
=
flint_model
.
Workspace
()
flint
.
setWorkspace
(
workspace
)
widget
=
CurvePlotWidget
()
workspace
.
addWidget
(
widget
)
manager
=
ManageMainBehaviours
()
manager
.
setFlintModel
(
flint
)
scan_info1
=
_create_lima_scan_info
(
include_roi2
=
False
)
scan
=
scan_info_helper
.
create_scan_model
(
scan_info1
)
plots
=
scan_info_helper
.
create_plot_model
(
scan_info1
,
scan
)
plot
=
[
p
for
p
in
plots
if
isinstance
(
p
,
plot_item_model
.
ImagePlot
)][
0
]
manager
.
updateWidgetWithPlot
(
widget
,
scan
,
plot
,
useDefaultPlot
=
True
)
plotModel
=
widget
.
plotModel
()
assert
len
(
plotModel
.
items
())
==
2
# image + ROI
roiItem
=
[
i
for
i
in
plotModel
.
items
()
if
isinstance
(
i
,
plot_item_model
.
RoiItem
)][
0
]
roiItem
.
setVisible
(
False
)
scan_info2
=
_create_lima_scan_info
(
include_roi2
=
True
)
scan
=
scan_info_helper
.
create_scan_model
(
scan_info2
)
plots
=
scan_info_helper
.
create_plot_model
(
scan_info2
,
scan
)
plot
=
[
p
for
p
in
plots
if
isinstance
(
p
,
plot_item_model
.
ImagePlot
)][
0
]
manager
.
updateWidgetWithPlot
(
widget
,
scan
,
plot
,
useDefaultPlot
=
True
)
plotModel
=
widget
.
plotModel
()
assert
len
(
plotModel
.
items
())
==
3
# image + ROI * 2
roiItems
=
[
i
for
i
in
plotModel
.
items
()
if
isinstance
(
i
,
plot_item_model
.
RoiItem
)]
rois
=
{
r
.
name
():
r
.
isVisible
()
for
r
in
roiItems
}
assert
rois
==
{
"roi1"
:
False
,
"roi2"
:
True
}
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