[resolves #371] MassCalculator now updates result on FlightConfiguration change
- added check in MassCalculator against last-used FlightConfiguration - removed dead code
This commit is contained in:
parent
bd42c7ecde
commit
9c93ada83f
@ -8,6 +8,7 @@ import net.sf.openrocket.motor.Motor;
|
|||||||
import net.sf.openrocket.motor.MotorConfiguration;
|
import net.sf.openrocket.motor.MotorConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
import net.sf.openrocket.rocketcomponent.Instanceable;
|
import net.sf.openrocket.rocketcomponent.Instanceable;
|
||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.ParallelStage;
|
import net.sf.openrocket.rocketcomponent.ParallelStage;
|
||||||
@ -26,7 +27,7 @@ public class MassCalculator implements Monitorable {
|
|||||||
|
|
||||||
private int rocketMassModID = -1;
|
private int rocketMassModID = -1;
|
||||||
private int rocketTreeModID = -1;
|
private int rocketTreeModID = -1;
|
||||||
|
private FlightConfigurationId configId = FlightConfigurationId.ERROR_FCID;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cached data. All CG data is in absolute coordinates. All moments of inertia
|
* Cached data. All CG data is in absolute coordinates. All moments of inertia
|
||||||
@ -321,7 +322,6 @@ public class MassCalculator implements Monitorable {
|
|||||||
|
|
||||||
// if instanced, adjust children's data too.
|
// if instanced, adjust children's data too.
|
||||||
if ( 1 < component.getInstanceCount() ){
|
if ( 1 < component.getInstanceCount() ){
|
||||||
|
|
||||||
final double curIxx = childrenData.getIxx(); // MOI about x-axis
|
final double curIxx = childrenData.getIxx(); // MOI about x-axis
|
||||||
final double curIyy = childrenData.getIyy(); // MOI about y axis
|
final double curIyy = childrenData.getIyy(); // MOI about y axis
|
||||||
final double curIzz = childrenData.getIzz(); // MOI about z axis
|
final double curIzz = childrenData.getIzz(); // MOI about z axis
|
||||||
@ -404,9 +404,11 @@ public class MassCalculator implements Monitorable {
|
|||||||
*/
|
*/
|
||||||
protected final boolean checkCache(FlightConfiguration configuration) {
|
protected final boolean checkCache(FlightConfiguration configuration) {
|
||||||
if (rocketMassModID != configuration.getRocket().getMassModID() ||
|
if (rocketMassModID != configuration.getRocket().getMassModID() ||
|
||||||
rocketTreeModID != configuration.getRocket().getTreeModID()) {
|
rocketTreeModID != configuration.getRocket().getTreeModID() ||
|
||||||
|
configId != configuration.getId()) {
|
||||||
rocketMassModID = configuration.getRocket().getMassModID();
|
rocketMassModID = configuration.getRocket().getMassModID();
|
||||||
rocketTreeModID = configuration.getRocket().getTreeModID();
|
rocketTreeModID = configuration.getRocket().getTreeModID();
|
||||||
|
configId = configuration.getId();
|
||||||
voidMassCache();
|
voidMassCache();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -18,22 +18,17 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import net.sf.openrocket.gui.figureelements.FigureElement;
|
import net.sf.openrocket.gui.figureelements.FigureElement;
|
||||||
import net.sf.openrocket.gui.rocketfigure.RocketComponentShape;
|
import net.sf.openrocket.gui.rocketfigure.RocketComponentShape;
|
||||||
import net.sf.openrocket.gui.util.ColorConversion;
|
import net.sf.openrocket.gui.util.ColorConversion;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||||
import net.sf.openrocket.motor.Motor;
|
import net.sf.openrocket.motor.Motor;
|
||||||
import net.sf.openrocket.motor.MotorConfiguration;
|
import net.sf.openrocket.motor.MotorConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
|
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.simulation.BasicEventSimulationEngine;
|
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.BugException;
|
import net.sf.openrocket.util.BugException;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
@ -52,8 +47,6 @@ import net.sf.openrocket.util.Transformation;
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class RocketFigure extends AbstractScaleFigure {
|
public class RocketFigure extends AbstractScaleFigure {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(BasicEventSimulationEngine.class);
|
|
||||||
|
|
||||||
private static final String ROCKET_FIGURE_PACKAGE = "net.sf.openrocket.gui.rocketfigure";
|
private static final String ROCKET_FIGURE_PACKAGE = "net.sf.openrocket.gui.rocketfigure";
|
||||||
private static final String ROCKET_FIGURE_SUFFIX = "Shapes";
|
private static final String ROCKET_FIGURE_SUFFIX = "Shapes";
|
||||||
|
|
||||||
@ -108,11 +101,6 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
updateFigure();
|
updateFigure();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfiguration getConfiguration() {
|
|
||||||
return this.rocket.getSelectedConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getOrigin() {
|
public Dimension getOrigin() {
|
||||||
return new Dimension((int) translateX, (int) translateY);
|
return new Dimension((int) translateX, (int) translateY);
|
||||||
@ -456,7 +444,7 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// generate shape for this component, if active
|
// generate shape for this component, if active
|
||||||
if( this.getConfiguration().isComponentActive( comp )){
|
if( this.rocket.getSelectedConfiguration().isComponentActive( comp )){
|
||||||
allShapes = addThisShape( allShapes, this.currentViewType, comp, currentLocation, currentTransform);
|
allShapes = addThisShape( allShapes, this.currentViewType, comp, currentLocation, currentTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ import net.sf.openrocket.gui.simulation.SimulationWorker;
|
|||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.masscalc.MassCalculator;
|
import net.sf.openrocket.masscalc.MassCalculator;
|
||||||
|
import net.sf.openrocket.masscalc.MassData;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
@ -360,10 +361,6 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
return aerodynamicCalculator;
|
return aerodynamicCalculator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfiguration getSelectedConfiguration() {
|
|
||||||
return document.getSelectedConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the center of pressure figure element.
|
* Get the center of pressure figure element.
|
||||||
*
|
*
|
||||||
@ -600,7 +597,6 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
|
|
||||||
cg = massCalculator.getRocketLaunchMassData( curConfig).getCG();
|
cg = massCalculator.getRocketLaunchMassData( curConfig).getCG();
|
||||||
|
|
||||||
|
|
||||||
if (cp.weight > MassCalculator.MIN_MASS){
|
if (cp.weight > MassCalculator.MIN_MASS){
|
||||||
cpx = cp.x;
|
cpx = cp.x;
|
||||||
}else{
|
}else{
|
||||||
@ -638,12 +634,14 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MassData emptyInfo = massCalculator.getRocketSpentMassData( curConfig.getRocket().getEmptyConfiguration());
|
||||||
|
|
||||||
extraText.setCG(cgx);
|
extraText.setCG(cgx);
|
||||||
extraText.setCP(cpx);
|
extraText.setCP(cpx);
|
||||||
extraText.setLength(length);
|
extraText.setLength(length);
|
||||||
extraText.setDiameter(diameter);
|
extraText.setDiameter(diameter);
|
||||||
extraText.setMass(cg.weight);
|
extraText.setMass(cg.weight);
|
||||||
extraText.setMassWithoutMotors( massCalculator.getRocketSpentMassData( curConfig.getRocket().getEmptyConfiguration() ).getMass() );
|
extraText.setMassWithoutMotors( emptyInfo.getMass() );
|
||||||
extraText.setWarnings(warnings);
|
extraText.setWarnings(warnings);
|
||||||
|
|
||||||
if (figure.getType() == RocketPanel.VIEW_TYPE.SideView && length > 0) {
|
if (figure.getType() == RocketPanel.VIEW_TYPE.SideView && length > 0) {
|
||||||
@ -784,6 +782,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
extraCG = new CGCaret(0, 0);
|
extraCG = new CGCaret(0, 0);
|
||||||
extraCP = new CPCaret(0, 0);
|
extraCP = new CPCaret(0, 0);
|
||||||
extraText = new RocketInfo(curConfig);
|
extraText = new RocketInfo(curConfig);
|
||||||
|
|
||||||
updateExtras();
|
updateExtras();
|
||||||
|
|
||||||
figure.clearRelativeExtra();
|
figure.clearRelativeExtra();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user