diff --git a/core/src/net/sf/openrocket/rocketcomponent/FreeformFinSet.java b/core/src/net/sf/openrocket/rocketcomponent/FreeformFinSet.java index 94a4f80b9..518433a6c 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FreeformFinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FreeformFinSet.java @@ -45,15 +45,16 @@ public class FreeformFinSet extends FinSet { * The specified fin set should not be used after the call! * * @param finset the fin set to convert. + * @param freezeRocket whether to freeze the rocket before conversion. * @return the new freeform fin set. */ - public static FreeformFinSet convertFinSet(FinSet finset) { + public static FreeformFinSet convertFinSet(FinSet finset, boolean freezeRocket) { final RocketComponent root = finset.getRoot(); FreeformFinSet freeform; List toInvalidate = new ArrayList<>(); try { - if (root instanceof Rocket) { + if (freezeRocket && root instanceof Rocket) { ((Rocket) root).freeze(); } @@ -91,9 +92,18 @@ public class FreeformFinSet extends FinSet { if (parent != null) { parent.addChild(freeform, position); } + + // Convert config listeners + for (RocketComponent listener : finset.configListeners) { + if (listener instanceof FinSet) { + FreeformFinSet listenerSet = FreeformFinSet.convertFinSet((FinSet) listener, false); + freeform.addConfigListener(listenerSet); + finset.removeConfigListener(listener); + } + } } finally { - if (root instanceof Rocket) { + if (freezeRocket && root instanceof Rocket) { ((Rocket) root).thaw(); } // Invalidate components after events have been fired @@ -101,9 +111,24 @@ public class FreeformFinSet extends FinSet { c.invalidate(); } } + return freeform; } + /** + * Convert an existing fin set into a freeform fin set. The specified + * fin set is taken out of the rocket tree (if any) and the new component + * inserted in its stead. + *

+ * The specified fin set should not be used after the call! + * + * @param finset the fin set to convert. + * @return the new freeform fin set. + */ + public static FreeformFinSet convertFinSet(FinSet finset) { + return convertFinSet(finset, true); + } + /** * Converts a point of this fin set to edit into a point for a config listener to edit. *