[fixes #358] Implement multi-component tube fin cluster split

This commit is contained in:
SiboVG 2022-02-17 17:38:46 +01:00
parent 6a9ce5d34a
commit ace8b2c24b
2 changed files with 15 additions and 5 deletions

View File

@ -432,6 +432,7 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab
*/ */
public static InnerTube makeIndividualClusterComponent(Coordinate coord, String splitName, RocketComponent theInnerTube) { public static InnerTube makeIndividualClusterComponent(Coordinate coord, String splitName, RocketComponent theInnerTube) {
InnerTube copy = (InnerTube) theInnerTube.copy(); InnerTube copy = (InnerTube) theInnerTube.copy();
copy.clearConfigListeners();
copy.setClusterConfiguration(ClusterConfiguration.SINGLE); copy.setClusterConfiguration(ClusterConfiguration.SINGLE);
copy.setClusterRotation(0.0); copy.setClusterRotation(0.0);
copy.setClusterScale(1.0); copy.setClusterScale(1.0);

View File

@ -12,6 +12,7 @@ import java.awt.event.ActionListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.geom.Ellipse2D; import java.awt.geom.Ellipse2D;
import java.util.ArrayList;
import java.util.EventObject; import java.util.EventObject;
import java.util.List; import java.util.List;
@ -327,6 +328,18 @@ public class InnerTubeConfig extends RocketComponentConfig {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
document.addUndoPosition("Split cluster");
List<RocketComponent> 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(); RocketComponent parent = component.getParent();
int index = parent.getChildPosition(component); int index = parent.getChildPosition(component);
if (index < 0) { if (index < 0) {
@ -338,11 +351,7 @@ public class InnerTubeConfig extends RocketComponentConfig {
if (tube.getInstanceCount() <= 1) if (tube.getInstanceCount() <= 1)
return; return;
document.addUndoPosition("Split cluster"); Coordinate[] coords = component.getComponentLocations();
Coordinate[] coords = new Coordinate[]{Coordinate.ZERO };
// coords = component.shiftCoordinates( coords); // old version
coords = component.getComponentLocations();
parent.removeChild(index); parent.removeChild(index);
for (int i = 0; i < coords.length; i++) { for (int i = 0; i < coords.length; i++) {
InnerTube copy = InnerTube.makeIndividualClusterComponent(coords[i], component.getName() + " #" + (i + 1), component); InnerTube copy = InnerTube.makeIndividualClusterComponent(coords[i], component.getName() + " #" + (i + 1), component);