Merge pull request #1766 from SiboVG/issue-1687
[#1687] Save stage activeness to design file
This commit is contained in:
commit
4deb6da68d
@ -15,6 +15,7 @@ public class OpenRocketDocumentFactory {
|
|||||||
//// Sustainer
|
//// Sustainer
|
||||||
stage.setName(trans.get("BasicFrame.StageName.Sustainer"));
|
stage.setName(trans.get("BasicFrame.StageName.Sustainer"));
|
||||||
rocket.addChild(stage);
|
rocket.addChild(stage);
|
||||||
|
rocket.getSelectedConfiguration().setAllStages();
|
||||||
OpenRocketDocument doc = new OpenRocketDocument(rocket);
|
OpenRocketDocument doc = new OpenRocketDocument(rocket);
|
||||||
doc.setSaved(true);
|
doc.setSaved(true);
|
||||||
return doc;
|
return doc;
|
||||||
|
@ -20,6 +20,7 @@ class MotorConfigurationHandler extends AbstractElementHandler {
|
|||||||
private final Rocket rocket;
|
private final Rocket rocket;
|
||||||
private String name = null;
|
private String name = null;
|
||||||
private boolean inNameElement = false;
|
private boolean inNameElement = false;
|
||||||
|
private HashMap<Integer, Boolean> stageActiveness = new HashMap<>();
|
||||||
|
|
||||||
public MotorConfigurationHandler(Rocket rocket, DocumentLoadingContext context) {
|
public MotorConfigurationHandler(Rocket rocket, DocumentLoadingContext context) {
|
||||||
this.rocket = rocket;
|
this.rocket = rocket;
|
||||||
@ -30,11 +31,13 @@ class MotorConfigurationHandler extends AbstractElementHandler {
|
|||||||
public ElementHandler openElement(String element, HashMap<String, String> attributes,
|
public ElementHandler openElement(String element, HashMap<String, String> attributes,
|
||||||
WarningSet warnings) {
|
WarningSet warnings) {
|
||||||
|
|
||||||
if (inNameElement || !element.equals("name")) {
|
if ((inNameElement && element.equals("name")) || !(element.equals("name") || element.equals("stage"))) {
|
||||||
warnings.add(Warning.FILE_INVALID_PARAMETER);
|
warnings.add(Warning.FILE_INVALID_PARAMETER);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
inNameElement = true;
|
if (element.equals("name")) {
|
||||||
|
inNameElement = true;
|
||||||
|
}
|
||||||
|
|
||||||
return PlainTextHandler.INSTANCE;
|
return PlainTextHandler.INSTANCE;
|
||||||
}
|
}
|
||||||
@ -42,7 +45,13 @@ class MotorConfigurationHandler extends AbstractElementHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void closeElement(String element, HashMap<String, String> attributes,
|
public void closeElement(String element, HashMap<String, String> attributes,
|
||||||
String content, WarningSet warnings) {
|
String content, WarningSet warnings) {
|
||||||
name = content;
|
if (element.equals("name")) {
|
||||||
|
name = content;
|
||||||
|
} else if (element.equals("stage")) {
|
||||||
|
int stageNr = Integer.parseInt(attributes.get("number"));
|
||||||
|
boolean isActive = Boolean.parseBoolean(attributes.get("active"));
|
||||||
|
stageActiveness.put(stageNr, isActive);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -60,7 +69,11 @@ class MotorConfigurationHandler extends AbstractElementHandler {
|
|||||||
if (name != null && name.trim().length() > 0) {
|
if (name != null && name.trim().length() > 0) {
|
||||||
rocket.getFlightConfiguration(fcid).setName(name);
|
rocket.getFlightConfiguration(fcid).setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int stageNr : stageActiveness.keySet()) {
|
||||||
|
rocket.getFlightConfiguration(fcid).preloadStageActiveness(stageNr, stageActiveness.get(stageNr));
|
||||||
|
}
|
||||||
|
|
||||||
if ("true".equals(attributes.remove("default"))) {
|
if ("true".equals(attributes.remove("default"))) {
|
||||||
rocket.setSelectedConfiguration( fcid);
|
rocket.setSelectedConfiguration( fcid);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
@ -53,7 +54,10 @@ public class OpenRocketLoader extends AbstractRocketLoader {
|
|||||||
throw new RocketLoadException("Malformed XML in input.", e);
|
throw new RocketLoadException("Malformed XML in input.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
doc.getSelectedConfiguration().setAllStages();
|
// load the stage activeness
|
||||||
|
for (FlightConfiguration config : doc.getRocket().getFlightConfigurations()) {
|
||||||
|
config.applyPreloadedStageActiveness();
|
||||||
|
}
|
||||||
|
|
||||||
// Deduce suitable time skip
|
// Deduce suitable time skip
|
||||||
double timeSkip = StorageOptions.SIMULATION_DATA_NONE;
|
double timeSkip = StorageOptions.SIMULATION_DATA_NONE;
|
||||||
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
||||||
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
import net.sf.openrocket.rocketcomponent.ReferenceType;
|
import net.sf.openrocket.rocketcomponent.ReferenceType;
|
||||||
@ -53,15 +55,23 @@ public class RocketSaver extends RocketComponentSaver {
|
|||||||
if ( rocket.getSelectedConfiguration().equals( flightConfig )){
|
if ( rocket.getSelectedConfiguration().equals( flightConfig )){
|
||||||
str += " default=\"true\"";
|
str += " default=\"true\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// close motorconfiguration opening tag
|
||||||
|
str += ">";
|
||||||
|
elements.add(str);
|
||||||
|
|
||||||
|
// flight configuration name
|
||||||
if (flightConfig.isNameOverridden()){
|
if (flightConfig.isNameOverridden()){
|
||||||
str += "><name>" + net.sf.openrocket.util.TextUtil.escapeXML(flightConfig.getNameRaw())
|
elements.add(OpenRocketSaver.INDENT + "<name>" + net.sf.openrocket.util.TextUtil.escapeXML(flightConfig.getNameRaw())
|
||||||
+ "</name></motorconfiguration>";
|
+ "</name>");
|
||||||
} else {
|
}
|
||||||
str += "/>";
|
// stage activeness
|
||||||
|
for (AxialStage stage : rocket.getStageList()) {
|
||||||
|
elements.add(OpenRocketSaver.INDENT + "<stage number=\"" + stage.getStageNumber() + "\"" +
|
||||||
|
" active=\"" + flightConfig.isStageActive(stage.getStageNumber()) + "\"/>");
|
||||||
}
|
}
|
||||||
|
|
||||||
elements.add(str);
|
elements.add("</motorconfiguration>");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference diameter
|
// Reference diameter
|
||||||
|
@ -64,6 +64,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
/* Cached data */
|
/* Cached data */
|
||||||
final protected Map<Integer, StageFlags> stages = new HashMap<>(); // Map of stage number to StageFlags of the corresponding stage
|
final protected Map<Integer, StageFlags> stages = new HashMap<>(); // Map of stage number to StageFlags of the corresponding stage
|
||||||
final protected Map<MotorConfigurationId, MotorConfiguration> motors = new HashMap<MotorConfigurationId, MotorConfiguration>();
|
final protected Map<MotorConfigurationId, MotorConfiguration> motors = new HashMap<MotorConfigurationId, MotorConfiguration>();
|
||||||
|
private Map<Integer, Boolean> preloadStageActiveness = null;
|
||||||
final private Collection<MotorConfiguration> activeMotors = new ConcurrentLinkedQueue<MotorConfiguration>();
|
final private Collection<MotorConfiguration> activeMotors = new ConcurrentLinkedQueue<MotorConfiguration>();
|
||||||
final private InstanceMap activeInstances = new InstanceMap();
|
final private InstanceMap activeInstances = new InstanceMap();
|
||||||
|
|
||||||
@ -276,6 +277,34 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
stages.get(stageNumber) != null && stages.get(stageNumber).active;
|
stages.get(stageNumber) != null && stages.get(stageNumber).active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload the stage activeness of a certain stage.
|
||||||
|
* This method is to be used during the import and readout of an OpenRocket design file.
|
||||||
|
* @param stageNumber stage number to preload the stage activeness for
|
||||||
|
* @param isActive whether the stage should be active or not
|
||||||
|
*/
|
||||||
|
public void preloadStageActiveness(int stageNumber, boolean isActive) {
|
||||||
|
if (this.preloadStageActiveness == null) {
|
||||||
|
preloadStageActiveness = new HashMap<>();
|
||||||
|
}
|
||||||
|
this.preloadStageActiveness.put(stageNumber, isActive);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies preloaded stage activeness.
|
||||||
|
* This method should be called after the rocket has been loaded from a file.
|
||||||
|
*/
|
||||||
|
public void applyPreloadedStageActiveness() {
|
||||||
|
if (preloadStageActiveness == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int stageNumber : preloadStageActiveness.keySet()) {
|
||||||
|
_setStageActive(stageNumber, preloadStageActiveness.get(stageNumber), false);
|
||||||
|
}
|
||||||
|
preloadStageActiveness.clear();
|
||||||
|
preloadStageActiveness = null;
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<RocketComponent> getAllComponents() {
|
public Collection<RocketComponent> getAllComponents() {
|
||||||
List<RocketComponent> traversalOrder = new ArrayList<RocketComponent>();
|
List<RocketComponent> traversalOrder = new ArrayList<RocketComponent>();
|
||||||
recurseAllComponentsDepthFirst(this.rocket,traversalOrder);
|
recurseAllComponentsDepthFirst(this.rocket,traversalOrder);
|
||||||
@ -795,6 +824,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
// Note the stages are updated in the constructor call.
|
// Note the stages are updated in the constructor call.
|
||||||
FlightConfiguration clone = new FlightConfiguration( this.rocket, this.fcid );
|
FlightConfiguration clone = new FlightConfiguration( this.rocket, this.fcid );
|
||||||
clone.setName(configurationName);
|
clone.setName(configurationName);
|
||||||
|
clone.preloadStageActiveness = this.preloadStageActiveness == null ? null : new HashMap<>(this.preloadStageActiveness);
|
||||||
|
|
||||||
clone.cachedBoundsAerodynamic = this.cachedBoundsAerodynamic.clone();
|
clone.cachedBoundsAerodynamic = this.cachedBoundsAerodynamic.clone();
|
||||||
clone.cachedBounds = this.cachedBounds.clone();
|
clone.cachedBounds = this.cachedBounds.clone();
|
||||||
@ -824,6 +854,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
cloneMotor.getMount().setMotorConfig(cloneMotor, copyId);
|
cloneMotor.getMount().setMotorConfig(cloneMotor, copyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copy.preloadStageActiveness = this.preloadStageActiveness == null ? null : new HashMap<>(this.preloadStageActiveness);
|
||||||
copy.cachedBoundsAerodynamic = this.cachedBoundsAerodynamic.clone();
|
copy.cachedBoundsAerodynamic = this.cachedBoundsAerodynamic.clone();
|
||||||
copy.cachedBounds = this.cachedBounds.clone();
|
copy.cachedBounds = this.cachedBounds.clone();
|
||||||
copy.modID = this.modID;
|
copy.modID = this.modID;
|
||||||
|
@ -752,23 +752,23 @@ public class Rocket extends ComponentAssembly {
|
|||||||
* Return a flight configuration. If the supplied id does not have a specific instance, the default is returned.
|
* Return a flight configuration. If the supplied id does not have a specific instance, the default is returned.
|
||||||
*
|
*
|
||||||
* @param fcid the flight configuration id
|
* @param fcid the flight configuration id
|
||||||
* @return FlightConfiguration instance
|
* @return FlightConfiguration instance
|
||||||
*/
|
*/
|
||||||
public FlightConfigurationId createFlightConfiguration( final FlightConfigurationId fcid) {
|
public FlightConfiguration createFlightConfiguration( final FlightConfigurationId fcid) {
|
||||||
checkState();
|
checkState();
|
||||||
|
|
||||||
if( null == fcid ){
|
if( null == fcid ){
|
||||||
// fall-through to the default case:
|
// fall-through to the default case:
|
||||||
// ...creating a FlightConfiguration( null ) just allocates a fresh new FCID
|
// ...creating a FlightConfiguration( null ) just allocates a fresh new FCID
|
||||||
}else if( fcid.hasError() ){
|
}else if( fcid.hasError() ){
|
||||||
return configSet.getDefault().getFlightConfigurationID();
|
return configSet.getDefault();
|
||||||
}else if( configSet.containsId(fcid)){
|
}else if( configSet.containsId(fcid)){
|
||||||
return fcid;
|
return configSet.get(fcid);
|
||||||
}
|
}
|
||||||
FlightConfiguration nextConfig = new FlightConfiguration(this, fcid);
|
FlightConfiguration nextConfig = new FlightConfiguration(this, fcid);
|
||||||
this.configSet.set(nextConfig.getId(), nextConfig);
|
this.configSet.set(nextConfig.getId(), nextConfig);
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.TREE_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.TREE_CHANGE);
|
||||||
return nextConfig.getFlightConfigurationID();
|
return nextConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -941,7 +941,7 @@ public class TestRockets {
|
|||||||
Rocket rocket = new Rocket();
|
Rocket rocket = new Rocket();
|
||||||
rocket.setName("Falcon9H Scale Rocket");
|
rocket.setName("Falcon9H Scale Rocket");
|
||||||
|
|
||||||
FlightConfigurationId selFCID = rocket.createFlightConfiguration( new FlightConfigurationId( FALCON_9H_FCID_1 ));
|
FlightConfigurationId selFCID = rocket.createFlightConfiguration( new FlightConfigurationId( FALCON_9H_FCID_1 )).getFlightConfigurationID();
|
||||||
rocket.setSelectedConfiguration(selFCID);
|
rocket.setSelectedConfiguration(selFCID);
|
||||||
|
|
||||||
// ====== Payload Stage ======
|
// ====== Payload Stage ======
|
||||||
@ -1625,6 +1625,14 @@ public class TestRockets {
|
|||||||
|
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static OpenRocketDocument makeTestRocket_v108_withDisabledStage() {
|
||||||
|
Rocket rocket = makeFalcon9Heavy();
|
||||||
|
rocket.getSelectedConfiguration()._setStageActive(0, false, false);
|
||||||
|
OpenRocketDocument document = OpenRocketDocumentFactory.createDocumentFromRocket(rocket);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new test rocket for testing OpenRocketSaver.estimateFileSize()
|
* Create a new test rocket for testing OpenRocketSaver.estimateFileSize()
|
||||||
|
@ -2,6 +2,8 @@ package net.sf.openrocket.file.openrocket;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -19,6 +21,7 @@ import net.sf.openrocket.database.ComponentPresetDatabase;
|
|||||||
import net.sf.openrocket.database.motor.MotorDatabase;
|
import net.sf.openrocket.database.motor.MotorDatabase;
|
||||||
import net.sf.openrocket.database.motor.ThrustCurveMotorSetDatabase;
|
import net.sf.openrocket.database.motor.ThrustCurveMotorSetDatabase;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
|
import net.sf.openrocket.document.OpenRocketDocumentFactory;
|
||||||
import net.sf.openrocket.document.StorageOptions;
|
import net.sf.openrocket.document.StorageOptions;
|
||||||
import net.sf.openrocket.file.GeneralRocketLoader;
|
import net.sf.openrocket.file.GeneralRocketLoader;
|
||||||
import net.sf.openrocket.file.RocketLoadException;
|
import net.sf.openrocket.file.RocketLoadException;
|
||||||
@ -29,6 +32,10 @@ import net.sf.openrocket.motor.Manufacturer;
|
|||||||
import net.sf.openrocket.motor.Motor;
|
import net.sf.openrocket.motor.Motor;
|
||||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||||
import net.sf.openrocket.plugin.PluginModule;
|
import net.sf.openrocket.plugin.PluginModule;
|
||||||
|
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.simulation.extension.impl.ScriptingExtension;
|
import net.sf.openrocket.simulation.extension.impl.ScriptingExtension;
|
||||||
import net.sf.openrocket.simulation.extension.impl.ScriptingUtil;
|
import net.sf.openrocket.simulation.extension.impl.ScriptingUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
@ -126,6 +133,7 @@ public class OpenRocketSaverTest {
|
|||||||
rocketDocs.add(TestRockets.makeTestRocket_v106_withStageSeparationConfig());
|
rocketDocs.add(TestRockets.makeTestRocket_v106_withStageSeparationConfig());
|
||||||
rocketDocs.add(TestRockets.makeTestRocket_v107_withSimulationExtension(SIMULATION_EXTENSION_SCRIPT));
|
rocketDocs.add(TestRockets.makeTestRocket_v107_withSimulationExtension(SIMULATION_EXTENSION_SCRIPT));
|
||||||
rocketDocs.add(TestRockets.makeTestRocket_v108_withBoosters());
|
rocketDocs.add(TestRockets.makeTestRocket_v108_withBoosters());
|
||||||
|
rocketDocs.add(TestRockets.makeTestRocket_v108_withDisabledStage());
|
||||||
rocketDocs.add(TestRockets.makeTestRocket_for_estimateFileSize());
|
rocketDocs.add(TestRockets.makeTestRocket_for_estimateFileSize());
|
||||||
|
|
||||||
StorageOptions options = new StorageOptions();
|
StorageOptions options = new StorageOptions();
|
||||||
@ -138,6 +146,77 @@ public class OpenRocketSaverTest {
|
|||||||
assertNotNull(rocketDocLoaded);
|
assertNotNull(rocketDocLoaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSaveStageActiveness() {
|
||||||
|
OpenRocketDocument rocketDoc = TestRockets.makeTestRocket_v108_withDisabledStage();
|
||||||
|
StorageOptions options = new StorageOptions();
|
||||||
|
options.setSimulationTimeSkip(0.05);
|
||||||
|
|
||||||
|
// Save rockets, load, validate
|
||||||
|
File file = saveRocket(rocketDoc, options);
|
||||||
|
OpenRocketDocument rocketDocLoaded = loadRocket(file.getPath());
|
||||||
|
|
||||||
|
// Check that the stages activeness is saved
|
||||||
|
FlightConfiguration config = rocketDocLoaded.getRocket().getSelectedConfiguration();
|
||||||
|
assertFalse(" selected config, stage 0 should have been disabled after saving", config.isStageActive(0));
|
||||||
|
assertTrue(" selected config, stage 1 should have been enabled after saving", config.isStageActive(1));
|
||||||
|
assertTrue(" selected config, stage 2 should have been enabled after saving", config.isStageActive(2));
|
||||||
|
|
||||||
|
// Disable second stage
|
||||||
|
config._setStageActive(1, false, false);
|
||||||
|
file = saveRocket(rocketDocLoaded, options);
|
||||||
|
rocketDocLoaded = loadRocket(file.getPath());
|
||||||
|
config = rocketDocLoaded.getRocket().getSelectedConfiguration();
|
||||||
|
assertFalse(" selected config, stage 0 should have been disabled after saving", config.isStageActive(0));
|
||||||
|
assertFalse(" selected config, stage 1 should have been disabled after saving", config.isStageActive(1));
|
||||||
|
assertTrue(" selected config, stage 2 should have been enabled after saving", config.isStageActive(2));
|
||||||
|
|
||||||
|
// Re-enable first stage
|
||||||
|
config._setStageActive(0, true, false);
|
||||||
|
file = saveRocket(rocketDocLoaded, options);
|
||||||
|
rocketDocLoaded = loadRocket(file.getPath());
|
||||||
|
config = rocketDocLoaded.getRocket().getSelectedConfiguration();
|
||||||
|
assertTrue(" selected config, stage 0 should have been enabled after saving", config.isStageActive(0));
|
||||||
|
assertFalse(" selected config, stage 1 should have been disabled after saving", config.isStageActive(1));
|
||||||
|
assertTrue(" selected config, stage 2 should have been enabled after saving", config.isStageActive(2));
|
||||||
|
|
||||||
|
// Check that other configurations are not affected
|
||||||
|
FlightConfiguration extraConfig = rocketDocLoaded.getRocket().createFlightConfiguration(TestRockets.TEST_FCID_0);
|
||||||
|
extraConfig.setAllStages();
|
||||||
|
file = saveRocket(rocketDocLoaded, options);
|
||||||
|
rocketDocLoaded = loadRocket(file.getPath());
|
||||||
|
config = rocketDocLoaded.getRocket().getSelectedConfiguration();
|
||||||
|
extraConfig = rocketDocLoaded.getRocket().getFlightConfiguration(TestRockets.TEST_FCID_0);
|
||||||
|
assertTrue(" selected config, stage 0 should have been enabled after saving", config.isStageActive(0));
|
||||||
|
assertFalse(" selected config, stage 1 should have been disabled after saving", config.isStageActive(1));
|
||||||
|
assertTrue(" selected config, stage 2 should have been enabled after saving", config.isStageActive(2));
|
||||||
|
assertTrue(" extra config, stage 0 should have been enabled after saving", extraConfig.isStageActive(0));
|
||||||
|
assertTrue(" extra config, stage 1 should have been enabled after saving", extraConfig.isStageActive(1));
|
||||||
|
assertTrue(" extra config, stage 2 should have been enabled after saving", extraConfig.isStageActive(2));
|
||||||
|
|
||||||
|
// Disable a stage in the extra config, and an extra one in the selected config
|
||||||
|
extraConfig._setStageActive(0, false, false);
|
||||||
|
config._setStageActive(2, false, false);
|
||||||
|
file = saveRocket(rocketDocLoaded, options);
|
||||||
|
rocketDocLoaded = loadRocket(file.getPath());
|
||||||
|
config = rocketDocLoaded.getRocket().getSelectedConfiguration();
|
||||||
|
extraConfig = rocketDocLoaded.getRocket().getFlightConfiguration(TestRockets.TEST_FCID_0);
|
||||||
|
assertTrue(" selected config, stage 0 should have been enabled after saving", config.isStageActive(0));
|
||||||
|
assertFalse(" selected config, stage 1 should have been disabled after saving", config.isStageActive(1));
|
||||||
|
assertFalse(" selected config, stage 2 should have been disabled after saving", config.isStageActive(2));
|
||||||
|
assertFalse(" extra config, stage 0 should have been disabled after saving", extraConfig.isStageActive(0));
|
||||||
|
assertTrue(" extra config, stage 1 should have been enabled after saving", extraConfig.isStageActive(1));
|
||||||
|
assertTrue(" extra config, stage 2 should have been enabled after saving", extraConfig.isStageActive(2));
|
||||||
|
|
||||||
|
// Test an empty rocket with no configurations
|
||||||
|
OpenRocketDocument document = OpenRocketDocumentFactory.createNewRocket();
|
||||||
|
file = saveRocket(document, options);
|
||||||
|
rocketDocLoaded = loadRocket(file.getPath());
|
||||||
|
rocketDocLoaded.getRocket().getStage(0).addChild(new BodyTube()); // Add a child, otherwise the stage is always marked inactive
|
||||||
|
config = rocketDocLoaded.getRocket().getSelectedConfiguration();
|
||||||
|
assertTrue(" empty rocket, selected config, stage 0 should have been enabled after saving", config.isStageActive(0));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUntrustedScriptDisabledOnLoad() {
|
public void testUntrustedScriptDisabledOnLoad() {
|
||||||
|
@ -16,7 +16,7 @@ public class AxialStageTest extends BaseTestCase {
|
|||||||
public void testDisableStage() {
|
public void testDisableStage() {
|
||||||
final Rocket rocket = TestRockets.makeFalcon9Heavy();
|
final Rocket rocket = TestRockets.makeFalcon9Heavy();
|
||||||
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||||
final FlightConfigurationId fcid = rocket.createFlightConfiguration(new FlightConfigurationId());
|
final FlightConfigurationId fcid = rocket.createFlightConfiguration(new FlightConfigurationId()).getFlightConfigurationID();
|
||||||
final FlightConfiguration config2 = rocket.getFlightConfiguration(fcid);
|
final FlightConfiguration config2 = rocket.getFlightConfiguration(fcid);
|
||||||
|
|
||||||
// Disable the payload stage
|
// Disable the payload stage
|
||||||
@ -106,7 +106,7 @@ public class AxialStageTest extends BaseTestCase {
|
|||||||
public void testDisableStageAndMove() {
|
public void testDisableStageAndMove() {
|
||||||
final Rocket rocket = TestRockets.makeFalcon9Heavy();
|
final Rocket rocket = TestRockets.makeFalcon9Heavy();
|
||||||
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||||
final FlightConfigurationId fcid = rocket.createFlightConfiguration(new FlightConfigurationId());
|
final FlightConfigurationId fcid = rocket.createFlightConfiguration(new FlightConfigurationId()).getFlightConfigurationID();
|
||||||
final FlightConfiguration config2 = rocket.getFlightConfiguration(fcid);
|
final FlightConfiguration config2 = rocket.getFlightConfiguration(fcid);
|
||||||
|
|
||||||
// Disable the payload stage
|
// Disable the payload stage
|
||||||
@ -173,7 +173,7 @@ public class AxialStageTest extends BaseTestCase {
|
|||||||
public void testDisableStageAndCopy() {
|
public void testDisableStageAndCopy() {
|
||||||
final Rocket rocket = TestRockets.makeFalcon9Heavy();
|
final Rocket rocket = TestRockets.makeFalcon9Heavy();
|
||||||
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||||
final FlightConfigurationId fcid = rocket.createFlightConfiguration(new FlightConfigurationId());
|
final FlightConfigurationId fcid = rocket.createFlightConfiguration(new FlightConfigurationId()).getFlightConfigurationID();
|
||||||
final FlightConfiguration config2 = rocket.getFlightConfiguration(fcid);
|
final FlightConfiguration config2 = rocket.getFlightConfiguration(fcid);
|
||||||
|
|
||||||
// Disable the core stage
|
// Disable the core stage
|
||||||
|
@ -57,6 +57,7 @@ The following file format versions exist:
|
|||||||
Transitions, Inner Tubes, Launch Lugs, and Fins.
|
Transitions, Inner Tubes, Launch Lugs, and Fins.
|
||||||
Added PhotoStudio settings saving (<photostudio>)
|
Added PhotoStudio settings saving (<photostudio>)
|
||||||
Added override CD parameter (<overridecd>)
|
Added override CD parameter (<overridecd>)
|
||||||
|
Added stage activeness remembrance (<stage> under <motorconfiguration>)
|
||||||
Separated <overridesubcomponents> into individual parameters for mass, CG, and CD.
|
Separated <overridesubcomponents> into individual parameters for mass, CG, and CD.
|
||||||
Rename <fincount> to <instancecount> (<fincount> remains for backward compatibility)
|
Rename <fincount> to <instancecount> (<fincount> remains for backward compatibility)
|
||||||
Rename <position> to <axialoffset> (<position> remains for backward compatibility)
|
Rename <position> to <axialoffset> (<position> remains for backward compatibility)
|
||||||
|
@ -154,7 +154,6 @@ public class BasicFrame extends JFrame {
|
|||||||
|
|
||||||
this.document = document;
|
this.document = document;
|
||||||
this.rocket = document.getRocket();
|
this.rocket = document.getRocket();
|
||||||
this.rocket.getSelectedConfiguration().setAllStages();
|
|
||||||
BasicFrame.lastFrameInstance = this;
|
BasicFrame.lastFrameInstance = this;
|
||||||
|
|
||||||
// Create the component tree selection model that will be used
|
// Create the component tree selection model that will be used
|
||||||
|
Loading…
x
Reference in New Issue
Block a user