Updated GUI with axial stage position elements
This commit is contained in:
parent
2cd5fe6306
commit
4f716b40af
@ -823,15 +823,12 @@ RocketCompCfg.lbl.Componentname = Component name:
|
||||
RocketCompCfg.ttip.Thecomponentname = The component name.
|
||||
RocketCompCfg.tab.Override = Override
|
||||
RocketCompCfg.tab.MassandCGoverride = Mass and CG override options
|
||||
RocketCompCfg.tab.Pod = Pod
|
||||
RocketCompCfg.tab.PodComment = Options for locating ExteriorComponents outside the Rocket
|
||||
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.outside.stage = Make this Stage Parallel
|
||||
RocketCompCfg.outside.pod = Move this Component Outside
|
||||
RocketCompCfg.outside.radius = Radial Distance (meters)
|
||||
RocketCompCfg.outside.angle = Angle (Radians)
|
||||
RocketCompCfg.outside.rotation = Rotation (Radians)
|
||||
RocketCompCfg.outside.radius = Radial Distance
|
||||
RocketCompCfg.outside.angle = Angle
|
||||
RocketCompCfg.outside.rotation = Rotation
|
||||
RocketCompCfg.tab.Figure = Figure
|
||||
RocketCompCfg.tab.Figstyleopt = Figure style options
|
||||
RocketCompCfg.tab.Comment = Comment
|
||||
|
@ -1000,11 +1000,22 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
mutex.lock("toRelative");
|
||||
try {
|
||||
double absoluteX = Double.NaN;
|
||||
double relativeY = 0;
|
||||
double relativeZ = 0;
|
||||
RocketComponent search = dest;
|
||||
Coordinate[] array = new Coordinate[1];
|
||||
array[0] = c;
|
||||
|
||||
RocketComponent component = this;
|
||||
if (component instanceof OutsideComponent) {
|
||||
OutsideComponent ext = (OutsideComponent) component;
|
||||
double phi = ext.getAngularPosition();
|
||||
double r = ext.getRadialPosition();
|
||||
relativeY = r * Math.cos(phi);
|
||||
relativeZ = r * Math.sin(phi);
|
||||
array[0].setY(relativeY);
|
||||
array[0].setZ(relativeZ);
|
||||
}
|
||||
while ((component != search) && (component.parent != null)) {
|
||||
|
||||
array = component.shiftCoordinates(array);
|
||||
@ -1012,21 +1023,21 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
switch (component.relativePosition) {
|
||||
case TOP:
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = array[i].add(component.position, 0, 0);
|
||||
array[i] = array[i].add(component.position, relativeY, relativeZ);
|
||||
}
|
||||
break;
|
||||
|
||||
case MIDDLE:
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = array[i].add(component.position +
|
||||
(component.parent.length - component.length) / 2, 0, 0);
|
||||
(component.parent.length - component.length) / 2, relativeY, relativeZ);
|
||||
}
|
||||
break;
|
||||
|
||||
case BOTTOM:
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = array[i].add(component.position +
|
||||
(component.parent.length - component.length), 0, 0);
|
||||
(component.parent.length - component.length), relativeY, relativeZ);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1038,17 +1049,18 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
RocketComponent comp = component.parent.children.get(index);
|
||||
double componentLength = comp.getTotalLength();
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = array[i].add(componentLength, 0, 0);
|
||||
array[i] = array[i].add(componentLength, relativeY, relativeZ);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = array[i].add(component.position + component.parent.length, 0, 0);
|
||||
array[i] = array[i].add(component.position + component.parent.length, relativeY, relativeZ);
|
||||
}
|
||||
break;
|
||||
|
||||
case ABSOLUTE:
|
||||
search = null; // Requires back-search if dest!=null
|
||||
if (Double.isNaN(absoluteX)) {
|
||||
// TODO: requires debugging if thsi component is an External Pods or stage
|
||||
absoluteX = component.position;
|
||||
}
|
||||
break;
|
||||
@ -1063,6 +1075,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
|
||||
if (!Double.isNaN(absoluteX)) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
// TODO: requires debugging if thsi component is an External Pods or stage
|
||||
array[i] = array[i].setX(absoluteX + c.x);
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
private double position_radial_m = 0;
|
||||
private double rotation_rad = 0;
|
||||
|
||||
// ParallelStagingConfiguration parallelConfiguration = null;
|
||||
|
||||
public Stage() {
|
||||
this.separationConfigurations = new FlightConfigurationImpl<StageSeparationConfiguration>(this, ComponentChangeEvent.EVENT_CHANGE, new StageSeparationConfiguration());
|
||||
}
|
||||
@ -31,11 +29,6 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
return separationConfigurations;
|
||||
}
|
||||
|
||||
// public ParallelStagingConfiguration getParallelStageConfiguration() {
|
||||
// return parallelConfiguration;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public boolean allowsChildren() {
|
||||
return true;
|
||||
@ -54,8 +47,6 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
return BodyComponent.class.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void cloneFlightConfiguration(String oldConfigId, String newConfigId) {
|
||||
separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId);
|
||||
@ -74,7 +65,6 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
return this.outside;
|
||||
}
|
||||
|
||||
|
||||
public boolean isInline() {
|
||||
return !this.outside;
|
||||
}
|
||||
@ -82,6 +72,9 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
@Override
|
||||
public void setOutside(final boolean _outside) {
|
||||
this.outside = _outside;
|
||||
if (this.outside) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -95,6 +88,9 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
@Override
|
||||
public void setAngularPosition(final double angle_rad) {
|
||||
this.position_angular_rad = angle_rad;
|
||||
if (this.outside) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,6 +104,10 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
@Override
|
||||
public void setRadialPosition(final double radius) {
|
||||
this.position_radial_m = radius;
|
||||
if (this.outside) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -121,6 +121,30 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
@Override
|
||||
public void setRotation(final double rotation) {
|
||||
this.rotation_rad = rotation;
|
||||
if (this.outside) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public RocketComponent.Position getRelativePositionMethod() {
|
||||
return this.relativePosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativePosition(final Position position) {
|
||||
super.setRelativePosition(position);
|
||||
}
|
||||
|
||||
public double getAxialPosition() {
|
||||
return super.getPositionValue();
|
||||
}
|
||||
|
||||
public void setAxialPosition(final double _pos) {
|
||||
super.setPositionValue(_pos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.sf.openrocket.gui.configdialog;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
@ -19,7 +20,9 @@ import net.sf.openrocket.gui.SpinnerEditor;
|
||||
import net.sf.openrocket.gui.adaptors.BooleanModel;
|
||||
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
||||
import net.sf.openrocket.gui.adaptors.EnumModel;
|
||||
import net.sf.openrocket.gui.components.BasicSlider;
|
||||
import net.sf.openrocket.gui.components.StyledLabel;
|
||||
import net.sf.openrocket.gui.components.UnitSelector;
|
||||
import net.sf.openrocket.gui.components.StyledLabel.Style;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.rocketcomponent.OutsideComponent;
|
||||
@ -28,12 +31,11 @@ import net.sf.openrocket.rocketcomponent.Stage;
|
||||
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.unit.UnitGroup;
|
||||
import net.sf.openrocket.util.ChangeSource;
|
||||
|
||||
public class StageConfig extends RocketComponentConfig {
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
private BooleanModel parallelEnabledModel = null;
|
||||
private JPanel parallelEnabledPanel = null;
|
||||
|
||||
|
||||
public StageConfig(OpenRocketDocument document, RocketComponent component) {
|
||||
super(document, component);
|
||||
@ -54,51 +56,84 @@ public class StageConfig extends RocketComponentConfig {
|
||||
private JPanel parallelTab( final Stage stage ){
|
||||
// enable parallel staging
|
||||
JPanel motherPanel = new JPanel( new MigLayout("fill"));
|
||||
parallelEnabledModel = new BooleanModel( component, "Outside");
|
||||
BooleanModel parallelEnabledModel = new BooleanModel( component, "Outside");
|
||||
parallelEnabledModel.setValue( stage.getOutside());
|
||||
JCheckBox parallelEnabled = new JCheckBox( parallelEnabledModel);
|
||||
parallelEnabled.setText(trans.get("RocketCompCfg.outside.stage"));
|
||||
motherPanel.add(parallelEnabled, "wrap");
|
||||
|
||||
JPanel enabledPanel = new JPanel( new MigLayout("fill"));
|
||||
this.parallelEnabledPanel = enabledPanel;
|
||||
|
||||
enabledPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "growx,wrap");
|
||||
motherPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "spanx 3, growx, wrap");
|
||||
|
||||
// set radial distance
|
||||
enabledPanel.add(new JLabel(trans.get("RocketCompCfg.outside.radius")), "align left");
|
||||
DoubleModel radiusModel = new DoubleModel( stage, "RadialPosition", 0.0);
|
||||
radiusModel.setCurrentUnit( UnitGroup.UNITS_DISTANCE.getSIUnit() );
|
||||
// set radial distance
|
||||
JLabel radiusLabel = new JLabel(trans.get("RocketCompCfg.outside.radius"));
|
||||
motherPanel.add( radiusLabel , "align left");
|
||||
parallelEnabledModel.addEnableComponent( radiusLabel, true);
|
||||
DoubleModel radiusModel = new DoubleModel( stage, "RadialPosition", UnitGroup.UNITS_LENGTH, 0);
|
||||
//radiusModel.setCurrentUnit( UnitGroup.UNITS_LENGTH.getUnit("cm"));
|
||||
JSpinner radiusSpinner = new JSpinner( radiusModel.getSpinnerModel());
|
||||
radiusSpinner.setEditor(new SpinnerEditor(radiusSpinner ));
|
||||
enabledPanel.add(radiusSpinner , "growx, wrap, align right");
|
||||
|
||||
// set angle around the primary stage
|
||||
enabledPanel.add(new JLabel(trans.get("RocketCompCfg.outside.angle")), "align left");
|
||||
DoubleModel angleModel = new DoubleModel( stage, "AngularPosition", 0.0, Math.PI*2);
|
||||
motherPanel.add(radiusSpinner , "growx 1, align right");
|
||||
parallelEnabledModel.addEnableComponent( radiusSpinner, true);
|
||||
UnitSelector radiusUnitSelector = new UnitSelector(radiusModel);
|
||||
motherPanel.add(radiusUnitSelector, "growx 1, wrap");
|
||||
parallelEnabledModel.addEnableComponent( radiusUnitSelector , true);
|
||||
|
||||
// set location angle around the primary stage
|
||||
JLabel angleLabel = new JLabel(trans.get("RocketCompCfg.outside.angle"));
|
||||
motherPanel.add( angleLabel, "align left");
|
||||
parallelEnabledModel.addEnableComponent( angleLabel, true);
|
||||
DoubleModel angleModel = new DoubleModel( stage, "AngularPosition", 1.0, UnitGroup.UNITS_ANGLE, 0.0, Math.PI*2);
|
||||
angleModel.setCurrentUnit( UnitGroup.UNITS_ANGLE.getUnit("rad"));
|
||||
JSpinner angleSpinner = new JSpinner(angleModel.getSpinnerModel());
|
||||
angleSpinner.setEditor(new SpinnerEditor(angleSpinner));
|
||||
enabledPanel.add(angleSpinner, "growx, wrap");
|
||||
motherPanel.add(angleSpinner, "growx 1");
|
||||
parallelEnabledModel.addEnableComponent( angleSpinner, true);
|
||||
UnitSelector angleUnitSelector = new UnitSelector(angleModel);
|
||||
motherPanel.add( angleUnitSelector, "growx 1, wrap");
|
||||
parallelEnabledModel.addEnableComponent( angleUnitSelector , true);
|
||||
|
||||
enabledPanel.add(new JLabel(trans.get("RocketCompCfg.outside.rotation")), "align left");
|
||||
DoubleModel rotationModel = new DoubleModel( stage, "Rotation", 0.0, Math.PI*2);
|
||||
// set rotation angle of the stage. Does not affect the location
|
||||
JLabel rotationLabel = new JLabel(trans.get("RocketCompCfg.outside.rotation"));
|
||||
motherPanel.add( rotationLabel, "align left");
|
||||
parallelEnabledModel.addEnableComponent( rotationLabel, true);
|
||||
DoubleModel rotationModel = new DoubleModel( stage, "Rotation", 1.0, UnitGroup.UNITS_ANGLE, 0.0, Math.PI*2);
|
||||
rotationModel.setCurrentUnit( UnitGroup.UNITS_ANGLE.getUnit("rad") );
|
||||
JSpinner rotationSpinner = new JSpinner(rotationModel.getSpinnerModel());
|
||||
rotationSpinner.setEditor(new SpinnerEditor(rotationSpinner));
|
||||
enabledPanel.add(rotationSpinner, "growx, wrap");
|
||||
|
||||
|
||||
parallelEnabled.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
setDeepEnabled( parallelEnabledPanel, parallelEnabledModel.getValue());
|
||||
}
|
||||
});
|
||||
setDeepEnabled( parallelEnabledPanel, parallelEnabledModel.getValue());
|
||||
motherPanel.add(rotationSpinner, "growx 1");
|
||||
parallelEnabledModel.addEnableComponent( rotationSpinner, true);
|
||||
UnitSelector rotationUnitSelector = new UnitSelector( rotationModel);
|
||||
motherPanel.add( rotationUnitSelector, "growx 1, wrap");
|
||||
parallelEnabledModel.addEnableComponent( rotationUnitSelector , true);
|
||||
|
||||
motherPanel.add( enabledPanel , "growx, wrap");
|
||||
|
||||
// setPositions relative to parent component
|
||||
JLabel positionLabel = new JLabel(trans.get("LaunchLugCfg.lbl.Posrelativeto"));
|
||||
motherPanel.add( positionLabel);
|
||||
parallelEnabledModel.addEnableComponent( positionLabel);
|
||||
|
||||
// EnumModel(ChangeSource source, String valueName, Enum<T>[] values) {
|
||||
ComboBoxModel<RocketComponent.Position> posRelModel = new EnumModel<RocketComponent.Position>(component, "RelativePosition",
|
||||
new RocketComponent.Position[] {
|
||||
RocketComponent.Position.TOP,
|
||||
RocketComponent.Position.MIDDLE,
|
||||
RocketComponent.Position.BOTTOM,
|
||||
RocketComponent.Position.ABSOLUTE
|
||||
});
|
||||
JComboBox<?> combo = new JComboBox<RocketComponent.Position>( posRelModel );
|
||||
motherPanel.add(combo, "spanx, growx, wrap");
|
||||
parallelEnabledModel.addEnableComponent( positionLabel);
|
||||
|
||||
// plus
|
||||
JLabel positionPlusLabel = new JLabel(trans.get("LaunchLugCfg.lbl.plus"));
|
||||
motherPanel.add( positionPlusLabel );
|
||||
parallelEnabledModel.addEnableComponent( positionPlusLabel );
|
||||
|
||||
DoubleModel axialPositionModel = new DoubleModel(component, "AxialPosition", UnitGroup.UNITS_LENGTH);
|
||||
JSpinner axPosSpin= new JSpinner( axialPositionModel.getSpinnerModel());
|
||||
axPosSpin.setEditor(new SpinnerEditor(axPosSpin));
|
||||
motherPanel.add(axPosSpin, "growx");
|
||||
parallelEnabledModel.addEnableComponent( positionPlusLabel );
|
||||
|
||||
return motherPanel;
|
||||
}
|
||||
|
||||
|
@ -173,9 +173,6 @@ public class RocketFigure extends AbstractScaleFigure {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates the figure shapes and figure size.
|
||||
*/
|
||||
@ -195,6 +192,7 @@ public class RocketFigure extends AbstractScaleFigure {
|
||||
}
|
||||
}
|
||||
|
||||
System.err.println(" updating the RocketFigure.");
|
||||
repaint();
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user