Merge pull request #1664 from SiboVG/issue-1661
[#1661] Add scaling for rail buttons
This commit is contained in:
commit
4e495c480e
@ -27,11 +27,6 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
|
|||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
// NOTE: Rail Button ARE NOT STANDARD -- They vary by manufacturer, and model.
|
|
||||||
// These presets have appropriate dimensions for each rail size, given the Rail Buttons contribute so little to flying properties.
|
|
||||||
public static final RailButton ROUND_1010 = make1010Button();
|
|
||||||
public static final RailButton ROUND_1515 = make1515Button();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Rail Button Dimensions (side view)
|
* Rail Button Dimensions (side view)
|
||||||
*
|
*
|
||||||
@ -93,34 +88,6 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
|
|||||||
super.displayOrder_side = 14; // Order for displaying the component in the 2D side view
|
super.displayOrder_side = 14; // Order for displaying the component in the 2D side view
|
||||||
super.displayOrder_back = 11; // Order for displaying the component in the 2D back view
|
super.displayOrder_back = 11; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final RailButton make1010Button(){
|
|
||||||
final double id = 0.008; // guess
|
|
||||||
final double od = 0.0097;
|
|
||||||
final double ht = 0.0097;
|
|
||||||
final double thickness = 0.002; // guess
|
|
||||||
final double standoff = 0.002; // guess
|
|
||||||
RailButton rb1010 = new RailButton( od, id, ht, thickness, standoff);
|
|
||||||
rb1010.setMassOverridden(true);
|
|
||||||
rb1010.setOverrideMass(0.0019);
|
|
||||||
|
|
||||||
rb1010.setInstanceCount(1);
|
|
||||||
rb1010.setInstanceSeparation( od*6 );
|
|
||||||
return rb1010;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final RailButton make1515Button(){
|
|
||||||
final double id = 0.012; // guess
|
|
||||||
final double od = 0.016;
|
|
||||||
final double ht = 0.0173;
|
|
||||||
final double thickness = 0.0032; // guess
|
|
||||||
final double standoff = 0.0032; // guess
|
|
||||||
RailButton rb1010 = new RailButton( od, id, ht, thickness, standoff);
|
|
||||||
rb1010.setMassOverridden(true);
|
|
||||||
rb1010.setOverrideMass(0.0077);
|
|
||||||
|
|
||||||
return rb1010;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getBaseHeight(){
|
public double getBaseHeight(){
|
||||||
return this.baseHeight_m;
|
return this.baseHeight_m;
|
||||||
|
@ -6,7 +6,6 @@ import java.awt.event.ActionListener;
|
|||||||
import java.awt.event.ItemEvent;
|
import java.awt.event.ItemEvent;
|
||||||
import java.awt.event.ItemListener;
|
import java.awt.event.ItemListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -99,7 +98,13 @@ public class ScaleDialog extends JDialog {
|
|||||||
// Body tube
|
// Body tube
|
||||||
addScaler(BodyTube.class, "OuterRadius", "isOuterRadiusAutomatic", SCALERS_NO_OFFSET);
|
addScaler(BodyTube.class, "OuterRadius", "isOuterRadiusAutomatic", SCALERS_NO_OFFSET);
|
||||||
addScaler(BodyTube.class, "MotorOverhang", SCALERS_NO_OFFSET);
|
addScaler(BodyTube.class, "MotorOverhang", SCALERS_NO_OFFSET);
|
||||||
|
|
||||||
|
// Rail button
|
||||||
|
list = new ArrayList<>(1);
|
||||||
|
list.add(new RailButtonScaler());
|
||||||
|
SCALERS_NO_OFFSET.put(RailButton.class, list);
|
||||||
|
addScaler(RailButton.class, "InstanceSeparation", SCALERS_OFFSET);
|
||||||
|
|
||||||
// Launch lug
|
// Launch lug
|
||||||
addScaler(LaunchLug.class, "OuterRadius", SCALERS_NO_OFFSET);
|
addScaler(LaunchLug.class, "OuterRadius", SCALERS_NO_OFFSET);
|
||||||
addScaler(LaunchLug.class, "Thickness", SCALERS_NO_OFFSET);
|
addScaler(LaunchLug.class, "Thickness", SCALERS_NO_OFFSET);
|
||||||
@ -754,12 +759,11 @@ public class ScaleDialog extends JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public void scale(RocketComponent component, double multiplier, boolean scaleMass) {
|
public void scale(RocketComponent component, double multiplier, boolean scaleMass) {
|
||||||
final Map<Class<? extends RocketComponent>, List<Scaler>> scalers = new HashMap<>();
|
final Map<Class<? extends RocketComponent>, List<Scaler>> scalers = new HashMap<>();
|
||||||
RadiusRingComponent ring = (RadiusRingComponent) component;
|
|
||||||
// We need to specify this particular order, otherwise scale the inner/outer radius may clip the dimensions of the other outer/inner radius
|
// We need to specify this particular order, otherwise scale the inner/outer radius may clip the dimensions of the other outer/inner radius
|
||||||
if (multiplier >= 1) {
|
if (multiplier >= 1) { // Scale up
|
||||||
addScaler(RadiusRingComponent.class, "OuterRadius", "isOuterRadiusAutomatic", scalers);
|
addScaler(RadiusRingComponent.class, "OuterRadius", "isOuterRadiusAutomatic", scalers);
|
||||||
addScaler(RadiusRingComponent.class, "InnerRadius", "isInnerRadiusAutomatic", scalers);
|
addScaler(RadiusRingComponent.class, "InnerRadius", "isInnerRadiusAutomatic", scalers);
|
||||||
} else {
|
} else { // Scale down
|
||||||
addScaler(RadiusRingComponent.class, "InnerRadius", "isInnerRadiusAutomatic", scalers);
|
addScaler(RadiusRingComponent.class, "InnerRadius", "isInnerRadiusAutomatic", scalers);
|
||||||
addScaler(RadiusRingComponent.class, "OuterRadius", "isOuterRadiusAutomatic", scalers);
|
addScaler(RadiusRingComponent.class, "OuterRadius", "isOuterRadiusAutomatic", scalers);
|
||||||
}
|
}
|
||||||
@ -772,5 +776,34 @@ public class ScaleDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class RailButtonScaler implements Scaler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void scale(RocketComponent component, double multiplier, boolean scaleMass) {
|
||||||
|
final Map<Class<? extends RocketComponent>, List<Scaler>> scalers = new HashMap<>();
|
||||||
|
// We need to specify this particular order, otherwise scale the inner/outer radius may clip the dimensions of the other outer/inner radius
|
||||||
|
if (multiplier >= 1) { // Scale up
|
||||||
|
addScaler(RailButton.class, "OuterDiameter", scalers);
|
||||||
|
addScaler(RailButton.class, "InnerDiameter", scalers);
|
||||||
|
addScaler(RailButton.class, "TotalHeight", scalers);
|
||||||
|
addScaler(RailButton.class, "BaseHeight", scalers);
|
||||||
|
addScaler(RailButton.class, "FlangeHeight", scalers);
|
||||||
|
} else { // Scale down
|
||||||
|
addScaler(RailButton.class, "InnerDiameter", scalers);
|
||||||
|
addScaler(RailButton.class, "OuterDiameter", scalers);
|
||||||
|
addScaler(RailButton.class, "BaseHeight", scalers);
|
||||||
|
addScaler(RailButton.class, "FlangeHeight", scalers);
|
||||||
|
addScaler(RailButton.class, "TotalHeight", scalers);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (List<Scaler> foo : scalers.values()) {
|
||||||
|
for (Scaler s : foo) {
|
||||||
|
s.scale(component, multiplier, scaleMass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user