ACTUAL bugfix commit: Stage Config dialog fixed.

This commit is contained in:
Daniel_M_Williams 2015-06-08 18:19:23 -04:00
parent 2a855ed2a4
commit 8371876718
6 changed files with 64 additions and 48 deletions

View File

@ -827,10 +827,11 @@ RocketCompCfg.tab.Pod = Pod
RocketCompCfg.tab.PodComment = Options for locating ExteriorComponents outside the Rocket RocketCompCfg.tab.PodComment = Options for locating ExteriorComponents outside the Rocket
RocketCompCfg.tab.Parallel = Parallel RocketCompCfg.tab.Parallel = Parallel
RocketCompCfg.tab.ParallelComment = Options for locating Stages parallel to other stages RocketCompCfg.tab.ParallelComment = Options for locating Stages parallel to other stages
RocketCompCfg.parallel.inline = Make this Stage Parallel RocketCompCfg.outside.stage = Make this Stage Parallel
RocketCompCfg.parallel.radius = Radial Distance (meters) RocketCompCfg.outside.pod = Move this Component Outside
RocketCompCfg.parallel.angle = Angle (Radians) RocketCompCfg.outside.radius = Radial Distance (meters)
RocketCompCfg.parallel.rotation = Rotation (Radians) RocketCompCfg.outside.angle = Angle (Radians)
RocketCompCfg.outside.rotation = Rotation (Radians)
RocketCompCfg.tab.Figure = Figure RocketCompCfg.tab.Figure = Figure
RocketCompCfg.tab.Figstyleopt = Figure style options RocketCompCfg.tab.Figstyleopt = Figure style options
RocketCompCfg.tab.Comment = Comment RocketCompCfg.tab.Comment = Comment

View File

@ -18,7 +18,7 @@ import net.sf.openrocket.unit.UnitGroup;
public abstract class ExternalComponent extends RocketComponent implements OutsideComponent { public abstract class ExternalComponent extends RocketComponent implements OutsideComponent {
private boolean axial = true; private boolean outside = false;
private double position_angular_rad = 0; private double position_angular_rad = 0;
private double position_radial_m = 0; private double position_radial_m = 0;
private double rotation_rad = 0; private double rotation_rad = 0;
@ -131,23 +131,23 @@ public abstract class ExternalComponent extends RocketComponent implements Outsi
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
} }
@Override
public boolean getOutside() {
return this.outside;
}
public boolean isInline() { public boolean isInline() {
return this.axial; return !this.outside;
} }
@Override @Override
public boolean getParallel() { public void setOutside(final boolean _outside) {
return !this.axial; this.outside = _outside;
}
@Override
public void setParallel(final boolean parallel) {
this.axial = !parallel;
} }
@Override @Override
public double getAngularPosition() { public double getAngularPosition() {
if (axial) { if (outside) {
return 0.; return 0.;
} }
return this.position_angular_rad; return this.position_angular_rad;
@ -160,7 +160,7 @@ public abstract class ExternalComponent extends RocketComponent implements Outsi
@Override @Override
public double getRadialPosition() { public double getRadialPosition() {
if (axial) { if (outside) {
return 0.; return 0.;
} }
return this.position_radial_m; return this.position_radial_m;
@ -173,7 +173,7 @@ public abstract class ExternalComponent extends RocketComponent implements Outsi
@Override @Override
public double getRotation() { public double getRotation() {
if (axial) { if (outside) {
return 0.; return 0.;
} }
return this.rotation_rad; return this.rotation_rad;

View File

@ -6,17 +6,17 @@ public interface OutsideComponent {
/** /**
* Indicates whether this component is located inside or outside of the rest of the rocket. (Specifically, inside or outside its parent.) * Indicates whether this component is located inside or outside of the rest of the rocket. (Specifically, inside or outside its parent.)
* *
* @return <code> True </code> This component is aligned with its parent * @return <code> False </code> This component is aligned with its parent
* <code> False </code> This component is offset from its parent -- like an external pod, or strap-on stage * <code> True </code> This component is offset from its parent -- like an external pod, or strap-on stage
*/ */
public boolean getParallel(); public boolean getOutside();
/** /**
* Change whether this component is located inside or outside of the rest of the rocket. (Specifically, inside or outside its parent.) * Change whether this component is located inside or outside of the rest of the rocket. (Specifically, inside or outside its parent.)
* *
* @param inline True indicates that this component axially aligned with its parent. False indicates an off-center component. * @param inline False indicates that this component axially aligned with its parent. True indicates an off-center component.
*/ */
public void setParallel(final boolean inline); public void setOutside(final boolean inline);
/** /**
* Get the position of this component in polar coordinates * Get the position of this component in polar coordinates

View File

@ -9,7 +9,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
private FlightConfigurationImpl<StageSeparationConfiguration> separationConfigurations; private FlightConfigurationImpl<StageSeparationConfiguration> separationConfigurations;
private boolean axial = true; private boolean outside = false;
private double position_angular_rad = 0; private double position_angular_rad = 0;
private double position_radial_m = 0; private double position_radial_m = 0;
private double rotation_rad = 0; private double rotation_rad = 0;
@ -70,22 +70,23 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
} }
@Override @Override
public boolean getParallel() { public boolean getOutside() {
return !this.axial; return this.outside;
} }
public boolean getInline() {
return this.axial; public boolean isInline() {
return !this.outside;
} }
@Override @Override
public void setParallel(final boolean parallel) { public void setOutside(final boolean _outside) {
this.axial = !parallel; this.outside = _outside;
} }
@Override @Override
public double getAngularPosition() { public double getAngularPosition() {
if (axial) { if (this.isInline()) {
return 0.; return 0.;
} }
return this.position_angular_rad; return this.position_angular_rad;
@ -98,7 +99,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
@Override @Override
public double getRadialPosition() { public double getRadialPosition() {
if (axial) { if (this.isInline()) {
return 0.; return 0.;
} }
return this.position_radial_m; return this.position_radial_m;
@ -111,7 +112,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
@Override @Override
public double getRotation() { public double getRotation() {
if (axial) { if (this.isInline()) {
return 0.; return 0.;
} }
return this.rotation_rad; return this.rotation_rad;

View File

@ -126,6 +126,9 @@ public class RocketComponentConfig extends JPanel {
tabbedPane.addTab(trans.get("RocketCompCfg.tab.Comment"), null, commentTab(), tabbedPane.addTab(trans.get("RocketCompCfg.tab.Comment"), null, commentTab(),
trans.get("RocketCompCfg.tab.Specifyacomment")); trans.get("RocketCompCfg.tab.Specifyacomment"));
if( component instanceof ExternalComponent ){
tabbedPane.insertTab( trans.get("RocketCompCfg.tab.Pod"), null, podTab( (ExternalComponent) component ), trans.get("RocketCompCfg.tab.PodComment"), 2);
}
addButtons(); addButtons();
@ -159,10 +162,6 @@ public class RocketComponentConfig extends JPanel {
}); });
buttonPanel.add(closeButton, "right, gap 30lp"); buttonPanel.add(closeButton, "right, gap 30lp");
if( component instanceof ExternalComponent ){
tabbedPane.insertTab( trans.get("RocketCompCfg.tab.Pod"), null, podTab( (ExternalComponent) component ), trans.get("RocketCompCfg.tab.PodComment"), 2);
}
updateFields(); updateFields();
this.add(buttonPanel, "spanx, growx"); this.add(buttonPanel, "spanx, growx");
@ -288,10 +287,10 @@ public class RocketComponentConfig extends JPanel {
private JPanel podTab( final ExternalComponent pod ){ private JPanel podTab( final ExternalComponent pod ){
// enable parallel staging // enable parallel staging
JPanel motherPanel = new JPanel( new MigLayout("fill")); JPanel motherPanel = new JPanel( new MigLayout("fill"));
podsEnabledModel = new BooleanModel( component, "Parallel"); podsEnabledModel = new BooleanModel( component, "Outside");
podsEnabledModel.setValue(false); podsEnabledModel.setValue( pod.getOutside());
JCheckBox parallelEnabled = new JCheckBox( podsEnabledModel); JCheckBox parallelEnabled = new JCheckBox( podsEnabledModel);
parallelEnabled.setText(trans.get("RocketCompCfg.parallel.inline")); parallelEnabled.setText(trans.get("RocketCompCfg.outside.pod"));
motherPanel.add(parallelEnabled, "wrap"); motherPanel.add(parallelEnabled, "wrap");
JPanel enabledPanel = new JPanel( new MigLayout("fill")); JPanel enabledPanel = new JPanel( new MigLayout("fill"));
@ -300,25 +299,35 @@ public class RocketComponentConfig extends JPanel {
enabledPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "growx,wrap"); enabledPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "growx,wrap");
// set radial distance // set radial distance
enabledPanel.add(new JLabel(trans.get("RocketCompCfg.parallel.radius")), "align left"); enabledPanel.add(new JLabel(trans.get("RocketCompCfg.outside.radius")), "align left");
DoubleModel radiusModel = new DoubleModel( pod, "RadialPosition", 0.); DoubleModel radiusModel = new DoubleModel( pod, "RadialPosition", 0.);
radiusModel.setCurrentUnit( UnitGroup.UNITS_DISTANCE.getSIUnit() );
JSpinner radiusSpinner = new JSpinner( radiusModel.getSpinnerModel()); JSpinner radiusSpinner = new JSpinner( radiusModel.getSpinnerModel());
radiusSpinner.setEditor(new SpinnerEditor(radiusSpinner )); radiusSpinner.setEditor(new SpinnerEditor(radiusSpinner ));
enabledPanel.add(radiusSpinner , "growx, wrap, align right"); enabledPanel.add(radiusSpinner , "growx, wrap, align right");
// set angle around the primary stage // set angle around the primary stage
enabledPanel.add(new JLabel(trans.get("RocketCompCfg.parallel.angle")), "align left"); enabledPanel.add(new JLabel(trans.get("RocketCompCfg.outside.angle")), "align left");
DoubleModel angleModel = new DoubleModel( pod, "AngularPosition", 0., Math.PI*2); DoubleModel angleModel = new DoubleModel( pod, "AngularPosition", 0., Math.PI*2);
angleModel.setCurrentUnit( UnitGroup.UNITS_ANGLE.getUnit("rad") );
JSpinner angleSpinner = new JSpinner(angleModel.getSpinnerModel()); JSpinner angleSpinner = new JSpinner(angleModel.getSpinnerModel());
angleSpinner.setEditor(new SpinnerEditor(angleSpinner)); angleSpinner.setEditor(new SpinnerEditor(angleSpinner));
enabledPanel.add(angleSpinner, "growx, wrap"); enabledPanel.add(angleSpinner, "growx, wrap");
enabledPanel.add(new JLabel(trans.get("RocketCompCfg.parallel.rotation")), "align left"); enabledPanel.add(new JLabel(trans.get("RocketCompCfg.outside.rotation")), "align left");
DoubleModel rotationModel = new DoubleModel( pod, "Rotation", 0.0, Math.PI*2); DoubleModel rotationModel = new DoubleModel( pod, "Rotation", 0.0, Math.PI*2);
rotationModel.setCurrentUnit( UnitGroup.UNITS_ANGLE.getUnit("rad") );
JSpinner rotationSpinner = new JSpinner(rotationModel.getSpinnerModel()); JSpinner rotationSpinner = new JSpinner(rotationModel.getSpinnerModel());
rotationSpinner.setEditor(new SpinnerEditor(rotationSpinner)); rotationSpinner.setEditor(new SpinnerEditor(rotationSpinner));
enabledPanel.add(rotationSpinner, "growx, wrap"); enabledPanel.add(rotationSpinner, "growx, wrap");
// TODO: add multiplicity
// enabledPanel.add(new JLabel(trans.get("RocketCompCfg.parallel.rotation")), "align left");
// DoubleModel rotationModel = new DoubleModel( pod, "Rotation", 0.0, Math.PI*2);
// JSpinner rotationSpinner = new JSpinner(rotationModel.getSpinnerModel());
// rotationSpinner.setEditor(new SpinnerEditor(rotationSpinner));
// enabledPanel.add(rotationSpinner, "growx, wrap");
//
setDeepEnabled( enabledPanel, podsEnabledModel.getValue()); setDeepEnabled( enabledPanel, podsEnabledModel.getValue());
parallelEnabled.addChangeListener(new ChangeListener() { parallelEnabled.addChangeListener(new ChangeListener() {
@Override @Override

View File

@ -27,6 +27,7 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.Stage; import net.sf.openrocket.rocketcomponent.Stage;
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration;
import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup;
public class StageConfig extends RocketComponentConfig { public class StageConfig extends RocketComponentConfig {
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
@ -53,10 +54,10 @@ public class StageConfig extends RocketComponentConfig {
private JPanel parallelTab( final Stage stage ){ private JPanel parallelTab( final Stage stage ){
// enable parallel staging // enable parallel staging
JPanel motherPanel = new JPanel( new MigLayout("fill")); JPanel motherPanel = new JPanel( new MigLayout("fill"));
parallelEnabledModel = new BooleanModel( component, "Parallel"); parallelEnabledModel = new BooleanModel( component, "Outside");
parallelEnabledModel.setValue( stage.getInline()); parallelEnabledModel.setValue( stage.getOutside());
JCheckBox parallelEnabled = new JCheckBox( parallelEnabledModel); JCheckBox parallelEnabled = new JCheckBox( parallelEnabledModel);
parallelEnabled.setText(trans.get("RocketCompCfg.parallel.inline")); parallelEnabled.setText(trans.get("RocketCompCfg.outside.stage"));
motherPanel.add(parallelEnabled, "wrap"); motherPanel.add(parallelEnabled, "wrap");
JPanel enabledPanel = new JPanel( new MigLayout("fill")); JPanel enabledPanel = new JPanel( new MigLayout("fill"));
@ -65,32 +66,36 @@ public class StageConfig extends RocketComponentConfig {
enabledPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "growx,wrap"); enabledPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "growx,wrap");
// set radial distance // set radial distance
enabledPanel.add(new JLabel(trans.get("RocketCompCfg.parallel.radius")), "align left"); enabledPanel.add(new JLabel(trans.get("RocketCompCfg.outside.radius")), "align left");
DoubleModel radiusModel = new DoubleModel( stage, "RadialPosition", 0.0); DoubleModel radiusModel = new DoubleModel( stage, "RadialPosition", 0.0);
radiusModel.setCurrentUnit( UnitGroup.UNITS_DISTANCE.getSIUnit() );
JSpinner radiusSpinner = new JSpinner( radiusModel.getSpinnerModel()); JSpinner radiusSpinner = new JSpinner( radiusModel.getSpinnerModel());
radiusSpinner.setEditor(new SpinnerEditor(radiusSpinner )); radiusSpinner.setEditor(new SpinnerEditor(radiusSpinner ));
enabledPanel.add(radiusSpinner , "growx, wrap, align right"); enabledPanel.add(radiusSpinner , "growx, wrap, align right");
// set angle around the primary stage // set angle around the primary stage
enabledPanel.add(new JLabel(trans.get("RocketCompCfg.parallel.angle")), "align left"); enabledPanel.add(new JLabel(trans.get("RocketCompCfg.outside.angle")), "align left");
DoubleModel angleModel = new DoubleModel( stage, "AngularPosition", 0.0, Math.PI*2); DoubleModel angleModel = new DoubleModel( stage, "AngularPosition", 0.0, Math.PI*2);
angleModel.setCurrentUnit( UnitGroup.UNITS_ANGLE.getUnit("rad"));
JSpinner angleSpinner = new JSpinner(angleModel.getSpinnerModel()); JSpinner angleSpinner = new JSpinner(angleModel.getSpinnerModel());
angleSpinner.setEditor(new SpinnerEditor(angleSpinner)); angleSpinner.setEditor(new SpinnerEditor(angleSpinner));
enabledPanel.add(angleSpinner, "growx, wrap"); enabledPanel.add(angleSpinner, "growx, wrap");
enabledPanel.add(new JLabel(trans.get("RocketCompCfg.parallel.rotation")), "align left"); enabledPanel.add(new JLabel(trans.get("RocketCompCfg.outside.rotation")), "align left");
DoubleModel rotationModel = new DoubleModel( stage, "Rotation", 0.0, Math.PI*2); DoubleModel rotationModel = new DoubleModel( stage, "Rotation", 0.0, Math.PI*2);
rotationModel.setCurrentUnit( UnitGroup.UNITS_ANGLE.getUnit("rad") );
JSpinner rotationSpinner = new JSpinner(rotationModel.getSpinnerModel()); JSpinner rotationSpinner = new JSpinner(rotationModel.getSpinnerModel());
rotationSpinner.setEditor(new SpinnerEditor(rotationSpinner)); rotationSpinner.setEditor(new SpinnerEditor(rotationSpinner));
enabledPanel.add(rotationSpinner, "growx, wrap"); enabledPanel.add(rotationSpinner, "growx, wrap");
setDeepEnabled( enabledPanel, parallelEnabledModel.getValue());
parallelEnabled.addChangeListener(new ChangeListener() { parallelEnabled.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
setDeepEnabled( parallelEnabledPanel, parallelEnabledModel.getValue()); setDeepEnabled( parallelEnabledPanel, parallelEnabledModel.getValue());
} }
}); });
setDeepEnabled( parallelEnabledPanel, parallelEnabledModel.getValue());
motherPanel.add( enabledPanel , "growx, wrap"); motherPanel.add( enabledPanel , "growx, wrap");