From 05242d4f81f8d460bcd87bc803ef986c588143e7 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Fri, 19 Dec 2014 14:31:30 -0700 Subject: [PATCH] Add option to disable flight parameter estimates in the design window. The plumbing was all there, but no one ever exposed the functionality to the users. --- core/resources/l10n/messages.properties | 1 + .../net/sf/openrocket/startup/Preferences.java | 1 + .../dialogs/preferences/PreferencesDialog.java | 12 ++++++++++++ .../gui/scalefigure/RocketPanel.java | 18 ++++++++++-------- .../openrocket/gui/util/SwingPreferences.java | 6 +++++- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index fc6d81e5a..c3a90af56 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -266,6 +266,7 @@ pref.dlg.opengl.lbl.useFBO = Use Off-screen Rendering pref.dlg.lbl.Positiontoinsert = Position to insert new body components: pref.dlg.lbl.Confirmdeletion = Confirm deletion of simulations: pref.dlg.checkbox.Runsimulations = Run all simulations automagically after design changes. +pref.dlg.checkbox.Updateestimates = Update estimated flight parameters in design window pref.dlg.lbl.User-definedthrust = User-defined thrust curves: pref.dlg.lbl.Windspeed = Wind speed pref.dlg.Allthrustcurvefiles = All thrust curve files (*.eng; *.rse; *.zip; directories) diff --git a/core/src/net/sf/openrocket/startup/Preferences.java b/core/src/net/sf/openrocket/startup/Preferences.java index 5d736df11..348f2c0e5 100644 --- a/core/src/net/sf/openrocket/startup/Preferences.java +++ b/core/src/net/sf/openrocket/startup/Preferences.java @@ -31,6 +31,7 @@ public abstract class Preferences { public static final String USER_THRUST_CURVES_KEY = "UserThrustCurves"; public static final String CONFIRM_DELETE_SIMULATION = "ConfirmDeleteSimulation"; public static final String AUTO_RUN_SIMULATIONS = "AutoRunSimulations"; + // Preferences related to data export public static final String EXPORT_FIELD_SEPARATOR = "ExportFieldSeparator"; public static final String EXPORT_SIMULATION_COMMENT = "ExportSimulationComment"; diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java index 37f06f932..945dec440 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java @@ -334,6 +334,18 @@ public class PreferencesDialog extends JDialog { }); panel.add(automaticallyRunSimsBox, "wrap, growx, sg combos "); + //// Automatically run all simulation out-dated by design changes. + final JCheckBox updateEstimates = + new JCheckBox(trans.get("pref.dlg.checkbox.Updateestimates")); + updateEstimates.setSelected(preferences.computeFlightInBackground()); + updateEstimates.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + preferences.setComputeFlightInBackground(updateEstimates.isSelected()); + } + }); + panel.add(updateEstimates, "wrap, growx, sg combos "); + return panel; } diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java index c458b8e66..d011ea5ec 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java @@ -699,15 +699,17 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change } // Start calculation process - extraText.setCalculatingData(true); + if(((SwingPreferences) Application.getPreferences()).computeFlightInBackground()){ + extraText.setCalculatingData(true); + + Rocket duplicate = (Rocket) configuration.getRocket().copy(); + Simulation simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate); + simulation.getOptions().setMotorConfigurationID( + configuration.getFlightConfigurationID()); - Rocket duplicate = (Rocket) configuration.getRocket().copy(); - Simulation simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate); - simulation.getOptions().setMotorConfigurationID( - configuration.getFlightConfigurationID()); - - backgroundSimulationWorker = new BackgroundSimulationWorker(document, simulation); - backgroundSimulationExecutor.execute(backgroundSimulationWorker); + backgroundSimulationWorker = new BackgroundSimulationWorker(document, simulation); + backgroundSimulationExecutor.execute(backgroundSimulationWorker); + } } /** diff --git a/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java b/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java index 5b35c753d..499620c9b 100644 --- a/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java +++ b/swing/src/net/sf/openrocket/gui/util/SwingPreferences.java @@ -418,7 +418,11 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences { public boolean computeFlightInBackground() { return PREFNODE.getBoolean("backgroundFlight", true); } - + + public void setComputeFlightInBackground(boolean b) { + PREFNODE.putBoolean("backgroundFlight", b); + } + public Simulation getBackgroundSimulation(Rocket rocket) { Simulation s = new Simulation(rocket); SimulationOptions cond = s.getOptions();