From e1d4e7be0ba960749a8c3bfd1973fd57615393e9 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Fri, 11 Feb 2022 23:18:50 +0100 Subject: [PATCH 1/6] [fixes #1119] Fix rocket rotation after component analysis --- .../sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java index 865b0a67e..be028cb99 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java @@ -11,6 +11,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; import java.util.ArrayList; import java.util.EventObject; import java.util.List; @@ -82,6 +83,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe private final JToggleButton worstToggle; private boolean fakeChange = false; private AerodynamicCalculator aerodynamicCalculator; + private double initTheta; private final ColumnTableModel longitudeStabilityTableModel; private final ColumnTableModel dragTableModel; @@ -115,6 +117,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe aoa = new DoubleModel(rocketPanel, "CPAOA", UnitGroup.UNITS_ANGLE, 0, Math.PI); rocketPanel.setCPMach(Application.getPreferences().getDefaultMach()); mach = new DoubleModel(rocketPanel, "CPMach", UnitGroup.UNITS_COEFFICIENT, 0); + initTheta = rocketPanel.getFigure().getRotation(); rocketPanel.setCPTheta(rocketPanel.getFigure().getRotation()); theta = new DoubleModel(rocketPanel, "CPTheta", UnitGroup.UNITS_ANGLE, 0, 2 * Math.PI); rocketPanel.setCPRoll(0); @@ -428,6 +431,8 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { + theta.setValue(initTheta); + //System.out.println("Closing method called: " + this); theta.removeChangeListener(ComponentAnalysisDialog.this); aoa.removeChangeListener(ComponentAnalysisDialog.this); From 01ad466ec050e295672a68193fccc1fe4062a9e5 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sat, 12 Feb 2022 16:59:45 +0100 Subject: [PATCH 2/6] [fixes #311] Fix undo selection after component edit --- .../openrocket/gui/main/componenttree/ComponentTreeModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/main/componenttree/ComponentTreeModel.java b/swing/src/net/sf/openrocket/gui/main/componenttree/ComponentTreeModel.java index ccf6ed8c4..b8a602869 100644 --- a/swing/src/net/sf/openrocket/gui/main/componenttree/ComponentTreeModel.java +++ b/swing/src/net/sf/openrocket/gui/main/componenttree/ComponentTreeModel.java @@ -138,7 +138,7 @@ public class ComponentTreeModel implements TreeModel, ComponentChangeListener { @Override public void componentChanged(ComponentChangeEvent e) { - if (e.isTreeChange() || e.isUndoChange() || e.isMassChange()) { + if (e.isTreeChange() || e.isUndoChange()) { // Tree must be fully updated also in case of an undo change fireTreeStructureChanged(e.getSource()); if (e.isTreeChange() && e.isUndoChange()) { From 9b0aea3624f184383a8acec52eae5525335bcd2d Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sat, 12 Feb 2022 17:34:11 +0100 Subject: [PATCH 3/6] Fix nose cone config layout --- .../src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java index 6be83867e..9a6a88bb8 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java @@ -144,7 +144,7 @@ public class NoseConeConfig extends RocketComponentConfig { description = new DescriptionArea(5); description.setText(PREDESC + ((NoseCone) component).getType().getNoseConeDescription()); - panel2.add(description, "wmin 250lp, spanx, growx, wrap para"); + panel2.add(description, "w 250lp, spanx, growx, wrap para"); //// Material From 3273f152026d4ecc6983a272e7a420f9e52e6a57 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sat, 12 Feb 2022 18:00:40 +0100 Subject: [PATCH 4/6] Fix transition config layout --- .../net/sf/openrocket/gui/configdialog/TransitionConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/configdialog/TransitionConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/TransitionConfig.java index d41945b5c..8b08ef70f 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/TransitionConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/TransitionConfig.java @@ -175,7 +175,7 @@ public class TransitionConfig extends RocketComponentConfig { description = new DescriptionArea(5); description.setText(PREDESC + ((Transition) component).getType(). getTransitionDescription()); - panel2.add(description, "wmin 250lp, spanx, growx, wrap para"); + panel2.add(description, "w 250lp, spanx, growx, wrap para"); //// Material From 2c311ba3c3189005ed2daa2d1f5e98df728d974c Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sun, 13 Feb 2022 13:19:10 +0100 Subject: [PATCH 5/6] [fixes #1101] Select motor mount in motor config table --- .../sf/openrocket/gui/main/BasicFrame.java | 10 +++-- .../FlightConfigurablePanel.java | 2 +- .../FlightConfigurationPanel.java | 14 +++++-- .../MotorConfigurationPanel.java | 41 ++++++++++++++++++- 4 files changed, 57 insertions(+), 10 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java index d3182f3e4..ee9b99b6f 100644 --- a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java +++ b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java @@ -209,7 +209,7 @@ public class BasicFrame extends JFrame { //// Rocket design tabbedPane.addTab(trans.get("BasicFrame.tab.Rocketdesign"), null, designTab()); //// Flight configurations - tabbedPane.addTab(trans.get("BasicFrame.tab.Flightconfig"), null, new FlightConfigurationPanel(document)); + tabbedPane.addTab(trans.get("BasicFrame.tab.Flightconfig"), null, new FlightConfigurationPanel(this, document)); //// Flight simulations tabbedPane.addTab(trans.get("BasicFrame.tab.Flightsim"), null, simulationPanel); @@ -1690,10 +1690,14 @@ public class BasicFrame extends JFrame { } } + public void setSelectedComponent(RocketComponent component) { + this.selectionModel.setSelectedComponent(component); + } + public void stateChanged(ChangeEvent e) { JTabbedPane tabSource = (JTabbedPane) e.getSource(); - String tab = tabSource.getTitleAt(tabSource.getSelectedIndex()); - if (tab.equals(trans.get("BasicFrame.tab.Flightsim"))) { + int tab = tabSource.getSelectedIndex(); + if (tab == SIMULATION_TAB) { simulationPanel.activating(); } } diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java index a0a0f4fc4..a937c56dd 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java @@ -132,7 +132,7 @@ public abstract class FlightConfigurablePanel return configurationTable; } + @Override + protected void installTableListener() { + super.installTableListener(); + + table.getColumnModel().getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + updateComponentSelection(e); + } + }); + + table.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + updateComponentSelection(new ListSelectionEvent(this, 0, 0, false)); + } + + @Override + public void focusLost(FocusEvent e) { + + } + }); + } + + public void updateComponentSelection(ListSelectionEvent e) { + if (e.getValueIsAdjusting()) { + return; + } + MotorMount mount = getSelectedComponent(); + if (mount instanceof RocketComponent) { + flightConfigurationPanel.setSelectedComponent((RocketComponent) mount); + } + } + protected void updateButtonState() { if( configurationTableModel.getColumnCount() > 1 ) { showContent(); From 4d82e76d50d26ae0569bdb967bc091eab27a7204 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sun, 13 Feb 2022 13:38:42 +0100 Subject: [PATCH 6/6] Fix DescriptionArea layout issue --- swing/src/net/sf/openrocket/gui/components/DescriptionArea.java | 1 + .../src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java | 2 +- .../net/sf/openrocket/gui/configdialog/TransitionConfig.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java index 91a5ad2a8..844c4909d 100644 --- a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java +++ b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java @@ -159,6 +159,7 @@ public class DescriptionArea extends JScrollPane { Dimension dim = editorPane.getPreferredSize(); dim.height = lineheight * rows + extraheight + 2; + this.setPreferredSize(dim); this.setViewportView(editorPane); this.setText(text); diff --git a/swing/src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java index 9a6a88bb8..6be83867e 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/NoseConeConfig.java @@ -144,7 +144,7 @@ public class NoseConeConfig extends RocketComponentConfig { description = new DescriptionArea(5); description.setText(PREDESC + ((NoseCone) component).getType().getNoseConeDescription()); - panel2.add(description, "w 250lp, spanx, growx, wrap para"); + panel2.add(description, "wmin 250lp, spanx, growx, wrap para"); //// Material diff --git a/swing/src/net/sf/openrocket/gui/configdialog/TransitionConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/TransitionConfig.java index 8b08ef70f..d41945b5c 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/TransitionConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/TransitionConfig.java @@ -175,7 +175,7 @@ public class TransitionConfig extends RocketComponentConfig { description = new DescriptionArea(5); description.setText(PREDESC + ((Transition) component).getType(). getTransitionDescription()); - panel2.add(description, "w 250lp, spanx, growx, wrap para"); + panel2.add(description, "wmin 250lp, spanx, growx, wrap para"); //// Material