Merge branch 'unstable' into issue-1348
# Conflicts: # core/test/net/sf/openrocket/file/rocksim/importt/RockSimLoaderTest.java
This commit is contained in:
commit
b074503a1e
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -0,0 +1,483 @@
|
||||
<RockSimDocument>
|
||||
<FileVersion>4</FileVersion>
|
||||
<DesignInformation>
|
||||
<RocketDesign>
|
||||
<Name>Body Tube Children Test</Name>
|
||||
<StageCount>1</StageCount>
|
||||
<DisplayFlags>7</DisplayFlags>
|
||||
<ViewType>0</ViewType>
|
||||
<ViewStageCount>3</ViewStageCount>
|
||||
<ViewTypeEdit>0</ViewTypeEdit>
|
||||
<ViewStageCountEdit>3</ViewStageCountEdit>
|
||||
<ZoomFactor>0.0</ZoomFactor>
|
||||
<ZoomFactorEdit>0.0</ZoomFactorEdit>
|
||||
<ScrollPosX>0</ScrollPosX>
|
||||
<ScrollPosY>0</ScrollPosY>
|
||||
<ScrollPosXEdit>0</ScrollPosXEdit>
|
||||
<ScrollPosYEdit>0</ScrollPosYEdit>
|
||||
<ThreeDFlags>0</ThreeDFlags>
|
||||
<ThreeDFlagsEdit>0</ThreeDFlagsEdit>
|
||||
<LastSerialNumber>18</LastSerialNumber>
|
||||
<Stage3Mass>0.0</Stage3Mass>
|
||||
<Stage2Mass>0.0</Stage2Mass>
|
||||
<Stage1Mass>0.0</Stage1Mass>
|
||||
<Stage3CG>426.6301716552979</Stage3CG>
|
||||
<Stage2CGAlone>0.0</Stage2CGAlone>
|
||||
<Stage1CGAlone>0.0</Stage1CGAlone>
|
||||
<Stage321CG>0.0</Stage321CG>
|
||||
<Stage32CG>0.0</Stage32CG>
|
||||
<CPCalcFlags>1</CPCalcFlags>
|
||||
<CPSimFlags>1</CPSimFlags>
|
||||
<UseKnownMass>0</UseKnownMass>
|
||||
<Stage3Parts>
|
||||
<NoseCone>
|
||||
<KnownMass>6.107306539734526</KnownMass>
|
||||
<Density>1049.21</Density>
|
||||
<Material>Polystyrene PS</Material>
|
||||
<Name>Nose cone</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>0.0</Xb>
|
||||
<CalcMass>6.107306539734526</CalcMass>
|
||||
<CalcCG>53.68748632541546</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>76.2</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>1</SerialNo>
|
||||
<ShapeCode>3</ShapeCode>
|
||||
<ConstructionType>1</ConstructionType>
|
||||
<WallThickness>1.00076</WallThickness>
|
||||
<ShapeParameter>0.0</ShapeParameter>
|
||||
<AttachedParts/>
|
||||
<BaseDia>24.8006</BaseDia>
|
||||
<ShoulderLen>19.1008</ShoulderLen>
|
||||
<ShoulderOD>23.5991</ShoulderOD>
|
||||
</NoseCone>
|
||||
<BodyTube>
|
||||
<KnownMass>15.040422946044567</KnownMass>
|
||||
<Density>1121.29</Density>
|
||||
<Material>Paper</Material>
|
||||
<Name>Forward Body tube</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>0.0</Xb>
|
||||
<CalcMass>15.040422946044567</CalcMass>
|
||||
<CalcCG>228.6</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>457.2</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>2</SerialNo>
|
||||
<OD>24.892</OD>
|
||||
<ID>24.13</ID>
|
||||
<IsMotorMount>0</IsMotorMount>
|
||||
<MotorDia>24.13</MotorDia>
|
||||
<EngineOverhang>0.0</EngineOverhang>
|
||||
<IsInsideTube>0</IsInsideTube>
|
||||
<AttachedParts>
|
||||
<Ring>
|
||||
<KnownMass>0.0</KnownMass>
|
||||
<Density>1121.29</Density>
|
||||
<Material>Paper</Material>
|
||||
<Name>Tube coupler</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>120.65</Xb>
|
||||
<CalcMass>0.0</CalcMass>
|
||||
<CalcCG>31.75</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>63.5</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>3</SerialNo>
|
||||
<OD>27.8892</OD>
|
||||
<ID>27.8892</ID>
|
||||
<UsageCode>4</UsageCode>
|
||||
<AutoSize>0</AutoSize>
|
||||
</Ring>
|
||||
<Streamer>
|
||||
<KnownMass>10.038912051168</KnownMass>
|
||||
<Density>0.00664972</Density>
|
||||
<Material>Mylar</Material>
|
||||
<Name>Streamer</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>44.45</Xb>
|
||||
<CalcMass>10.038912051168</CalcMass>
|
||||
<CalcCG>57.15</CalcCG>
|
||||
<DensityType>1</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>114.3</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>4</SerialNo>
|
||||
<Width>114.3</Width>
|
||||
<DragCoefficient>0.138</DragCoefficient>
|
||||
</Streamer>
|
||||
<MassObject>
|
||||
<KnownMass>1.2996672000000002</KnownMass>
|
||||
<Density>0.0</Density>
|
||||
<Material></Material>
|
||||
<Name>Shock Cord</Name>
|
||||
<KnownCG>187.325</KnownCG>
|
||||
<UseKnownCG>1</UseKnownCG>
|
||||
<Xb>187.325</Xb>
|
||||
<CalcMass>0.0</CalcMass>
|
||||
<CalcCG>0.0</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>12.192000000000002</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>5</SerialNo>
|
||||
<TypeCode>0</TypeCode>
|
||||
</MassObject>
|
||||
<MassObject>
|
||||
<KnownMass>2.549</KnownMass>
|
||||
<Density>0.0</Density>
|
||||
<Material></Material>
|
||||
<Name>Mass object - 2.549 g</Name>
|
||||
<KnownCG>282.575</KnownCG>
|
||||
<UseKnownCG>1</UseKnownCG>
|
||||
<Xb>282.575</Xb>
|
||||
<CalcMass>0.0</CalcMass>
|
||||
<CalcCG>0.0</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>0.0</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>6</SerialNo>
|
||||
<TypeCode>0</TypeCode>
|
||||
</MassObject>
|
||||
<Ring>
|
||||
<KnownMass>1.1277286611933457</KnownMass>
|
||||
<Density>1121.29</Density>
|
||||
<Material>Paper</Material>
|
||||
<Name>Centering ring</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>384.175</Xb>
|
||||
<CalcMass>1.1277286611933457</CalcMass>
|
||||
<CalcCG>3.175</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>6.35</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>7</SerialNo>
|
||||
<OD>28.702</OD>
|
||||
<ID>24.9428</ID>
|
||||
<UsageCode>0</UsageCode>
|
||||
<AutoSize>0</AutoSize>
|
||||
</Ring>
|
||||
<Ring>
|
||||
<KnownMass>1.1277286611933457</KnownMass>
|
||||
<Density>1121.29</Density>
|
||||
<Material>Paper</Material>
|
||||
<Name>Centering ring</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>358.775</Xb>
|
||||
<CalcMass>1.1277286611933457</CalcMass>
|
||||
<CalcCG>3.175</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>6.35</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>8</SerialNo>
|
||||
<OD>28.702</OD>
|
||||
<ID>24.9428</ID>
|
||||
<UsageCode>0</UsageCode>
|
||||
<AutoSize>0</AutoSize>
|
||||
</Ring>
|
||||
<Ring>
|
||||
<KnownMass>1.1277286611933457</KnownMass>
|
||||
<Density>1121.29</Density>
|
||||
<Material>Paper</Material>
|
||||
<Name>Centering ring</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>288.925</Xb>
|
||||
<CalcMass>1.1277286611933457</CalcMass>
|
||||
<CalcCG>3.175</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>6.35</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>9</SerialNo>
|
||||
<OD>28.702</OD>
|
||||
<ID>24.9428</ID>
|
||||
<UsageCode>0</UsageCode>
|
||||
<AutoSize>0</AutoSize>
|
||||
</Ring>
|
||||
</AttachedParts>
|
||||
</BodyTube>
|
||||
<BodyTube>
|
||||
<KnownMass>13.498613632777841</KnownMass>
|
||||
<Density>1121.29</Density>
|
||||
<Material>Paper</Material>
|
||||
<Name>Aft Body tube</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>0.0</Xb>
|
||||
<CalcMass>13.498613632777841</CalcMass>
|
||||
<CalcCG>165.1</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>330.2</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>10</SerialNo>
|
||||
<OD>29.8704</OD>
|
||||
<ID>29.083</ID>
|
||||
<IsMotorMount>1</IsMotorMount>
|
||||
<MotorDia>29.083</MotorDia>
|
||||
<EngineOverhang>12.7</EngineOverhang>
|
||||
<IsInsideTube>0</IsInsideTube>
|
||||
<AttachedParts>
|
||||
<Ring>
|
||||
<KnownMass>1.25084668869137</KnownMass>
|
||||
<Density>1121.29</Density>
|
||||
<Material>Paper</Material>
|
||||
<Name>Engine block</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>252.73000000000002</Xb>
|
||||
<CalcMass>1.25084668869137</CalcMass>
|
||||
<CalcCG>3.175</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>6.35</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>11</SerialNo>
|
||||
<OD>29.083</OD>
|
||||
<ID>24.9428</ID>
|
||||
<UsageCode>2</UsageCode>
|
||||
<AutoSize>0</AutoSize>
|
||||
</Ring>
|
||||
<FinSet>
|
||||
<KnownMass>0.9977479979838839</KnownMass>
|
||||
<Density>128.148</Density>
|
||||
<Material>Balsa</Material>
|
||||
<Name>Fin set-1</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>257.175</Xb>
|
||||
<CalcMass>0.9977479979838839</CalcMass>
|
||||
<CalcCG>54.72939060773481</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>0.0</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>12</SerialNo>
|
||||
<FinCount>1</FinCount>
|
||||
<RootChord>66.675</RootChord>
|
||||
<TipChord>29.8704</TipChord>
|
||||
<SemiSpan>50.8</SemiSpan>
|
||||
<SweepDistance>67.4141</SweepDistance>
|
||||
<Thickness>3.175</Thickness>
|
||||
<ShapeCode>0</ShapeCode>
|
||||
<TipShapeCode>0</TipShapeCode>
|
||||
<TabLength>0.0</TabLength>
|
||||
<TabDepth>0.0</TabDepth>
|
||||
<TabOffset>0.0</TabOffset>
|
||||
<SweepMode>1</SweepMode>
|
||||
<CantAngle>0.0</CantAngle>
|
||||
</FinSet>
|
||||
<FinSet>
|
||||
<KnownMass>2.8874580315239995</KnownMass>
|
||||
<Density>128.148</Density>
|
||||
<Material>Balsa</Material>
|
||||
<Name>Fin set</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>146.05</Xb>
|
||||
<CalcMass>2.8874580315239995</CalcMass>
|
||||
<CalcCG>61.383333333333326</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.785398</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>0.0</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>13</SerialNo>
|
||||
<FinCount>4</FinCount>
|
||||
<RootChord>101.6</RootChord>
|
||||
<TipChord>0.0</TipChord>
|
||||
<SemiSpan>34.925</SemiSpan>
|
||||
<SweepDistance>82.55</SweepDistance>
|
||||
<Thickness>3.175</Thickness>
|
||||
<ShapeCode>0</ShapeCode>
|
||||
<TipShapeCode>0</TipShapeCode>
|
||||
<TabLength>0.0</TabLength>
|
||||
<TabDepth>0.0</TabDepth>
|
||||
<TabOffset>0.0</TabOffset>
|
||||
<SweepMode>1</SweepMode>
|
||||
<CantAngle>0.0</CantAngle>
|
||||
</FinSet>
|
||||
<FinSet>
|
||||
<KnownMass>0.9977479979838839</KnownMass>
|
||||
<Density>128.148</Density>
|
||||
<Material>Balsa</Material>
|
||||
<Name>Fin set-2</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>257.175</Xb>
|
||||
<CalcMass>0.9977479979838839</CalcMass>
|
||||
<CalcCG>54.72939060773481</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>1.5708</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>0.0</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>14</SerialNo>
|
||||
<FinCount>1</FinCount>
|
||||
<RootChord>66.675</RootChord>
|
||||
<TipChord>29.8704</TipChord>
|
||||
<SemiSpan>50.8</SemiSpan>
|
||||
<SweepDistance>67.4141</SweepDistance>
|
||||
<Thickness>3.175</Thickness>
|
||||
<ShapeCode>0</ShapeCode>
|
||||
<TipShapeCode>0</TipShapeCode>
|
||||
<TabLength>0.0</TabLength>
|
||||
<TabDepth>0.0</TabDepth>
|
||||
<TabOffset>0.0</TabOffset>
|
||||
<SweepMode>1</SweepMode>
|
||||
<CantAngle>0.0</CantAngle>
|
||||
</FinSet>
|
||||
<FinSet>
|
||||
<KnownMass>0.9977479979838839</KnownMass>
|
||||
<Density>128.148</Density>
|
||||
<Material>Balsa</Material>
|
||||
<Name>Fin set-3</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>257.175</Xb>
|
||||
<CalcMass>0.9977479979838839</CalcMass>
|
||||
<CalcCG>54.72939060773481</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>3.14159</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>0.0</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>15</SerialNo>
|
||||
<FinCount>1</FinCount>
|
||||
<RootChord>66.675</RootChord>
|
||||
<TipChord>29.8704</TipChord>
|
||||
<SemiSpan>50.8</SemiSpan>
|
||||
<SweepDistance>67.4141</SweepDistance>
|
||||
<Thickness>3.175</Thickness>
|
||||
<ShapeCode>0</ShapeCode>
|
||||
<TipShapeCode>0</TipShapeCode>
|
||||
<TabLength>0.0</TabLength>
|
||||
<TabDepth>0.0</TabDepth>
|
||||
<TabOffset>0.0</TabOffset>
|
||||
<SweepMode>1</SweepMode>
|
||||
<CantAngle>0.0</CantAngle>
|
||||
</FinSet>
|
||||
<FinSet>
|
||||
<KnownMass>0.9977479979838839</KnownMass>
|
||||
<Density>128.148</Density>
|
||||
<Material>Balsa</Material>
|
||||
<Name>Fin set-4</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>257.175</Xb>
|
||||
<CalcMass>0.9977479979838839</CalcMass>
|
||||
<CalcCG>54.72939060773481</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>-1.5708</RadialAngle>
|
||||
<LocationMode>0</LocationMode>
|
||||
<Len>0.0</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>16</SerialNo>
|
||||
<FinCount>1</FinCount>
|
||||
<RootChord>66.675</RootChord>
|
||||
<TipChord>29.8704</TipChord>
|
||||
<SemiSpan>50.8</SemiSpan>
|
||||
<SweepDistance>67.4141</SweepDistance>
|
||||
<Thickness>3.175</Thickness>
|
||||
<ShapeCode>0</ShapeCode>
|
||||
<TipShapeCode>0</TipShapeCode>
|
||||
<TabLength>0.0</TabLength>
|
||||
<TabDepth>0.0</TabDepth>
|
||||
<TabOffset>0.0</TabOffset>
|
||||
<SweepMode>1</SweepMode>
|
||||
<CantAngle>0.0</CantAngle>
|
||||
</FinSet>
|
||||
<Ring>
|
||||
<KnownMass>1.1277286611933457</KnownMass>
|
||||
<Density>1121.29</Density>
|
||||
<Material>Paper</Material>
|
||||
<Name>Centering ring</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>323.85</Xb>
|
||||
<CalcMass>1.1277286611933457</CalcMass>
|
||||
<CalcCG>3.175</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>2</LocationMode>
|
||||
<Len>6.35</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>17</SerialNo>
|
||||
<OD>28.702</OD>
|
||||
<ID>24.9428</ID>
|
||||
<UsageCode>0</UsageCode>
|
||||
<AutoSize>0</AutoSize>
|
||||
</Ring>
|
||||
<Ring>
|
||||
<KnownMass>1.1277286611933457</KnownMass>
|
||||
<Density>1121.29</Density>
|
||||
<Material>Paper</Material>
|
||||
<Name>Centering ring</Name>
|
||||
<KnownCG>0.0</KnownCG>
|
||||
<UseKnownCG>0</UseKnownCG>
|
||||
<Xb>282.575</Xb>
|
||||
<CalcMass>1.1277286611933457</CalcMass>
|
||||
<CalcCG>3.175</CalcCG>
|
||||
<DensityType>0</DensityType>
|
||||
<RadialLoc>0.0</RadialLoc>
|
||||
<RadialAngle>0.0</RadialAngle>
|
||||
<LocationMode>2</LocationMode>
|
||||
<Len>6.35</Len>
|
||||
<FinishCode>0</FinishCode>
|
||||
<SerialNo>18</SerialNo>
|
||||
<OD>28.702</OD>
|
||||
<ID>24.9428</ID>
|
||||
<UsageCode>0</UsageCode>
|
||||
<AutoSize>0</AutoSize>
|
||||
</Ring>
|
||||
</AttachedParts>
|
||||
</BodyTube>
|
||||
</Stage3Parts>
|
||||
<Stage2Parts/>
|
||||
<Stage1Parts/>
|
||||
</RocketDesign>
|
||||
</DesignInformation>
|
||||
</RockSimDocument>
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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<SimulationModifier> 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<SimulationModifier> 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<SimulationModifier> 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<SimulationModifier> 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<SimulationModifier> 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<SimulationModifier> 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<SimulationModifier> 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 <code>null</code> 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<SimulationModifier> getSelectedAvailableModifiers() {
|
||||
List<SimulationModifier> 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 <code>null</code> if none selected.
|
||||
* @return the selected modifier or <code>null</code>.
|
||||
* 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<SimulationModifier> getSelectedModifiers() {
|
||||
List<SimulationModifier> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -609,7 +609,11 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
List<RocketComponent> 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user