[Minor] Harmonized interface for instanceable components
Implemented 'Instanceable' Interface
- MotorMount implements instanceable
- BodyTube
- Innertube
-RingInstance interface
- BoosterSet
- PodSet
-LineInstanceable interface [This feature is not exposed in UI)
- LaunchLug
- LaunchButton (Stub only, ATT)
- RingComponent (abstract ancestor class)
-Reverted MotorMount Function names to "[is|set]MotorMount"
This commit is contained in:
parent
1401d99528
commit
0a55f59548
@ -1376,7 +1376,9 @@ RocketComponent.Position.ABSOLUTE = Tip of the nose cone
|
||||
|
||||
|
||||
! LaunchLug
|
||||
LaunchLug.Launchlug = Launch lug
|
||||
LaunchLug.Launchlug = Launch Lug
|
||||
! LaunchButton
|
||||
LaunchButton.LaunchButton = Launch Button
|
||||
! NoseCone
|
||||
NoseCone.NoseCone = Nose cone
|
||||
! Transition
|
||||
|
||||
@ -21,7 +21,9 @@ import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
|
||||
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||
import net.sf.openrocket.rocketcomponent.Instanceable;
|
||||
import net.sf.openrocket.rocketcomponent.LaunchLug;
|
||||
import net.sf.openrocket.rocketcomponent.LineInstanceable;
|
||||
import net.sf.openrocket.rocketcomponent.MassComponent;
|
||||
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||
import net.sf.openrocket.rocketcomponent.NoseCone;
|
||||
@ -31,6 +33,7 @@ import net.sf.openrocket.rocketcomponent.RadiusRingComponent;
|
||||
import net.sf.openrocket.rocketcomponent.RecoveryDevice;
|
||||
import net.sf.openrocket.rocketcomponent.ReferenceType;
|
||||
import net.sf.openrocket.rocketcomponent.RingComponent;
|
||||
import net.sf.openrocket.rocketcomponent.RingInstanceable;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.ShockCord;
|
||||
@ -411,9 +414,27 @@ class DocumentConfig {
|
||||
Reflection.findMethod(AxialStage.class, "getSeparationConfigurations"),
|
||||
Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationDelay", double.class)));
|
||||
|
||||
setters.put("ComponentAssembly:instancecount", new IntSetter(Reflection.findMethod(AxialStage.class, "setInstanceCount", int.class)));
|
||||
setters.put("ComponentAssembly:radialoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setRadialOffset", double.class)));
|
||||
setters.put("ComponentAssembly:angleoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setAngularOffset", double.class)));
|
||||
/*
|
||||
* The keys are of the form Class:param, where Class is the class name and param
|
||||
* the element name. Setters are searched for in descending class order.
|
||||
* A setter of null means setting the parameter is not allowed.
|
||||
*/
|
||||
|
||||
// setters.put("ComponentAssembly:instancecount", new IntSetter(Reflection.findMethod(AxialStage.class, "setInstanceCount", int.class)));
|
||||
// setters.put("ComponentAssembly:radialoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setRadialOffset", double.class)));
|
||||
// setters.put("ComponentAssembly:angleoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setAngularOffset", double.class)));
|
||||
|
||||
setters.put("Instanceable:instancecount", new IntSetter(
|
||||
Reflection.findMethod(Instanceable.class, "setInstanceCount",int.class)));
|
||||
setters.put("RingInstanceable:radialoffset", new DoubleSetter(
|
||||
Reflection.findMethod(RingInstanceable.class, "setRadialOffset", double.class)));
|
||||
setters.put("RingInstance:angleoffset", new DoubleSetter(
|
||||
Reflection.findMethod(RingInstanceable.class, "setAngularOffset", double.class)));
|
||||
|
||||
setters.put("LineInstanceable:instanceseparation", new DoubleSetter(
|
||||
Reflection.findMethod( LineInstanceable.class, "setInstanceSeparation", double.class)));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ class MotorMountHandler extends AbstractElementHandler {
|
||||
public MotorMountHandler(MotorMount mount, DocumentLoadingContext context) {
|
||||
this.mount = mount;
|
||||
this.context = context;
|
||||
mount.setActive(true);
|
||||
mount.setMotorMount(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -27,7 +27,7 @@ public class BodyTubeSaver extends SymmetricComponentSaver {
|
||||
else
|
||||
elements.add("<radius>" + tube.getOuterRadius() + "</radius>");
|
||||
|
||||
if (tube.isActive()) {
|
||||
if (tube.isMotorMount()) {
|
||||
elements.addAll(motorMountParams(tube));
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,9 @@ import java.util.List;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.BoosterSet;
|
||||
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
|
||||
import net.sf.openrocket.rocketcomponent.Instanceable;
|
||||
import net.sf.openrocket.rocketcomponent.PodSet;
|
||||
import net.sf.openrocket.rocketcomponent.RingInstanceable;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
|
||||
public class ComponentAssemblySaver extends RocketComponentSaver {
|
||||
@ -50,14 +52,17 @@ public class ComponentAssemblySaver extends RocketComponentSaver {
|
||||
final String startangle_tag = "angleoffset";
|
||||
|
||||
|
||||
if (null != currentStage) {
|
||||
if ( currentStage instanceof Instanceable) {
|
||||
int instanceCount = currentStage.getInstanceCount();
|
||||
elementsToReturn.add("<" + instCt_tag + ">" + instanceCount + "</" + instCt_tag + ">");
|
||||
double radialOffset = currentStage.getRadialOffset();
|
||||
if( currentStage instanceof RingInstanceable ){
|
||||
RingInstanceable ring = (RingInstanceable) currentStage;
|
||||
double radialOffset = ring.getRadialOffset();
|
||||
elementsToReturn.add("<" + radoffs_tag + ">" + radialOffset + "</" + radoffs_tag + ">");
|
||||
double angularOffset = currentStage.getAngularOffset();
|
||||
double angularOffset = ring.getAngularOffset();
|
||||
elementsToReturn.add("<" + startangle_tag + ">" + angularOffset + "</" + startangle_tag + ">");
|
||||
}
|
||||
}
|
||||
|
||||
return elementsToReturn;
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ public class InnerTubeSaver extends ThicknessRingComponentSaver {
|
||||
elements.add("<clusterrotation>" + (tube.getClusterRotation() * 180.0 / Math.PI)
|
||||
+ "</clusterrotation>");
|
||||
|
||||
if (tube.isActive()) {
|
||||
if (tube.isMotorMount()) {
|
||||
elements.addAll(motorMountParams(tube));
|
||||
}
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ public class RocketComponentSaver {
|
||||
|
||||
|
||||
protected final List<String> motorMountParams(MotorMount mount) {
|
||||
if (!mount.isActive())
|
||||
if (!mount.isMotorMount())
|
||||
return Collections.emptyList();
|
||||
|
||||
//FlightConfigurationID[] motorConfigIDs = ((RocketComponent) mount).getRocket().getFlightConfigurationIDs();
|
||||
|
||||
@ -87,7 +87,7 @@ public class BodyTubeDTO extends BasePartDTO implements AttachableParts {
|
||||
setID(theORBodyTube.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOD(theORBodyTube.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorDia((theORBodyTube.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorMount(theORBodyTube.isActive());
|
||||
setMotorMount(theORBodyTube.isMotorMount());
|
||||
|
||||
List<RocketComponent> children = theORBodyTube.getChildren();
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
|
||||
@ -49,7 +49,7 @@ public class InnerBodyTubeDTO extends BodyTubeDTO implements AttachableParts {
|
||||
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setMotorMount(bt.isActive());
|
||||
setMotorMount(bt.isMotorMount());
|
||||
setInsideTube(true);
|
||||
setRadialAngle(bt.getRadialDirection());
|
||||
setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||
|
||||
@ -72,7 +72,7 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
|
||||
MotorInstance inst = mount.getMotorInstance(fcid);
|
||||
Motor motor = inst.getMotor();
|
||||
|
||||
if (mount.isActive() && motor != null) {
|
||||
if (mount.isMotorMount() && motor != null) {
|
||||
String designation = motor.getDesignation(inst.getEjectionDelay());
|
||||
|
||||
for (int i = 0; i < mount.getMotorCount(); i++) {
|
||||
|
||||
@ -179,7 +179,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
|
||||
// Conditional motor mount parameters
|
||||
if (c instanceof MotorMount) {
|
||||
MotorMount mount = (MotorMount) c;
|
||||
if (mount.isActive()) {
|
||||
if (mount.isMotorMount()) {
|
||||
|
||||
SimulationModifier mod = new GenericComponentModifier(
|
||||
trans.get("optimization.modifier.motormount.overhang"),
|
||||
|
||||
@ -12,7 +12,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
//private static final Logger log = LoggerFactory.getLogger(AxialStage.class);
|
||||
|
||||
private FlightConfigurationSet<StageSeparationConfiguration> separationConfigurations;
|
||||
protected FlightConfigurationSet<StageSeparationConfiguration> separationConfigurations;
|
||||
|
||||
protected int stageNumber;
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
|
||||
|
||||
// When changing the inner radius, thickness is modified
|
||||
private double overhang = 0;
|
||||
private boolean isActiveMount = false;
|
||||
private boolean isActing = false;
|
||||
|
||||
private MotorConfigurationSet motors;
|
||||
|
||||
@ -382,7 +382,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
|
||||
if( null != newMotorInstance ){
|
||||
newMotorInstance.setMount( this);
|
||||
if( MotorInstanceId.EMPTY_ID != newMotorInstance.getID()){
|
||||
this.setActive(true);
|
||||
this.setMotorMount(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -398,21 +398,23 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean _active){
|
||||
if (this.isActiveMount == _active)
|
||||
public void setMotorMount(boolean _active){
|
||||
if (this.isActing == _active)
|
||||
return;
|
||||
this.isActiveMount = _active;
|
||||
this.isActing = _active;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(){
|
||||
return this.isActiveMount;
|
||||
public boolean isMotorMount(){
|
||||
return this.isActing;
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Override
|
||||
public boolean hasMotor() {
|
||||
return ( 0 < this.motors.size());
|
||||
// the default MotorInstance is the EMPTY_INSTANCE.
|
||||
// If the class contains more instances, at least one will have motors.
|
||||
return ( 1 < this.motors.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -11,16 +11,28 @@ import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.BugException;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
public class BoosterSet extends AxialStage implements FlightConfigurableComponent, OutsideComponent {
|
||||
public class BoosterSet extends AxialStage implements FlightConfigurableComponent, RingInstanceable, OutsideComponent {
|
||||
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
private static final Logger log = LoggerFactory.getLogger(BoosterSet.class);
|
||||
|
||||
private FlightConfigurationSet<StageSeparationConfiguration> separationConfigurations;
|
||||
protected int count = 1;
|
||||
|
||||
protected double angularSeparation = Math.PI;
|
||||
protected double angularPosition_rad = 0;
|
||||
protected double radialPosition_m = 0;
|
||||
|
||||
public BoosterSet() {
|
||||
this.count = 2;
|
||||
this.relativePosition = Position.BOTTOM;
|
||||
this.angularSeparation = Math.PI * 2 / this.count;
|
||||
}
|
||||
|
||||
public BoosterSet( final int _count ){
|
||||
this();
|
||||
|
||||
this.count = _count;
|
||||
this.angularSeparation = Math.PI * 2 / this.count;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,7 +83,7 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
|
||||
|
||||
@Override
|
||||
public void cloneFlightConfiguration(FlightConfigurationID oldConfigId, FlightConfigurationID newConfigId) {
|
||||
separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId);
|
||||
this.separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,6 +92,21 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAngularOffset() {
|
||||
return this.angularPosition_rad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstanceCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRadialOffset() {
|
||||
return this.radialPosition_m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coordinate[] getLocation() {
|
||||
if (null == this.parent) {
|
||||
@ -102,6 +129,11 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
|
||||
return !isCenterline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPatternName(){
|
||||
return (this.getInstanceCount() + "-ring");
|
||||
}
|
||||
|
||||
/**
|
||||
* Boosters are, by definition, not centerline.
|
||||
*
|
||||
@ -130,6 +162,18 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
|
||||
return this.getAxialOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRadialOffset(final double radius) {
|
||||
this.radialPosition_m = radius;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngularOffset(final double angle_rad) {
|
||||
this.angularPosition_rad = angle_rad;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coordinate[] shiftCoordinates(Coordinate[] c) {
|
||||
checkState();
|
||||
@ -159,4 +203,31 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void toDebugTreeNode(final StringBuilder buffer, final String prefix) {
|
||||
|
||||
String thisLabel = this.getName() + " (" + this.getStageNumber() + ")";
|
||||
|
||||
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(" (offset: %4.1f via: %s )\n", this.getAxialOffset(), this.relativePosition.name()));
|
||||
Coordinate[] relCoords = this.shiftCoordinates(new Coordinate[] { Coordinate.ZERO });
|
||||
Coordinate[] absCoords = this.getLocation();
|
||||
|
||||
for (int instanceNumber = 0; instanceNumber < this.count; instanceNumber++) {
|
||||
Coordinate instanceRelativePosition = relCoords[instanceNumber];
|
||||
Coordinate instanceAbsolutePosition = absCoords[instanceNumber];
|
||||
buffer.append(String.format("%s [instance %2d of %2d] %32s %32s\n", prefix, instanceNumber, count,
|
||||
instanceRelativePosition, instanceAbsolutePosition));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import net.sf.openrocket.startup.Application;
|
||||
public class Bulkhead extends RadiusRingComponent {
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
|
||||
public Bulkhead() {
|
||||
setOuterRadiusAutomatic(true);
|
||||
setLength(0.002);
|
||||
|
||||
@ -7,7 +7,7 @@ import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
|
||||
public class CenteringRing extends RadiusRingComponent {
|
||||
public class CenteringRing extends RadiusRingComponent implements LineInstanceable {
|
||||
|
||||
public CenteringRing() {
|
||||
setOuterRadiusAutomatic(true);
|
||||
|
||||
@ -2,10 +2,13 @@ package net.sf.openrocket.rocketcomponent;
|
||||
|
||||
import net.sf.openrocket.util.ChangeSource;
|
||||
|
||||
public interface Clusterable extends ChangeSource {
|
||||
public interface Clusterable extends ChangeSource, Instanceable {
|
||||
|
||||
public ClusterConfiguration getClusterConfiguration();
|
||||
|
||||
public void setClusterConfiguration(ClusterConfiguration cluster);
|
||||
|
||||
public double getClusterSeparation();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -4,11 +4,11 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -22,12 +22,6 @@ import org.slf4j.LoggerFactory;
|
||||
public abstract class ComponentAssembly extends RocketComponent {
|
||||
private static final Logger log = LoggerFactory.getLogger(ComponentAssembly.class);
|
||||
|
||||
protected double angularPosition_rad = 0;
|
||||
protected double radialPosition_m = 0;
|
||||
|
||||
protected int count = 1;
|
||||
protected double angularSeparation = Math.PI;
|
||||
|
||||
/**
|
||||
* Sets the position of the components to POSITION_RELATIVE_AFTER.
|
||||
* (Should have no effect.)
|
||||
@ -36,23 +30,11 @@ public abstract class ComponentAssembly extends RocketComponent {
|
||||
super(RocketComponent.Position.AFTER);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getInstanceCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public double getAngularOffset() {
|
||||
return this.angularPosition_rad;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getAxialOffset() {
|
||||
return super.asPositionValue(this.relativePosition);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Null method (ComponentAssembly has no bounds of itself).
|
||||
*/
|
||||
@ -77,11 +59,6 @@ public abstract class ComponentAssembly extends RocketComponent {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getRadialOffset() {
|
||||
return this.radialPosition_m;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Null method (ComponentAssembly has no mass of itself).
|
||||
*/
|
||||
@ -121,15 +98,6 @@ public abstract class ComponentAssembly extends RocketComponent {
|
||||
}
|
||||
|
||||
|
||||
public void setAngularOffset(final double angle_rad) {
|
||||
if (this.isCenterline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.angularPosition_rad = angle_rad;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAxialOffset(final double _pos) {
|
||||
this.updateBounds();
|
||||
@ -151,18 +119,9 @@ public abstract class ComponentAssembly extends RocketComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
this.count = _count;
|
||||
this.angularSeparation = Math.PI * 2 / this.count;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
public void setRadialOffset(final double radius) {
|
||||
if (false == this.isCenterline()) {
|
||||
this.radialPosition_m = radius;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRelativePositionMethod(final Position _newPosition) {
|
||||
if (null == this.parent) {
|
||||
throw new NullPointerException(" a Stage requires a parent before any positioning! ");
|
||||
@ -192,31 +151,6 @@ public abstract class ComponentAssembly extends RocketComponent {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void toDebugTreeNode(final StringBuilder buffer, final String prefix) {
|
||||
|
||||
String thisLabel = this.getName() + " (" + this.getStageNumber() + ")";
|
||||
|
||||
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(" (offset: %4.1f via: %s )\n", this.getAxialOffset(), this.relativePosition.name()));
|
||||
Coordinate[] relCoords = this.shiftCoordinates(new Coordinate[] { Coordinate.ZERO });
|
||||
Coordinate[] absCoords = this.getLocation();
|
||||
|
||||
for (int instanceNumber = 0; instanceNumber < this.count; instanceNumber++) {
|
||||
Coordinate instanceRelativePosition = relCoords[instanceNumber];
|
||||
Coordinate instanceAbsolutePosition = absCoords[instanceNumber];
|
||||
buffer.append(String.format("%s [instance %2d of %2d] %32s %32s\n", prefix, instanceNumber, count,
|
||||
instanceRelativePosition, instanceAbsolutePosition));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update() {
|
||||
if (null == this.parent) {
|
||||
|
||||
@ -188,11 +188,12 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
}
|
||||
// DEVEL
|
||||
// see planning notes...
|
||||
if (comp instanceof MotorMount) { // is instance, AND is activeMount
|
||||
if ( comp instanceof MotorMount ){
|
||||
MotorMount mount = (MotorMount)comp;
|
||||
//if( mount.isActive() ){
|
||||
|
||||
// if( mount instanceof Clusterable ){
|
||||
// if( 1 < comp.getInstanceCount() ){
|
||||
// if comp is clustered, it will be clustered from the innerTube, no?
|
||||
//List<MotorInstance> instanceList = mount.getMotorInstance(this.fcid);
|
||||
|
||||
|
||||
@ -4,6 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.motor.MotorInstance;
|
||||
@ -23,13 +26,14 @@ import net.sf.openrocket.util.MathUtil;
|
||||
*/
|
||||
public class InnerTube extends ThicknessRingComponent implements Clusterable, RadialParent, MotorMount {
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
private static final Logger log = LoggerFactory.getLogger(InnerTube.class);
|
||||
|
||||
private ClusterConfiguration cluster = ClusterConfiguration.SINGLE;
|
||||
private double clusterScale = 1.0;
|
||||
private double clusterRotation = 0.0;
|
||||
|
||||
private double overhang = 0;
|
||||
private boolean isActiveMount;
|
||||
private boolean isActing;
|
||||
private FlightConfigurationSet<MotorInstance> motors;
|
||||
|
||||
/**
|
||||
@ -63,6 +67,12 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
|
||||
return trans.get("InnerTube.InnerTube");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPatternName() {
|
||||
return this.cluster.getXMLName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean allowsChildren() {
|
||||
return true;
|
||||
@ -133,6 +143,11 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
|
||||
return cluster.getClusterCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstanceCount( final int newCount ){
|
||||
log.error("Programmer Error: cannot set the instance count of an "+this.getClass().getSimpleName()+" directly. Please set setClusterConfiguration(ClusterConfiguration) instead.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cluster scaling. A value of 1.0 indicates that the tubes are packed
|
||||
* touching each other, larger values separate the tubes and smaller values
|
||||
@ -142,6 +157,11 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
|
||||
return clusterScale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCenterline() {
|
||||
return (1 == this.getClusterCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cluster scaling.
|
||||
* @see #getClusterScale()
|
||||
@ -243,7 +263,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
|
||||
if( null != newMotorInstance ){
|
||||
newMotorInstance.setMount( this);
|
||||
if( MotorInstanceId.EMPTY_ID != newMotorInstance.getID()){
|
||||
this.setActive(true);
|
||||
this.setMotorMount(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -260,21 +280,22 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
|
||||
|
||||
|
||||
@Override
|
||||
public void setActive(boolean _active){
|
||||
if (this.isActiveMount == _active)
|
||||
public void setMotorMount(boolean _active){
|
||||
if (this.isActing == _active)
|
||||
return;
|
||||
this.isActiveMount = _active;
|
||||
this.isActing = _active;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(){
|
||||
return this.isActiveMount;
|
||||
public boolean isMotorMount(){
|
||||
return this.isActing;
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Override
|
||||
public boolean hasMotor() {
|
||||
return ( 0 < this.motors.size());
|
||||
// the default MotorInstance is the EMPTY_INSTANCE. If we have more than that, then the other instance will have a motor.
|
||||
return ( 1 < this.motors.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -339,4 +360,6 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
26
core/src/net/sf/openrocket/rocketcomponent/Instanceable.java
Normal file
26
core/src/net/sf/openrocket/rocketcomponent/Instanceable.java
Normal file
@ -0,0 +1,26 @@
|
||||
package net.sf.openrocket.rocketcomponent;
|
||||
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
public interface Instanceable {
|
||||
|
||||
/** duplicate override... especially vs shiftCoordinates...
|
||||
// one of the two should be private
|
||||
*
|
||||
* @return coordinates each instance of this component
|
||||
*/
|
||||
public Coordinate[] getLocation();
|
||||
|
||||
// overrides a method in RocketComponent
|
||||
// not modifiable
|
||||
public boolean isCenterline();
|
||||
|
||||
public void setInstanceCount( final int newCount );
|
||||
|
||||
public int getInstanceCount();
|
||||
|
||||
public Coordinate[] shiftCoordinates(Coordinate[] c);
|
||||
|
||||
public String getPatternName();
|
||||
|
||||
}
|
||||
275
core/src/net/sf/openrocket/rocketcomponent/LaunchButton.java
Normal file
275
core/src/net/sf/openrocket/rocketcomponent/LaunchButton.java
Normal file
@ -0,0 +1,275 @@
|
||||
package net.sf.openrocket.rocketcomponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.preset.ComponentPreset;
|
||||
import net.sf.openrocket.preset.ComponentPreset.Type;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
|
||||
/**
|
||||
* WARNING! This class is stubbed out, partially implemented, but DEFINITELY not ready for use.
|
||||
* @author widget (Daniel Williams)
|
||||
*
|
||||
*/
|
||||
public abstract class LaunchButton extends ExternalComponent implements LineInstanceable {
|
||||
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
private double radius;
|
||||
private double thickness;
|
||||
|
||||
private double radialDirection = 0;
|
||||
|
||||
private int instanceCount = 1;
|
||||
private double instanceSeparation = 0; // front-front along the positive rocket axis. i.e. [1,0,0];
|
||||
|
||||
/* These are calculated when the component is first attached to any Rocket */
|
||||
private double shiftY, shiftZ;
|
||||
|
||||
|
||||
|
||||
public LaunchButton() {
|
||||
super(Position.MIDDLE);
|
||||
radius = 0.01 / 2;
|
||||
thickness = 0.001;
|
||||
length = 0.03;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public double getOuterRadius() {
|
||||
// return radius;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setOuterRadius(double radius) {
|
||||
// if (MathUtil.equals(this.radius, radius))
|
||||
// return;
|
||||
// this.radius = radius;
|
||||
// this.thickness = Math.min(this.thickness, this.radius);
|
||||
// clearPreset();
|
||||
// fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public double getInnerRadius() {
|
||||
// return radius - thickness;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setInnerRadius(double innerRadius) {
|
||||
// setOuterRadius(innerRadius + thickness);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double getThickness() {
|
||||
// return thickness;
|
||||
// }
|
||||
|
||||
public void setThickness(double thickness) {
|
||||
if (MathUtil.equals(this.thickness, thickness))
|
||||
return;
|
||||
this.thickness = MathUtil.clamp(thickness, 0, radius);
|
||||
clearPreset();
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
public double getRadialDirection() {
|
||||
return radialDirection;
|
||||
}
|
||||
|
||||
public void setRadialDirection(double direction) {
|
||||
direction = MathUtil.reduce180(direction);
|
||||
if (MathUtil.equals(this.radialDirection, direction))
|
||||
return;
|
||||
this.radialDirection = direction;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setLength(double length) {
|
||||
if (MathUtil.equals(this.length, length))
|
||||
return;
|
||||
this.length = length;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCenterline() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRelativePosition(RocketComponent.Position position) {
|
||||
super.setRelativePosition(position);
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPositionValue(double value) {
|
||||
super.setPositionValue(value);
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void loadFromPreset(ComponentPreset preset) {
|
||||
if (preset.has(ComponentPreset.OUTER_DIAMETER)) {
|
||||
double outerDiameter = preset.get(ComponentPreset.OUTER_DIAMETER);
|
||||
this.radius = outerDiameter / 2.0;
|
||||
if (preset.has(ComponentPreset.INNER_DIAMETER)) {
|
||||
double innerDiameter = preset.get(ComponentPreset.INNER_DIAMETER);
|
||||
this.thickness = (outerDiameter - innerDiameter) / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
super.loadFromPreset(preset);
|
||||
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Type getPresetType() {
|
||||
return ComponentPreset.Type.LAUNCH_LUG;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Coordinate[] shiftCoordinates(Coordinate[] array) {
|
||||
array = super.shiftCoordinates(array);
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = array[i].add(0, shiftY, shiftZ);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void componentChanged(ComponentChangeEvent e) {
|
||||
super.componentChanged(e);
|
||||
|
||||
/*
|
||||
* shiftY and shiftZ must be computed here since calculating them
|
||||
* in shiftCoordinates() would cause an infinite loop due to .toRelative
|
||||
*/
|
||||
RocketComponent body;
|
||||
double parentRadius;
|
||||
|
||||
for (body = this.getParent(); body != null; body = body.getParent()) {
|
||||
if (body instanceof SymmetricComponent)
|
||||
break;
|
||||
}
|
||||
|
||||
if (body == null) {
|
||||
parentRadius = 0;
|
||||
} else {
|
||||
SymmetricComponent s = (SymmetricComponent) body;
|
||||
double x1, x2;
|
||||
x1 = this.toRelative(Coordinate.NUL, body)[0].x;
|
||||
x2 = this.toRelative(new Coordinate(length, 0, 0), body)[0].x;
|
||||
x1 = MathUtil.clamp(x1, 0, body.getLength());
|
||||
x2 = MathUtil.clamp(x2, 0, body.getLength());
|
||||
parentRadius = Math.max(s.getRadius(x1), s.getRadius(x2));
|
||||
}
|
||||
|
||||
shiftY = Math.cos(radialDirection) * (parentRadius + radius);
|
||||
shiftZ = Math.sin(radialDirection) * (parentRadius + radius);
|
||||
|
||||
// System.out.println("Computed shift: y="+shiftY+" z="+shiftZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public double getComponentVolume() {
|
||||
return length * Math.PI * (MathUtil.pow2(radius) - MathUtil.pow2(radius - thickness));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Coordinate> getComponentBounds() {
|
||||
ArrayList<Coordinate> set = new ArrayList<Coordinate>();
|
||||
addBound(set, 0, radius);
|
||||
addBound(set, length, radius);
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coordinate getComponentCG() {
|
||||
return new Coordinate(length / 2, 0, 0, getComponentMass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
// Launch Button
|
||||
return trans.get("LaunchButton.LaunchButton");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLongitudinalUnitInertia() {
|
||||
// 1/12 * (3 * (r2^2 + r1^2) + h^2)
|
||||
// return (3 * (MathUtil.pow2(getOuterRadius()) + MathUtil.pow2(getInnerRadius())) + MathUtil.pow2(getLength())) / 12;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRotationalUnitInertia() {
|
||||
// 1/2 * (r1^2 + r2^2)
|
||||
// return (MathUtil.pow2(getInnerRadius()) + MathUtil.pow2(getOuterRadius())) / 2;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsChildren() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatible(Class<? extends RocketComponent> type) {
|
||||
// Allow nothing to be attached to a LaunchButton
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public double getInstanceSeparation(){
|
||||
return this.instanceSeparation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstanceSeparation(final double _separation){
|
||||
this.instanceSeparation = _separation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstanceCount( final int newCount ){
|
||||
if( 0 < newCount ){
|
||||
this.instanceCount = newCount;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstanceCount(){
|
||||
return this.instanceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPatternName(){
|
||||
return (this.getInstanceCount() + "-Line");
|
||||
}
|
||||
|
||||
}
|
||||
@ -12,7 +12,7 @@ import net.sf.openrocket.util.MathUtil;
|
||||
|
||||
|
||||
|
||||
public class LaunchLug extends ExternalComponent implements Coaxial {
|
||||
public class LaunchLug extends ExternalComponent implements Coaxial, LineInstanceable {
|
||||
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
@ -21,6 +21,9 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
|
||||
|
||||
private double radialDirection = 0;
|
||||
|
||||
private int instanceCount = 1;
|
||||
private double instanceSeparation = 0; // front-front along the positive rocket axis. i.e. [1,0,0];
|
||||
|
||||
/* These are calculated when the component is first attached to any Rocket */
|
||||
private double shiftY, shiftZ;
|
||||
|
||||
@ -95,7 +98,10 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCenterline() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@ -232,4 +238,33 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public double getInstanceSeparation(){
|
||||
return this.instanceSeparation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstanceSeparation(final double _separation){
|
||||
this.instanceSeparation = _separation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstanceCount( final int newCount ){
|
||||
if( 0 < newCount ){
|
||||
this.instanceCount = newCount;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstanceCount(){
|
||||
return this.instanceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPatternName(){
|
||||
return (this.getInstanceCount() + "-Line");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
package net.sf.openrocket.rocketcomponent;
|
||||
|
||||
public interface LineInstanceable extends Instanceable {
|
||||
|
||||
public double getInstanceSeparation();
|
||||
|
||||
public void setInstanceSeparation(final double radius);
|
||||
|
||||
}
|
||||
@ -3,7 +3,7 @@ package net.sf.openrocket.rocketcomponent;
|
||||
import net.sf.openrocket.motor.MotorInstance;
|
||||
|
||||
/**
|
||||
* FlightConfiguration implementation that prevents changing the default value.
|
||||
* FlightConfigurationSet for motors.
|
||||
* This is used for motors, where the default value is always no motor.
|
||||
*/
|
||||
public class MotorConfigurationSet extends FlightConfigurationSet<MotorInstance> {
|
||||
@ -15,7 +15,7 @@ public class MotorConfigurationSet extends FlightConfigurationSet<MotorInstance>
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a copy of an existing FlightConfigurationImpl.
|
||||
* Construct a copy of an existing FlightConfigurationSet.
|
||||
*
|
||||
* @param flightConfiguration another flightConfiguration to copy data from.
|
||||
* @param component the rocket component on which events are fired when the parameter values are changed
|
||||
|
||||
@ -10,23 +10,28 @@ public interface MotorMount extends ChangeSource, FlightConfigurableComponent {
|
||||
|
||||
|
||||
/**
|
||||
* is this mount currently configured to carry a motor?
|
||||
* Does this mount contain at least one motor?
|
||||
*
|
||||
* @return whether the component holds a motor
|
||||
*/
|
||||
public boolean hasMotor();
|
||||
|
||||
/**
|
||||
* Set whether the component is acting as a motor mount.
|
||||
* Programmatically : implementing classes will always be <code>(x instanceof MotorMount)</code>
|
||||
* The component may potentially act as a mount, or just a structural component.
|
||||
* This flag indicates how the component behaves.
|
||||
*
|
||||
* @param acting if the component should behave like a motor mount. False if it's structural only.
|
||||
*/
|
||||
public void setActive(boolean mount);
|
||||
public void setMotorMount(boolean acting);
|
||||
|
||||
/**
|
||||
* Is the component currently acting as a motor mount.
|
||||
* Programmatically : implementing classes will always be <code>(x instanceof MotorMount)</code>
|
||||
* This flag indicates whether the component is acting as a motor mount, or just a structural component
|
||||
*
|
||||
* @return if the motor mount is turned on
|
||||
* @return true if the component is acting as a motor mount
|
||||
*/
|
||||
public boolean isActive();
|
||||
public boolean isMotorMount();
|
||||
|
||||
/**
|
||||
* Get all motors configured for this mount.
|
||||
|
||||
@ -8,13 +8,16 @@ 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 PodSet extends ComponentAssembly implements OutsideComponent {
|
||||
public class PodSet extends ComponentAssembly implements RingInstanceable, OutsideComponent {
|
||||
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
private static final Logger log = LoggerFactory.getLogger(PodSet.class);
|
||||
//private static final Logger log = LoggerFactory.getLogger(PodSet.class);
|
||||
|
||||
protected int count = 1;
|
||||
|
||||
protected double angularSeparation = Math.PI;
|
||||
protected double angularPosition_rad = 0;
|
||||
protected double radialPosition_m = 0;
|
||||
|
||||
public PodSet() {
|
||||
this.count = 2;
|
||||
@ -152,6 +155,22 @@ public class PodSet extends ComponentAssembly implements OutsideComponent {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAngularOffset() {
|
||||
return this.angularPosition_rad;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPatternName(){
|
||||
return (this.getInstanceCount() + "-ring");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRadialOffset() {
|
||||
return this.radialPosition_m;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Coordinate[] shiftCoordinates(Coordinate[] c) {
|
||||
checkState();
|
||||
@ -191,4 +210,16 @@ public class PodSet extends ComponentAssembly implements OutsideComponent {
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngularOffset(double angle_rad) {
|
||||
this.angularPosition_rad = angle_rad;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRadialOffset(double radius_m) {
|
||||
this.radialPosition_m = radius_m;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -16,18 +16,21 @@ import net.sf.openrocket.util.MathUtil;
|
||||
*
|
||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||
*/
|
||||
public abstract class RingComponent extends StructuralComponent implements Coaxial {
|
||||
public abstract class RingComponent extends StructuralComponent implements Coaxial, LineInstanceable {
|
||||
|
||||
protected boolean outerRadiusAutomatic = false;
|
||||
protected boolean innerRadiusAutomatic = false;
|
||||
|
||||
|
||||
private double radialDirection = 0;
|
||||
private double radialPosition = 0;
|
||||
protected double radialDirection = 0;
|
||||
protected double radialPosition = 0;
|
||||
|
||||
private double shiftY = 0;
|
||||
private double shiftZ = 0;
|
||||
|
||||
protected int instanceCount = 1;
|
||||
// front-front along the positive rocket axis. i.e. [1,0,0];
|
||||
protected double instanceSeparation = 0;
|
||||
|
||||
|
||||
@Override
|
||||
@ -218,4 +221,33 @@ public abstract class RingComponent extends StructuralComponent implements Coaxi
|
||||
return ringRotationalUnitInertia(getOuterRadius(), getInnerRadius());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public double getInstanceSeparation(){
|
||||
return this.instanceSeparation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstanceSeparation(final double _separation){
|
||||
this.instanceSeparation = _separation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstanceCount( final int newCount ){
|
||||
if( 0 < newCount ){
|
||||
this.instanceCount = newCount;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstanceCount(){
|
||||
return this.instanceCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPatternName(){
|
||||
return (this.getInstanceCount() + "-Line");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package net.sf.openrocket.rocketcomponent;
|
||||
|
||||
public interface RingInstanceable extends Instanceable {
|
||||
|
||||
public double getAngularOffset();
|
||||
|
||||
public double getRadialOffset();
|
||||
|
||||
public void setAngularOffset(final double radius);
|
||||
|
||||
public void setRadialOffset(final double radius);
|
||||
|
||||
}
|
||||
@ -582,7 +582,7 @@ public class Rocket extends RocketComponent {
|
||||
|
||||
if (c instanceof MotorMount) {
|
||||
MotorMount mount = (MotorMount) c;
|
||||
if (!mount.isActive())
|
||||
if (!mount.isMotorMount())
|
||||
continue;
|
||||
if (mount.getMotorInstance(fcid).getMotor() != null) {
|
||||
return true;
|
||||
|
||||
@ -270,6 +270,14 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
|
||||
|
||||
//////////// Methods that may be overridden ////////////
|
||||
/**
|
||||
* This enables one-line testing if a component is on the rocket center-line or not.
|
||||
*
|
||||
* @return indicates if this component is centered around the rocket's centerline
|
||||
*/
|
||||
public boolean isCenterline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -959,14 +967,6 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
return this.asPositionValue(this.relativePosition);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return always returns false for base components. This enables one-line testing if a component is on the rocket center-line or not.
|
||||
*/
|
||||
public boolean isCenterline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isAncestor(final RocketComponent testComp) {
|
||||
RocketComponent curComp = testComp.parent;
|
||||
while (curComp != null) {
|
||||
|
||||
@ -11,7 +11,7 @@ public class ListMotorMounts extends ListComponents<RocketComponent> {
|
||||
|
||||
@Override
|
||||
protected void doAction(RocketComponent visitable) {
|
||||
if (visitable instanceof MotorMount && ((MotorMount) visitable).isActive()) {
|
||||
if (visitable instanceof MotorMount && ((MotorMount) visitable).isMotorMount()) {
|
||||
components.add(visitable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,11 +99,11 @@ public class BodyTubeHandlerTest extends RocksimTestBase {
|
||||
warnings.clear();
|
||||
|
||||
handler.closeElement("IsMotorMount", attributes, "1", warnings);
|
||||
Assert.assertTrue(component.isActive());
|
||||
Assert.assertTrue(component.isMotorMount());
|
||||
handler.closeElement("IsMotorMount", attributes, "0", warnings);
|
||||
Assert.assertFalse(component.isActive());
|
||||
Assert.assertFalse(component.isMotorMount());
|
||||
handler.closeElement("IsMotorMount", attributes, "foo", warnings);
|
||||
Assert.assertFalse(component.isActive());
|
||||
Assert.assertFalse(component.isMotorMount());
|
||||
|
||||
handler.closeElement("EngineOverhang", attributes, "-1", warnings);
|
||||
Assert.assertEquals(-1d/ RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
|
||||
|
||||
@ -98,11 +98,11 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase {
|
||||
warnings.clear();
|
||||
|
||||
handler.closeElement("IsMotorMount", attributes, "1", warnings);
|
||||
Assert.assertTrue(component.isActive());
|
||||
Assert.assertTrue(component.isMotorMount());
|
||||
handler.closeElement("IsMotorMount", attributes, "0", warnings);
|
||||
Assert.assertFalse(component.isActive());
|
||||
Assert.assertFalse(component.isMotorMount());
|
||||
handler.closeElement("IsMotorMount", attributes, "foo", warnings);
|
||||
Assert.assertFalse(component.isActive());
|
||||
Assert.assertFalse(component.isMotorMount());
|
||||
|
||||
handler.closeElement("EngineOverhang", attributes, "-1", warnings);
|
||||
Assert.assertEquals(-1d/ RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);
|
||||
|
||||
@ -240,7 +240,7 @@ public abstract class FinSetConfig extends RocketComponentConfig {
|
||||
RocketComponent rocketComponent = iter.next();
|
||||
if (rocketComponent instanceof InnerTube) {
|
||||
InnerTube it = (InnerTube) rocketComponent;
|
||||
if (it.isActive()) {
|
||||
if (it.isMotorMount()) {
|
||||
double depth = ((Coaxial) parent).getOuterRadius() - it.getOuterRadius();
|
||||
//Set fin tab depth
|
||||
if (depth >= 0.0d) {
|
||||
|
||||
@ -40,7 +40,7 @@ public class MotorConfig extends JPanel {
|
||||
|
||||
BooleanModel model;
|
||||
|
||||
model = new BooleanModel(motorMount, "Active");
|
||||
model = new BooleanModel(motorMount, "MotorMount");
|
||||
JCheckBox check = new JCheckBox(model);
|
||||
////This component is a motor mount
|
||||
check.setText(trans.get("MotorCfg.checkbox.compmotormount"));
|
||||
@ -64,7 +64,6 @@ public class MotorConfig extends JPanel {
|
||||
panel.add(new BasicSlider(dm.getSliderModel(-0.02, 0.06)), "w 100lp, wrap unrel");
|
||||
|
||||
|
||||
|
||||
// Select ignition event
|
||||
//// Ignition at:
|
||||
panel.add(new JLabel(trans.get("MotorCfg.lbl.Ignitionat") + " " + CommonStrings.dagger), "");
|
||||
@ -113,11 +112,11 @@ public class MotorConfig extends JPanel {
|
||||
|
||||
// Set enabled status
|
||||
|
||||
setDeepEnabled(panel, motorMount.isActive());
|
||||
setDeepEnabled(panel, motorMount.isMotorMount());
|
||||
check.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
setDeepEnabled(panel, mount.isActive());
|
||||
setDeepEnabled(panel, mount.isMotorMount());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ class MotorMountTableModel extends AbstractTableModel implements ComponentChange
|
||||
public Object getValueAt(int row, int column) {
|
||||
switch (column) {
|
||||
case 0:
|
||||
return new Boolean(potentialMounts.get(row).isActive());
|
||||
return new Boolean(potentialMounts.get(row).isMotorMount());
|
||||
|
||||
case 1:
|
||||
return potentialMounts.get(row).toString();
|
||||
|
||||
@ -141,7 +141,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
|
||||
@Override
|
||||
protected boolean includeComponent(MotorMount component) {
|
||||
return component.isActive();
|
||||
return component.isMotorMount();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -356,11 +356,11 @@ public class DesignReport {
|
||||
topBorder = true;
|
||||
}
|
||||
|
||||
if (c instanceof MotorMount && ((MotorMount) c).isActive()) {
|
||||
if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
|
||||
MotorMount mount = (MotorMount) c;
|
||||
|
||||
// TODO: refactor this... it's redundant with containing if, and could probably be simplified
|
||||
if (mount.isActive() && (mount.getMotorInstance(motorId) != null) &&(null != mount.getMotorInstance(motorId).getMotor())) {
|
||||
if (mount.isMotorMount() && (mount.getMotorInstance(motorId) != null) &&(null != mount.getMotorInstance(motorId).getMotor())) {
|
||||
Motor motor = mount.getMotorInstance(motorId).getMotor();
|
||||
int motorCount = mount.getMotorCount();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user