diff --git a/core/src/net/sf/openrocket/file/rocksim/importt/RockSimHandler.java b/core/src/net/sf/openrocket/file/rocksim/importt/RockSimHandler.java
index 52f0c8fe7..1aef79cd3 100644
--- a/core/src/net/sf/openrocket/file/rocksim/importt/RockSimHandler.java
+++ b/core/src/net/sf/openrocket/file/rocksim/importt/RockSimHandler.java
@@ -350,6 +350,9 @@ class StageHandler extends AbstractElementHandler {
if (RockSimCommonConstants.TRANSITION.equals(element)) {
return new TransitionHandler(context, component, warnings);
}
+ if (RockSimCommonConstants.SUBASSEMBLY.equals(element)) {
+ return new SubAssemblyHandler(context, component);
+ }
return null;
}
}
diff --git a/core/src/net/sf/openrocket/file/rocksim/importt/SubAssemblyHandler.java b/core/src/net/sf/openrocket/file/rocksim/importt/SubAssemblyHandler.java
index 476696a03..a80f3034d 100644
--- a/core/src/net/sf/openrocket/file/rocksim/importt/SubAssemblyHandler.java
+++ b/core/src/net/sf/openrocket/file/rocksim/importt/SubAssemblyHandler.java
@@ -10,18 +10,21 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
import java.util.HashMap;
/**
- * This class handles Rocksim 'SubAssembly' elements. They are similar to 'AttachedParts' (which is why this class is subclassed from
- * AttachedPartsHandler) with some key differences. In Rocksim, AttachedParts elements can contain SubAssembly elements, which can in turn
+ * This class handles RockSim 'SubAssembly' elements. They are similar to 'AttachedParts' (which is why this class is subclassed from
+ * AttachedPartsHandler) with some key differences. In RockSim, AttachedParts elements can contain SubAssembly elements, which can in turn
* contain AttachedParts elements. To represent them in OR, SubAssembly elements are treated as children of the stage - much like a nose cone or
* external body tube.
*/
public class SubAssemblyHandler extends AttachedPartsHandler {
+ /**
+ * Constructor
+ * @param c the parent component
+ * @throws IllegalArgumentException
+ */
public SubAssemblyHandler(final DocumentLoadingContext context, final RocketComponent c)
throws IllegalArgumentException {
- //A bit of a risk here, but assign the subassembly to the stage, not to the component. This is because typically the
- //first component within the subassembly will be an external component.
- super(context, c.getStage());
+ super(context, c);
}
@Override
@@ -33,9 +36,14 @@ public class SubAssemblyHandler extends AttachedPartsHandler {
if (RockSimCommonConstants.ATTACHED_PARTS.equals(element)) {
return this;
}
- // The key override of this class - treat body tubes as external body tubes.
+ // The key override of this class - treat body tubes, transitions, and nose cones as external components.
+ // note: this will only work if the parent component is a stage.
else if (RockSimCommonConstants.BODY_TUBE.equals(element)) {
return new BodyTubeHandler(getContext(), getComponent(), warnings);
+ } else if (RockSimCommonConstants.TRANSITION.equals(element)) {
+ return new TransitionHandler(getContext(), getComponent(), warnings);
+ } else if (RockSimCommonConstants.NOSE_CONE.equals(element)) {
+ return new NoseConeHandler(getContext(), getComponent(), warnings);
}
return super.openElement(element, attributes, warnings);
}
diff --git a/core/test/net/sf/openrocket/file/rocksim/export/RockSimDocumentDTOTest.java b/core/test/net/sf/openrocket/file/rocksim/export/RockSimDocumentDTOTest.java
index cbc82e30f..afaeef030 100644
--- a/core/test/net/sf/openrocket/file/rocksim/export/RockSimDocumentDTOTest.java
+++ b/core/test/net/sf/openrocket/file/rocksim/export/RockSimDocumentDTOTest.java
@@ -78,7 +78,7 @@ public class RockSimDocumentDTOTest extends RockSimTestBase {
@Test
public void testRoundTrip() throws Exception {
// TODO need checks here to validate that correct things were done
- OpenRocketDocument ord = RockSimLoaderTest.loadRockSimRocket3(new RockSimLoader());
+ OpenRocketDocument ord = RockSimLoaderTest.loadRockSimRocket(new RockSimLoader(), "rocksimTestRocket3.rkt");
Assert.assertNotNull(ord);
String result = new RockSimSaver().marshalToRockSim(ord);
diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeChildrenTest.rkt b/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeChildrenTest.rkt
new file mode 100644
index 000000000..a678fd281
--- /dev/null
+++ b/core/test/net/sf/openrocket/file/rocksim/importt/BodyTubeChildrenTest.rkt
@@ -0,0 +1,483 @@
+
+ 4
+
+
+ Body Tube Children Test
+ 1
+ 7
+ 0
+ 3
+ 0
+ 3
+ 0.0
+ 0.0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 18
+ 0.0
+ 0.0
+ 0.0
+ 426.6301716552979
+ 0.0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 1
+ 0
+
+
+ 6.107306539734526
+ 1049.21
+ Polystyrene PS
+ Nose cone
+ 0.0
+ 0
+ 0.0
+ 6.107306539734526
+ 53.68748632541546
+ 0
+ 0.0
+ 0.0
+ 0
+ 76.2
+ 0
+ 1
+ 3
+ 1
+ 1.00076
+ 0.0
+
+ 24.8006
+ 19.1008
+ 23.5991
+
+
+ 15.040422946044567
+ 1121.29
+ Paper
+ Forward Body tube
+ 0.0
+ 0
+ 0.0
+ 15.040422946044567
+ 228.6
+ 0
+ 0.0
+ 0.0
+ 0
+ 457.2
+ 0
+ 2
+ 24.892
+ 24.13
+ 0
+ 24.13
+ 0.0
+ 0
+
+
+ 0.0
+ 1121.29
+ Paper
+ Tube coupler
+ 0.0
+ 0
+ 120.65
+ 0.0
+ 31.75
+ 0
+ 0.0
+ 0.0
+ 0
+ 63.5
+ 0
+ 3
+ 27.8892
+ 27.8892
+ 4
+ 0
+
+
+ 10.038912051168
+ 0.00664972
+ Mylar
+ Streamer
+ 0.0
+ 0
+ 44.45
+ 10.038912051168
+ 57.15
+ 1
+ 0.0
+ 0.0
+ 0
+ 114.3
+ 0
+ 4
+ 114.3
+ 0.138
+
+
+ 1.2996672000000002
+ 0.0
+
+ Shock Cord
+ 187.325
+ 1
+ 187.325
+ 0.0
+ 0.0
+ 0
+ 0.0
+ 0.0
+ 0
+ 12.192000000000002
+ 0
+ 5
+ 0
+
+
+ 2.549
+ 0.0
+
+ Mass object - 2.549 g
+ 282.575
+ 1
+ 282.575
+ 0.0
+ 0.0
+ 0
+ 0.0
+ 0.0
+ 0
+ 0.0
+ 0
+ 6
+ 0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 384.175
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 0
+ 6.35
+ 0
+ 7
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 358.775
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 0
+ 6.35
+ 0
+ 8
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 288.925
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 0
+ 6.35
+ 0
+ 9
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+
+
+ 13.498613632777841
+ 1121.29
+ Paper
+ Aft Body tube
+ 0.0
+ 0
+ 0.0
+ 13.498613632777841
+ 165.1
+ 0
+ 0.0
+ 0.0
+ 0
+ 330.2
+ 0
+ 10
+ 29.8704
+ 29.083
+ 1
+ 29.083
+ 12.7
+ 0
+
+
+ 1.25084668869137
+ 1121.29
+ Paper
+ Engine block
+ 0.0
+ 0
+ 252.73000000000002
+ 1.25084668869137
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 0
+ 6.35
+ 0
+ 11
+ 29.083
+ 24.9428
+ 2
+ 0
+
+
+ 0.9977479979838839
+ 128.148
+ Balsa
+ Fin set-1
+ 0.0
+ 0
+ 257.175
+ 0.9977479979838839
+ 54.72939060773481
+ 0
+ 0.0
+ 0.0
+ 0
+ 0.0
+ 0
+ 12
+ 1
+ 66.675
+ 29.8704
+ 50.8
+ 67.4141
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 2.8874580315239995
+ 128.148
+ Balsa
+ Fin set
+ 0.0
+ 0
+ 146.05
+ 2.8874580315239995
+ 61.383333333333326
+ 0
+ 0.0
+ 0.785398
+ 0
+ 0.0
+ 0
+ 13
+ 4
+ 101.6
+ 0.0
+ 34.925
+ 82.55
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 0.9977479979838839
+ 128.148
+ Balsa
+ Fin set-2
+ 0.0
+ 0
+ 257.175
+ 0.9977479979838839
+ 54.72939060773481
+ 0
+ 0.0
+ 1.5708
+ 0
+ 0.0
+ 0
+ 14
+ 1
+ 66.675
+ 29.8704
+ 50.8
+ 67.4141
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 0.9977479979838839
+ 128.148
+ Balsa
+ Fin set-3
+ 0.0
+ 0
+ 257.175
+ 0.9977479979838839
+ 54.72939060773481
+ 0
+ 0.0
+ 3.14159
+ 0
+ 0.0
+ 0
+ 15
+ 1
+ 66.675
+ 29.8704
+ 50.8
+ 67.4141
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 0.9977479979838839
+ 128.148
+ Balsa
+ Fin set-4
+ 0.0
+ 0
+ 257.175
+ 0.9977479979838839
+ 54.72939060773481
+ 0
+ 0.0
+ -1.5708
+ 0
+ 0.0
+ 0
+ 16
+ 1
+ 66.675
+ 29.8704
+ 50.8
+ 67.4141
+ 3.175
+ 0
+ 0
+ 0.0
+ 0.0
+ 0.0
+ 1
+ 0.0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 323.85
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 2
+ 6.35
+ 0
+ 17
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+ 1.1277286611933457
+ 1121.29
+ Paper
+ Centering ring
+ 0.0
+ 0
+ 282.575
+ 1.1277286611933457
+ 3.175
+ 0
+ 0.0
+ 0.0
+ 2
+ 6.35
+ 0
+ 18
+ 28.702
+ 24.9428
+ 0
+ 0
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/RockSimLoaderTest.java b/core/test/net/sf/openrocket/file/rocksim/importt/RockSimLoaderTest.java
index cb2871e7b..1f342bc27 100644
--- a/core/test/net/sf/openrocket/file/rocksim/importt/RockSimLoaderTest.java
+++ b/core/test/net/sf/openrocket/file/rocksim/importt/RockSimLoaderTest.java
@@ -7,7 +7,6 @@ package net.sf.openrocket.file.rocksim.importt;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Arrays;
import net.sf.openrocket.rocketcomponent.CenteringRing;
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
@@ -62,6 +61,88 @@ public class RockSimLoaderTest extends BaseTestCase {
Assert.assertTrue(loader.getWarnings().size() == 2);
}
+ @Test
+ public void testFinsOnTransitions() throws IOException, RocketLoadException {
+ RockSimLoader loader = new RockSimLoader();
+ OpenRocketDocument doc = loadRockSimRocket(loader, "FinsOnTransitions.rkt");
+
+ Assert.assertNotNull(doc);
+ Rocket rocket = doc.getRocket();
+ Assert.assertNotNull(rocket);
+ Assert.assertEquals("FinsOnTransitions", doc.getRocket().getName());
+ Assert.assertTrue(loader.getWarnings().isEmpty());
+
+ InputStream stream = this.getClass().getResourceAsStream("FinsOnTransitions.rkt");
+ Assert.assertNotNull("Could not open FinsOnTransitions.rkt", stream);
+
+ doc = OpenRocketDocumentFactory.createEmptyRocket();
+ DocumentLoadingContext context = new DocumentLoadingContext();
+ context.setOpenRocketDocument(doc);
+ context.setMotorFinder(new DatabaseMotorFinder());
+ loader.loadFromStream(context, new BufferedInputStream(stream));
+
+ Assert.assertNotNull(doc);
+ rocket = doc.getRocket();
+ Assert.assertNotNull(rocket);
+ Assert.assertEquals(1, rocket.getStageCount());
+ AxialStage stage1 = (AxialStage) rocket.getChild(0);
+
+ RocketComponent transition1 = stage1.getChild(0);
+ RocketComponent transition2 = stage1.getChild(1);
+ Assert.assertEquals(" Component should have been transition", Transition.class, transition1.getClass());
+ Assert.assertEquals(" Component should have been transition", Transition.class, transition2.getClass());
+ Assert.assertEquals("Transition 1", transition1.getName());
+ Assert.assertEquals("Transition 2", transition2.getName());
+ Assert.assertEquals(1, transition1.getChildCount());
+ Assert.assertEquals(1, transition2.getChildCount());
+
+ Assert.assertEquals(" Transition 1 length does not match", 0.075, transition1.getLength(), MathUtil.EPSILON);
+ Assert.assertEquals(" Transition 1 fore radius does not match", 0.0125,((Transition) transition1).getForeRadius(), MathUtil.EPSILON);
+ Assert.assertEquals(" Transition 1 aft radius does not match", 0.025, ((Transition) transition1).getAftRadius(), MathUtil.EPSILON);
+ Assert.assertEquals(" Transition 1 shape does not match", Transition.Shape.CONICAL, ((Transition) transition1).getType());
+
+ Assert.assertEquals(" Transition 2 length does not match", 0.075, transition2.getLength(), MathUtil.EPSILON);
+ Assert.assertEquals(" Transition 2 fore radius does not match", 0.025,((Transition) transition2).getForeRadius(), MathUtil.EPSILON);
+ Assert.assertEquals(" Transition 2 aft radius does not match", 0.0125, ((Transition) transition2).getAftRadius(), MathUtil.EPSILON);
+ Assert.assertEquals(" Transition 2 shape does not match", Transition.Shape.CONICAL, ((Transition) transition2).getType());
+
+ RocketComponent finSet1 = transition1.getChild(0);
+ RocketComponent finSet2 = transition2.getChild(0);
+ Assert.assertEquals(" Component should have been free form fin set", FreeformFinSet.class, finSet1.getClass());
+ Assert.assertEquals(" Component should have been free form fin set", FreeformFinSet.class, finSet2.getClass());
+ Assert.assertEquals("Fin set 1", finSet1.getName());
+ Assert.assertEquals("Fin set 2", finSet2.getName());
+
+ FreeformFinSet freeformFinSet1 = (FreeformFinSet) finSet1;
+ FreeformFinSet freeformFinSet2 = (FreeformFinSet) finSet2;
+ Assert.assertEquals(3, freeformFinSet1.getFinCount());
+ Assert.assertEquals(3, freeformFinSet2.getFinCount());
+
+ Coordinate[] points1 = freeformFinSet1.getFinPoints();
+ Coordinate[] expectedPoints1 = new Coordinate[] {
+ new Coordinate(0.0, 0.0, 0.0),
+ new Coordinate(0.035, 0.03, 0.0),
+ new Coordinate(0.07250, 0.03, 0.0),
+ new Coordinate(0.07500, 0.01250, 0.0)
+ };
+ Assert.assertArrayEquals(" Fin set 1 fin points do not match", expectedPoints1, points1);
+ Assert.assertEquals(" Fin set 1 fin tab length does not match", 0.05, freeformFinSet1.getTabLength(), MathUtil.EPSILON);
+ Assert.assertEquals(" Fin set 1 fin tab height does not match", 0.0075, freeformFinSet1.getTabHeight(), MathUtil.EPSILON);
+ Assert.assertEquals(" Fin set 1 fin tab offset does not match", 0.01, freeformFinSet1.getTabOffset(), MathUtil.EPSILON);
+
+ Coordinate[] points2 = freeformFinSet2.getFinPoints();
+ Coordinate[] expectedPoints2 = new Coordinate[] {
+ new Coordinate(0.0, 0.0, 0.0),
+ new Coordinate(0.025, 0.035, 0.0),
+ new Coordinate(0.05, 0.03, 0.0),
+ new Coordinate(0.06, -0.01, 0.0)
+ };
+ Assert.assertArrayEquals(" Fin set 2 fin points do not match", expectedPoints2, points2);
+ Assert.assertEquals(" Fin set 2 fin tab length does not match", 0.03, freeformFinSet2.getTabLength(), MathUtil.EPSILON);
+ Assert.assertEquals(" Fin set 2 fin tab height does not match", 0.005, freeformFinSet2.getTabHeight(), MathUtil.EPSILON);
+ Assert.assertEquals(" Fin set 2 fin tab offset does not match", 0, freeformFinSet2.getTabOffset(), MathUtil.EPSILON);
+ }
+
/**
* Method: loadFromStream(InputStream source)
*
@@ -71,7 +152,7 @@ public class RockSimLoaderTest extends BaseTestCase {
public void testLoadFromStream() throws Exception {
RockSimLoader loader = new RockSimLoader();
//Stupid single stage rocket
- OpenRocketDocument doc = loadRockSimRocket(loader);
+ OpenRocketDocument doc = loadRockSimRocket(loader, "rocksimTestRocket1.rkt");
InputStream stream;
Assert.assertNotNull(doc);
@@ -192,20 +273,20 @@ public class RockSimLoaderTest extends BaseTestCase {
}
@org.junit.Test
- public void testSubAssemblyRocket() throws IOException, RocketLoadException {
+ public void testBodyTubeChildrenRocket() throws IOException, RocketLoadException {
RockSimLoader loader = new RockSimLoader();
//Stupid single stage rocket
- OpenRocketDocument doc = loadRockSimSubassemblyRocket(loader);
+ OpenRocketDocument doc = loadRockSimRocket(loader, "BodyTubeChildrenTest.rkt");
InputStream stream;
Assert.assertNotNull(doc);
Rocket rocket = doc.getRocket();
Assert.assertNotNull(rocket);
- Assert.assertEquals("SubAssembly Element Test", doc.getRocket().getName());
+ Assert.assertEquals("Body Tube Children Test", doc.getRocket().getName());
Assert.assertTrue(loader.getWarnings().isEmpty());
- stream = this.getClass().getResourceAsStream("SubAssemblyTest.rkt");
- Assert.assertNotNull("Could not open SubAssemblyTest.rkt", stream);
+ stream = this.getClass().getResourceAsStream("BodyTubeChildrenTest.rkt");
+ Assert.assertNotNull("Could not open BodyTubeChildrenTest.rkt", stream);
doc = OpenRocketDocumentFactory.createEmptyRocket();
DocumentLoadingContext context = new DocumentLoadingContext();
@@ -235,18 +316,18 @@ public class RockSimLoaderTest extends BaseTestCase {
}
@Test
- public void testFinsOnTransitions() throws IOException, RocketLoadException {
+ public void testSubAssemblyRocket() throws IOException, RocketLoadException {
RockSimLoader loader = new RockSimLoader();
- OpenRocketDocument doc = loadRockSimFinsOnTransitionsRocket(loader);
+ OpenRocketDocument doc = loadRockSimRocket(loader, "SubAssemblyTest.rkt");
Assert.assertNotNull(doc);
Rocket rocket = doc.getRocket();
Assert.assertNotNull(rocket);
- Assert.assertEquals("FinsOnTransitions", doc.getRocket().getName());
- Assert.assertTrue(loader.getWarnings().isEmpty());
+ Assert.assertEquals("SubAssembly Test", doc.getRocket().getName());
+ Assert.assertEquals(2, loader.getWarnings().size()); // can't add BodyTube to NoseCone, and can't add Transition to Transition
- InputStream stream = this.getClass().getResourceAsStream("FinsOnTransitions.rkt");
- Assert.assertNotNull("Could not open FinsOnTransitions.rkt", stream);
+ InputStream stream = this.getClass().getResourceAsStream("SubAssemblyTest.rkt");
+ Assert.assertNotNull("Could not open SubAssemblyTest.rkt", stream);
doc = OpenRocketDocumentFactory.createEmptyRocket();
DocumentLoadingContext context = new DocumentLoadingContext();
@@ -260,113 +341,48 @@ public class RockSimLoaderTest extends BaseTestCase {
Assert.assertEquals(1, rocket.getStageCount());
AxialStage stage1 = (AxialStage) rocket.getChild(0);
- RocketComponent transition1 = stage1.getChild(0);
- RocketComponent transition2 = stage1.getChild(1);
- Assert.assertEquals(" Component should have been transition", Transition.class, transition1.getClass());
- Assert.assertEquals(" Component should have been transition", Transition.class, transition2.getClass());
+ Assert.assertEquals(5, stage1.getChildCount());
+ NoseCone noseCone1 = (NoseCone) stage1.getChild(0);
+ BodyTube bodyTube2 = (BodyTube) stage1.getChild(1);
+ Transition transition1 = (Transition) stage1.getChild(2);
+ Transition transition3 = (Transition) stage1.getChild(3);
+ BodyTube bodyTube3 = (BodyTube) stage1.getChild(4);
+ Assert.assertEquals("Nose cone 1", noseCone1.getName());
+ Assert.assertEquals("Body tube 2", bodyTube2.getName());
Assert.assertEquals("Transition 1", transition1.getName());
- Assert.assertEquals("Transition 2", transition2.getName());
- Assert.assertEquals(1, transition1.getChildCount());
- Assert.assertEquals(1, transition2.getChildCount());
+ Assert.assertEquals("Transition 3", transition3.getName());
+ Assert.assertEquals("Body tube 3", bodyTube3.getName());
- Assert.assertEquals(" Transition 1 length does not match", 0.075, transition1.getLength(), MathUtil.EPSILON);
- Assert.assertEquals(" Transition 1 fore radius does not match", 0.0125,((Transition) transition1).getForeRadius(), MathUtil.EPSILON);
- Assert.assertEquals(" Transition 1 aft radius does not match", 0.025, ((Transition) transition1).getAftRadius(), MathUtil.EPSILON);
- Assert.assertEquals(" Transition 1 shape does not match", Transition.Shape.CONICAL, ((Transition) transition1).getType());
+ Assert.assertEquals(1, noseCone1.getChildCount());
+ Assert.assertEquals("Mass object 1", noseCone1.getChild(0).getName());
- Assert.assertEquals(" Transition 2 length does not match", 0.075, transition2.getLength(), MathUtil.EPSILON);
- Assert.assertEquals(" Transition 2 fore radius does not match", 0.025,((Transition) transition2).getForeRadius(), MathUtil.EPSILON);
- Assert.assertEquals(" Transition 2 aft radius does not match", 0.0125, ((Transition) transition2).getAftRadius(), MathUtil.EPSILON);
- Assert.assertEquals(" Transition 2 shape does not match", Transition.Shape.CONICAL, ((Transition) transition2).getType());
+ Assert.assertEquals(12, bodyTube2.getChildCount());
+ Assert.assertEquals("Mass object 2", bodyTube2.getChild(0).getName());
+ Assert.assertEquals("Launch lug 1", bodyTube2.getChild(1).getName());
+ Assert.assertEquals("Centering ring 1", bodyTube2.getChild(2).getName());
+ Assert.assertEquals("Tube coupler 1", bodyTube2.getChild(3).getName());
+ Assert.assertEquals("Fin set 1", bodyTube2.getChild(4).getName());
+ Assert.assertEquals("Fin set 2", bodyTube2.getChild(5).getName());
+ Assert.assertEquals("Parachute 1", bodyTube2.getChild(6).getName());
+ Assert.assertEquals("Streamer 1", bodyTube2.getChild(7).getName());
+ Assert.assertEquals("Bulkhead 1", bodyTube2.getChild(8).getName());
+ Assert.assertEquals("Engine block 1", bodyTube2.getChild(9).getName());
+ Assert.assertEquals("Tube fins 1", bodyTube2.getChild(10).getName());
+ Assert.assertEquals("Sleeve 1", bodyTube2.getChild(11).getName());
- RocketComponent finSet1 = transition1.getChild(0);
- RocketComponent finSet2 = transition2.getChild(0);
- Assert.assertEquals(" Component should have been free form fin set", FreeformFinSet.class, finSet1.getClass());
- Assert.assertEquals(" Component should have been free form fin set", FreeformFinSet.class, finSet2.getClass());
- Assert.assertEquals("Fin set 1", finSet1.getName());
- Assert.assertEquals("Fin set 2", finSet2.getName());
+ Assert.assertEquals(3, transition1.getChildCount());
+ Assert.assertEquals("Mass object 3", transition1.getChild(0).getName());
+ Assert.assertEquals("Fin set 3", transition1.getChild(1).getName());
+ Assert.assertEquals("Fin set 4", transition1.getChild(2).getName());
- FreeformFinSet freeformFinSet1 = (FreeformFinSet) finSet1;
- FreeformFinSet freeformFinSet2 = (FreeformFinSet) finSet2;
- Assert.assertEquals(3, freeformFinSet1.getFinCount());
- Assert.assertEquals(3, freeformFinSet2.getFinCount());
+ Assert.assertEquals(0, transition3.getChildCount());
- Coordinate[] points1 = freeformFinSet1.getFinPoints();
- Coordinate[] expectedPoints1 = new Coordinate[] {
- new Coordinate(0.0, 0.0, 0.0),
- new Coordinate(0.035, 0.03, 0.0),
- new Coordinate(0.07250, 0.03, 0.0),
- new Coordinate(0.07500, 0.01250, 0.0)
- };
- Assert.assertArrayEquals(" Fin set 1 fin points do not match", expectedPoints1, points1);
- Assert.assertEquals(" Fin set 1 fin tab length does not match", 0.05, freeformFinSet1.getTabLength(), MathUtil.EPSILON);
- Assert.assertEquals(" Fin set 1 fin tab height does not match", 0.0075, freeformFinSet1.getTabHeight(), MathUtil.EPSILON);
- Assert.assertEquals(" Fin set 1 fin tab offset does not match", 0.01, freeformFinSet1.getTabOffset(), MathUtil.EPSILON);
-
- Coordinate[] points2 = freeformFinSet2.getFinPoints();
- Coordinate[] expectedPoints2 = new Coordinate[] {
- new Coordinate(0.0, 0.0, 0.0),
- new Coordinate(0.025, 0.035, 0.0),
- new Coordinate(0.05, 0.03, 0.0),
- new Coordinate(0.06, -0.01, 0.0)
- };
- Assert.assertArrayEquals(" Fin set 2 fin points do not match", expectedPoints2, points2);
- Assert.assertEquals(" Fin set 2 fin tab length does not match", 0.03, freeformFinSet2.getTabLength(), MathUtil.EPSILON);
- Assert.assertEquals(" Fin set 2 fin tab height does not match", 0.005, freeformFinSet2.getTabHeight(), MathUtil.EPSILON);
- Assert.assertEquals(" Fin set 2 fin tab offset does not match", 0, freeformFinSet2.getTabOffset(), MathUtil.EPSILON);
+ Assert.assertEquals(0, bodyTube3.getChildCount());
}
- public static OpenRocketDocument loadRockSimRocket(RockSimLoader theLoader) throws IOException, RocketLoadException {
- InputStream stream = RockSimLoaderTest.class.getResourceAsStream("rocksimTestRocket1.rkt");
- try {
- Assert.assertNotNull("Could not open rocksimTestRocket1.rkt", stream);
- OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
- DocumentLoadingContext context = new DocumentLoadingContext();
- context.setOpenRocketDocument(doc);
- context.setMotorFinder(new DatabaseMotorFinder());
- theLoader.loadFromStream(context, new BufferedInputStream(stream));
- return doc;
- }
- finally {
- stream.close();
- }
- }
-
- public static OpenRocketDocument loadRockSimRocket3(RockSimLoader theLoader) throws IOException, RocketLoadException {
- InputStream stream = RockSimLoaderTest.class.getResourceAsStream("rocksimTestRocket3.rkt");
- try {
- Assert.assertNotNull("Could not open rocksimTestRocket3.rkt", stream);
- OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
- DocumentLoadingContext context = new DocumentLoadingContext();
- context.setOpenRocketDocument(doc);
- context.setMotorFinder(new DatabaseMotorFinder());
- theLoader.loadFromStream(context, new BufferedInputStream(stream));
- return doc;
- }
- finally {
- stream.close();
- }
- }
-
- public static OpenRocketDocument loadRockSimSubassemblyRocket(RockSimLoader theLoader) throws IOException, RocketLoadException {
- InputStream stream = RockSimLoaderTest.class.getResourceAsStream("SubAssemblyTest.rkt");
- try {
- Assert.assertNotNull("Could not open SubAssemblyTest.rkt", stream);
- OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
- DocumentLoadingContext context = new DocumentLoadingContext();
- context.setOpenRocketDocument(doc);
- context.setMotorFinder(new DatabaseMotorFinder());
- theLoader.loadFromStream(context, new BufferedInputStream(stream));
- return doc;
- }
- finally {
- stream.close();
- }
- }
-
- public static OpenRocketDocument loadRockSimFinsOnTransitionsRocket(RockSimLoader theLoader) throws IOException, RocketLoadException {
- try (InputStream stream = RockSimLoaderTest.class.getResourceAsStream("FinsOnTransitions.rkt")) {
- Assert.assertNotNull("Could not open FinsOnTransitions.rkt", stream);
+ public static OpenRocketDocument loadRockSimRocket(RockSimLoader theLoader, String fileName) throws IOException, RocketLoadException {
+ try (InputStream stream = RockSimLoaderTest.class.getResourceAsStream(fileName)) {
+ Assert.assertNotNull("Could not open " + fileName, stream);
OpenRocketDocument doc = OpenRocketDocumentFactory.createEmptyRocket();
DocumentLoadingContext context = new DocumentLoadingContext();
context.setOpenRocketDocument(doc);
@@ -375,5 +391,4 @@ public class RockSimLoaderTest extends BaseTestCase {
return doc;
}
}
-
}
diff --git a/core/test/net/sf/openrocket/file/rocksim/importt/SubAssemblyTest.rkt b/core/test/net/sf/openrocket/file/rocksim/importt/SubAssemblyTest.rkt
index 7bb84f148..06a226c9e 100644
--- a/core/test/net/sf/openrocket/file/rocksim/importt/SubAssemblyTest.rkt
+++ b/core/test/net/sf/openrocket/file/rocksim/importt/SubAssemblyTest.rkt
@@ -1,483 +1,1684 @@
- 4
-
-
- SubAssembly Element Test
- 1
- 7
- 0
- 3
- 0
- 3
- 0.0
- 0.0
- 0
- 0
- 0
- 0
- 0
- 0
- 18
- 0.0
- 0.0
- 0.0
- 426.6301716552979
- 0.0
- 0.0
- 0.0
- 0.0
- 1
- 1
- 0
-
-
- 6.107306539734526
- 1049.21
- Polystyrene PS
- Nose cone
- 0.0
- 0
- 0.0
- 6.107306539734526
- 53.68748632541546
- 0
- 0.0
- 0.0
- 0
- 76.2
- 0
- 1
- 3
- 1
- 1.00076
- 0.0
-
- 24.8006
- 19.1008
- 23.5991
-
-
- 15.040422946044567
- 1121.29
- Paper
- Forward Body tube
- 0.0
- 0
- 0.0
- 15.040422946044567
- 228.6
- 0
- 0.0
- 0.0
- 0
- 457.2
- 0
- 2
- 24.892
- 24.13
- 0
- 24.13
- 0.0
- 0
-
-
- 0.0
- 1121.29
- Paper
- Tube coupler
- 0.0
- 0
- 120.65
- 0.0
- 31.75
- 0
- 0.0
- 0.0
- 0
- 63.5
- 0
- 3
- 27.8892
- 27.8892
- 4
- 0
-
-
- 10.038912051168
- 0.00664972
- Mylar
- Streamer
- 0.0
- 0
- 44.45
- 10.038912051168
- 57.15
- 1
- 0.0
- 0.0
- 0
- 114.3
- 0
- 4
- 114.3
- 0.138
-
-
- 1.2996672000000002
- 0.0
-
- Shock Cord
- 187.325
- 1
- 187.325
- 0.0
- 0.0
- 0
- 0.0
- 0.0
- 0
- 12.192000000000002
- 0
- 5
- 0
-
-
- 2.549
- 0.0
-
- Mass object - 2.549 g
- 282.575
- 1
- 282.575
- 0.0
- 0.0
- 0
- 0.0
- 0.0
- 0
- 0.0
- 0
- 6
- 0
-
-
- 1.1277286611933457
- 1121.29
- Paper
- Centering ring
- 0.0
- 0
- 384.175
- 1.1277286611933457
- 3.175
- 0
- 0.0
- 0.0
- 0
- 6.35
- 0
- 7
- 28.702
- 24.9428
- 0
- 0
-
-
- 1.1277286611933457
- 1121.29
- Paper
- Centering ring
- 0.0
- 0
- 358.775
- 1.1277286611933457
- 3.175
- 0
- 0.0
- 0.0
- 0
- 6.35
- 0
- 8
- 28.702
- 24.9428
- 0
- 0
-
-
- 1.1277286611933457
- 1121.29
- Paper
- Centering ring
- 0.0
- 0
- 288.925
- 1.1277286611933457
- 3.175
- 0
- 0.0
- 0.0
- 0
- 6.35
- 0
- 9
- 28.702
- 24.9428
- 0
- 0
-
-
-
-
- 13.498613632777841
- 1121.29
- Paper
- Aft Body tube
- 0.0
- 0
- 0.0
- 13.498613632777841
- 165.1
- 0
- 0.0
- 0.0
- 0
- 330.2
- 0
- 10
- 29.8704
- 29.083
- 1
- 29.083
- 12.7
- 0
-
-
- 1.25084668869137
- 1121.29
- Paper
- Engine block
- 0.0
- 0
- 252.73000000000002
- 1.25084668869137
- 3.175
- 0
- 0.0
- 0.0
- 0
- 6.35
- 0
- 11
- 29.083
- 24.9428
- 2
- 0
-
-
- 0.9977479979838839
- 128.148
- Balsa
- Fin set-1
- 0.0
- 0
- 257.175
- 0.9977479979838839
- 54.72939060773481
- 0
- 0.0
- 0.0
- 0
- 0.0
- 0
- 12
- 1
- 66.675
- 29.8704
- 50.8
- 67.4141
- 3.175
- 0
- 0
- 0.0
- 0.0
- 0.0
- 1
- 0.0
-
-
- 2.8874580315239995
- 128.148
- Balsa
- Fin set
- 0.0
- 0
- 146.05
- 2.8874580315239995
- 61.383333333333326
- 0
- 0.0
- 0.785398
- 0
- 0.0
- 0
- 13
- 4
- 101.6
- 0.0
- 34.925
- 82.55
- 3.175
- 0
- 0
- 0.0
- 0.0
- 0.0
- 1
- 0.0
-
-
- 0.9977479979838839
- 128.148
- Balsa
- Fin set-2
- 0.0
- 0
- 257.175
- 0.9977479979838839
- 54.72939060773481
- 0
- 0.0
- 1.5708
- 0
- 0.0
- 0
- 14
- 1
- 66.675
- 29.8704
- 50.8
- 67.4141
- 3.175
- 0
- 0
- 0.0
- 0.0
- 0.0
- 1
- 0.0
-
-
- 0.9977479979838839
- 128.148
- Balsa
- Fin set-3
- 0.0
- 0
- 257.175
- 0.9977479979838839
- 54.72939060773481
- 0
- 0.0
- 3.14159
- 0
- 0.0
- 0
- 15
- 1
- 66.675
- 29.8704
- 50.8
- 67.4141
- 3.175
- 0
- 0
- 0.0
- 0.0
- 0.0
- 1
- 0.0
-
-
- 0.9977479979838839
- 128.148
- Balsa
- Fin set-4
- 0.0
- 0
- 257.175
- 0.9977479979838839
- 54.72939060773481
- 0
- 0.0
- -1.5708
- 0
- 0.0
- 0
- 16
- 1
- 66.675
- 29.8704
- 50.8
- 67.4141
- 3.175
- 0
- 0
- 0.0
- 0.0
- 0.0
- 1
- 0.0
-
-
- 1.1277286611933457
- 1121.29
- Paper
- Centering ring
- 0.0
- 0
- 323.85
- 1.1277286611933457
- 3.175
- 0
- 0.0
- 0.0
- 2
- 6.35
- 0
- 17
- 28.702
- 24.9428
- 0
- 0
-
-
- 1.1277286611933457
- 1121.29
- Paper
- Centering ring
- 0.0
- 0
- 282.575
- 1.1277286611933457
- 3.175
- 0
- 0.0
- 0.0
- 2
- 6.35
- 0
- 18
- 28.702
- 24.9428
- 0
- 0
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+4
+
+
+SubAssembly Test
+1
+1
+1
+0.75
+0.8
+0.81
+0.95
+0.95
+1
+0.
+0.
+0.
+0.
+0.
+0.
+0.
+0.
+4
+914.4
+0
+0
+0
+1
+0
+4
+48
+1
+0
+0,161.293,0,0
+0,33.4942,0,0
+0,172.472,0,0
+0,46.4108,0,0
+0,0,0,0
+0,0,0,0
+0
+1
+0
+1
+0.
+0.
+0
+0
+0
+0
+0
+0
+0
+0
+0.
+10.
+10.
+10.
+10.
+0
+0
+0
+10.
+0.15
+black
+233.93
+78.74
+863.6
+863.6
+0.
+863.6
+0,78.74,0,0
+0,863.6,0,0
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+
+
+
+
+
+
+Apogee
+23.5
+88.1015
+Flexible Urethane Foam - firm
+Nose cone 1
+63.5
+1
+0.
+9.28808
+39.6875
+0.00944361
+0.00944361
+0.
+0
+14811
+56mm TARC Foam Nose Cone
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+1
+1
+0
+0
+blue
+2.
+0.0211667
+2.
+0.0211667
+1
+0
+8
+0
+0.
+63.5
+56.31
+0
+3
+0
+0.
+0.
+0.
+0.
+0.
+0.
+0.
+
+
+Custom
+0.
+0.
+Custom
+Subassembly 1
+0.
+0
+0.
+0.
+0.
+0.
+0.
+0.
+0
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+7
+1
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+0.
+
+
+Apogee
+41.4
+0.
+Mass object 1
+0.
+1
+0.
+0.
+0.
+0.
+0.
+0.
+0
+29633
+
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+15
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+0.
+0
+0.
+
+
+
+
+Apogee
+0.
+1121.29
+Paper
+Body tube 1
+0.
+0
+0.
+80.3519
+431.8
+0.0833729
+0.0833729
+0.
+0
+10251
+
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+47
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+0.
+30.73
+28.96
+863.6
+0
+0
+0.
+0.5
+0.
+0.
+0
+0
+
+
+
+
+
+
+
+
+Apogee
+0.
+1121.29
+Paper
+Body tube 2
+0.
+0
+0.
+11.621
+62.45
+0.012058
+0.012058
+0.
+0
+10251
+
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+2
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+30.73
+28.96
+124.9
+0
+0
+0.
+0.5
+0.
+0.
+0
+0
+
+
+Custom
+0.
+0.
+Custom
+Subassembly 2
+0.
+0
+0.
+0.
+0.
+0.
+0.
+0.
+0
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+8
+1
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+
+
+AeroPack
+6.8
+0.
+Aluminum
+Mass object 2
+0.
+1
+0.
+0.
+0.
+0.
+0.
+0.
+0
+24051
+24mm Aeropack Retainer - L
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+18
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+0
+0.
+
+
+
+
+Public Missiles
+0.
+8553.86
+Brass
+Launch lug 1
+0.
+0
+0.
+34.8781
+152.4
+0.0173643
+0.00912552
+0.
+0
+LL-0.38
+3/8in Brass Launch Lug
+20.13
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+22
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+9.53
+8.59
+304.8
+0
+
+
+
+
+Apogee
+0.
+400.462
+Cardstock
+Centering ring 1
+0.
+0
+0.
+0.512713
+0.635
+0.
+0.
+0.
+0
+13394
+CR 13-41.6 Cardstock
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+24
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+40.46
+13.87
+1.27
+0
+0
+0
+
+
+
+
+Apogee
+63.786
+1121.29
+Paper
+Tube coupler 1
+0.
+1
+0.
+2.40724
+31.75
+0.
+0.
+0.
+0
+13010
+AC-29A
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+27
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+28.7
+27.94
+63.5
+0
+4
+0
+
+
+
+
+Apogee
+0.
+128.148
+Balsa
+Fin set 1
+0.
+0
+63.44
+2.55121
+27.6561
+0.00417366
+0.012521
+0.
+0
+15645
+Avion Fins
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+26
+0
+0
+0
+blue
+5.24169
+0.144771
+7.498
+0.144771
+1
+0
+8
+0
+126.94
+3
+53.98
+19.05
+57.15
+57.172
+19.05
+3.18
+0
+0
+0
+0.
+0.
+0.
+1
+0.320006
+0.
+39.3842
+4.32897
+0.352908
+0.
+0.
+
+
+
+
+Public Missiles
+0.
+1905.24
+G10 fiberglass
+Fin set 2
+0.
+0
+63.44
+51.2497
+43.164
+0.0112786
+0.0338357
+0.
+0
+
+Fins
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+rgb(126,150,121)
+white
+1
+29
+0
+0
+0
+rgb(61,177,187)
+14.1955
+0.15664
+18.9793
+0.154953
+1
+0
+8
+0
+126.94
+3
+101.6
+8.21
+101.6
+102.231
+35.35
+1.59
+2
+0
+0
+0.
+0.
+0.
+1
+0.
+0.
+51.7637
+10.9577
+0.0808071
+0.
+0.
+61.25
+8.20927
+101.6,0|76.2,61.46|25.4,101.6|0,0|
+0,0,0,0,0,0,0
+10,10,10,10,10,10,10
+0,0,0,0,0,0,0
+0.5,10,0.5,0.5,0.00018939,0.001,1
+0.25,5,0.1,0.1,0.00018939,0.001,1
+0,0,0,0,0,0,0
+10,10,10,10,10,10,10
+0,0,0,0,0,0,0
+0.5,10,0.5,0.5,0.00018939,0.001,1
+0.25,5,0.1,0.1,0.00018939,0.001,1
+
+
+
+
+Apogee
+7.5
+0.
+Rip stop nylon
+Parachute 1
+0.
+1
+0.
+0.75374
+31.75
+0.
+0.
+0.
+0
+29091
+
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+25
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+381.
+0.
+6
+6
+0.76
+381.
+1
+0.00032972
+Carpet String (Apogee 29500)
+0.75
+
+
+
+
+Apogee
+0.
+1309.
+Mylar
+Streamer 1
+0.
+0
+0.
+1891.71
+50.8
+0.
+0.
+0.
+0
+30305
+4in x 56in Mylar
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+28
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+1422.4
+101.6
+10.
+1
+0.13
+0
+1
+
+
+
+
+Aerospace Speciality Products
+0.
+724.996
+Aircraft plywood (Birch)
+Bulkhead 1
+0.
+0
+0.
+1.51385
+1.585
+0.
+0.
+0.
+0
+PBH-70
+Plywood Bulkhead 70 (fits TC70 Coupler)
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+30
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+28.96
+0.
+3.17
+0
+1
+1
+
+
+
+
+Apogee
+1.8
+1121.29
+Paper
+Engine block 1
+0.
+1
+0.
+1.12787
+3.175
+0.
+0.
+0.
+0
+13035
+CR 24-29 ring
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+32
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+28.7
+24.94
+6.35
+0
+2
+0
+
+
+
+
+Custom
+0.
+1121.29
+Paper
+Tube fins 1
+0.
+0
+0.
+5.17189
+38.1
+0.0264173
+0.0264173
+0.
+0
+1
+Test tube fins save 1
+24.715
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+33
+0
+0
+0
+blue
+4.7033
+0.637977
+1.08811
+0.071517
+1
+0
+8
+0
+63.5
+18.7
+18.
+76.2
+0
+3
+0.775946
+8
+
+
+
+
+Apogee
+5.4
+1121.29
+Paper
+Sleeve 1
+0.
+1
+0.
+7.66959
+50.8
+0.
+0.
+0.
+0
+10090
+AS-24
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+34
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+63.5
+26.8
+25.15
+101.6
+0
+3
+0
+
+
+
+
+
+
+
+
+LOC Precision
+0.25
+1049.21
+Polystyrene PS
+Transition 1
+107.95
+0
+0.
+54.365
+41.7981
+0.0170804
+0.0170804
+0.
+0
+AR-3.00-2.14
+Airframe Reducer from 3.00 to 2.14
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+3
+1
+0
+0
+blue
+1.83262
+0.230096
+1.83262
+0.230096
+1
+0
+8
+0
+188.4
+57.4
+78.74
+79.25
+0
+0.
+0.
+1
+3.18
+0.
+0.
+0.
+0
+0.
+292.389
+213.139
+
+
+Custom
+0.
+0.
+Custom
+Subassembly 3
+0.
+0
+0.
+0.
+0.
+0.
+0.
+0.
+0
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+9
+1
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+188.4
+
+
+Apogee
+8.5
+0.
+Aluminum
+Mass object 3
+0.
+1
+0.
+0.
+0.
+0.
+0.
+0.
+0
+29620
+
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+39
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+188.4
+0
+0.
+
+
+
+
+Aerospace Speciality Products
+0.
+1905.24
+G10 phenolic
+Fin set 3
+0.
+0
+0.
+1.43908
+12.423
+0.00122818
+0.00368454
+0.
+0
+FGST16
+G10 Fin Sm Trap (0.016)
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+43
+0
+0
+0
+blue
+1.98949
+0.195851
+3.35146
+0.195851
+1
+0
+8
+0
+188.4
+3
+25.4
+15.9
+31.8
+31.8
+4.76
+0.41
+0
+0
+0
+0.
+0.
+0.
+1
+0.149994
+0.
+43.3799
+1.93497
+0.625984
+0.
+0.
+
+
+
+
+Public Missiles
+0.
+1905.24
+G10 fiberglass
+Fin set 4
+0.
+0
+0.
+64.1326
+118.675
+0.0140255
+0.0420765
+0.
+0
+FIN-MBBX-LWR
+Lower fins
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+rgb(126,150,121)
+white
+1
+44
+0
+0
+0
+rgb(61,177,187)
+9.81031
+0.275032
+14.3248
+0.278513
+1
+0
+8
+0
+188.4
+3
+146.05
+84.18
+69.84
+117.616
+125.57
+1.6
+2
+0
+0
+0.
+0.
+0.
+1
+0.
+0.
+60.491
+8.27043
+0.576378
+0.
+0.
+118.44
+84.183
+146.05,0|165.1,9.525|200.025,69.84|120.65,69.633|0,0|
+0,0,0,0,0,0,0
+10,10,10,10,10,10,10
+0,0,0,0,0,0,0
+0.5,10,0.5,0.5,0.00018939,0.001,1
+0.25,5,0.1,0.1,0.00018939,0.001,1
+0,0,0,0,0,0,0
+10,10,10,10,10,10,10
+0,0,0,0,0,0,0
+0.5,10,0.5,0.5,0.00018939,0.001,1
+0.25,5,0.1,0.1,0.00018939,0.001,1
+
+
+
+
+Apogee
+0.
+1049.21
+Polystyrene PS
+Transition 2
+0.
+0
+0.
+13.106
+26.1291
+0.00980779
+0.00980779
+0.
+0
+17081
+BT-70/BT-80 Blow Mold Transition
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+48
+0
+0
+0
+blue
+0.772815
+0.2138
+0.772815
+0.2138
+1
+0
+8
+0
+188.4
+56.
+66.04
+50.8
+0
+0.
+0.
+1
+1.3
+0.
+0.
+0.
+2
+0.
+180.826
+130.026
+
+
+
+
+
+
+
+
+Custom
+0.
+0.
+Custom
+Subassembly 4
+0.
+0
+0.
+0.
+0.
+0.
+0.
+0.
+0
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+4
+1
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+267.65
+
+
+LOC Precision
+0.238
+1049.21
+Polystyrene PS
+Transition 3
+82.5
+0
+0.
+190.756
+97.0467
+0.0593746
+0.0593746
+0.
+0
+PTC-3.90
+Tail Cone
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+5
+0
+0
+0
+blue
+-3.4363
+0.400114
+-3.4363
+0.400114
+1
+0
+8
+0
+267.65
+102.
+70.4
+206.
+0
+0.
+0.
+1
+3.17
+0.
+0.
+0.
+1
+0.
+367.667
+161.667
+
+
+
+
+Apogee
+0.
+1199.78
+Polycarbonate
+Body tube 3
+0.
+0
+0.
+5.35012
+76.2
+0.0119168
+0.0119168
+0.
+0
+10102
+
+0.
+0.
+file=()|position=(0,0,0)|origin=(0.5,0.5,0.5)|scale=(1,1,1)|repeat=(1)|interpolate=(0)|flipr=(0)|flips=(0)|flipt=(0)|preventseam=(1)|rotate=(0)
+1.
+0.
+1.
+0.
+1.
+blue
+blue
+white
+1
+6
+0
+0
+0
+blue
+0.
+0.
+0.
+0.
+1
+0
+8
+0
+473.65
+24.89
+24.13
+152.4
+0
+0
+0.
+0.5
+0.
+0.
+0
+0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/optimization/GeneralOptimizationDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/optimization/GeneralOptimizationDialog.java
index 59ce8c45a..c963ae877 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/optimization/GeneralOptimizationDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/optimization/GeneralOptimizationDialog.java
@@ -17,6 +17,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@@ -218,7 +219,7 @@ public class GeneralOptimizationDialog extends JDialog {
selectedModifierTable.setDefaultRenderer(Double.class, new DoubleCellRenderer());
selectedModifierTable.setRowSelectionAllowed(true);
selectedModifierTable.setColumnSelectionAllowed(false);
- selectedModifierTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ selectedModifierTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
// Make sure spinner editor fits into the cell height
selectedModifierTable.setRowHeight(new JSpinner().getPreferredSize().height - 4);
@@ -264,9 +265,9 @@ public class GeneralOptimizationDialog extends JDialog {
addButton = new SelectColorButton(Chars.LEFT_ARROW + " " + trans.get("btn.add") + " ");
addButton.setToolTipText(trans.get("btn.add.ttip"));
addButton.addActionListener(e -> {
- SimulationModifier mod = getSelectedAvailableModifier();
- if (mod != null) {
- addModifier(mod);
+ List mods = getSelectedAvailableModifiers();
+ if (mods.size() > 0) {
+ addModifiers(mods);
clearHistory();
} else {
log.error("Attempting to add simulation modifier when none is selected");
@@ -281,8 +282,8 @@ public class GeneralOptimizationDialog extends JDialog {
removeButton = new SelectColorButton(" " + trans.get("btn.delete") + " " + Chars.RIGHT_ARROW);
removeButton.setToolTipText(trans.get("btn.delete.ttip"));
removeButton.addActionListener(e -> {
- SimulationModifier mod = getSelectedModifier();
- if (mod == null) {
+ List mods = getSelectedModifiers();
+ if (mods.size() == 0) {
log.error("Attempting to remove simulation modifier when none is selected");
return;
}
@@ -291,7 +292,7 @@ public class GeneralOptimizationDialog extends JDialog {
selectedModifierTable.getCellEditor().stopCellEditing();
}
- removeModifier(mod);
+ removeModifiers(mods);
clearHistory();
});
disableComponents.add(removeButton);
@@ -328,9 +329,9 @@ public class GeneralOptimizationDialog extends JDialog {
@Override
public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2) {
- SimulationModifier mod = getSelectedAvailableModifier();
- if (mod != null) {
- addModifier(mod);
+ List mods = getSelectedAvailableModifiers();
+ if (mods.size() == 1) {
+ addModifiers(mods);
clearHistory();
} else {
log.info(Markers.USER_MARKER, "Double-clicked non-available option");
@@ -1027,20 +1028,30 @@ public class GeneralOptimizationDialog extends JDialog {
}
- private void addModifier(SimulationModifier mod) {
- if (!selectedModifiers.contains(mod)) {
+ private void addModifiers(List mods) {
+ if (mods == null || mods.size() == 0) {
+ return;
+ }
+ for (SimulationModifier mod : mods) {
+ if (selectedModifiers.contains(mod)) {
+ log.info(Markers.USER_MARKER, "Attempting to add an already existing simulation modifier " + mod);
+ continue;
+ }
log.info(Markers.USER_MARKER, "Adding simulation modifier " + mod);
selectedModifiers.add(mod);
- selectedModifierTableModel.fireTableDataChanged();
- availableModifierTree.repaint();
- } else {
- log.info(Markers.USER_MARKER, "Attempting to add an already existing simulation modifier " + mod);
}
+ selectedModifierTableModel.fireTableDataChanged();
+ availableModifierTree.repaint();
}
- private void removeModifier(SimulationModifier mod) {
- log.info(Markers.USER_MARKER, "Removing simulation modifier " + mod);
- selectedModifiers.remove(mod);
+ private void removeModifiers(List mods) {
+ if (mods == null || mods.size() == 0) {
+ return;
+ }
+ log.info(Markers.USER_MARKER, "Removing simulation modifiers " + mods);
+ for (SimulationModifier mod : mods) {
+ selectedModifiers.remove(mod);
+ }
selectedModifierTableModel.fireTableDataChanged();
availableModifierTree.repaint();
}
@@ -1069,8 +1080,8 @@ public class GeneralOptimizationDialog extends JDialog {
}
// "Add" button
- SimulationModifier mod = getSelectedAvailableModifier();
- state = (mod != null && !selectedModifiers.contains(mod));
+ List mods = getSelectedAvailableModifiers();
+ state = (mods.size() > 0 && !new HashSet<>(selectedModifiers).containsAll(mods));
log.debug("addButton enabled: " + state);
addButton.setEnabled(state);
@@ -1122,9 +1133,9 @@ public class GeneralOptimizationDialog extends JDialog {
}
// Update description text
- mod = getSelectedModifier();
- if (mod != null) {
- selectedModifierDescription.setText(mod.getDescription());
+ List selectedMods = getSelectedModifiers();
+ if (selectedMods.size() == 1) {
+ selectedModifierDescription.setText(selectedMods.get(0).getDescription());
} else {
selectedModifierDescription.setText("");
}
@@ -1221,18 +1232,20 @@ public class GeneralOptimizationDialog extends JDialog {
}
/**
- * Return the currently selected available simulation modifier from the modifier tree,
- * or null
if none selected.
+ * Return the currently selected available simulation modifier from the modifier tree.
*/
- private SimulationModifier getSelectedAvailableModifier() {
- TreePath treepath = availableModifierTree.getSelectionPath();
- if (treepath != null) {
- Object o = ((DefaultMutableTreeNode) treepath.getLastPathComponent()).getUserObject();
- if (o instanceof SimulationModifier) {
- return (SimulationModifier) o;
+ private List getSelectedAvailableModifiers() {
+ List result = new ArrayList<>();
+ TreePath[] treepaths = availableModifierTree.getSelectionPaths();
+ if (treepaths != null) {
+ for (TreePath treepath : treepaths) {
+ Object obj = ((DefaultMutableTreeNode) treepath.getLastPathComponent()).getUserObject();
+ if (obj instanceof SimulationModifier) {
+ result.add((SimulationModifier) obj);
+ }
}
}
- return null;
+ return result;
}
/**
@@ -1257,17 +1270,17 @@ public class GeneralOptimizationDialog extends JDialog {
}
/**
- * Return the currently selected simulation modifier from the table,
- * or null
if none selected.
- * @return the selected modifier or null
.
+ * Return the currently selected simulation modifiers from the table.
+ * @return the selected modifier.
*/
- private SimulationModifier getSelectedModifier() {
- int row = selectedModifierTable.getSelectedRow();
- if (row < 0) {
- return null;
+ private List getSelectedModifiers() {
+ List result = new ArrayList<>();
+ int[] rows = selectedModifierTable.getSelectedRows();
+ for (int row : rows) {
+ int idx = selectedModifierTable.convertRowIndexToModel(row);
+ result.add(selectedModifiers.get(idx));
}
- row = selectedModifierTable.convertRowIndexToModel(row);
- return selectedModifiers.get(row);
+ return result;
}
/**
diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java
index 2accd4702..bda631bc3 100644
--- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java
+++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java
@@ -609,7 +609,11 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
List selectedComponents = Arrays.stream(selectionModel.getSelectionPaths())
.map(c -> (RocketComponent) c.getLastPathComponent()).collect(Collectors.toList());
- if (clicked == null || clicked.length == 0) return;
+ if (clicked == null || clicked.length == 0) {
+ selectionModel.setSelectionPaths(null);
+ ComponentConfigDialog.disposeDialog();
+ return;
+ }
// Check for double-click.
// If the shift/meta key is not pressed and the component was not already selected, ignore the double click and treat it as a single click