Use proper units for the CSV parameters export
This commit is contained in:
parent
525190b37f
commit
1a81fd5a21
@ -3,6 +3,7 @@ package info.openrocket.core.componentanalysis;
|
||||
import info.openrocket.core.rocketcomponent.FlightConfiguration;
|
||||
import info.openrocket.core.rocketcomponent.Rocket;
|
||||
import info.openrocket.core.startup.Application;
|
||||
import info.openrocket.core.unit.Unit;
|
||||
import info.openrocket.core.util.Mutable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -20,6 +21,11 @@ public class CAParameters implements Cloneable {
|
||||
private double mach;
|
||||
private double rollRate;
|
||||
|
||||
private Unit thetaUnit;
|
||||
private Unit aoaUnit;
|
||||
private Unit machUnit;
|
||||
private Unit rollRateUnit;
|
||||
|
||||
public CAParameters(Rocket rocket, double initialTheta) {
|
||||
this.rocket = rocket;
|
||||
|
||||
@ -50,6 +56,14 @@ public class CAParameters implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public Unit getThetaUnit() {
|
||||
return thetaUnit;
|
||||
}
|
||||
|
||||
public void setThetaUnit(Unit thetaUnit) {
|
||||
this.thetaUnit = thetaUnit;
|
||||
}
|
||||
|
||||
public double getInitialTheta() {
|
||||
return initialTheta;
|
||||
}
|
||||
@ -66,6 +80,14 @@ public class CAParameters implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public Unit getAOAUnit() {
|
||||
return aoaUnit;
|
||||
}
|
||||
|
||||
public void setAOAUnit(Unit aoaUnit) {
|
||||
this.aoaUnit = aoaUnit;
|
||||
}
|
||||
|
||||
public double getMach() {
|
||||
return mach;
|
||||
}
|
||||
@ -78,6 +100,14 @@ public class CAParameters implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public Unit getMachUnit() {
|
||||
return machUnit;
|
||||
}
|
||||
|
||||
public void setMachUnit(Unit machUnit) {
|
||||
this.machUnit = machUnit;
|
||||
}
|
||||
|
||||
public double getRollRate() {
|
||||
return rollRate;
|
||||
}
|
||||
@ -90,6 +120,14 @@ public class CAParameters implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public Unit getRollRateUnit() {
|
||||
return rollRateUnit;
|
||||
}
|
||||
|
||||
public void setRollRateUnit(Unit rollRateUnit) {
|
||||
this.rollRateUnit = rollRateUnit;
|
||||
}
|
||||
|
||||
public FlightConfiguration getSelectedConfiguration() {
|
||||
return rocket.getSelectedConfiguration();
|
||||
}
|
||||
|
@ -320,22 +320,41 @@ public class CSVExport {
|
||||
String fieldSeparator, String commentStarter) {
|
||||
StringBuilder line = new StringBuilder(prependComment(commentStarter, "Parameters:")).append(fieldSeparator);
|
||||
|
||||
// TODO: use proper units for the parameters
|
||||
if (domainDataType != CADomainDataType.WIND_DIRECTION) {
|
||||
line.append("Wind direction:").append(fieldSeparator);
|
||||
line.append(parameters.getTheta()).append("°").append(fieldSeparator);
|
||||
Unit unit = parameters.getThetaUnit();
|
||||
if (unit != null) {
|
||||
line.append(unit.toStringUnit(parameters.getTheta())).append(fieldSeparator);
|
||||
} else {
|
||||
line.append(parameters.getTheta()).append(fieldSeparator);
|
||||
}
|
||||
}
|
||||
if (domainDataType != CADomainDataType.AOA) {
|
||||
line.append("Angle of attack:").append(fieldSeparator);
|
||||
line.append(parameters.getAOA()).append("°").append(fieldSeparator);
|
||||
Unit unit = parameters.getAOAUnit();
|
||||
if (unit != null) {
|
||||
line.append(unit.toStringUnit(parameters.getAOA())).append(fieldSeparator);
|
||||
} else {
|
||||
line.append(parameters.getAOA()).append(fieldSeparator);
|
||||
}
|
||||
}
|
||||
if (domainDataType != CADomainDataType.MACH) {
|
||||
line.append("Mach:").append(fieldSeparator);
|
||||
line.append(parameters.getMach()).append(fieldSeparator);
|
||||
Unit unit = parameters.getMachUnit();
|
||||
if (unit != null) {
|
||||
line.append(unit.toStringUnit(parameters.getMach())).append(fieldSeparator);
|
||||
} else {
|
||||
line.append(parameters.getMach()).append(fieldSeparator);
|
||||
}
|
||||
}
|
||||
if (domainDataType != CADomainDataType.ROLL_RATE) {
|
||||
line.append("Roll rate:").append(fieldSeparator);
|
||||
line.append(parameters.getRollRate()).append("°/s").append(fieldSeparator);
|
||||
Unit unit = parameters.getRollRateUnit();
|
||||
if (unit != null) {
|
||||
line.append(unit.toStringUnit(parameters.getRollRate())).append(fieldSeparator);
|
||||
} else {
|
||||
line.append(parameters.getRollRate()).append(fieldSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
line.append("Active stages:").append(fieldSeparator);
|
||||
|
@ -118,7 +118,10 @@ public class ComponentAnalysisGeneralPanel extends JPanel implements StateChange
|
||||
this.add(new JLabel(trans.get("ComponentAnalysisGeneralTab.lbl.winddir")));
|
||||
EditableSpinner spinner = new EditableSpinner(theta.getSpinnerModel());
|
||||
this.add(spinner, "growx");
|
||||
this.add(new UnitSelector(theta));
|
||||
final UnitSelector unitSelectorTheta = new UnitSelector(theta);
|
||||
unitSelectorTheta.addItemListener(e -> setParametersThetaUnit(unitSelectorTheta));
|
||||
setParametersThetaUnit(unitSelectorTheta);
|
||||
this.add(unitSelectorTheta);
|
||||
BasicSlider slider = new BasicSlider(theta.getSliderModel(0, 2 * Math.PI));
|
||||
this.add(slider, "growx, split 2");
|
||||
//// Worst button
|
||||
@ -149,19 +152,28 @@ public class ComponentAnalysisGeneralPanel extends JPanel implements StateChange
|
||||
////Angle of attack:
|
||||
this.add(new JLabel(trans.get("ComponentAnalysisGeneralTab.lbl.angleofattack")));
|
||||
this.add(new EditableSpinner(aoa.getSpinnerModel()), "growx");
|
||||
this.add(new UnitSelector(aoa));
|
||||
final UnitSelector unitSelectorAOA = new UnitSelector(aoa);
|
||||
unitSelectorAOA.addItemListener(e -> setParametersAOAUnit(unitSelectorAOA));
|
||||
setParametersAOAUnit(unitSelectorAOA);
|
||||
this.add(unitSelectorAOA);
|
||||
this.add(new BasicSlider(aoa.getSliderModel(0, Math.PI)), "growx, wrap");
|
||||
|
||||
//// Mach number:
|
||||
this.add(new JLabel(trans.get("ComponentAnalysisGeneralTab.lbl.machnumber")));
|
||||
this.add(new EditableSpinner(mach.getSpinnerModel()));
|
||||
this.add(new UnitSelector(mach));
|
||||
final UnitSelector unitSelectorMach = new UnitSelector(mach);
|
||||
unitSelectorMach.addItemListener(e -> setParametersMachUnit(unitSelectorMach));
|
||||
setParametersMachUnit(unitSelectorMach);
|
||||
this.add(unitSelectorMach);
|
||||
this.add(new BasicSlider(mach.getSliderModel(0, 3)), "growx, wrap");
|
||||
|
||||
//// Roll rate:
|
||||
this.add(new JLabel(trans.get("ComponentAnalysisGeneralTab.lbl.rollrate")));
|
||||
this.add(new EditableSpinner(roll.getSpinnerModel()), "growx");
|
||||
this.add(new UnitSelector(roll));
|
||||
final UnitSelector unitSelectorRoll = new UnitSelector(roll);
|
||||
unitSelectorRoll.addItemListener(e -> setParametersRollUnit(unitSelectorRoll));
|
||||
setParametersRollUnit(unitSelectorRoll);
|
||||
this.add(unitSelectorRoll);
|
||||
this.add(new BasicSlider(roll.getSliderModel(-20 * 2 * Math.PI, 20 * 2 * Math.PI)),
|
||||
"growx, wrap");
|
||||
|
||||
@ -468,6 +480,22 @@ public class ComponentAnalysisGeneralPanel extends JPanel implements StateChange
|
||||
});
|
||||
}
|
||||
|
||||
private void setParametersThetaUnit(UnitSelector unitSelector) {
|
||||
parameters.setThetaUnit(unitSelector.getSelectedUnit());
|
||||
}
|
||||
|
||||
private void setParametersAOAUnit(UnitSelector unitSelector) {
|
||||
parameters.setAOAUnit(unitSelector.getSelectedUnit());
|
||||
}
|
||||
|
||||
private void setParametersMachUnit(UnitSelector unitSelector) {
|
||||
parameters.setMachUnit(unitSelector.getSelectedUnit());
|
||||
}
|
||||
|
||||
private void setParametersRollUnit(UnitSelector unitSelector) {
|
||||
parameters.setRollRateUnit(unitSelector.getSelectedUnit());
|
||||
}
|
||||
|
||||
|
||||
public CAParameters getParameters() {
|
||||
return parameters;
|
||||
|
Loading…
x
Reference in New Issue
Block a user