Added ability to export different branches from simulations.
This commit is contained in:
parent
5239123f6c
commit
0bba32fb59
@ -452,6 +452,7 @@ SimulationModifierTree.OptimizationParameters = Optimization Parameters
|
|||||||
! SimulationExportPanel
|
! SimulationExportPanel
|
||||||
SimExpPan.desc = Comma Separated Files (*.csv)
|
SimExpPan.desc = Comma Separated Files (*.csv)
|
||||||
SimExpPan.border.Vartoexport = Variables to export
|
SimExpPan.border.Vartoexport = Variables to export
|
||||||
|
SimExpPan.border.Stage = Stage to export
|
||||||
SimExpPan.but.Selectall = Select all
|
SimExpPan.but.Selectall = Select all
|
||||||
SimExpPan.but.Selectnone = Select none
|
SimExpPan.but.Selectnone = Select none
|
||||||
SimExpPan.border.Fieldsep = Field separator
|
SimExpPan.border.Fieldsep = Field separator
|
||||||
|
@ -3,11 +3,15 @@ package net.sf.openrocket.gui.simulation;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@ -23,6 +27,7 @@ import net.miginfocom.swing.MigLayout;
|
|||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
import net.sf.openrocket.gui.components.CsvOptionPanel;
|
import net.sf.openrocket.gui.components.CsvOptionPanel;
|
||||||
import net.sf.openrocket.gui.components.UnitCellEditor;
|
import net.sf.openrocket.gui.components.UnitCellEditor;
|
||||||
|
import net.sf.openrocket.gui.plot.Util;
|
||||||
import net.sf.openrocket.gui.util.FileHelper;
|
import net.sf.openrocket.gui.util.FileHelper;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.SaveCSVWorker;
|
import net.sf.openrocket.gui.util.SaveCSVWorker;
|
||||||
@ -50,7 +55,7 @@ public class SimulationExportPanel extends JPanel {
|
|||||||
private final JLabel selectedCountLabel;
|
private final JLabel selectedCountLabel;
|
||||||
|
|
||||||
private final Simulation simulation;
|
private final Simulation simulation;
|
||||||
private final FlightDataBranch branch;
|
private FlightDataBranch branch;
|
||||||
|
|
||||||
private final boolean[] selected;
|
private final boolean[] selected;
|
||||||
private final FlightDataType[] types;
|
private final FlightDataType[] types;
|
||||||
@ -65,11 +70,8 @@ public class SimulationExportPanel extends JPanel {
|
|||||||
JPanel panel;
|
JPanel panel;
|
||||||
JButton button;
|
JButton button;
|
||||||
|
|
||||||
|
|
||||||
this.simulation = sim;
|
this.simulation = sim;
|
||||||
|
|
||||||
// TODO: MEDIUM: Only exports primary branch
|
|
||||||
|
|
||||||
final FlightData data = simulation.getSimulatedData();
|
final FlightData data = simulation.getSimulatedData();
|
||||||
|
|
||||||
// Check that data exists
|
// Check that data exists
|
||||||
@ -173,6 +175,27 @@ public class SimulationExportPanel extends JPanel {
|
|||||||
|
|
||||||
this.add(csvOptions, "spany, split, growx 1");
|
this.add(csvOptions, "spany, split, growx 1");
|
||||||
|
|
||||||
|
//// Add series selection box
|
||||||
|
ArrayList<String> stages = new ArrayList<String>();
|
||||||
|
stages.addAll(Util.generateSeriesLabels(simulation));
|
||||||
|
|
||||||
|
final JComboBox stageSelection = new JComboBox(stages.toArray(new String[0]));
|
||||||
|
stageSelection.addItemListener(new ItemListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void itemStateChanged(ItemEvent e) {
|
||||||
|
int selectedStage = stageSelection.getSelectedIndex();
|
||||||
|
branch = data.getBranch(selectedStage);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
if (stages.size() > 1) {
|
||||||
|
// Only show the combo box if there are at least 2 entries (ie, "Main", and one other one
|
||||||
|
JPanel stagePanel = new JPanel(new MigLayout("fill"));
|
||||||
|
stagePanel.setBorder(BorderFactory.createTitledBorder(trans.get("SimExpPan.border.Stage")));
|
||||||
|
stagePanel.add(stageSelection, "growx");
|
||||||
|
this.add(stagePanel, "spany, split, growx 1");
|
||||||
|
}
|
||||||
|
|
||||||
// Space-filling panel
|
// Space-filling panel
|
||||||
panel = new JPanel();
|
panel = new JPanel();
|
||||||
@ -191,7 +214,6 @@ public class SimulationExportPanel extends JPanel {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean doExport() {
|
public boolean doExport() {
|
||||||
JFileChooser chooser = new JFileChooser();
|
JFileChooser chooser = new JFileChooser();
|
||||||
chooser.setFileFilter(FileHelper.CSV_FILE_FILTER);
|
chooser.setFileFilter(FileHelper.CSV_FILE_FILTER);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user