Displays a "Process all images?" dialog. Returns 'flags'+PlugInFilter.DOES_STACKS if the user selects "Yes", 'flags' if the user selects "No" and PlugInFilter.DONE if the user selects "Cancel".
(ImagePlus imp, int flags)
| 1325 | if the user selects "Cancel". |
| 1326 | */ |
| 1327 | public static int setupDialog(ImagePlus imp, int flags) { |
| 1328 | if (imp==null || (ij!=null&&ij.hotkey)) { |
| 1329 | if (ij!=null) ij.hotkey=false; |
| 1330 | return flags; |
| 1331 | } |
| 1332 | int stackSize = imp.getStackSize(); |
| 1333 | if (stackSize>1) { |
| 1334 | String macroOptions = Macro.getOptions(); |
| 1335 | if (imp.isComposite() && ((CompositeImage)imp).getMode()==IJ.COMPOSITE) { |
| 1336 | if (macroOptions==null || !macroOptions.contains("slice")) |
| 1337 | return flags | PlugInFilter.DOES_STACKS; |
| 1338 | } |
| 1339 | if (macroOptions!=null) { |
| 1340 | if (macroOptions.indexOf("stack ")>=0) |
| 1341 | return flags | PlugInFilter.DOES_STACKS; |
| 1342 | else |
| 1343 | return flags; |
| 1344 | } |
| 1345 | if (hideProcessStackDialog) |
| 1346 | return flags; |
| 1347 | String note = ((flags&PlugInFilter.NO_CHANGES)==0)?" There is\nno Undo if you select \"Yes\".":""; |
| 1348 | YesNoCancelDialog d = new YesNoCancelDialog(getInstance(), |
| 1349 | "Process Stack?", "Process all "+stackSize+" images?"+note); |
| 1350 | if (d.cancelPressed()) |
| 1351 | return PlugInFilter.DONE; |
| 1352 | else if (d.yesPressed()) { |
| 1353 | if (imp.getStack().isVirtual() && ((flags&PlugInFilter.NO_CHANGES)==0)) { |
| 1354 | int size = (stackSize*imp.getWidth()*imp.getHeight()*imp.getBytesPerPixel()+524288)/1048576; |
| 1355 | String msg = |
| 1356 | "Use the Process>Batch>Virtual Stack command\n"+ |
| 1357 | "to process a virtual stack or convert it into a\n"+ |
| 1358 | "normal stack using Image>Duplicate, which\n"+ |
| 1359 | "will require "+size+"MB of additional memory."; |
| 1360 | error(msg); |
| 1361 | return PlugInFilter.DONE; |
| 1362 | } |
| 1363 | if (IJ.recording()) |
| 1364 | Recorder.recordOption("stack"); |
| 1365 | return flags | PlugInFilter.DOES_STACKS; |
| 1366 | } |
| 1367 | if (IJ.recording()) |
| 1368 | Recorder.recordOption("slice"); |
| 1369 | } |
| 1370 | return flags; |
| 1371 | } |
| 1372 | |
| 1373 | /** Creates a rectangular selection. Removes any existing |
| 1374 | selection if width or height are less than 1. */ |
no test coverage detected