added save-to-ork code, removed stage rotation parameter.
This commit is contained in:
parent
8b4c1c386b
commit
d5de1cbac4
@ -1,6 +1,7 @@
|
||||
package net.sf.openrocket.file.openrocket.savers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -28,6 +29,10 @@ public class StageSaver extends ComponentAssemblySaver {
|
||||
super.addParams(c, elements);
|
||||
Stage stage = (Stage) c;
|
||||
|
||||
if (stage.getOutside()) {
|
||||
elements.addAll(this.addStageReplicationParams(stage));
|
||||
}
|
||||
|
||||
if (stage.getStageNumber() > 0) {
|
||||
// NOTE: Default config must be BEFORE overridden config for proper backward compatibility later on
|
||||
elements.addAll(separationConfig(stage.getStageSeparationConfiguration().getDefault(), false));
|
||||
@ -49,11 +54,43 @@ public class StageSaver extends ComponentAssemblySaver {
|
||||
elements.add("<separationconfiguration configid=\"" + id + "\">");
|
||||
elements.addAll(separationConfig(config, true));
|
||||
elements.add("</separationconfiguration>");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<? extends String> addStageReplicationParams(final Stage currentStage) {
|
||||
List<String> elementsToReturn = new ArrayList<String>();
|
||||
|
||||
if (null != currentStage) {
|
||||
|
||||
boolean outsideFlag = currentStage.getOutside();
|
||||
elementsToReturn.add("<outside=\"" + outsideFlag + "\">");
|
||||
int instanceCount = currentStage.getInstanceCount();
|
||||
elementsToReturn.add("<instanceCount=\"" + instanceCount + "\">");
|
||||
double radialOffset = currentStage.getRadialPosition();
|
||||
elementsToReturn.add("<radialOffset=\"" + radialOffset + "\">");
|
||||
double angularOffset = currentStage.getAngularPosition();
|
||||
elementsToReturn.add("<angleOffset=\"" + angularOffset + "\">");
|
||||
|
||||
// Save position unless "AFTER"
|
||||
if (currentStage.getRelativePosition() != RocketComponent.Position.AFTER) {
|
||||
// The type names are currently equivalent to the enum names except for case.
|
||||
String type = currentStage.getRelativePositionMethod().name().toLowerCase(Locale.ENGLISH);
|
||||
double axialOffset = currentStage.getAxialPosition();
|
||||
elementsToReturn.add("<position type=\"" + type + "\">" + axialOffset + "</position>");
|
||||
int relativeTo = currentStage.getRelativeToStage();
|
||||
elementsToReturn.add("<relativeTo=\"" + relativeTo + "\">");
|
||||
}
|
||||
|
||||
// do not save
|
||||
double angularSeparation = Double.NaN; // doesn't need to be saved b/c it's derived from instanceCount
|
||||
}
|
||||
|
||||
return elementsToReturn;
|
||||
}
|
||||
|
||||
private List<String> separationConfig(StageSeparationConfiguration config, boolean indent) {
|
||||
List<String> elements = new ArrayList<String>(2);
|
||||
elements.add((indent ? " " : "") + "<separationevent>"
|
||||
|
@ -61,19 +61,4 @@ public interface OutsideComponent {
|
||||
*/
|
||||
public void setRadialPosition(final double radius);
|
||||
|
||||
/**
|
||||
* If component is not symmetric, this is the axial rotation angle (around it's own center). Defaults to 0.
|
||||
*
|
||||
* @return Rotation angle in radians.
|
||||
*/
|
||||
public double getRotation();
|
||||
|
||||
/**
|
||||
* If component is not symmetric, this is the axial rotation angle (around it's own center). Defaults to 0.
|
||||
*
|
||||
* @param rotation Rotation angle in radians.
|
||||
*/
|
||||
public void setRotation(final double rotation);
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
private boolean outside = false;
|
||||
private double angularPosition_rad = 0;
|
||||
private double radialPosition_m = 0;
|
||||
private double rotation_rad = 0;
|
||||
private int stageRelativeTo = 0;
|
||||
|
||||
private int count = 1;
|
||||
private double angularSeparation = Math.PI;
|
||||
@ -146,37 +146,33 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon
|
||||
if (this.outside) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRotation() {
|
||||
if (this.outside) {
|
||||
return this.rotation_rad;
|
||||
} else {
|
||||
return 0.;
|
||||
/**
|
||||
* Stages may be positioned relative to other stages. In that case, this will set the stage number
|
||||
* against which this stage is positioned.
|
||||
*
|
||||
* @return the stage number which this stage is positioned relative to
|
||||
*/
|
||||
public int getRelativeToStage() {
|
||||
return this.stageRelativeTo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(final double rotation) {
|
||||
this.rotation_rad = rotation;
|
||||
if (this.outside) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
/*
|
||||
*
|
||||
* @param _relTo the stage number which this stage is positioned relative to
|
||||
*/
|
||||
public void setRelativeToStage(final int _relTo) {
|
||||
mutex.verify();
|
||||
this.stageRelativeTo = _relTo;
|
||||
}
|
||||
|
||||
public RocketComponent.Position getRelativePositionMethod() {
|
||||
return this.relativePosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativePosition(final Position position) {
|
||||
public void setRelativePositionMethod(final Position position) {
|
||||
super.setRelativePosition(position);
|
||||
if (this.outside) {
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
public double getAxialPosition() {
|
||||
|
@ -95,21 +95,6 @@ public class StageConfig extends RocketComponentConfig {
|
||||
motherPanel.add( angleUnitSelector, "growx 1, wrap");
|
||||
parallelEnabledModel.addEnableComponent( angleUnitSelector , true);
|
||||
|
||||
// Not convinced this is a useful option, or that the user will need to modify this.
|
||||
// // 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));
|
||||
// motherPanel.add(rotationSpinner, "growx 1");
|
||||
// parallelEnabledModel.addEnableComponent( rotationSpinner, true);
|
||||
// UnitSelector rotationUnitSelector = new UnitSelector( rotationModel);
|
||||
// motherPanel.add( rotationUnitSelector, "growx 1, wrap");
|
||||
// parallelEnabledModel.addEnableComponent( rotationUnitSelector , true);
|
||||
|
||||
// set multiplicity
|
||||
JLabel countLabel = new JLabel(trans.get("RocketCompCfg.outside.count"));
|
||||
motherPanel.add( countLabel, "align left");
|
||||
@ -127,7 +112,7 @@ public class StageConfig extends RocketComponentConfig {
|
||||
parallelEnabledModel.addEnableComponent( positionLabel, true);
|
||||
|
||||
// EnumModel(ChangeSource source, String valueName, Enum<T>[] values) {
|
||||
ComboBoxModel<RocketComponent.Position> posRelModel = new EnumModel<RocketComponent.Position>(component, "RelativePosition",
|
||||
ComboBoxModel<RocketComponent.Position> posRelModel = new EnumModel<RocketComponent.Position>(component, "RelativePositionMethod",
|
||||
new RocketComponent.Position[] {
|
||||
RocketComponent.Position.TOP,
|
||||
RocketComponent.Position.MIDDLE,
|
||||
@ -143,6 +128,7 @@ public class StageConfig extends RocketComponentConfig {
|
||||
motherPanel.add( relativeStageLabel);
|
||||
parallelEnabledModel.addEnableComponent( relativeStageLabel, true);
|
||||
// may need to implement a new ComponentComboModel or something
|
||||
IntegerModel relToStageModel = new IntegerModel( stage, "RelativeToStage",0);
|
||||
List<RocketComponent> stageList = stage.getParent().getChildren();
|
||||
RocketComponent[] forCombo = new RocketComponent[stageList.size()];
|
||||
forCombo = stageList.toArray(forCombo);
|
||||
@ -152,7 +138,6 @@ public class StageConfig extends RocketComponentConfig {
|
||||
motherPanel.add( relToCombo , "growx, wrap");
|
||||
parallelEnabledModel.addEnableComponent( relToCombo, true );
|
||||
|
||||
|
||||
// plus
|
||||
JLabel positionPlusLabel = new JLabel(trans.get("LaunchLugCfg.lbl.plus"));
|
||||
motherPanel.add( positionPlusLabel );
|
||||
|
Loading…
x
Reference in New Issue
Block a user