Fix run sim after config change + fix sim table not updating

This commit is contained in:
Sibo Van Gool 2021-06-20 22:06:58 +02:00 committed by Sibo Van Gool
parent b7dc313ee8
commit 2c2a7a2d3b
4 changed files with 9 additions and 6 deletions

View File

@ -810,7 +810,7 @@ public class OpenRocketDocument implements ComponentChangeListener {
listeners.remove(listener);
}
protected void fireDocumentChangeEvent(DocumentChangeEvent event) {
public void fireDocumentChangeEvent(DocumentChangeEvent event) {
DocumentChangeListener[] array = listeners.toArray(new DocumentChangeListener[0]);
for (DocumentChangeListener l : array) {
l.documentChanged(event);

View File

@ -534,6 +534,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
}
// TODO : FUTURE : do not hard code the 1200 (maybe even make it configurable by the user)
if( 1200 < currentStatus.getSimulationTime() ){
ret = false;
log.error("Simulation hit max time (1200s): aborting.");

View File

@ -576,7 +576,7 @@ public class SimulationPanel extends JPanel {
public void documentChanged(DocumentChangeEvent event) {
if (!(event instanceof SimulationChangeEvent))
return;
simulationTableModel.fireTableDataChanged();
fireMaintainSelection();
}
});

View File

@ -38,6 +38,7 @@ import net.sf.openrocket.aerodynamics.FlightConditions;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.document.events.SimulationChangeEvent;
import net.sf.openrocket.gui.adaptors.DoubleModel;
import net.sf.openrocket.gui.components.BasicSlider;
import net.sf.openrocket.gui.components.ConfigurationComboBox;
@ -216,6 +217,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
rkt.addComponentChangeListener(new ComponentChangeListener() {
@Override
public void componentChanged(ComponentChangeEvent e) {
updateExtras();
if (is3d) {
if (e.isTextureChange()) {
figure3d.flushTextureCaches();
@ -557,7 +559,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
/**
* Updates the extra data included in the figure. Currently this includes
* the CP and CG carets.
* the CP and CG carets. Also start the background simulator.
*/
private WarningSet warnings = new WarningSet();
@ -758,12 +760,12 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
// Do nothing if cancelled
if (isCancelled() || backgroundSimulationWorker != this)
return;
backgroundSimulationWorker = null;
extraText.setFlightData(simulation.getSimulatedData());
extraText.setCalculatingData(false);
figure.repaint();
figure3d.repaint();
document.fireDocumentChangeEvent(new SimulationChangeEvent(simulation));
}
@Override