DGP - fix to honor launch conditions in printed simulations
This commit is contained in:
parent
bf0e3d978a
commit
acf3505cec
@ -6,13 +6,13 @@ package net.sf.openrocket.gui.print;
|
||||
import java.awt.Graphics2D;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
import net.sf.openrocket.gui.figureelements.FigureElement;
|
||||
import net.sf.openrocket.gui.figureelements.RocketInfo;
|
||||
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||
import net.sf.openrocket.logging.LogHelper;
|
||||
import net.sf.openrocket.masscalc.BasicMassCalculator;
|
||||
import net.sf.openrocket.masscalc.MassCalculator;
|
||||
@ -225,6 +225,7 @@ public class DesignReport {
|
||||
document.add(paragraph);
|
||||
|
||||
String[] motorIds = rocket.getMotorConfigurationIDs();
|
||||
List<Simulation> simulations = rocketDocument.getSimulations();
|
||||
|
||||
for (int j = 0; j < motorIds.length; j++) {
|
||||
String motorId = motorIds[j];
|
||||
@ -239,7 +240,8 @@ public class DesignReport {
|
||||
if (j > 1) {
|
||||
leading = 25;
|
||||
}
|
||||
addFlightData(rocket, motorId, parent, leading);
|
||||
FlightData flight = findSimulation(motorId, simulations);
|
||||
addFlightData(flight, rocket, motorId, parent, leading);
|
||||
addMotorData(rocket, motorId, parent);
|
||||
document.add(parent);
|
||||
}
|
||||
@ -429,26 +431,15 @@ public class DesignReport {
|
||||
|
||||
|
||||
/**
|
||||
* Add the motor data for a motor configuration to the table.
|
||||
* Add the flight data for a simulation configuration to the table.
|
||||
*
|
||||
* @param flight the flight data for a single simulation
|
||||
* @param theRocket the rocket
|
||||
* @param motorId a motor configuration id
|
||||
* @param parent the parent to which the motor data will be added
|
||||
* @param parent the parent to which the simulation flight data will be added
|
||||
* @param leading the number of points for the leading
|
||||
*/
|
||||
private void addFlightData(final Rocket theRocket, final String motorId, final PdfPTable parent, int leading) {
|
||||
|
||||
// Perform flight simulation
|
||||
Rocket duplicate = theRocket.copyWithOriginalID();
|
||||
FlightData flight = null;
|
||||
try {
|
||||
Simulation simulation = ((SwingPreferences)Application.getPreferences()).getBackgroundSimulation(duplicate);
|
||||
simulation.getOptions().setMotorConfigurationID(motorId);
|
||||
simulation.simulate();
|
||||
flight = simulation.getSimulatedData();
|
||||
} catch (SimulationException e1) {
|
||||
// Ignore
|
||||
}
|
||||
private void addFlightData(final FlightData flight, final Rocket theRocket, final String motorId, final PdfPTable parent, int leading) {
|
||||
|
||||
// Output the flight data
|
||||
if (flight != null) {
|
||||
@ -502,6 +493,34 @@ public class DesignReport {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate the simulation based on the motor id. Copy the simulation and execute it, then return the resulting
|
||||
* flight data.
|
||||
*
|
||||
* @param motorId the motor id corresponding to the simulation to find
|
||||
* @param simulations the list of simulations currently associated with the rocket
|
||||
*
|
||||
* @return the flight data from the simulation for the specified motor id, or null if not found
|
||||
*/
|
||||
private FlightData findSimulation(final String motorId, List<Simulation> simulations) {
|
||||
// Perform flight simulation
|
||||
FlightData flight = null;
|
||||
try {
|
||||
for (int i = 0; i < simulations.size(); i++) {
|
||||
Simulation simulation = simulations.get(i);
|
||||
if (simulation.getOptions().getMotorConfigurationID().equals(motorId)) {
|
||||
simulation = simulation.copy();
|
||||
simulation.simulate();
|
||||
flight = simulation.getSimulatedData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (SimulationException e1) {
|
||||
// Ignore
|
||||
}
|
||||
return flight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip [] brackets from a string.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user