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.awt.Graphics2D;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
import net.sf.openrocket.gui.figureelements.FigureElement;
|
import net.sf.openrocket.gui.figureelements.FigureElement;
|
||||||
import net.sf.openrocket.gui.figureelements.RocketInfo;
|
import net.sf.openrocket.gui.figureelements.RocketInfo;
|
||||||
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.logging.LogHelper;
|
import net.sf.openrocket.logging.LogHelper;
|
||||||
import net.sf.openrocket.masscalc.BasicMassCalculator;
|
import net.sf.openrocket.masscalc.BasicMassCalculator;
|
||||||
import net.sf.openrocket.masscalc.MassCalculator;
|
import net.sf.openrocket.masscalc.MassCalculator;
|
||||||
@ -225,6 +225,7 @@ public class DesignReport {
|
|||||||
document.add(paragraph);
|
document.add(paragraph);
|
||||||
|
|
||||||
String[] motorIds = rocket.getMotorConfigurationIDs();
|
String[] motorIds = rocket.getMotorConfigurationIDs();
|
||||||
|
List<Simulation> simulations = rocketDocument.getSimulations();
|
||||||
|
|
||||||
for (int j = 0; j < motorIds.length; j++) {
|
for (int j = 0; j < motorIds.length; j++) {
|
||||||
String motorId = motorIds[j];
|
String motorId = motorIds[j];
|
||||||
@ -239,7 +240,8 @@ public class DesignReport {
|
|||||||
if (j > 1) {
|
if (j > 1) {
|
||||||
leading = 25;
|
leading = 25;
|
||||||
}
|
}
|
||||||
addFlightData(rocket, motorId, parent, leading);
|
FlightData flight = findSimulation(motorId, simulations);
|
||||||
|
addFlightData(flight, rocket, motorId, parent, leading);
|
||||||
addMotorData(rocket, motorId, parent);
|
addMotorData(rocket, motorId, parent);
|
||||||
document.add(parent);
|
document.add(parent);
|
||||||
}
|
}
|
||||||
@ -429,28 +431,17 @@ 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 theRocket the rocket
|
||||||
* @param motorId a motor configuration id
|
* @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
|
* @param leading the number of points for the leading
|
||||||
*/
|
*/
|
||||||
private void addFlightData(final Rocket theRocket, final String motorId, final PdfPTable parent, int leading) {
|
private void addFlightData(final FlightData flight, final Rocket theRocket, final String motorId, final PdfPTable parent, int leading) {
|
||||||
|
|
||||||
// Perform flight simulation
|
// Output the flight data
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output the flight data
|
|
||||||
if (flight != null) {
|
if (flight != null) {
|
||||||
try {
|
try {
|
||||||
final Unit distanceUnit = UnitGroup.UNITS_DISTANCE.getDefaultUnit();
|
final Unit distanceUnit = UnitGroup.UNITS_DISTANCE.getDefaultUnit();
|
||||||
@ -502,7 +493,35 @@ 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.
|
* Strip [] brackets from a string.
|
||||||
*
|
*
|
||||||
* @param target the original string
|
* @param target the original string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user