From 7fac3677492917bbbed3c4a97bb4c2dd4f471c86 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sun, 11 Sep 2022 11:29:59 +0200 Subject: [PATCH 1/3] Remove unneeded make 1010/1515 rail button generators --- .../rocketcomponent/RailButton.java | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java index 794e639f1..a9cc2cc60 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java @@ -27,11 +27,6 @@ public class RailButton extends ExternalComponent implements AnglePositionable, private static final Translator trans = Application.getTranslator(); - // NOTE: Rail Button ARE NOT STANDARD -- They vary by manufacturer, and model. - // These presets have appropriate dimensions for each rail size, given the Rail Buttons contribute so little to flying properties. - public static final RailButton ROUND_1010 = make1010Button(); - public static final RailButton ROUND_1515 = make1515Button(); - /* * Rail Button Dimensions (side view) * @@ -93,34 +88,6 @@ public class RailButton extends ExternalComponent implements AnglePositionable, super.displayOrder_side = 14; // Order for displaying the component in the 2D side view super.displayOrder_back = 11; // Order for displaying the component in the 2D back view } - - private static final RailButton make1010Button(){ - final double id = 0.008; // guess - final double od = 0.0097; - final double ht = 0.0097; - final double thickness = 0.002; // guess - final double standoff = 0.002; // guess - RailButton rb1010 = new RailButton( od, id, ht, thickness, standoff); - rb1010.setMassOverridden(true); - rb1010.setOverrideMass(0.0019); - - rb1010.setInstanceCount(1); - rb1010.setInstanceSeparation( od*6 ); - return rb1010; - } - - private static final RailButton make1515Button(){ - final double id = 0.012; // guess - final double od = 0.016; - final double ht = 0.0173; - final double thickness = 0.0032; // guess - final double standoff = 0.0032; // guess - RailButton rb1010 = new RailButton( od, id, ht, thickness, standoff); - rb1010.setMassOverridden(true); - rb1010.setOverrideMass(0.0077); - - return rb1010; - } public double getBaseHeight(){ return this.baseHeight_m; From 3b270e499b92554c62e474067ebb1704488782bd Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sun, 11 Sep 2022 14:35:53 +0200 Subject: [PATCH 2/3] [#1661] Add scaling for rail buttons --- .../openrocket/gui/dialogs/ScaleDialog.java | 43 ++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java index ce2fe5c16..85a48b039 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java @@ -6,7 +6,6 @@ import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -99,7 +98,13 @@ public class ScaleDialog extends JDialog { // Body tube addScaler(BodyTube.class, "OuterRadius", "isOuterRadiusAutomatic", SCALERS_NO_OFFSET); addScaler(BodyTube.class, "MotorOverhang", SCALERS_NO_OFFSET); - + + // Rail button + list = new ArrayList<>(1); + list.add(new RailButtonScaler()); + SCALERS_NO_OFFSET.put(RailButton.class, list); + addScaler(RailButton.class, "InstanceSeparation", SCALERS_OFFSET); + // Launch lug addScaler(LaunchLug.class, "OuterRadius", SCALERS_NO_OFFSET); addScaler(LaunchLug.class, "Thickness", SCALERS_NO_OFFSET); @@ -752,12 +757,11 @@ public class ScaleDialog extends JDialog { @Override public void scale(RocketComponent component, double multiplier, boolean scaleMass) { final Map, List> scalers = new HashMap<>(); - RadiusRingComponent ring = (RadiusRingComponent) component; // We need to specify this particular order, otherwise scale the inner/outer radius may clip the dimensions of the other outer/inner radius - if (multiplier >= 1) { + if (multiplier >= 1) { // Scale up addScaler(RadiusRingComponent.class, "OuterRadius", "isOuterRadiusAutomatic", scalers); addScaler(RadiusRingComponent.class, "InnerRadius", "isInnerRadiusAutomatic", scalers); - } else { + } else { // Scale down addScaler(RadiusRingComponent.class, "InnerRadius", "isInnerRadiusAutomatic", scalers); addScaler(RadiusRingComponent.class, "OuterRadius", "isOuterRadiusAutomatic", scalers); } @@ -770,5 +774,34 @@ public class ScaleDialog extends JDialog { } } + + private static class RailButtonScaler implements Scaler { + + @Override + public void scale(RocketComponent component, double multiplier, boolean scaleMass) { + final Map, List> scalers = new HashMap<>(); + // We need to specify this particular order, otherwise scale the inner/outer radius may clip the dimensions of the other outer/inner radius + if (multiplier >= 1) { // Scale up + addScaler(RailButton.class, "OuterDiameter", scalers); + addScaler(RailButton.class, "InnerDiameter", scalers); + addScaler(RailButton.class, "TotalHeight", scalers); + addScaler(RailButton.class, "BaseHeight", scalers); + addScaler(RailButton.class, "FlangeHeight", scalers); + } else { // Scale down + addScaler(RailButton.class, "InnerDiameter", scalers); + addScaler(RailButton.class, "OuterDiameter", scalers); + addScaler(RailButton.class, "BaseHeight", scalers); + addScaler(RailButton.class, "FlangeHeight", scalers); + addScaler(RailButton.class, "TotalHeight", scalers); + } + + for (List foo : scalers.values()) { + for (Scaler s : foo) { + s.scale(component, multiplier, scaleMass); + } + } + } + + } } From eea2c03f8bebca60eb3e68baf66c71509504c9aa Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sun, 11 Sep 2022 14:50:36 +0200 Subject: [PATCH 3/3] [#1663] Fix duplicate scaling of multi-selection children --- swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java index ce2fe5c16..3fe83fa26 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java @@ -527,8 +527,10 @@ public class ScaleDialog extends JDialog { // they were also part of selection) List scaledComponents = new ArrayList<>(); for (RocketComponent component : selection) { - scale(component, mul, scaleMass, scaleOffsets.isSelected()); - scaledComponents.add(component); + if (!scaledComponents.contains(component)) { + scale(component, mul, scaleMass, scaleOffsets.isSelected()); + scaledComponents.add(component); + } if (component.getChildCount() > 0) { scaleChildren(component, scaledComponents, mul, scaleMass);