Commit dc78031d authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rf/show-commandline-warning' into 'master'

RF: Show command line option shows a message if any unsaved/unsaveable images

See merge request fsl/fsleyes/fsleyes!226
parents 521e336f 798dab8e
......@@ -51,6 +51,8 @@ Changed
so that, instead of the data being normalised to unit variance before the
fourier transform, the fourier-transformed data itself is normalised to the
range [-1, 1].
* The *Show command line for scene* option will display a warning if any
overlays are not saved.
Fixed
......
......@@ -18,6 +18,7 @@ are also defined here:
import wx
import fsl.data.image as fslimage
import fsleyes_widgets.dialog as fsldlg
import fsleyes.strings as strings
import fsleyes.parseargs as parseargs
......@@ -59,6 +60,21 @@ def showCommandLineArgs(overlayList, displayCtx, canvas):
:arg displayCtx: A :class:`.DisplayContext` instance.
:arg canvas: A :class:`CanvasPanel` instance.
"""
unsaved = False
for o in overlayList:
if o.dataSource is None:
unsaved = True
elif isinstance(o, fslimage.Image) and not o.saveState:
unsaved = True
if unsaved:
msg = strings.messages[canvas, 'showCommandLineArgs', 'unsaved']
title = strings.titles[ canvas, 'showCommandLineArgs', 'unsaved']
wx.MessageBox(msg, title, wx.ICON_EXCLAMATION | wx.OK)
return
args = genCommandLineArgs(overlayList, displayCtx, canvas)
dlg = fsldlg.TextEditDialog(
canvas,
......
......@@ -144,6 +144,9 @@ messages = TypeDict({
'CanvasPanel.showCommandLineArgs.message' : 'Use these parameters on the '
'command line to recreate '
'the current scene',
'CanvasPanel.showCommandLineArgs.unsaved' :
'All of your images must be saved to a file before a command line can be '
'generated!',
'PlotPanel.preparingData' : 'Preparing data - please wait...',
......@@ -447,6 +450,8 @@ titles = TypeDict({
'ClearSettingsAction.confirm' : 'Clear all settings?',
'CanvasPanel.showCommandLineArgs.unsaved' : 'Unsaved images',
'LoadColourMapAction.namecmap' : 'Name colour map.',
'LoadColourMapAction.installcmap' : 'Install colour map?',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment