diff --git a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java index 5b737dae6..e8215e2c9 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java @@ -550,4 +550,19 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou // The motor config also has listeners, so clear them as well getDefaultMotorConfig().clearConfigListeners(); } + + /** + * The first time we add a TubeFinSet to the component tree, inherit the tube thickness from + * the parent body tube + */ + @Override + public final void addChild(RocketComponent component, int index, boolean trackStage) { + super.addChild(component, index, trackStage); + if (component instanceof TubeFinSet) { + TubeFinSet finset = (TubeFinSet) component; + if (Double.isNaN(finset.getThickness())) { + finset.setThickness(getThickness()); + } + } + } } diff --git a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java index b5823989c..86e97e472 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java @@ -24,7 +24,7 @@ public class TubeFinSet extends Tube implements AxialPositionable, BoxBounded, R private boolean autoRadius = true; // Radius chosen automatically based on parent component private double outerRadius = DEFAULT_RADIUS; - protected double thickness = 0.002; + protected double thickness = Double.NaN; private AngleMethod angleMethod = AngleMethod.FIXED; protected RadiusMethod radiusMethod = RadiusMethod.RELATIVE; @@ -49,7 +49,7 @@ public class TubeFinSet extends Tube implements AxialPositionable, BoxBounded, R /** - * New FinSet with given number of fins and given base rotation angle. + * New TubeFinSet with default values * Sets the component relative position to POSITION_RELATIVE_BOTTOM, * i.e. fins are positioned at the bottom of the parent component. */ @@ -146,6 +146,7 @@ public class TubeFinSet extends Tube implements AxialPositionable, BoxBounded, R * Sets whether the radius is selected automatically or not. */ public void setOuterRadiusAutomatic(boolean auto) { + for (RocketComponent listener : configListeners) { if (listener instanceof TubeFinSet) { ((TubeFinSet) listener).setOuterRadiusAutomatic(auto); @@ -195,8 +196,9 @@ public class TubeFinSet extends Tube implements AxialPositionable, BoxBounded, R if ((this.thickness == thickness)) return; + this.thickness = MathUtil.clamp(thickness, 0, getOuterRadius()); - fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); + fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); clearPreset(); }