From 50e14410088e70ff0923a1cc2cef63a77d329f12 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Wed, 30 Nov 2022 17:30:24 -0700 Subject: [PATCH 1/2] Remove bounds limit on rocket figure scaling Note the sanity checks (scale must be greater than 0, etc) are still present Make epsilon in check of new vs. old scale factor depend on old scale factor so setting new scale can still work with tiny scales. --- .../openrocket/gui/scalefigure/AbstractScaleFigure.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/AbstractScaleFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/AbstractScaleFigure.java index ebeb76ebb..492c5c483 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/AbstractScaleFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/AbstractScaleFigure.java @@ -27,9 +27,6 @@ public abstract class AbstractScaleFigure extends JPanel { public static final double INCHES_PER_METER = 39.3701; public static final double METERS_PER_INCH = 0.0254; - public static final double MINIMUM_ZOOM = 0.01; // == 1 % - public static final double MAXIMUM_ZOOM = 1000.00; // == 10,000 % - // Number of pixels to leave at edges when fitting figure private static final int DEFAULT_BORDER_PIXELS_WIDTH = 30; private static final int DEFAULT_BORDER_PIXELS_HEIGHT = 20; @@ -113,7 +110,7 @@ public abstract class AbstractScaleFigure extends JPanel { * @return true if the scale changed, false if it was already at the requested scale or something went wrong. */ public boolean scaleTo(final double newScaleRequest, final Dimension newVisibleBounds) { - if (MathUtil.equals(this.userScale, newScaleRequest, 0.01) && + if (MathUtil.equals(this.userScale, newScaleRequest, newScaleRequest * 0.01) && (visibleBounds_px.width == newVisibleBounds.width) && (visibleBounds_px.height == newVisibleBounds.height) ) { return false; @@ -122,7 +119,8 @@ public abstract class AbstractScaleFigure extends JPanel { return false; } - this.userScale = MathUtil.clamp( newScaleRequest, MINIMUM_ZOOM, MAXIMUM_ZOOM); + this.userScale = newScaleRequest; + this.scale = baseScale * userScale; updateCanvasOrigin(); From 00301bb866b4b8bdf6f52c3a373e58d8b7b3fcf0 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Wed, 30 Nov 2022 17:33:39 -0700 Subject: [PATCH 2/2] Code was setting MINIMUM_ZOOM and MAXIMUM_ZOOM but never using them --- swing/src/net/sf/openrocket/gui/scalefigure/ScaleSelector.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/ScaleSelector.java b/swing/src/net/sf/openrocket/gui/scalefigure/ScaleSelector.java index 661d45bdf..c216b4f50 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/ScaleSelector.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/ScaleSelector.java @@ -18,9 +18,6 @@ import net.sf.openrocket.util.StateChangeListener; @SuppressWarnings("serial") public class ScaleSelector { - - public static final double MINIMUM_ZOOM = 0.01; // == 1 % - public static final double MAXIMUM_ZOOM = 1000.00; // == 10,000 % // Ready zoom settings private static final DecimalFormat PERCENT_FORMAT = new DecimalFormat("0.#%");