From 43eb329e46a0aedfe89a856ab12201df1be90efd Mon Sep 17 00:00:00 2001 From: NickC25 Date: Sun, 11 Aug 2024 16:24:57 -0500 Subject: [PATCH 1/9] [#2521] Add stage description to sim plot tooltips for the main rocket, including the sustainer --- .../swing/gui/plot/SimulationPlot.java | 68 ++++++++++++++++--- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java b/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java index 53b7f3336..e7714a277 100644 --- a/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java +++ b/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java @@ -200,14 +200,62 @@ public class SimulationPlot { // Store data in provided units List plotx = thisBranch.get(domainType); List ploty = thisBranch.get(type); - XYSeries series = new XYSeries(seriesCount++, false, true); - series.setDescription(name); int pointCount = plotx.size(); - for (int j = 0; j < pointCount; j++) { - series.add(domainUnit.toUnit(plotx.get(j)), unit.toUnit(ploty.get(j))); + + // For a single-stage rocket, there is no need to disambiguate stages + if (branchCount == 1) { + XYSeries series = new XYSeries(seriesCount++, false, true); + series.setDescription(name); + for (int j = 0; j < pointCount; j++) { + series.add(domainUnit.toUnit(plotx.get(j)), unit.toUnit(ploty.get(j))); + } + data[axis].addSeries(series); + } + + // For a multi-stage rocket, the stages must be distinguished on the plot + else { + int numStages = branchCount; + int breakpoint = 0; + while (numStages > 0) { + // Create series for this portion of the main rocket flight + XYSeries currentSeries = new XYSeries(seriesCount++, false, true); + StringBuilder str = new StringBuilder(); + + // Add name of each stage that is still connected to main rocket to the string above + for (int j = 0; j < numStages; j++) { + FlightDataBranch currentBranch = simulation.getSimulatedData().getBranch(j); + str.append(currentBranch.getName()); + if(j < numStages-1) { + str.append(" + "); + } + } + + // Set the label for the current series + currentSeries.setDescription(str + ": " + name); + // Create list of y-value data for the branch after this series + // This is used to find the stage separation point and stop the current series plot there + List plotyNext = null; + + if (numStages > 1) { + plotyNext = simulation.getSimulatedData().getBranch(numStages - 1).get(type); + } + + for (int j = breakpoint; j < pointCount; j++) { + if ( plotyNext != null && !ploty.get(j).equals(plotyNext.get(j)) ) { + if (j != 0) {breakpoint = j - 1;} + break; + } + currentSeries.add(domainUnit.toUnit(plotx.get(j)), unit.toUnit(ploty.get(j))); + } + + // Add newly created series to the data + data[axis].addSeries(currentSeries); + // Decrement number of stages connected to main rocket (after separation of current stage) + numStages--; + } } - data[axis].addSeries(series); } + // Secondary branches for (int branchIndex = 1; branchIndex < branchCount; branchIndex++) { FlightDataBranch thisBranch = simulation.getSimulatedData().getBranch(branchIndex); @@ -304,7 +352,8 @@ public class SimulationPlot { // Add data and map to the axis plot.setDataset(axisno, data[axisno]); - ModifiedXYItemRenderer r = new ModifiedXYItemRenderer(branchCount); + // Number of Series = (Number of Branches * 2) - 1 + ModifiedXYItemRenderer r = new ModifiedXYItemRenderer(2*branchCount-1); renderers.add(r); r.setDefaultToolTipGenerator(tooltipGenerator); plot.setRenderer(axisno, r); @@ -321,11 +370,12 @@ public class SimulationPlot { } // Update the cumulative count for the next axis - cumulativeSeriesCount += data[axisno].getSeriesCount(); + cumulativeSeriesCount += data[axisno].getSeriesCount() / branchCount; // Now we pull the colors for the legend. - for (int j = 0; j < data[axisno].getSeriesCount(); j += branchCount) { - String name = data[axisno].getSeries(j).getDescription(); + for (int j = 0; j < data[axisno].getSeriesCount(); j += (2*branchCount-1)) { + String[] description = data[axisno].getSeries(j).getDescription().split(": "); + String name = description[description.length-1]; // Get data type and units from description this.legendItems.lineLabels.add(name); Paint linePaint = r.lookupSeriesPaint(j); this.legendItems.linePaints.add(linePaint); From 6e247b273da9efbf8aa2a8f29f76a639af402ec2 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Mon, 12 Aug 2024 21:12:28 +0200 Subject: [PATCH 2/9] [#2531] Don't close edit sim dialog after plotting or exporting --- .../swing/gui/simulation/SimulationConfigDialog.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swing/src/main/java/info/openrocket/swing/gui/simulation/SimulationConfigDialog.java b/swing/src/main/java/info/openrocket/swing/gui/simulation/SimulationConfigDialog.java index 450a638af..3980481a4 100644 --- a/swing/src/main/java/info/openrocket/swing/gui/simulation/SimulationConfigDialog.java +++ b/swing/src/main/java/info/openrocket/swing/gui/simulation/SimulationConfigDialog.java @@ -373,12 +373,13 @@ public class SimulationConfigDialog extends JDialog { if (plot != null) { plot.setVisible(true); } - closeDialog(); return; } else if (tabIdx == EXPORT_IDX) { - if (exportTab == null || exportTab.doExport()) { + if (exportTab == null) { closeDialog(); + return; } + exportTab.doExport(); return; } From 928f56e3084a6572d2597d5da3b6d7bb6883dd14 Mon Sep 17 00:00:00 2001 From: NickC25 Date: Mon, 12 Aug 2024 21:30:26 -0500 Subject: [PATCH 3/9] Fix broken plot when selecting a specific stage --- .../java/info/openrocket/swing/gui/plot/SimulationPlot.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java b/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java index b3e7247ca..9412d3e84 100644 --- a/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java +++ b/swing/src/main/java/info/openrocket/swing/gui/plot/SimulationPlot.java @@ -113,13 +113,14 @@ public class SimulationPlot { } void setShowBranch(int branch) { + int series = branch + branchCount-1; XYPlot plot = (XYPlot) chart.getPlot(); int datasetcount = plot.getDatasetCount(); for (int i = 0; i < datasetcount; i++) { int seriescount = ((XYSeriesCollection) plot.getDataset(i)).getSeriesCount(); XYItemRenderer r = ((XYPlot) chart.getPlot()).getRenderer(i); for (int j = 0; j < seriescount; j++) { - boolean show = (branch < 0) || (j % branchCount == branch); + boolean show = (branch < 0) || (j % (2*branchCount-1) == series); r.setSeriesVisible(j, show); } } @@ -246,6 +247,9 @@ public class SimulationPlot { if (numStages > 1) { plotyNext = simulation.getSimulatedData().getBranch(numStages - 1).get(type); } + else { + breakpoint = 0; // Start sustainer stage-plotting from the beginning + } for (int j = breakpoint; j < pointCount; j++) { if ( plotyNext != null && !ploty.get(j).equals(plotyNext.get(j)) ) { From c598004ba03e10a30b9d866bec246ab02aaa3a11 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Tue, 13 Aug 2024 19:39:26 +0200 Subject: [PATCH 4/9] [#2537] Allow for reconfiguration of the default flight config name --- .../preferences/ApplicationPreferences.java | 17 ++++++++++++++++- .../rocketcomponent/FlightConfiguration.java | 18 ++++++++++-------- .../main/resources/l10n/messages.properties | 3 +++ .../RenameConfigDialog.java | 14 ++++++++++++++ 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/info/openrocket/core/preferences/ApplicationPreferences.java b/core/src/main/java/info/openrocket/core/preferences/ApplicationPreferences.java index e3a4c87d7..8666e5f5a 100644 --- a/core/src/main/java/info/openrocket/core/preferences/ApplicationPreferences.java +++ b/core/src/main/java/info/openrocket/core/preferences/ApplicationPreferences.java @@ -20,6 +20,7 @@ import info.openrocket.core.material.Material; import info.openrocket.core.models.atmosphere.AtmosphericModel; import info.openrocket.core.models.atmosphere.ExtendedISAModel; import info.openrocket.core.preset.ComponentPreset; +import info.openrocket.core.rocketcomponent.FlightConfiguration; import info.openrocket.core.rocketcomponent.MassObject; import info.openrocket.core.rocketcomponent.Rocket; import info.openrocket.core.rocketcomponent.RocketComponent; @@ -101,8 +102,10 @@ public abstract class ApplicationPreferences implements ChangeSource, ORPreferen public static final String ROCKET_INFO_FONT_SIZE = "RocketInfoFontSize"; - // Preferences Related to Simulations + // Preferences related to flight configurations + public static final String DEFAULT_FLIGHT_CONFIG_NAME = "DefaultFlightConfigName"; + // Preferences Related to Simulations public static final String CONFIRM_DELETE_SIMULATION = "ConfirmDeleteSimulation"; public static final String AUTO_RUN_SIMULATIONS = "AutoRunSimulations"; public static final String LAUNCH_ROD_LENGTH = "LaunchRodLength"; @@ -258,6 +261,18 @@ public abstract class ApplicationPreferences implements ChangeSource, ORPreferen } + /* + * ****************************************************************************************** + */ + + public String getDefaultFlightConfigName() { + return getString(DEFAULT_FLIGHT_CONFIG_NAME, FlightConfiguration.DEFAULT_CONFIG_NAME); + } + + public void setDefaultFlightConfigName(String name) { + putString(DEFAULT_FLIGHT_CONFIG_NAME, name); + } + /* * ****************************************************************************************** */ diff --git a/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java b/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java index 6da889418..dc8c95adc 100644 --- a/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java +++ b/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java @@ -10,6 +10,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentLinkedQueue; import info.openrocket.core.formatting.RocketDescriptor; +import info.openrocket.core.preferences.ApplicationPreferences; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +34,7 @@ import info.openrocket.core.util.Transformation; */ public class FlightConfiguration implements FlightConfigurableParameter, Monitorable { private static final Logger log = LoggerFactory.getLogger(FlightConfiguration.class); + private static final ApplicationPreferences prefs = Application.getPreferences(); private String configurationName; public static String DEFAULT_CONFIG_NAME = "[{motors}]"; @@ -105,7 +107,7 @@ public class FlightConfiguration implements FlightConfigurableParameter{motors}' will be replaced with the motor designation(s).
\te.g. '{motors} \u2192 'M1350-0'
RenameConfigDialog.lbl.infoManufacturers = The text '{manufacturers}' will be replaced with the motor manufacturer(s).
\te.g. '{manufacturers}' \u2192 'AeroTech'
diff --git a/swing/src/main/java/info/openrocket/swing/gui/dialogs/flightconfiguration/RenameConfigDialog.java b/swing/src/main/java/info/openrocket/swing/gui/dialogs/flightconfiguration/RenameConfigDialog.java index 6aa581c3e..b8384edd8 100644 --- a/swing/src/main/java/info/openrocket/swing/gui/dialogs/flightconfiguration/RenameConfigDialog.java +++ b/swing/src/main/java/info/openrocket/swing/gui/dialogs/flightconfiguration/RenameConfigDialog.java @@ -9,10 +9,12 @@ import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import info.openrocket.core.l10n.Translator; +import info.openrocket.core.preferences.ApplicationPreferences; import info.openrocket.core.rocketcomponent.FlightConfigurationId; import info.openrocket.core.rocketcomponent.Rocket; import info.openrocket.core.startup.Application; @@ -26,6 +28,7 @@ import info.openrocket.swing.gui.theme.UITheme; public class RenameConfigDialog extends JDialog { private static final long serialVersionUID = -5423008694485357248L; private static final Translator trans = Application.getTranslator(); + private static final ApplicationPreferences prefs = Application.getPreferences(); private static Color dimTextColor; @@ -55,6 +58,17 @@ public class RenameConfigDialog extends JDialog { } }); panel.add(okButton); + + JButton saveAsDefaultButton = new JButton(trans.get("RenameConfigDialog.but.saveDefault")); + saveAsDefaultButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(RenameConfigDialog.this, trans.get("RenameConfigDialog.dlg.saveDefault.msg"), + trans.get("RenameConfigDialog.dlg.saveDefault.title"), JOptionPane.INFORMATION_MESSAGE); + prefs.setDefaultFlightConfigName(textbox.getText()); + } + }); + panel.add(saveAsDefaultButton); JButton resetToDefaultButton = new JButton(trans.get("RenameConfigDialog.but.reset")); resetToDefaultButton.addActionListener(new ActionListener() { From f4e9d0db4562f5ddd4e919b86879839087d4ea23 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Tue, 13 Aug 2024 21:28:28 +0200 Subject: [PATCH 5/9] Return DEFAULT_CONFIG_NAME if default name cannot be found in prefs --- .../rocketcomponent/FlightConfiguration.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java b/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java index dc8c95adc..8e41744fa 100644 --- a/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java +++ b/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java @@ -107,7 +107,7 @@ public class FlightConfiguration implements FlightConfigurableParameter Date: Fri, 16 Aug 2024 19:01:58 +0200 Subject: [PATCH 6/9] Update snap for gradle build --- snap/snapcraft.yaml | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index c93859634..22ea0b494 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -6,14 +6,14 @@ description: | OpenRocket is a free, fully featured model rocket simulator that allows you to design and simulate your rockets before actually building and flying them. - The main features include + The main features include: * Six-degree-of-freedom flight simulation * Automatic design optimization * Realtime simulated altitude, velocity and acceleration display * Staging and clustering support * Cross-platform (Java-based) - * Read more about it on the OpenRocket.info. + * Read more about it on OpenRocket.info license: GPL-3.0 base: core22 confinement: strict @@ -51,40 +51,23 @@ apps: parts: openrocket: - plugin: ant - build-packages: - - ant - - ant-contrib - - ant-optional - - openjdk-17-jdk - - openjdk-17-jre + plugin: gradle source: . - source-type: git - ant-build-targets: - - clean - - check - - unittest - - jar + gradle-output-dir: 'build/libs' + gradle-options: + - shadowJar + - -Dorg.gradle.java.home=$JAVA_HOME + build-packages: + - openjdk-17-jdk override-pull: | - # Override the pull in order to set the version and the grade. - # In the future, the releases can be annotated tags and snapcraft - # will use those for the version numbers. - # - # This can be extended to other parts of OpenRocket (to use the - # git describe --tags command) but the build should be updated at - # the same time so its consistent across all artifacts. Will defer - # that to a later pull request. - # - # Until then, just use the build.version value craftctl default - VERSION=$(cat core/resources/build.properties | awk -F'=' '/build\.version/ { print $2 }') - craftctl set version="$VERSION" + version=$(grep 'version =' build.gradle | awk '{print $3}' | tr -d "'") + craftctl set version="$version" override-build: | craftctl default - mv swing/build/jar/OpenRocket.jar $CRAFT_PART_INSTALL/OpenRocket.jar + mv build/libs/OpenRocket-*.jar $CRAFT_PART_INSTALL/OpenRocket.jar stage-packages: - - openjdk-17-jdk - - openjdk-17-jre + - openjdk-17-jre-headless - ca-certificates - ca-certificates-java prime: @@ -97,4 +80,3 @@ parts: source: snap/local organize: 'launcher': 'bin/' - From 772faf73d50b4bf9c9dd4931c728b7a2c19191c4 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Fri, 16 Aug 2024 21:33:41 +0200 Subject: [PATCH 7/9] Try to fix snap gradle --- snap/snapcraft.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 22ea0b494..ce1fd71e5 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -51,12 +51,13 @@ apps: parts: openrocket: - plugin: gradle + plugin: java source: . + java-version: "17" + java-build-system: gradle gradle-output-dir: 'build/libs' gradle-options: - shadowJar - - -Dorg.gradle.java.home=$JAVA_HOME build-packages: - openjdk-17-jdk override-pull: | @@ -79,4 +80,4 @@ parts: plugin: dump source: snap/local organize: - 'launcher': 'bin/' + 'launcher': 'bin/' \ No newline at end of file From d43f023f04975a02b1aa444b216fef449a82f6f3 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Fri, 16 Aug 2024 21:49:46 +0200 Subject: [PATCH 8/9] Revert back to core18, because gradle isn't supported elsewhere... --- snap/snapcraft.yaml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index ce1fd71e5..393126a3c 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -15,7 +15,7 @@ description: | * Cross-platform (Java-based) * Read more about it on OpenRocket.info license: GPL-3.0 -base: core22 +base: core18 confinement: strict plugs: @@ -37,38 +37,39 @@ architectures: apps: openrocket: - extensions: [gnome] command: bin/launcher plugs: - home - network - cups-control - opengl + - x11 + - wayland + - desktop + - desktop-legacy - dot-java-user-prefs-openrocket - dot-openrocket environment: - JAVA_HOME: "$SNAP/usr/lib/jvm/java-17-openjdk-$CRAFT_TARGET_ARCH" + JAVA_HOME: "$SNAP/usr/lib/jvm/java-17-openjdk-$SNAP_ARCH" parts: openrocket: - plugin: java + plugin: gradle source: . - java-version: "17" - java-build-system: gradle gradle-output-dir: 'build/libs' gradle-options: - shadowJar build-packages: - openjdk-17-jdk override-pull: | - craftctl default + snapcraftctl pull version=$(grep 'version =' build.gradle | awk '{print $3}' | tr -d "'") - craftctl set version="$version" + snapcraftctl set-version "$version" override-build: | - craftctl default - mv build/libs/OpenRocket-*.jar $CRAFT_PART_INSTALL/OpenRocket.jar + snapcraftctl build + mv build/libs/OpenRocket-*.jar $SNAPCRAFT_PART_INSTALL/OpenRocket.jar stage-packages: - - openjdk-17-jre-headless + - openjdk-17-jre - ca-certificates - ca-certificates-java prime: From 17813cfec650b616e090b5c815dfc11bd388b3e6 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sat, 17 Aug 2024 00:05:48 +0200 Subject: [PATCH 9/9] Urgh, gradle snap really does not work? --- snap/snapcraft.yaml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 393126a3c..f8c077ae0 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -43,10 +43,6 @@ apps: - network - cups-control - opengl - - x11 - - wayland - - desktop - - desktop-legacy - dot-java-user-prefs-openrocket - dot-openrocket environment: @@ -56,18 +52,16 @@ parts: openrocket: plugin: gradle source: . - gradle-output-dir: 'build/libs' - gradle-options: - - shadowJar build-packages: - openjdk-17-jdk override-pull: | - snapcraftctl pull + craftctl default version=$(grep 'version =' build.gradle | awk '{print $3}' | tr -d "'") - snapcraftctl set-version "$version" + craftctl set version="$version" override-build: | - snapcraftctl build - mv build/libs/OpenRocket-*.jar $SNAPCRAFT_PART_INSTALL/OpenRocket.jar + craftctl default + mkdir -p $CRAFT_PART_INSTALL/bin + cp build/libs/OpenRocket-*.jar $CRAFT_PART_INSTALL/OpenRocket.jar stage-packages: - openjdk-17-jre - ca-certificates @@ -80,5 +74,6 @@ parts: launcher: plugin: dump source: snap/local + source-type: local organize: - 'launcher': 'bin/' \ No newline at end of file + launcher: bin/launcher \ No newline at end of file