Currently, calibration always requires drawing a line segment and entering its length. The scale (mm/pixel) is calculated in ScaleCalibrationWindow as length/number of pixels and is written to PixelWidth / PixelHeight. The result is not retained anywhere.
The existing workflow (line segment + length) remains unchanged and continues to write the scale to the current frame, or to all frames of that image when Apply to Series is checked. The new button applies the saved scale to all selected images.
flowchart TD
measure["Calibrate: line segment on image"] --> dialog["Dialog: enter length"]
dialog --> persist["Static variable: mm/pixel"]
persist --> applyFrame["Current frame or its series"]
reuse["Previous calibration button"] --> confirm["Dialog without length input"]
confirm --> applyImages["All selected images"]
A single value: the scale from the last successful calibration in millimeters per pixel (the same value that is already assigned to frame.PixelWidth). Store it in a static field in ScaleCalibrationWindow, with a default value of 0. Settings, app.config, and the user settings file are not modified. The value is lost when the application is restarted.
Add a second mode to ScaleCalibrationWindow for cases where the scale is already known:
Add a constructor with double savedScale alongside the existing ScaleCalibrationWindow(int pixelLength). In this mode, Scale returns the saved value instead of 0.
Next to Calibrate in GwView/MainPage.xaml and CdView/MainPage.xaml, add a button with the tooltip Apply Previous Calibration. It is enabled when there are selected images (SelectionController.ContainsFrames) and the static field is greater than 0. The code updates the button state after a successful calibration and whenever the selection changes.
When clicked, the dialog opens in saved-scale mode. After OK, the scale is written not just to the current frame, but to the selection via ImageControl.GetSelectedImages() — the same approach used by the filter in FilterWindow.xaml.cs:
IsDicomDataSetShared): all frames of each selected image;GetSelectedFrames).For each frame, keep the existing CheckCrossLink and SetPixelSize logic from GwView/MainPage.xaml.cs and CdView/MainPage.xaml.cs. If a frame has a cross-link, show the existing warning.
The regular line-based calibration does not use this path. After it is successfully applied (Scale > 0 and SetPixelSize succeeds), save window.Scale to the static field.