Fix bug radius offset not updating with radius method
This commit is contained in:
parent
bd3770ddc3
commit
7ec703964c
@ -424,7 +424,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
|
||||
this.stages.clear();
|
||||
for (AxialStage curStage : this.rocket.getStageList()) {
|
||||
|
||||
if (curStage == null) continue;
|
||||
StageFlags flagsToAdd = new StageFlags( curStage.getStageNumber(), true);
|
||||
this.stages.put(curStage.getStageNumber(), flagsToAdd);
|
||||
}
|
||||
|
@ -204,7 +204,14 @@ public class ParallelStage extends AxialStage implements FlightConfigurableCompo
|
||||
}
|
||||
}
|
||||
|
||||
setRadius( radiusMethod, radius_m );
|
||||
if (radius_m == this.radiusOffset_m) return;
|
||||
|
||||
if (this.radiusMethod.clampToZero() ) {
|
||||
this.radiusOffset_m = 0.0;
|
||||
} else {
|
||||
this.radiusOffset_m = radius_m;
|
||||
}
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -229,16 +236,15 @@ public class ParallelStage extends AxialStage implements FlightConfigurableCompo
|
||||
}
|
||||
|
||||
mutex.verify();
|
||||
|
||||
RadiusMethod newMethod = requestedMethod;
|
||||
|
||||
double newRadius = requestedRadius;
|
||||
|
||||
if( newMethod.clampToZero() ) {
|
||||
if( requestedMethod.clampToZero() ) {
|
||||
newRadius = 0.;
|
||||
}
|
||||
|
||||
this.radiusMethod = newMethod;
|
||||
this.radiusOffset_m = newRadius;
|
||||
this.radiusMethod = requestedMethod;
|
||||
this.radiusOffset_m = this.radiusMethod.getAsOffset(getParent(), this, newRadius);
|
||||
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
@ -267,14 +273,18 @@ public class ParallelStage extends AxialStage implements FlightConfigurableCompo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRadiusMethod(RadiusMethod newRadiusMethod) {
|
||||
public void setRadiusMethod(RadiusMethod newMethod) {
|
||||
for (RocketComponent listener : configListeners) {
|
||||
if (listener instanceof ParallelStage) {
|
||||
((ParallelStage) listener).setRadiusMethod(newRadiusMethod);
|
||||
((ParallelStage) listener).setRadiusMethod(newMethod);
|
||||
}
|
||||
}
|
||||
|
||||
setRadius( newRadiusMethod, this.radiusOffset_m );
|
||||
if (newMethod == this.radiusMethod) return;
|
||||
|
||||
mutex.verify();
|
||||
double radius = this.radiusMethod.getRadius(getParent(), this, this.radiusOffset_m); // Radius from the parent's center
|
||||
setRadius(newMethod, radius);
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class PodSet extends ComponentAssembly implements RingInstanceable {
|
||||
protected double angleSeparation = Math.PI;
|
||||
// angle to the first pod
|
||||
protected double angleOffset_rad = 0;
|
||||
|
||||
|
||||
protected RadiusMethod radiusMethod = RadiusMethod.RELATIVE;
|
||||
protected double radiusOffset_m = 0;
|
||||
|
||||
@ -225,19 +225,22 @@ public class PodSet extends ComponentAssembly implements RingInstanceable {
|
||||
}
|
||||
|
||||
mutex.verify();
|
||||
if( this.radiusMethod.clampToZero() ) {
|
||||
|
||||
if (radius_m == this.radiusOffset_m) return;
|
||||
|
||||
if (this.radiusMethod.clampToZero()) {
|
||||
this.radiusOffset_m = 0.0;
|
||||
}else {
|
||||
} else {
|
||||
this.radiusOffset_m = radius_m;
|
||||
}
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RadiusMethod getRadiusMethod() {
|
||||
return this.radiusMethod;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRadiusMethod(RadiusMethod newMethod ) {
|
||||
for (RocketComponent listener : configListeners) {
|
||||
@ -246,11 +249,13 @@ public class PodSet extends ComponentAssembly implements RingInstanceable {
|
||||
}
|
||||
}
|
||||
|
||||
if (newMethod == this.radiusMethod) return;
|
||||
|
||||
mutex.verify();
|
||||
this.radiusMethod = newMethod;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
double radius = this.radiusMethod.getRadius(getParent(), this, this.radiusOffset_m); // Radius from the parent's center
|
||||
setRadius(newMethod, radius);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRadius(RadiusMethod requestMethod, double requestRadius ) {
|
||||
for (RocketComponent listener : configListeners) {
|
||||
@ -260,16 +265,15 @@ public class PodSet extends ComponentAssembly implements RingInstanceable {
|
||||
}
|
||||
|
||||
mutex.verify();
|
||||
|
||||
RadiusMethod newMethod = requestMethod;
|
||||
|
||||
double newRadius = requestRadius;
|
||||
|
||||
|
||||
if( this.radiusMethod.clampToZero() ) {
|
||||
newRadius = 0.;
|
||||
}
|
||||
|
||||
this.radiusMethod = newMethod;
|
||||
this.radiusOffset_m = newRadius;
|
||||
|
||||
this.radiusMethod = requestMethod;
|
||||
this.radiusOffset_m = this.radiusMethod.getAsOffset(getParent(), this, newRadius);
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,11 @@ public enum RadiusMethod implements DistanceMethod {
|
||||
public double getRadius( final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset ){
|
||||
return 0.;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAsOffset(final RocketComponent parentComponent, final RocketComponent thisComponent, double radius) {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
FREE(Application.getTranslator().get("RocketComponent.Position.Method.Radius.FREE") ){
|
||||
@ -26,6 +31,11 @@ public enum RadiusMethod implements DistanceMethod {
|
||||
public double getRadius( final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset ){
|
||||
return requestedOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAsOffset(final RocketComponent parentComponent, final RocketComponent thisComponent, double radius) {
|
||||
return radius;
|
||||
}
|
||||
},
|
||||
|
||||
RELATIVE ( Application.getTranslator().get("RocketComponent.Position.Method.Radius.RELATIVE") ){
|
||||
@ -43,6 +53,18 @@ public enum RadiusMethod implements DistanceMethod {
|
||||
}
|
||||
return radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAsOffset(final RocketComponent parentComponent, final RocketComponent thisComponent, double radius) {
|
||||
double offset = radius;
|
||||
if (parentComponent instanceof BodyTube) {
|
||||
offset -= ((BodyTube)parentComponent).getOuterRadius();
|
||||
}
|
||||
if (thisComponent instanceof RadiusPositionable) {
|
||||
offset -= ((RadiusPositionable)thisComponent).getBoundingRadius();
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
},
|
||||
|
||||
// Defines placement relative to the outside of the target component
|
||||
@ -60,10 +82,15 @@ public enum RadiusMethod implements DistanceMethod {
|
||||
}
|
||||
return radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAsOffset(RocketComponent parentComponent, RocketComponent thisComponent, double radius) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
public static final RadiusMethod[] choices(){
|
||||
return new RadiusMethod[]{ RadiusMethod.FREE, RadiusMethod.RELATIVE };
|
||||
return new RadiusMethod[]{ RadiusMethod.FREE, RadiusMethod.RELATIVE };
|
||||
}
|
||||
|
||||
public final String description;
|
||||
@ -82,5 +109,15 @@ public enum RadiusMethod implements DistanceMethod {
|
||||
@Override
|
||||
public boolean clampToZero() { return true; }
|
||||
|
||||
public abstract double getRadius( final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset );
|
||||
public abstract double getRadius(final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset );
|
||||
|
||||
/**
|
||||
* Returns the radius offset argument (starting from the center of its parent) as an offset value for this
|
||||
* RadiusMethod.
|
||||
* @param parentComponent parent of this component
|
||||
* @param thisComponent the component for which the offset is requested
|
||||
* @param radius the radius offset argument
|
||||
* @return the offset value of this RadiusMethod that yields the given radius
|
||||
*/
|
||||
public abstract double getAsOffset(final RocketComponent parentComponent, final RocketComponent thisComponent, final double radius);
|
||||
}
|
@ -207,6 +207,19 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
|
||||
|
||||
quad2 = quad1 = quad0 = 0; // Not used
|
||||
}
|
||||
|
||||
public ValueSliderModel(double min, DoubleModel max) {
|
||||
this.islinear = true;
|
||||
linearPosition = 1.0;
|
||||
|
||||
this.min = new DoubleModel(min);
|
||||
this.mid = max; // Never use exponential scale
|
||||
this.max = max;
|
||||
|
||||
max.addChangeListener(this);
|
||||
|
||||
quad2 = quad1 = quad0 = 0; // Not used
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -426,6 +439,10 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
|
||||
public BoundedRangeModel getSliderModel(double min, double max) {
|
||||
return new ValueSliderModel(min, max);
|
||||
}
|
||||
|
||||
public BoundedRangeModel getSliderModel(double min, DoubleModel max) {
|
||||
return new ValueSliderModel(min, max);
|
||||
}
|
||||
|
||||
public BoundedRangeModel getSliderModel(double min, double mid, double max) {
|
||||
return new ValueSliderModel(min, mid, max);
|
||||
|
Loading…
x
Reference in New Issue
Block a user