diff --git a/core/src/net/sf/openrocket/simulation/SimulationOptions.java b/core/src/net/sf/openrocket/simulation/SimulationOptions.java index a4d4b959b..f22015e76 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationOptions.java +++ b/core/src/net/sf/openrocket/simulation/SimulationOptions.java @@ -574,5 +574,28 @@ public class SimulationOptions implements ChangeSource, Cloneable { return conditions; } + + public String toString() { + return "SimulationOptions [\n" + .concat(" AtmosphericModel: " + getAtmosphericModel().toString() + "\n") + .concat(String.format(" launchRodLength: %f\n", launchRodLength)) + .concat(String.format(" launchIntoWind: %b\n", launchIntoWind)) + .concat(String.format(" launchRodAngle: %f\n", launchRodAngle)) + .concat(String.format(" windDirection: %f\n", windDirection)) + .concat(String.format(" launchRodDirection: %f\n", launchRodDirection)) + .concat(String.format(" windAverage: %f\n", windAverage)) + .concat(String.format(" windTurbulence: %f\n", windTurbulence)) + .concat(String.format(" launchAltitude: %f\n", launchAltitude)) + .concat(String.format(" launchLatitude: %f\n", launchLatitude)) + .concat(String.format(" launchLongitude: %f\n", launchLongitude)) + .concat(" geodeticComputation: " + geodeticComputation.toString() + "\n") + .concat(String.format(" useISA: %b\n", useISA)) + .concat(String.format(" launchTemperature: %f\n", launchTemperature)) + .concat(String.format(" launchPressure: %f\n", launchPressure)) + .concat(String.format(" timeStep: %f\n", timeStep)) + .concat(String.format(" maximumAngle: %f\n", maximumAngle)) + .concat(String.format(" calculateExtras: %b\n", calculateExtras)) + .concat("]\n"); + } } diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java index 8c4638881..ab40cb422 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java @@ -682,9 +682,27 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change extraText.setCalculatingData(true); Rocket duplicate = (Rocket) document.getRocket().copy(); - Simulation simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate); - simulation.setFlightConfigurationId( document.getSelectedConfiguration().getId()); + // find a Simulation based on the current flight configuration + FlightConfigurationId curID = curConfig.getFlightConfigurationID(); + Simulation simulation = null; + for (Simulation sim : document.getSimulations()) { + if (sim.getFlightConfigurationId().compareTo(curID) == 0) { + simulation = sim; + break; + } + } + + // I *think* every FlightConfiguration has at least one associated simulation; just in case I'm wrong, + // if there isn't one we'll create a new simulation to update the statistics in the panel using the + // default simulation conditions + if (simulation == null) { + System.out.println("creating new simulation"); + simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate); + simulation.setFlightConfigurationId( document.getSelectedConfiguration().getId()); + } else + System.out.println("using pre-existing simulation"); + backgroundSimulationWorker = new BackgroundSimulationWorker(document, simulation); backgroundSimulationExecutor.execute(backgroundSimulationWorker); }