refactored Stages (Axial & Booster) now load correctly.

This commit is contained in:
Daniel_M_Williams 2015-08-25 22:38:13 -04:00
parent c8a3d675d8
commit 0c01123551
17 changed files with 172 additions and 394 deletions

View File

@ -894,6 +894,10 @@ StageConfig.tab.Separation.ttip = Stage separation options
StageConfig.separation.lbl.title = Select when this stage separates:
StageConfig.separation.lbl.plus = plus
StageConfig.separation.lbl.seconds = seconds
StageConfig.parallel.radius = Radial Distance
StageConfig.parallel.angle = Angle
StageConfig.parallel.count = Number of Boosters
StageConfig.parallel.offset = Offset Value
!EllipticalFinSetConfig
EllipticalFinSetCfg.Nbroffins = Number of fins:
@ -1387,13 +1391,6 @@ Stage.SeparationEvent.EJECTION = Current stage ejection charge
Stage.SeparationEvent.LAUNCH = Launch
Stage.SeparationEvent.NEVER = Never
Stage.parallel.radius = Radial Distance
Stage.parallel.angle = Angle
Stage.parallel.count = Number of Boosters
Stage.parallel.rotation = Rotation
Stage.parallel.componentname = Relative to Stage
Stage.parallel.offset = Offset Value
BoosterSet.BoosterSet = Booster Set
PodSet.PodSet = Pod Set
@ -1454,6 +1451,9 @@ MotorMount.IgnitionEvent.short.NEVER = Never
!ComponentIcons
ComponentIcons.Stage = Axial Stage
ComponentIcons.Boosters = Booster Stage
ComponentIcons.Pods = Pod Stage
ComponentIcons.Nosecone = Nose cone
ComponentIcons.Bodytube = Body tube
ComponentIcons.Transition = Transition
@ -1471,8 +1471,6 @@ ComponentIcons.Parachute = Parachute
ComponentIcons.Streamer = Streamer
ComponentIcons.Shockcord = Shock cord
ComponentIcons.Masscomponent = Mass component
ComponentIcons.Boosters = Booster Stage
ComponentIcons.Pods = Pod Stage
ComponentIcons.disabled = (disabled)
ComponentIcons.Altimeter = Altimeter
ComponentIcons.Flightcomputer = Flight computer

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

View File

@ -6,8 +6,10 @@ import java.util.Locale;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.rocketcomponent.AxialStage;
import net.sf.openrocket.rocketcomponent.BodyComponent;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.BoosterSet;
import net.sf.openrocket.rocketcomponent.Bulkhead;
import net.sf.openrocket.rocketcomponent.CenteringRing;
import net.sf.openrocket.rocketcomponent.DeploymentConfiguration;
@ -24,6 +26,7 @@ import net.sf.openrocket.rocketcomponent.MassComponent;
import net.sf.openrocket.rocketcomponent.MassObject;
import net.sf.openrocket.rocketcomponent.NoseCone;
import net.sf.openrocket.rocketcomponent.Parachute;
import net.sf.openrocket.rocketcomponent.PodSet;
import net.sf.openrocket.rocketcomponent.RadiusRingComponent;
import net.sf.openrocket.rocketcomponent.RecoveryDevice;
import net.sf.openrocket.rocketcomponent.ReferenceType;
@ -31,7 +34,6 @@ import net.sf.openrocket.rocketcomponent.RingComponent;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.ShockCord;
import net.sf.openrocket.rocketcomponent.AxialStage;
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration;
import net.sf.openrocket.rocketcomponent.Streamer;
import net.sf.openrocket.rocketcomponent.StructuralComponent;
@ -49,7 +51,7 @@ import net.sf.openrocket.util.Reflection;
class DocumentConfig {
/* Remember to update OpenRocketSaver as well! */
public static final String[] SUPPORTED_VERSIONS = { "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7" };
public static final String[] SUPPORTED_VERSIONS = { "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8" };
/**
* Divisor used in converting an integer version to the point-represented version.
@ -87,6 +89,8 @@ class DocumentConfig {
// Other
constructors.put("stage", AxialStage.class.getConstructor(new Class<?>[0]));
constructors.put("boosterset", BoosterSet.class.getConstructor(new Class<?>[0]));
constructors.put("podset", PodSet.class.getConstructor(new Class<?>[0]));
} catch (NoSuchMethodException e) {
throw new BugException(
@ -406,11 +410,21 @@ class DocumentConfig {
setters.put("Stage:separationdelay", new DoubleSetter(
Reflection.findMethod(AxialStage.class, "getStageSeparationConfiguration"),
Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationDelay", double.class)));
setters.put("Stage:outside", new BooleanSetter(Reflection.findMethod(AxialStage.class, "setOutside", boolean.class)));
setters.put("Stage:relativeto", new IntSetter(Reflection.findMethod(AxialStage.class, "setRelativeToStage", int.class)));
setters.put("Stage:instancecount", new IntSetter(Reflection.findMethod(AxialStage.class, "setInstanceCount", int.class)));
setters.put("Stage:radialoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setRadialOffset", double.class)));
setters.put("Stage:angleoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setAngularOffset", double.class)));
// // Stage
// setters.put("Stage:separationevent", new EnumSetter<StageSeparationConfiguration.SeparationEvent>(
// Reflection.findMethod(AxialStage.class, "getStageSeparationConfiguration"),
// Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationEvent", StageSeparationConfiguration.SeparationEvent.class),
// StageSeparationConfiguration.SeparationEvent.class));
// setters.put("Stage:separationdelay", new DoubleSetter(
// Reflection.findMethod(AxialStage.class, "getStageSeparationConfiguration"),
// Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationDelay", double.class)));
//
// setters.put("Stage:outside", new BooleanSetter(Reflection.findMethod(AxialStage.class, "setOutside", boolean.class)));
// setters.put("Stage:relativeto", new IntSetter(Reflection.findMethod(AxialStage.class, "setRelativeToStage", int.class)));
// setters.put("Stage:instancecount", new IntSetter(Reflection.findMethod(AxialStage.class, "setInstanceCount", int.class)));
// setters.put("Stage:radialoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setRadialOffset", double.class)));
// setters.put("Stage:angleoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setAngularOffset", double.class)));
}

View File

@ -5,9 +5,10 @@ import java.util.Collection;
import java.util.List;
import java.util.Locale;
import net.sf.openrocket.rocketcomponent.AxialStage;
import net.sf.openrocket.rocketcomponent.BoosterSet;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.AxialStage;
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration;
public class StageSaver extends ComponentAssemblySaver {
@ -29,8 +30,9 @@ public class StageSaver extends ComponentAssemblySaver {
super.addParams(c, elements);
AxialStage stage = (AxialStage) c;
if (stage.getOutside()) {
elements.addAll(this.addStageReplicationParams(stage));
if (stage instanceof BoosterSet) {
BoosterSet booster = (BoosterSet) stage;
elements.addAll(this.addStageReplicationParams(booster));
}
if (stage.getStageNumber() > 0) {
@ -60,7 +62,7 @@ public class StageSaver extends ComponentAssemblySaver {
}
}
private Collection<? extends String> addStageReplicationParams(final AxialStage currentStage) {
private Collection<? extends String> addStageReplicationParams(final BoosterSet currentStage) {
List<String> elementsToReturn = new ArrayList<String>();
final String instCt_tag = "instancecount";
final String radoffs_tag = "radialoffset";
@ -74,7 +76,6 @@ public class StageSaver extends ComponentAssemblySaver {
elementsToReturn.add("<" + radoffs_tag + ">" + radialOffset + "</" + radoffs_tag + ">");
double angularOffset = currentStage.getAngularOffset();
elementsToReturn.add("<" + startangle_tag + ">" + angularOffset + "</" + startangle_tag + ">");
}
return elementsToReturn;

View File

@ -6,20 +6,16 @@ import java.util.Iterator;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.Coordinate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AxialStage extends ComponentAssembly implements FlightConfigurableComponent {
private static final Translator trans = Application.getTranslator();
private static final Logger log = LoggerFactory.getLogger(AxialStage.class);
//private static final Logger log = LoggerFactory.getLogger(AxialStage.class);
private FlightConfigurationImpl<StageSeparationConfiguration> separationConfigurations;
private int stageNumber;
protected int stageNumber;
private static int stageCount;
public AxialStage() {
@ -57,7 +53,6 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
double x_max = x_min + this.length;
double r_max = 0;
addBound(bounds, x_min, r_max);
addBound(bounds, x_max, r_max);
@ -74,11 +69,16 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
*/
@Override
public boolean isCompatible(Class<? extends RocketComponent> type) {
if (type.equals(AxialStage.class)) {
if (BoosterSet.class.isAssignableFrom(type)) {
return true;
} else if (PodSet.class.isAssignableFrom(type)) {
return true;
// DEBUG ONLY. Remove this clause before production.
} else if (AxialStage.class.isAssignableFrom(type)) {
return true;
} else {
return BodyComponent.class.isAssignableFrom(type);
}
return BodyComponent.class.isAssignableFrom(type);
}
@Override
@ -94,46 +94,10 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
return copy;
}
@Override
public Coordinate[] getLocation() {
if (null == this.parent) {
throw new BugException(" Attempted to get absolute position Vector of a Stage without a parent. ");
}
if (this.isCenterline()) {
return super.getLocation();
} else {
Coordinate[] parentInstances = this.parent.getLocation();
if (1 != parentInstances.length) {
throw new BugException(" OpenRocket does not (yet) support external stages attached to external stages. " +
"(assumed reason for getting multiple parent locations into an external stage.)");
}
Coordinate[] toReturn = this.shiftCoordinates(parentInstances);
return toReturn;
}
}
public void setRelativePositionMethod(final Position _newPosition) {
if (null == this.parent) {
throw new NullPointerException(" a Stage requires a parent before any positioning! ");
}
if (this.isCenterline()) {
// Centerline stages must be set via AFTER-- regardless of what was requested:
super.setRelativePosition(Position.AFTER);
} else if (this.parent instanceof AxialStage) {
if (Position.AFTER == _newPosition) {
log.warn("Stages cannot be relative to other stages via AFTER! Ignoring.");
super.setRelativePosition(Position.TOP);
} else {
super.setRelativePosition(_newPosition);
}
}
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
// Axial Stages are restricted to .AFTER, and cannot be changed.
return;
}
@Override
@ -152,8 +116,6 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
public int getRelativeToStage() {
if (null == this.parent) {
return -1;
} else if (this.parent instanceof AxialStage) {
return this.parent.parent.getChildPosition(this.parent);
} else if (this.isCenterline()) {
if (0 < this.stageNumber) {
return --this.stageNumber;
@ -174,14 +136,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
@Override
public double getAxialOffset() {
double returnValue = Double.NaN;
if ((this.isCenterline() && (Position.AFTER != this.relativePosition))) {
// remember the implicit (this instanceof Stage)
throw new BugException("found a Stage on centerline, but not positioned as AFTER. Please fix this! " + this.getName() + " is " + this.getRelativePosition().name());
} else {
returnValue = super.asPositionValue(this.relativePosition);
}
double returnValue = super.asPositionValue(this.relativePosition);
if (0.000001 > Math.abs(returnValue)) {
returnValue = 0.0;
@ -248,7 +203,6 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
}
this.updateBounds();
if (this.parent instanceof Rocket) {
// stages which are directly children of the rocket are inline, and positioned
int childNumber = this.parent.getChildPosition(this);
if (0 == childNumber) {
@ -257,11 +211,6 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
RocketComponent prevStage = this.parent.getChild(childNumber - 1);
this.setAfter(prevStage);
}
} else if (this.parent instanceof AxialStage) {
this.updateBounds();
// because if parent is instanceof Stage, that means 'this' is positioned externally
super.update();
}
// updates the internal 'previousComponent' field.
this.updateChildSequence();

View File

@ -19,39 +19,23 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
private FlightConfigurationImpl<StageSeparationConfiguration> separationConfigurations;
private boolean centerline = true;
private double angularPosition_rad = 0;
private double radialPosition_m = 0;
private int count = 2;
private double angularSeparation = Math.PI;
private int stageNumber;
private static int stageCount;
public BoosterSet() {
this.relativePosition = Position.BOTTOM;
}
@Override
public boolean allowsChildren() {
return true;
}
@Override
public String getComponentName() {
//// Stage
return trans.get("BoosterSet.BoosterSet");
}
public static int getStageCount() {
return BoosterSet.stageCount;
}
public FlightConfiguration<StageSeparationConfiguration> getStageSeparationConfiguration() {
return separationConfigurations;
}
// not strictly accurate, but this should provide an acceptable estimate for total vehicle size
@Override
public Collection<Coordinate> getComponentBounds() {
@ -90,12 +74,8 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
*/
@Override
public boolean isCompatible(Class<? extends RocketComponent> type) {
if (type.equals(BoosterSet.class)) {
return true;
} else {
return BodyComponent.class.isAssignableFrom(type);
}
}
@Override
public void cloneFlightConfiguration(String oldConfigId, String newConfigId) {
@ -104,9 +84,7 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
@Override
protected RocketComponent copyWithOriginalID() {
BoosterSet copy = (BoosterSet) super.copyWithOriginalID();
copy.separationConfigurations = new FlightConfigurationImpl<StageSeparationConfiguration>(separationConfigurations,
copy, ComponentChangeEvent.EVENT_CHANGE);
BoosterSet copy = (BoosterSet) (super.copyWithOriginalID());
return copy;
}
@ -116,9 +94,6 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
throw new BugException(" Attempted to get absolute position Vector of a Stage without a parent. ");
}
if (this.isCenterline()) {
return super.getLocation();
} else {
Coordinate[] parentInstances = this.parent.getLocation();
if (1 != parentInstances.length) {
throw new BugException(" OpenRocket does not (yet) support external stages attached to external stages. " +
@ -130,53 +105,30 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return toReturn;
}
}
@Override
public boolean getOutside() {
return !isCenterline();
}
/**
* Detects if this Stage is attached directly to the Rocket (and is thus centerline)
* Or if this stage is a parallel (external) stage.
* Boosters are, by definition, not centerline.
*
* @return whether this Stage is along the center line of the Rocket.
* @return whether this Stage is along the center line of the Rocket. Always false.
*/
@Override
public boolean isCenterline() {
if (this.parent instanceof Rocket) {
this.centerline = true;
} else {
this.centerline = false;
}
return this.centerline;
}
/**
* Stub.
* The actual value is set via 'isCenterline()'
*/
@Override
public void setOutside(final boolean _outside) {
return false;
}
@Override
public int getInstanceCount() {
if (this.isCenterline()) {
return 1;
} else {
return this.count;
}
}
@Override
public void setInstanceCount(final int _count) {
mutex.verify();
if (this.centerline) {
return;
}
if (_count < 1) {
if (_count < 2) {
// there must be at least one instance....
return;
}
@ -188,56 +140,35 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
@Override
public double getAngularOffset() {
if (this.centerline) {
return 0.;
} else {
return this.angularPosition_rad;
}
}
@Override
public void setAngularOffset(final double angle_rad) {
if (this.centerline) {
return;
}
this.angularPosition_rad = angle_rad;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override
public double getRadialOffset() {
if (this.centerline) {
return 0.;
} else {
return this.radialPosition_m;
}
}
@Override
public void setRadialOffset(final double radius) {
// log.error(" set radial position for: " + this.getName() + " to: " + this.radialPosition_m + " ... in meters?");
if (false == this.centerline) {
this.radialPosition_m = radius;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
}
@Override
public void setRelativePositionMethod(final Position _newPosition) {
if (null == this.parent) {
throw new NullPointerException(" a Stage requires a parent before any positioning! ");
}
if (this.isCenterline()) {
// Centerline stages must be set via AFTER-- regardless of what was requested:
super.setRelativePosition(Position.AFTER);
} else if (this.parent instanceof BoosterSet) {
if (Position.AFTER == _newPosition) {
log.warn("Stages cannot be relative to other stages via AFTER! Ignoring.");
super.setRelativePosition(Position.TOP);
} else {
super.setRelativePosition(_newPosition);
}
}
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
}
@ -248,19 +179,13 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return this.getAxialOffset();
}
/*
* @deprecated remove when the file is fixed....
*/
public void setRelativeToStage(final int _relToStage) {
// no-op
}
/**
* 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
*/
@Override
public int getRelativeToStage() {
if (null == this.parent) {
return -1;
@ -275,10 +200,6 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return -1;
}
public static void resetStageCount() {
BoosterSet.stageCount = 0;
}
@Override
public int getStageNumber() {
return this.stageNumber;
@ -383,10 +304,8 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
Iterator<RocketComponent> childIterator = this.getChildren().iterator();
while (childIterator.hasNext()) {
RocketComponent curChild = childIterator.next();
if (curChild.isCenterline()) {
this.length += curChild.getLength();
}
}
}
@ -396,21 +315,9 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return;
}
this.updateBounds();
if (this.parent instanceof Rocket) {
// stages which are directly children of the rocket are inline, and positioned
int childNumber = this.parent.getChildPosition(this);
if (0 == childNumber) {
this.setAfter(this.parent);
} else {
RocketComponent prevStage = this.parent.getChild(childNumber - 1);
this.setAfter(prevStage);
}
} else if (this.parent instanceof BoosterSet) {
this.updateBounds();
// because if parent is instanceof Stage, that means 'this' is positioned externally
super.update();
}
// updates the internal 'previousComponent' field.
this.updateChildSequence();
@ -418,21 +325,4 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return;
}
protected void updateChildSequence() {
Iterator<RocketComponent> childIterator = this.getChildren().iterator();
RocketComponent prevComp = null;
while (childIterator.hasNext()) {
RocketComponent curChild = childIterator.next();
if (curChild.isCenterline()) {
//curChild.previousComponent = prevComp;
curChild.setAfter(prevComp);
prevComp = curChild;
// } else {
// curChild.previousComponent = null;
}
}
}
}

View File

@ -11,13 +11,6 @@ public interface OutsideComponent {
*/
public boolean getOutside();
/**
* Change whether this component is located inside or outside of the rest of the rocket. (Specifically, inside or outside its parent.)
*
* @param inline False indicates that this component axially aligned with its parent. True indicates an off-center component.
*/
public void setOutside(final boolean inline);
/**
* Get the position of this component in polar coordinates
*

View File

@ -12,13 +12,11 @@ import net.sf.openrocket.util.Coordinate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PodSet extends ComponentAssembly implements FlightConfigurableComponent, OutsideComponent {
public class PodSet extends ComponentAssembly implements OutsideComponent {
private static final Translator trans = Application.getTranslator();
private static final Logger log = LoggerFactory.getLogger(PodSet.class);
private FlightConfigurationImpl<StageSeparationConfiguration> separationConfigurations;
private boolean centerline = true;
private double angularPosition_rad = 0;
private double radialPosition_m = 0;
@ -26,30 +24,11 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
private int count = 2;
private double angularSeparation = Math.PI;
private int stageNumber;
private static int stageCount;
public PodSet() {
this.separationConfigurations = new FlightConfigurationImpl<StageSeparationConfiguration>(this, ComponentChangeEvent.EVENT_CHANGE, new StageSeparationConfiguration());
this.relativePosition = Position.AFTER;
stageNumber = PodSet.stageCount;
PodSet.stageCount++;
this.relativePosition = Position.BOTTOM;
}
public class Boosters extends PodSet {
public Boosters() {
super();
}
};
public class Pods extends PodSet {
public Pods() {
super();
}
};
@Override
public boolean allowsChildren() {
return true;
@ -61,9 +40,6 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
return trans.get("PodSet.PodSet");
}
public FlightConfiguration<StageSeparationConfiguration> getStageSeparationConfiguration() {
return separationConfigurations;
}
// not strictly accurate, but this should provide an acceptable estimate for total vehicle size
@Override
@ -103,25 +79,8 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
*/
@Override
public boolean isCompatible(Class<? extends RocketComponent> type) {
if (type.equals(PodSet.class)) {
return true;
} else {
return BodyComponent.class.isAssignableFrom(type);
}
}
@Override
public void cloneFlightConfiguration(String oldConfigId, String newConfigId) {
separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId);
}
@Override
protected RocketComponent copyWithOriginalID() {
PodSet copy = (PodSet) super.copyWithOriginalID();
copy.separationConfigurations = new FlightConfigurationImpl<StageSeparationConfiguration>(separationConfigurations,
copy, ComponentChangeEvent.EVENT_CHANGE);
return copy;
}
@Override
public Coordinate[] getLocation() {
@ -158,30 +117,13 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
*/
@Override
public boolean isCenterline() {
if (this.parent instanceof Rocket) {
this.centerline = true;
} else {
this.centerline = false;
}
return this.centerline;
}
/**
* Stub.
* The actual value is set via 'isCenterline()'
*/
@Override
public void setOutside(final boolean _outside) {
return false;
}
@Override
public int getInstanceCount() {
if (this.isCenterline()) {
return 1;
} else {
return this.count;
}
}
@Override
public void setInstanceCount(final int _count) {
@ -189,7 +131,7 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
if (this.centerline) {
return;
}
if (_count < 1) {
if (_count < 2) {
// there must be at least one instance....
return;
}
@ -279,24 +221,11 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
return -1;
} else if (this.parent instanceof PodSet) {
return this.parent.parent.getChildPosition(this.parent);
} else if (this.isCenterline()) {
if (0 < this.stageNumber) {
return --this.stageNumber;
}
}
return -1;
}
public static void resetStageCount() {
PodSet.stageCount = 0;
}
@Override
public int getStageNumber() {
return this.stageNumber;
}
@Override
public double getAxialOffset() {
double returnValue = Double.NaN;
@ -326,10 +255,6 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
public Coordinate[] shiftCoordinates(Coordinate[] c) {
checkState();
if (this.isCenterline()) {
return c;
}
if (1 < c.length) {
throw new BugException("implementation of 'shiftCoordinates' assumes the coordinate array has len == 1; this is not true, and may produce unexpected behavior! ");
}
@ -372,9 +297,6 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
buffer.append(String.format("%s %-24s %5.3f", prefix, thisLabel, this.getLength()));
if (this.isCenterline()) {
buffer.append(String.format(" %24s %24s\n", this.getOffset(), this.getLocation()[0]));
} else {
buffer.append(String.format(" %4.1f via: %s \n", this.getAxialOffset(), this.relativePosition.name()));
Coordinate[] relCoords = this.shiftCoordinates(new Coordinate[] { Coordinate.ZERO });
Coordinate[] absCoords = this.getLocation();
@ -385,7 +307,6 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
buffer.append(String.format("%s [instance %2d of %2d] %32s %32s\n", prefix, instanceNumber, count,
instanceRelativePosition, instanceAbsolutePosition));
}
}
}
@ -396,10 +317,8 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
Iterator<RocketComponent> childIterator = this.getChildren().iterator();
while (childIterator.hasNext()) {
RocketComponent curChild = childIterator.next();
if (curChild.isCenterline()) {
this.length += curChild.getLength();
}
}
}
@ -410,20 +329,9 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
}
this.updateBounds();
if (this.parent instanceof Rocket) {
// stages which are directly children of the rocket are inline, and positioned
int childNumber = this.parent.getChildPosition(this);
if (0 == childNumber) {
this.setAfter(this.parent);
} else {
RocketComponent prevStage = this.parent.getChild(childNumber - 1);
this.setAfter(prevStage);
}
} else if (this.parent instanceof PodSet) {
this.updateBounds();
// because if parent is instanceof Stage, that means 'this' is positioned externally
super.update();
}
// updates the internal 'previousComponent' field.
this.updateChildSequence();
@ -436,16 +344,14 @@ public class PodSet extends ComponentAssembly implements FlightConfigurableCompo
RocketComponent prevComp = null;
while (childIterator.hasNext()) {
RocketComponent curChild = childIterator.next();
if (curChild.isCenterline()) {
//curChild.previousComponent = prevComp;
curChild.setAfter(prevComp);
prevComp = curChild;
// } else {
// curChild.previousComponent = null;
}
}
}
}
}

View File

@ -133,7 +133,6 @@ public class Rocket extends RocketComponent {
return AxialStage.getStageCount();
}
/**
* Return the non-negative modification ID of this rocket. The ID is changed
* every time any change occurs in the rocket. This can be used to check
@ -703,11 +702,11 @@ public class Rocket extends RocketComponent {
}
/**
* Allows only <code>Stage</code> components to be added to the type Rocket.
* Allows only <code>AxialStage</code> components to be added to the type Rocket.
*/
@Override
public boolean isCompatible(Class<? extends RocketComponent> type) {
return (AxialStage.class.isAssignableFrom(type));
return (AxialStage.class.equals(type));
}
}

View File

@ -1327,8 +1327,8 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
}
if (!isCompatible(component)) {
throw new IllegalStateException("Component " + component.getComponentName() +
" not currently compatible with component " + getComponentName());
throw new IllegalStateException("Component: " + component.getComponentName() +
" not currently compatible with component: " + getComponentName());
}
children.add(index, component);

View File

@ -10,7 +10,7 @@ import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
import org.junit.Test;
public class StageTest extends BaseTestCase {
public class BoosterSetTest extends BaseTestCase {
// tolerance for compared double test results
protected final double EPSILON = 0.00001;
@ -52,12 +52,11 @@ public class StageTest extends BaseTestCase {
return rocket;
}
public AxialStage createBooster() {
public BoosterSet createBooster() {
double tubeRadius = 0.8;
AxialStage booster = new AxialStage();
BoosterSet booster = new BoosterSet();
booster.setName("Booster Stage");
booster.setOutside(true);
RocketComponent boosterNose = new NoseCone(Transition.Shape.CONICAL, 2.0, tubeRadius);
boosterNose.setName("Booster Nosecone");
booster.addChild(boosterNose);
@ -212,7 +211,7 @@ public class StageTest extends BaseTestCase {
// without making the rocket 'external' and the Stage should be restricted to AFTER positioning.
sustainer.setRelativePositionMethod(Position.ABSOLUTE);
assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.getOutside(), equalTo(false));
assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.isCenterline(), equalTo(true));
assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.getRelativePosition(), equalTo(Position.AFTER));
// vv function under test
@ -233,32 +232,32 @@ public class StageTest extends BaseTestCase {
// setup
RocketComponent rocket = createTestRocket();
AxialStage core = (AxialStage) rocket.getChild(1);
AxialStage boosterSet = createBooster();
core.addChild(boosterSet);
BoosterSet set0 = createBooster();
core.addChild(set0);
double targetOffset = 0;
boosterSet.setAxialOffset(Position.BOTTOM, targetOffset);
set0.setAxialOffset(Position.BOTTOM, targetOffset);
// vv function under test
boosterSet.setInstanceCount(2);
boosterSet.setRadialOffset(4.0);
boosterSet.setAngularOffset(Math.PI / 2);
set0.setInstanceCount(2);
set0.setRadialOffset(4.0);
set0.setAngularOffset(Math.PI / 2);
// ^^ function under test
String treeDump = rocket.toDebugTree();
int expectedInstanceCount = 2;
int instanceCount = boosterSet.getInstanceCount();
int instanceCount = set0.getInstanceCount();
assertThat(" 'setInstancecount(int)' failed: ", instanceCount, equalTo(expectedInstanceCount));
double expectedAbsX = 6.0;
double resultantX = boosterSet.getLocation()[0].x;
double resultantX = set0.getLocation()[0].x;
assertEquals(">>'setAxialOffset()' failed:\n" + treeDump + " 1st Inst absolute position", expectedAbsX, resultantX, EPSILON);
double expectedRadialOffset = 4.0;
double radialOffset = boosterSet.getRadialOffset();
double radialOffset = set0.getRadialOffset();
assertEquals(" 'setRadialOffset(double)' failed: \n" + treeDump + " radial offset: ", expectedRadialOffset, radialOffset, EPSILON);
double expectedAngularOffset = Math.PI / 2;
double angularOffset = boosterSet.getAngularOffset();
double angularOffset = set0.getAngularOffset();
assertEquals(" 'setAngularOffset(double)' failed:\n" + treeDump + " angular offset: ", expectedAngularOffset, angularOffset, EPSILON);
}
@ -269,16 +268,16 @@ public class StageTest extends BaseTestCase {
// setup
RocketComponent rocket = createTestRocket();
AxialStage core = (AxialStage) rocket.getChild(1);
AxialStage boosterSet = createBooster();
core.addChild(boosterSet);
BoosterSet set0 = createBooster();
core.addChild(set0);
double targetOffset = 0;
boosterSet.setAxialOffset(Position.BOTTOM, targetOffset);
set0.setAxialOffset(Position.BOTTOM, targetOffset);
int targetInstanceCount = 3;
double targetRadialOffset = 1.8;
// vv function under test
boosterSet.setInstanceCount(targetInstanceCount);
boosterSet.setRadialOffset(targetRadialOffset);
set0.setInstanceCount(targetInstanceCount);
set0.setRadialOffset(targetRadialOffset);
// ^^ function under test
String treeDump = rocket.toDebugTree();
@ -286,7 +285,7 @@ public class StageTest extends BaseTestCase {
double angle = Math.PI * 2 / targetInstanceCount;
double radius = targetRadialOffset;
Coordinate[] instanceAbsoluteCoords = boosterSet.getLocation();
Coordinate[] instanceAbsoluteCoords = set0.getLocation();
// Coordinate[] instanceRelativeCoords = new Coordinate[] { componentAbsolutePosition };
// instanceRelativeCoords = boosterSet.shiftCoordinates(instanceRelativeCoords);
@ -346,7 +345,6 @@ public class StageTest extends BaseTestCase {
RocketComponent rocket = createTestRocket();
AxialStage sustainer = (AxialStage) rocket.getChild(0);
Coordinate targetPosition = new Coordinate(+4.0, 0., 0.);
Coordinate expectedPosition = targetPosition;
int expectedRelativeIndex = -1;
int resultantRelativeIndex = sustainer.getRelativeToStage();

View File

@ -21,20 +21,21 @@ import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup;
public class StageConfig extends RocketComponentConfig {
public class AxialStageConfig extends RocketComponentConfig {
private static final long serialVersionUID = -944969957186522471L;
private static final Translator trans = Application.getTranslator();
public StageConfig(OpenRocketDocument document, RocketComponent component) {
public AxialStageConfig(OpenRocketDocument document, RocketComponent component) {
super(document, component);
// Stage separation config (for non-first stage)
if (component.getStageNumber() > 0) {
JPanel tab = separationTab((AxialStage) component);
tabbedPane.insertTab(trans.get("tab.Separation"), null, tab,
trans.get("tab.Separation.ttip"), 1);
tabbedPane.insertTab(trans.get("StageConfig.tab.Separation"), null, tab,
trans.get("StageConfig.tab.Separation.ttip"), 1);
}
System.err.println(" building Stage Config Dialogue for: "+component.getName()+" type: "+component.getComponentName());
// only stages which are actually off-centerline will get the dialog here:
if( ! component.isCenterline()){
tabbedPane.insertTab( trans.get("RocketCompCfg.tab.Parallel"), null, parallelTab( (AxialStage) component ), trans.get("RocketCompCfg.tab.ParallelComment"), 2);
@ -45,7 +46,7 @@ public class StageConfig extends RocketComponentConfig {
JPanel motherPanel = new JPanel( new MigLayout("fill"));
// set radial distance
JLabel radiusLabel = new JLabel(trans.get("Stage.parallel.radius"));
JLabel radiusLabel = new JLabel(trans.get("StageConfig.parallel.radius"));
motherPanel.add( radiusLabel , "align left");
DoubleModel radiusModel = new DoubleModel( stage, "RadialOffset", UnitGroup.UNITS_LENGTH, 0);
//radiusModel.setCurrentUnit( UnitGroup.UNITS_LENGTH.getUnit("cm"));
@ -56,7 +57,7 @@ public class StageConfig extends RocketComponentConfig {
motherPanel.add(radiusUnitSelector, "growx 1, wrap");
// set location angle around the primary stage
JLabel angleLabel = new JLabel(trans.get("Stage.parallel.angle"));
JLabel angleLabel = new JLabel(trans.get("StageConfig.parallel.angle"));
motherPanel.add( angleLabel, "align left");
DoubleModel angleModel = new DoubleModel( stage, "AngularOffset", 1.0, UnitGroup.UNITS_ANGLE, 0.0, Math.PI*2);
angleModel.setCurrentUnit( UnitGroup.UNITS_ANGLE.getUnit("rad"));
@ -67,7 +68,7 @@ public class StageConfig extends RocketComponentConfig {
motherPanel.add( angleUnitSelector, "growx 1, wrap");
// set multiplicity
JLabel countLabel = new JLabel(trans.get("Stage.parallel.count"));
JLabel countLabel = new JLabel(trans.get("StageConfig.parallel.count"));
motherPanel.add( countLabel, "align left");
IntegerModel countModel = new IntegerModel( stage, "InstanceCount", 2);
@ -91,7 +92,7 @@ public class StageConfig extends RocketComponentConfig {
motherPanel.add(positionMethodCombo, "spanx 2, growx, wrap");
// relative offset labels
JLabel positionPlusLabel = new JLabel(trans.get("Stage.parallel.offset"));
JLabel positionPlusLabel = new JLabel(trans.get("StageConfig.parallel.offset"));
motherPanel.add( positionPlusLabel );
DoubleModel axialOffsetModel = new DoubleModel(component, "AxialOffset", UnitGroup.UNITS_LENGTH);
axialOffsetModel.setCurrentUnit(UnitGroup.UNITS_LENGTH.getUnit("cm"));
@ -111,14 +112,14 @@ public class StageConfig extends RocketComponentConfig {
JPanel panel = new JPanel(new MigLayout("fill"));
// Select separation event
panel.add(new StyledLabel(trans.get("separation.lbl.title") + " " + CommonStrings.dagger, Style.BOLD), "spanx, wrap rel");
panel.add(new StyledLabel(trans.get("StageConfig.separation.lbl.title") + " " + CommonStrings.dagger, Style.BOLD), "spanx, wrap rel");
StageSeparationConfiguration config = stage.getStageSeparationConfiguration().getDefault();
JComboBox combo = new JComboBox(new EnumModel<StageSeparationConfiguration.SeparationEvent>(config, "SeparationEvent"));
panel.add(combo, "");
// ... and delay
panel.add(new JLabel(trans.get("separation.lbl.plus")), "");
panel.add(new JLabel(trans.get("StageConfig.separation.lbl.plus")), "");
DoubleModel dm = new DoubleModel(config, "SeparationDelay", 0);
JSpinner spin = new JSpinner(dm.getSpinnerModel());
@ -126,7 +127,7 @@ public class StageConfig extends RocketComponentConfig {
panel.add(spin, "width 45");
//// seconds
panel.add(new JLabel(trans.get("separation.lbl.seconds")), "wrap unrel");
panel.add(new JLabel(trans.get("StageConfig.separation.lbl.seconds")), "wrap unrel");
panel.add(new StyledLabel(CommonStrings.override_description, -1), "spanx, wrap para");

View File

@ -10,6 +10,7 @@ import javax.swing.Icon;
import javax.swing.ImageIcon;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.AxialStage;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.BoosterSet;
import net.sf.openrocket.rocketcomponent.Bulkhead;
@ -81,6 +82,9 @@ public class ComponentIcons {
ShockCord.class);
load("mass", trans.get("ComponentIcons.Masscomponent"),
MassComponent.class);
// // Component Assemblies
load("stage", trans.get("ComponentIcons.Stage"),
AxialStage.class);
load("boosters", trans.get("ComponentIcons.Boosters"),
BoosterSet.class);
load("pods", trans.get("ComponentIcons.Pods"),

View File

@ -277,6 +277,11 @@ public class RocketActions {
/////// Action classes
private abstract class RocketAction extends AbstractAction implements ClipboardListener {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public abstract void clipboardChanged();
}
@ -286,6 +291,8 @@ public class RocketActions {
* Action that deletes the selected component.
*/
private class DeleteComponentAction extends RocketAction {
private static final long serialVersionUID = 1L;
public DeleteComponentAction() {
//// Delete
this.putValue(NAME, trans.get("RocketActions.DelCompAct.Delete"));
@ -321,6 +328,8 @@ public class RocketActions {
* Action that deletes the selected component.
*/
private class DeleteSimulationAction extends RocketAction {
private static final long serialVersionUID = 1L;
public DeleteSimulationAction() {
//// Delete
this.putValue(NAME, trans.get("RocketActions.DelSimuAct.Delete"));
@ -356,6 +365,8 @@ public class RocketActions {
* Action that deletes the selected component.
*/
private class DeleteAction extends RocketAction {
private static final long serialVersionUID = 1L;
public DeleteAction() {
//// Delete
this.putValue(NAME, trans.get("RocketActions.DelAct.Delete"));
@ -391,6 +402,8 @@ public class RocketActions {
* Action the cuts the selected component (copies to clipboard and deletes).
*/
private class CutAction extends RocketAction {
private static final long serialVersionUID = 1L;
public CutAction() {
//// Cut
this.putValue(NAME, trans.get("RocketActions.CutAction.Cut"));
@ -442,6 +455,8 @@ public class RocketActions {
* Action that copies the selected component to the clipboard.
*/
private class CopyAction extends RocketAction {
private static final long serialVersionUID = 1L;
public CopyAction() {
//// Copy
this.putValue(NAME, trans.get("RocketActions.CopyAct.Copy"));
@ -488,6 +503,8 @@ public class RocketActions {
* as a child, and after that as a sibling after the selected component.
*/
private class PasteAction extends RocketAction {
private static final long serialVersionUID = 1L;
public PasteAction() {
//// Paste
this.putValue(NAME, trans.get("RocketActions.PasteAct.Paste"));
@ -551,6 +568,8 @@ public class RocketActions {
* Action to edit the currently selected component.
*/
private class EditAction extends RocketAction {
private static final long serialVersionUID = 1L;
public EditAction() {
//// Edit
this.putValue(NAME, trans.get("RocketActions.EditAct.Edit"));
@ -584,6 +603,8 @@ public class RocketActions {
* Action to add a new stage to the rocket.
*/
private class NewStageAction extends RocketAction {
private static final long serialVersionUID = 1L;
public NewStageAction() {
//// New stage
this.putValue(NAME, trans.get("RocketActions.NewStageAct.Newstage"));
@ -622,6 +643,8 @@ public class RocketActions {
* Action to move the selected component upwards in the parent's child list.
*/
private class MoveUpAction extends RocketAction {
private static final long serialVersionUID = 1L;
public MoveUpAction() {
//// Move up
this.putValue(NAME, trans.get("RocketActions.MoveUpAct.Moveup"));
@ -665,6 +688,8 @@ public class RocketActions {
* Action to move the selected component down in the parent's child list.
*/
private class MoveDownAction extends RocketAction {
private static final long serialVersionUID = 1L;
public MoveDownAction() {
//// Move down
this.putValue(NAME, trans.get("RocketActions.MoveDownAct.Movedown"));