Merge pull request #798 from teyrana/fix/786/display-motor-mass
[fixes# 786] Updates config when drawing extras on 2D RocketFigure
This commit is contained in:
commit
334bd1d3db
@ -41,12 +41,12 @@ public class RocketInfo implements FigureElement {
|
|||||||
private final Caret cpCaret = new CPCaret(0,0);
|
private final Caret cpCaret = new CPCaret(0,0);
|
||||||
private final Caret cgCaret = new CGCaret(0,0);
|
private final Caret cgCaret = new CGCaret(0,0);
|
||||||
|
|
||||||
private final FlightConfiguration configuration;
|
|
||||||
private final UnitGroup stabilityUnits;
|
private final UnitGroup stabilityUnits;
|
||||||
|
|
||||||
|
private FlightConfiguration configuration;
|
||||||
private double cg = 0, cp = 0;
|
private double cg = 0, cp = 0;
|
||||||
private double length = 0, diameter = 0;
|
private double length = 0, diameter = 0;
|
||||||
private double mass = 0;
|
private double massWithMotors = 0;
|
||||||
private double aoa = Double.NaN;
|
private double aoa = Double.NaN;
|
||||||
private double theta = Double.NaN;
|
private double theta = Double.NaN;
|
||||||
private double mach = Application.getPreferences().getDefaultMach();
|
private double mach = Application.getPreferences().getDefaultMach();
|
||||||
@ -112,8 +112,8 @@ public class RocketInfo implements FigureElement {
|
|||||||
this.diameter = diameter;
|
this.diameter = diameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMass(double mass) {
|
public void setMassWithMotors(double mass) {
|
||||||
this.mass = mass;
|
this.massWithMotors = mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMassWithoutMotors(double mass) {
|
public void setMassWithoutMotors(double mass) {
|
||||||
@ -175,11 +175,10 @@ public class RocketInfo implements FigureElement {
|
|||||||
if( configuration.hasMotors() ) {
|
if( configuration.hasMotors() ) {
|
||||||
//// Mass with motors
|
//// Mass with motors
|
||||||
massTextWithMotors = trans.get("RocketInfo.massWithMotors") + " ";
|
massTextWithMotors = trans.get("RocketInfo.massWithMotors") + " ";
|
||||||
massTextWithMotors += UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(mass);
|
massTextWithMotors += UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(massWithMotors);
|
||||||
GlyphVector massLineWithMotors = createText(massTextWithMotors);
|
GlyphVector massLineWithMotors = createText(massTextWithMotors);
|
||||||
g2.drawGlyphVector(massLineWithMotors, x1, y1+3*line);
|
g2.drawGlyphVector(massLineWithMotors, x1, y1+3*line);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -254,8 +253,8 @@ public class RocketInfo implements FigureElement {
|
|||||||
*
|
*
|
||||||
* @return the mass
|
* @return the mass
|
||||||
*/
|
*/
|
||||||
public double getMass() {
|
public double getMassWithMotors() {
|
||||||
return mass;
|
return massWithMotors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -265,8 +264,8 @@ public class RocketInfo implements FigureElement {
|
|||||||
*
|
*
|
||||||
* @return the mass
|
* @return the mass
|
||||||
*/
|
*/
|
||||||
public String getMass(Unit u) {
|
public String getMassWithMotors(Unit u) {
|
||||||
return u.toStringUnit(mass);
|
return u.toStringUnit(massWithMotors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -451,4 +450,7 @@ public class RocketInfo implements FigureElement {
|
|||||||
return (SMALLFONT.deriveFont(size)).createGlyphVector(g2.getFontRenderContext(), text);
|
return (SMALLFONT.deriveFont(size)).createGlyphVector(g2.getFontRenderContext(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCurrentConfig(FlightConfiguration newConfig) {
|
||||||
|
this.configuration = newConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ public class DesignReport {
|
|||||||
} else {
|
} else {
|
||||||
canvas.newlineShowText(MASS_EMPTY);
|
canvas.newlineShowText(MASS_EMPTY);
|
||||||
}
|
}
|
||||||
canvas.showText(text.getMass(UnitGroup.UNITS_MASS.getDefaultUnit()));
|
canvas.showText(text.getMassWithMotors(UnitGroup.UNITS_MASS.getDefaultUnit()));
|
||||||
|
|
||||||
canvas.newlineShowText(STABILITY);
|
canvas.newlineShowText(STABILITY);
|
||||||
canvas.showText(text.getStability());
|
canvas.showText(text.getStability());
|
||||||
|
@ -573,6 +573,8 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
FlightConditions conditions = new FlightConditions(curConfig);
|
FlightConditions conditions = new FlightConditions(curConfig);
|
||||||
warnings.clear();
|
warnings.clear();
|
||||||
|
|
||||||
|
extraText.setCurrentConfig(curConfig);
|
||||||
|
|
||||||
if (!Double.isNaN(cpMach)) {
|
if (!Double.isNaN(cpMach)) {
|
||||||
conditions.setMach(cpMach);
|
conditions.setMach(cpMach);
|
||||||
extraText.setMach(cpMach);
|
extraText.setMach(cpMach);
|
||||||
@ -601,15 +603,13 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
cp = aerodynamicCalculator.getWorstCP(curConfig, conditions, warnings);
|
cp = aerodynamicCalculator.getWorstCP(curConfig, conditions, warnings);
|
||||||
}
|
}
|
||||||
extraText.setTheta(cpTheta);
|
extraText.setTheta(cpTheta);
|
||||||
|
|
||||||
cg = MassCalculator.calculateLaunch( curConfig).getCM();
|
|
||||||
|
|
||||||
if (cp.weight > MathUtil.EPSILON){
|
if (cp.weight > MathUtil.EPSILON){
|
||||||
cpx = cp.x;
|
cpx = cp.x;
|
||||||
// map the 3D value into the 2D Display Panel
|
// map the 3D value into the 2D Display Panel
|
||||||
cpy = cp.y * Math.cos(rotation) + cp.z*Math.sin(rotation);
|
cpy = cp.y * Math.cos(rotation) + cp.z*Math.sin(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cg = MassCalculator.calculateLaunch( curConfig).getCM();
|
||||||
if (cg.weight > MassCalculator.MIN_MASS){
|
if (cg.weight > MassCalculator.MIN_MASS){
|
||||||
cgx = cg.x;
|
cgx = cg.x;
|
||||||
// map the 3D value into the 2D Display Panel
|
// map the 3D value into the 2D Display Panel
|
||||||
@ -636,7 +636,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
extraText.setCP(cpx);
|
extraText.setCP(cpx);
|
||||||
extraText.setLength(length);
|
extraText.setLength(length);
|
||||||
extraText.setDiameter(diameter);
|
extraText.setDiameter(diameter);
|
||||||
extraText.setMass(cg.weight);
|
extraText.setMassWithMotors(cg.weight);
|
||||||
extraText.setMassWithoutMotors( emptyInfo.getMass() );
|
extraText.setMassWithoutMotors( emptyInfo.getMass() );
|
||||||
extraText.setWarnings(warnings);
|
extraText.setWarnings(warnings);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user