diff --git a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java index f1bd573dc..3f9f607ac 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java @@ -432,6 +432,7 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab */ public static InnerTube makeIndividualClusterComponent(Coordinate coord, String splitName, RocketComponent theInnerTube) { InnerTube copy = (InnerTube) theInnerTube.copy(); + copy.clearConfigListeners(); copy.setClusterConfiguration(ClusterConfiguration.SINGLE); copy.setClusterRotation(0.0); copy.setClusterScale(1.0); diff --git a/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java index 4dccf176d..80842547c 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java @@ -12,6 +12,7 @@ import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.geom.Ellipse2D; +import java.util.ArrayList; import java.util.EventObject; import java.util.List; @@ -327,6 +328,18 @@ public class InnerTubeConfig extends RocketComponentConfig { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { + document.addUndoPosition("Split cluster"); + + List listeners = new ArrayList<>(component.getConfigListeners()); + splitAction(component); + for (RocketComponent listener : listeners) { + if (listener instanceof InnerTube) { + splitAction(listener); + } + } + } + + private void splitAction(RocketComponent component) { RocketComponent parent = component.getParent(); int index = parent.getChildPosition(component); if (index < 0) { @@ -338,11 +351,7 @@ public class InnerTubeConfig extends RocketComponentConfig { if (tube.getInstanceCount() <= 1) return; - document.addUndoPosition("Split cluster"); - - Coordinate[] coords = new Coordinate[]{Coordinate.ZERO }; - // coords = component.shiftCoordinates( coords); // old version - coords = component.getComponentLocations(); + Coordinate[] coords = component.getComponentLocations(); parent.removeChild(index); for (int i = 0; i < coords.length; i++) { InnerTube copy = InnerTube.makeIndividualClusterComponent(coords[i], component.getName() + " #" + (i + 1), component);