diff --git a/bliss/flint/manager/manager.py b/bliss/flint/manager/manager.py index 1271fb99669fef3aec147814baf893273208fbcd..596e3cf7c5b4a1c9b61a1ae1ce697a8550043166 100755 --- a/bliss/flint/manager/manager.py +++ b/bliss/flint/manager/manager.py @@ -559,7 +559,7 @@ class ManageMainBehaviours(qt.QObject): if isinstance(plotModel, plot_item_model.CurvePlot): previousPlotModel = widget.plotModel() - if previousPlotModel is None: + if useDefaultPlot or previousPlotModel is None: pass else: userEditTime = previousPlotModel.userEditTime() diff --git a/tests/qt/flint/manager/test_manager.py b/tests/qt/flint/manager/test_manager.py index a5b39848dc0f2d55c093793cca34a965f0a384ff..c68f9b4212d6b7e9eb64f41b94b568a8402a7063 100644 --- a/tests/qt/flint/manager/test_manager.py +++ b/tests/qt/flint/manager/test_manager.py @@ -120,7 +120,7 @@ def _create_lima_scan_info(include_roi2): return result -def test_consecutive_scans__loopscan_ascan(local_flint): +def test_curve_plot__from_loopscan_to_ascan(local_flint): """ Test plot state with consecutive scans @@ -151,7 +151,7 @@ def test_consecutive_scans__loopscan_ascan(local_flint): assert item.xChannel().name() == "axis:sx" -def test_consecutive_scans__user_selection(local_flint): +def test_curve_plot__user_selection(local_flint): """ Test plot state with consecutive scans and a user selection in between @@ -170,7 +170,7 @@ def test_consecutive_scans__user_selection(local_flint): scan = scan_info_helper.create_scan_model(loopscan_info) plots = scan_info_helper.create_plot_model(loopscan_info, scan) plot = [p for p in plots if isinstance(p, plot_item_model.CurvePlot)][0] - manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=True) + manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=False) model = widget.plotModel() assert len(model.items()) == 1 @@ -189,13 +189,13 @@ def test_consecutive_scans__user_selection(local_flint): scan = scan_info_helper.create_scan_model(ascan_info) plots = scan_info_helper.create_plot_model(ascan_info, scan) plot = [p for p in plots if isinstance(p, plot_item_model.CurvePlot)][0] - manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=True) + manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=False) model = widget.plotModel() assert len(model.items()) == 2 -def test_consecutive_scans__ascan_ascan(local_flint): +def test_curve_plot__ascan_axis_updated(local_flint): """ Test plot state with consecutive scans @@ -230,7 +230,48 @@ def test_consecutive_scans__ascan_ascan(local_flint): assert item.xChannel().name() == "axis:sy" -def test_plot_with_new_roi(local_flint): +def test_curve_plot__enforced_channel_from_scan_info(local_flint): + """ + Test a new plot with enforced channel (plotinit) + + We expect the channel from the scan_info to be used, + anyway the user selection was done on the previous plot + """ + flint = flint_model.FlintState() + workspace = flint_model.Workspace() + flint.setWorkspace(workspace) + widget = CurvePlotWidget() + workspace.addWidget(widget) + + manager = ManageMainBehaviours() + manager.setFlintModel(flint) + + ascan_info = _create_ascan_scan_info("axis:sx", "axis:sy") + scan = scan_info_helper.create_scan_model(ascan_info) + plots = scan_info_helper.create_plot_model(ascan_info, scan) + manager.updateScanAndPlots(scan, plots) + + enforced_channel = "axis:sy" + + # Enforce a user selection + plotModel = widget.plotModel() + plotModel.tagUserEditTime() + item = plotModel.items()[0] + # Make sure the following test have meaning + assert item.yChannel().name() != enforced_channel + + ascan_info = _create_ascan_scan_info("axis:sy", "axis:sx") + ascan_info["_display_extra"] = {"displayed_channels": [enforced_channel]} + scan = scan_info_helper.create_scan_model(ascan_info) + plots = scan_info_helper.create_plot_model(ascan_info, scan) + manager.updateScanAndPlots(scan, plots) + + plotModel = widget.plotModel() + item = plotModel.items()[0] + assert item.yChannel().name() == enforced_channel + + +def test_image_plot_with_new_roi(local_flint): """Test the resulted image plot when a new ROI is part of the scan. We expect: