(ImagePlus imp)
| 259 | } |
| 260 | |
| 261 | boolean showDialog(ImagePlus imp) { |
| 262 | Calibration cal = imp.getCalibration(); |
| 263 | if (cal.pixelDepth<0.0) |
| 264 | cal.pixelDepth = -cal.pixelDepth; |
| 265 | String units = cal.getUnits(); |
| 266 | if (cal.pixelWidth==0.0) |
| 267 | cal.pixelWidth = 1.0; |
| 268 | inputZSpacing = cal.pixelDepth; |
| 269 | double outputSpacing = cal.pixelDepth; |
| 270 | Roi roi = imp.getRoi(); |
| 271 | boolean line = roi!=null && roi.getType()==Roi.LINE; |
| 272 | if (line) saveLineInfo(roi); |
| 273 | String macroOptions = Macro.getOptions(); |
| 274 | boolean macroRunning = macroOptions!=null; |
| 275 | if (macroRunning) { |
| 276 | if (macroOptions.indexOf("input=")!=-1) |
| 277 | macroOptions = macroOptions.replaceAll("slice=", "slice_count="); |
| 278 | macroOptions = macroOptions.replaceAll("slice=", "output="); |
| 279 | Macro.setOptions(macroOptions); |
| 280 | nointerpolate = false; |
| 281 | } else { |
| 282 | startAt = startAtS; |
| 283 | rotate = rotateS; |
| 284 | flip = flipS; |
| 285 | sliceCount = sliceCountS; |
| 286 | } |
| 287 | GenericDialog gd = new GenericDialog("Reslice"); |
| 288 | gd.addNumericField("Output spacing ("+units+"):", outputSpacing, 3); |
| 289 | if (line) { |
| 290 | if (!IJ.isMacro()) outputSlices=sliceCount; |
| 291 | gd.addNumericField("Slice_count:", outputSlices, 0); |
| 292 | } else |
| 293 | gd.addChoice("Start at:", starts, startAt); |
| 294 | gd.addCheckbox("Flip vertically", flip); |
| 295 | gd.addCheckbox("Rotate 90 degrees", rotate); |
| 296 | gd.addCheckbox("Avoid interpolation", nointerpolate); |
| 297 | gd.setInsets(0, 32, 0); |
| 298 | gd.addMessage("(use 1 pixel spacing)"); |
| 299 | gd.setInsets(15, 0, 0); |
| 300 | gd.addMessage("Voxel size: "+d2s(cal.pixelWidth)+"x"+d2s(cal.pixelHeight) |
| 301 | +"x"+d2s(cal.pixelDepth)+" "+cal.getUnit()); |
| 302 | gd.setInsets(5, 0, 0); |
| 303 | gd.addMessage("Output size: "+getSize(cal.pixelDepth,outputSpacing,outputSlices)+" "); |
| 304 | fields = gd.getNumericFields(); |
| 305 | if (!macroRunning) { |
| 306 | for (int i=0; i<fields.size(); i++) |
| 307 | ((TextField)fields.elementAt(i)).addTextListener(this); |
| 308 | } |
| 309 | checkboxes = gd.getCheckboxes(); |
| 310 | if (!macroRunning) |
| 311 | ((Checkbox)checkboxes.elementAt(2)).addItemListener(this); |
| 312 | message = (Label)gd.getMessage(); |
| 313 | gd.addHelp(IJ.URL2+"/docs/menus/image.html#reslice"); |
| 314 | gd.showDialog(); |
| 315 | if (gd.wasCanceled()) |
| 316 | return false; |
| 317 | outputZSpacing = gd.getNextNumber()/cal.pixelWidth; |
| 318 | if (line) { |
no test coverage detected