Merge pull request #1538 from SiboVG/issue-1537

[#1537] Add additional configuration parameters for rail buttons
This commit is contained in:
Joe Pfeiffer 2022-07-31 09:44:30 -06:00 committed by GitHub
commit e313546a65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 192 additions and 148 deletions

View File

@ -1052,7 +1052,10 @@ LaunchLugCfg.tab.Generalprop = General properties
! RailButtonConfig ! RailButtonConfig
RailBtnCfg.lbl.OuterDiam = Outer Diameter: RailBtnCfg.lbl.OuterDiam = Outer Diameter:
RailBtnCfg.lbl.TotalHeight = Total Height RailBtnCfg.lbl.InnerDiam = Inner Diameter:
RailBtnCfg.lbl.TotalHeight = Total Height:
RailBtnCfg.lbl.BaseHeight = Base Height:
RailBtnCfg.lbl.FlangeHeight = Flange Height:
RailBtnCfg.lbl.Angle = Rotation: RailBtnCfg.lbl.Angle = Rotation:
RailBtnCfg.lbl.PosRelativeTo = Position relative to: RailBtnCfg.lbl.PosRelativeTo = Position relative to:
RailBtnCfg.lbl.Plus = plus RailBtnCfg.lbl.Plus = plus

View File

@ -190,8 +190,15 @@ class DocumentConfig {
setters.put("RailButton:angleoffset", new AnglePositionSetter() ); setters.put("RailButton:angleoffset", new AnglePositionSetter() );
setters.put("RailButton:height", new DoubleSetter( setters.put("RailButton:height", new DoubleSetter(
Reflection.findMethod( RailButton.class, "setTotalHeight", double.class))); Reflection.findMethod( RailButton.class, "setTotalHeight", double.class)));
setters.put("RailButton:baseheight", new DoubleSetter(
Reflection.findMethod( RailButton.class, "setBaseHeight", double.class)));
setters.put("RailButton:flangeheight", new DoubleSetter(
Reflection.findMethod( RailButton.class, "setFlangeHeight", double.class)));
setters.put("RailButton:outerdiameter", new DoubleSetter( setters.put("RailButton:outerdiameter", new DoubleSetter(
Reflection.findMethod( RailButton.class, "setOuterDiameter", double.class))); Reflection.findMethod( RailButton.class, "setOuterDiameter", double.class)));
setters.put("RailButton:innerdiameter", new DoubleSetter(
Reflection.findMethod( RailButton.class, "setInnerDiameter", double.class)));
// Transition // Transition
setters.put("Transition:shape", new EnumSetter<Transition.Shape>( setters.put("Transition:shape", new EnumSetter<Transition.Shape>(

View File

@ -26,8 +26,10 @@ public class RailButtonSaver extends ExternalComponentSaver {
RailButton rb = (RailButton) c; RailButton rb = (RailButton) c;
emitDouble( elements, "outerdiameter", rb.getOuterDiameter()); emitDouble( elements, "outerdiameter", rb.getOuterDiameter());
emitDouble( elements, "innerdiameter", rb.getInnerDiameter());
emitDouble( elements, "height", rb.getTotalHeight()); emitDouble( elements, "height", rb.getTotalHeight());
emitDouble( elements, "baseheight", rb.getBaseHeight());
emitDouble( elements, "flangeheight", rb.getFlangeHeight());
} }

View File

@ -2,10 +2,7 @@ package net.sf.openrocket.rocketcomponent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EventObject;
import net.sf.openrocket.appearance.Appearance;
import net.sf.openrocket.appearance.Decal;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.preset.ComponentPreset; import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.preset.ComponentPreset.Type; import net.sf.openrocket.preset.ComponentPreset.Type;
@ -14,7 +11,6 @@ import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BoundingBox; import net.sf.openrocket.util.BoundingBox;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.MathUtil;
import net.sf.openrocket.util.StateChangeListener;
public class LaunchLug extends Tube implements AnglePositionable, BoxBounded, LineInstanceable, InsideColorComponent { public class LaunchLug extends Tube implements AnglePositionable, BoxBounded, LineInstanceable, InsideColorComponent {

View File

@ -40,19 +40,18 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
* ^ [[[[[[]]]]]] flangeHeight * ^ [[[[[[]]]]]] flangeHeight
* total >||||||<= inner dia ^ * total >||||||<= inner dia ^
* height |||||| v * height |||||| v
* v [[[[[[]]]]]] standoff == baseHeight * v [[[[[[]]]]]] baseHeight / standoff
* ================== ^ * ================== ^
* (body) * (body)
* *
*/ */
// Note: the reference point for Rail Button Components is in the center bottom of the button. // Note: the reference point for Rail Button Components is in the center bottom of the button.
protected double outerDiameter_m; protected double outerDiameter_m;
protected double totalHeight_m;
protected double innerDiameter_m; protected double innerDiameter_m;
protected double totalHeight_m;
protected double flangeHeight_m; protected double flangeHeight_m;
protected double standoff_m; protected double baseHeight_m;
protected final static double MINIMUM_STANDOFF= 0.001;
private double radialDistance_m=0; private double radialDistance_m=0;
protected static final AngleMethod angleMethod = AngleMethod.RELATIVE; protected static final AngleMethod angleMethod = AngleMethod.RELATIVE;
@ -66,7 +65,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
this.totalHeight_m = 0.0097; this.totalHeight_m = 0.0097;
this.innerDiameter_m = 0.008; this.innerDiameter_m = 0.008;
this.flangeHeight_m = 0.002; this.flangeHeight_m = 0.002;
this.setStandoff( 0.002); this.setBaseHeight(0.002);
this.setInstanceSeparation( this.outerDiameter_m * 6); this.setInstanceSeparation( this.outerDiameter_m * 6);
this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin"));
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
@ -75,19 +74,19 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
public RailButton( final double od, final double ht ) { public RailButton( final double od, final double ht ) {
this(); this();
this.setOuterDiameter( od); this.setOuterDiameter(od);
this.setTotalHeight( ht); this.setTotalHeight(ht);
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
} }
public RailButton( final double od, final double id, final double ht, final double flangeThickness, final double _standoff ) { public RailButton( final double od, final double id, final double ht, final double _flangeHeight, final double _baseHeight ) {
super(AxialMethod.MIDDLE); super(AxialMethod.MIDDLE);
this.outerDiameter_m = od; this.outerDiameter_m = od;
this.totalHeight_m = ht; this.totalHeight_m = ht;
this.innerDiameter_m = id; this.innerDiameter_m = id;
this.flangeHeight_m = flangeThickness; this.flangeHeight_m = _flangeHeight;
this.setStandoff( _standoff); this.setBaseHeight(_baseHeight);
this.setInstanceSeparation( od*2); this.setInstanceSeparation( od*2);
this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin"));
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
@ -122,12 +121,8 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
return rb1010; return rb1010;
} }
public double getStandoff(){
return this.standoff_m;
}
public double getBaseHeight(){ public double getBaseHeight(){
return this.getStandoff(); return this.baseHeight_m;
} }
public double getOuterDiameter() { public double getOuterDiameter() {
@ -139,7 +134,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
} }
public double getInnerHeight() { public double getInnerHeight() {
return (this.totalHeight_m - this.flangeHeight_m - this.standoff_m); return (this.totalHeight_m - this.flangeHeight_m - this.baseHeight_m);
} }
public double getTotalHeight() { public double getTotalHeight() {
@ -151,14 +146,28 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
} }
public void setStandoff(double newStandoff){ public void setBaseHeight(double newBaseHeight){
for (RocketComponent listener : configListeners) { for (RocketComponent listener : configListeners) {
if (listener instanceof RailButton) { if (listener instanceof RailButton) {
((RailButton) listener).setStandoff(newStandoff); ((RailButton) listener).setBaseHeight(newBaseHeight);
} }
} }
this.standoff_m = Math.max( newStandoff, RailButton.MINIMUM_STANDOFF ); this.baseHeight_m = Math.max(newBaseHeight, 0);
this.baseHeight_m = Math.min(this.baseHeight_m, this.totalHeight_m - this.flangeHeight_m);
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
public void setFlangeHeight(double newFlangeHeight){
for (RocketComponent listener : configListeners) {
if (listener instanceof RailButton) {
((RailButton) listener).setFlangeHeight(newFlangeHeight);
}
}
this.flangeHeight_m = Math.max(newFlangeHeight, 0);
this.flangeHeight_m = Math.min(this.flangeHeight_m, this.totalHeight_m - this.baseHeight_m);
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
public void setInnerDiameter(double newID ){ public void setInnerDiameter(double newID ){
@ -168,7 +177,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
} }
} }
this.innerDiameter_m = newID; this.innerDiameter_m = Math.min(newID, this.outerDiameter_m);
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@ -181,6 +190,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
} }
this.outerDiameter_m = newOD; this.outerDiameter_m = newOD;
setInnerDiameter(this.innerDiameter_m);
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@ -192,22 +202,11 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
} }
} }
this.totalHeight_m = newHeight; this.totalHeight_m = Math.max(newHeight, this.flangeHeight_m + this.baseHeight_m);
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
public void setThickness(double newThickness ) {
for (RocketComponent listener : configListeners) {
if (listener instanceof RailButton) {
((RailButton) listener).setThickness(newThickness);
}
}
this.flangeHeight_m = newThickness;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override @Override
public boolean isAerodynamic(){ public boolean isAerodynamic(){
// TODO: implement aerodynamics // TODO: implement aerodynamics
@ -253,14 +252,16 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
} }
@Override
public BoundingBox getInstanceBoundingBox(){ public BoundingBox getInstanceBoundingBox(){
BoundingBox instanceBounds = new BoundingBox(); BoundingBox instanceBounds = new BoundingBox();
instanceBounds.update(new Coordinate(0, this.getTotalHeight(), 0)); instanceBounds.update(new Coordinate(0, this.totalHeight_m, 0));
instanceBounds.update(new Coordinate(0, -this.totalHeight_m, 0));
final double r = this.getOuterDiameter(); final double r = this.getOuterDiameter() / 2;
instanceBounds.update(new Coordinate(r,r,0)); instanceBounds.update(new Coordinate(r, 0, r));
instanceBounds.update(new Coordinate(-r,-r,0)); instanceBounds.update(new Coordinate(-r, 0, -r));
return instanceBounds; return instanceBounds;
} }
@ -306,7 +307,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
public double getComponentVolume() { public double getComponentVolume() {
final double volOuter = Math.PI*Math.pow( outerDiameter_m/2, 2)*flangeHeight_m; final double volOuter = Math.PI*Math.pow( outerDiameter_m/2, 2)*flangeHeight_m;
final double volInner = Math.PI*Math.pow( innerDiameter_m/2, 2)*getInnerHeight(); final double volInner = Math.PI*Math.pow( innerDiameter_m/2, 2)*getInnerHeight();
final double volStandoff = Math.PI*Math.pow( outerDiameter_m/2, 2)*standoff_m; final double volStandoff = Math.PI*Math.pow( outerDiameter_m/2, 2)* baseHeight_m;
return (volOuter+ return (volOuter+
volInner+ volInner+
volStandoff); volStandoff);
@ -371,11 +372,11 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
@Override @Override
public Coordinate getComponentCG() { public Coordinate getComponentCG() {
// Math.PI and density are assumed constant through calculation, and thus may be factored out. // Math.PI and density are assumed constant through calculation, and thus may be factored out.
final double volumeFlange = Math.pow( outerDiameter_m/2, 2)*flangeHeight_m; final double volumeBase = Math.pow(outerDiameter_m / 2, 2) * this.baseHeight_m;
final double volumeInner = Math.pow( innerDiameter_m/2, 2)*(getInnerHeight()); final double volumeFlange = Math.pow(outerDiameter_m / 2, 2)* this.flangeHeight_m;
final double volumeStandoff = Math.pow( outerDiameter_m/2, 2)*this.standoff_m; final double volumeInner = Math.pow(innerDiameter_m / 2, 2)* getInnerHeight();
final double totalVolume = volumeFlange + volumeInner + volumeStandoff; final double totalVolume = volumeFlange + volumeInner + volumeBase;
final double heightCM = (volumeFlange*( this.totalHeight_m-getFlangeHeight()/2) + volumeInner*( this.standoff_m + this.getInnerHeight()/2) + volumeStandoff*(this.standoff_m/2))/totalVolume; final double heightCM = (volumeFlange*( this.totalHeight_m-getFlangeHeight()/2) + volumeInner*( this.baseHeight_m + this.getInnerHeight()/2) + volumeBase*(this.baseHeight_m /2))/totalVolume;
if( heightCM > this.totalHeight_m ){ if( heightCM > this.totalHeight_m ){
throw new BugException(" bug found while computing the CG of a RailButton: "+this.getName()+"\n height of CG: "+heightCM); throw new BugException(" bug found while computing the CG of a RailButton: "+this.getName()+"\n height of CG: "+heightCM);

View File

@ -30,13 +30,6 @@ public class RailButtonConfig extends RocketComponentConfig {
public RailButtonConfig( OpenRocketDocument document, RocketComponent component, JDialog parent) { public RailButtonConfig( OpenRocketDocument document, RocketComponent component, JDialog parent) {
super(document, component, parent); super(document, component, parent);
// For DEBUG purposes
// if( component instanceof AxialStage ){
// System.err.println(" Dumping AxialStage tree info for devel / debugging.");
// System.err.println(component.toDebugTree());
// }
//// General and General properties //// General and General properties
tabbedPane.insertTab( trans.get("RailBtnCfg.tab.General"), null, buttonTab( (RailButton)component ), trans.get("RailBtnCfg.tab.GeneralProp"), 0); tabbedPane.insertTab( trans.get("RailBtnCfg.tab.General"), null, buttonTab( (RailButton)component ), trans.get("RailBtnCfg.tab.GeneralProp"), 0);
tabbedPane.setSelectedIndex(0); tabbedPane.setSelectedIndex(0);
@ -59,6 +52,33 @@ public class RailButtonConfig extends RocketComponentConfig {
panel.add(new UnitSelector(ODModel), "growx"); panel.add(new UnitSelector(ODModel), "growx");
panel.add(new BasicSlider(ODModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap"); panel.add(new BasicSlider(ODModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap");
} }
{ //// Inner Diameter
panel.add(new JLabel(trans.get("RailBtnCfg.lbl.InnerDiam")));
DoubleModel IDModel = new DoubleModel(component, "InnerDiameter", UnitGroup.UNITS_LENGTH, 0);
JSpinner IDSpinner = new JSpinner(IDModel.getSpinnerModel());
IDSpinner.setEditor(new SpinnerEditor(IDSpinner));
panel.add(IDSpinner, "growx");
panel.add(new UnitSelector(IDModel), "growx");
panel.add(new BasicSlider(IDModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap para");
}
{ //// Base Height
panel.add(new JLabel(trans.get("RailBtnCfg.lbl.BaseHeight")));
DoubleModel heightModel = new DoubleModel(component, "BaseHeight", UnitGroup.UNITS_LENGTH, 0);
JSpinner heightSpinner = new JSpinner(heightModel.getSpinnerModel());
heightSpinner.setEditor(new SpinnerEditor(heightSpinner));
panel.add(heightSpinner, "growx");
panel.add(new UnitSelector(heightModel), "growx");
panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap");
}
{ //// Flange Height
panel.add(new JLabel(trans.get("RailBtnCfg.lbl.FlangeHeight")));
DoubleModel heightModel = new DoubleModel(component, "FlangeHeight", UnitGroup.UNITS_LENGTH, 0);
JSpinner heightSpinner = new JSpinner(heightModel.getSpinnerModel());
heightSpinner.setEditor(new SpinnerEditor(heightSpinner));
panel.add(heightSpinner, "growx");
panel.add(new UnitSelector(heightModel), "growx");
panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap");
}
{ //// Height { //// Height
panel.add(new JLabel(trans.get("RailBtnCfg.lbl.TotalHeight"))); panel.add(new JLabel(trans.get("RailBtnCfg.lbl.TotalHeight")));
DoubleModel heightModel = new DoubleModel(component, "TotalHeight", UnitGroup.UNITS_LENGTH, 0); DoubleModel heightModel = new DoubleModel(component, "TotalHeight", UnitGroup.UNITS_LENGTH, 0);
@ -66,7 +86,7 @@ public class RailButtonConfig extends RocketComponentConfig {
heightSpinner.setEditor(new SpinnerEditor(heightSpinner)); heightSpinner.setEditor(new SpinnerEditor(heightSpinner));
panel.add(heightSpinner, "growx"); panel.add(heightSpinner, "growx");
panel.add(new UnitSelector(heightModel), "growx"); panel.add(new UnitSelector(heightModel), "growx");
panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap"); panel.add(new BasicSlider(heightModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap para");
} }
{ //// Angular Position: { //// Angular Position:
@ -79,6 +99,9 @@ public class RailButtonConfig extends RocketComponentConfig {
panel.add(new BasicSlider( angleModel.getSliderModel(-Math.PI, Math.PI)), "w 100lp, wrap"); panel.add(new BasicSlider( angleModel.getSliderModel(-Math.PI, Math.PI)), "w 100lp, wrap");
} }
primary.add(panel, "grow, gapright 201p");
panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::][]", ""));
{ //// Position relative to: { //// Position relative to:
panel.add(new JLabel(trans.get("RailBtnCfg.lbl.PosRelativeTo"))); panel.add(new JLabel(trans.get("RailBtnCfg.lbl.PosRelativeTo")));
@ -101,12 +124,8 @@ public class RailButtonConfig extends RocketComponentConfig {
"w 100lp, wrap para"); "w 100lp, wrap para");
} }
primary.add(panel, "grow, gapright 201p");
panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::][]", ""));
//// Instance count //// Instance count
panel.add( instanceablePanel(rbc), "span, wrap"); panel.add(instanceablePanel(rbc), "span, wrap");
//// Material //// Material
panel.add(materialPanel(Material.Type.BULK),"span, wrap"); panel.add(materialPanel(Material.Type.BULK),"span, wrap");

View File

@ -385,7 +385,7 @@ public class RocketComponentConfig extends JPanel {
} }
protected JPanel instanceablePanel( Instanceable inst ){ protected JPanel instanceablePanel( Instanceable inst ){
JPanel panel = new JPanel( new MigLayout("fill")); JPanel panel = new JPanel( new MigLayout("fill, insets 0") );
{ // Instance Count { // Instance Count
panel.add(new JLabel(trans.get("RocketCompCfg.lbl.InstanceCount"))); panel.add(new JLabel(trans.get("RocketCompCfg.lbl.InstanceCount")));
IntegerModel countModel = new IntegerModel(component, "InstanceCount", 1); IntegerModel countModel = new IntegerModel(component, "InstanceCount", 1);

View File

@ -295,26 +295,37 @@ public class ComponentRenderer {
final double ir = r.getInnerDiameter() / 2.0; final double ir = r.getInnerDiameter() / 2.0;
gl.glRotated(r.getAngleOffset()*180/Math.PI -90 , 1, 0, 0); gl.glRotated(r.getAngleOffset()*180/Math.PI -90 , 1, 0, 0);
//Inner Diameter // Base Cylinder
glu.gluCylinder(q, ir, ir, r.getTotalHeight(), LOD, 1); if (r.getBaseHeight() > 0) {
//Bottom Disc
glu.gluCylinder(q, or, or, r.getBaseHeight(), LOD, 1); glu.gluCylinder(q, or, or, r.getBaseHeight(), LOD, 1);
glu.gluQuadricOrientation(q, GLU.GLU_INSIDE); glu.gluQuadricOrientation(q, GLU.GLU_INSIDE);
glu.gluDisk(q, 0, or, LOD, 2); glu.gluDisk(q, 0, or, LOD, 2);
glu.gluQuadricOrientation(q, GLU.GLU_OUTSIDE); glu.gluQuadricOrientation(q, GLU.GLU_OUTSIDE);
gl.glTranslated(0,0,r.getBaseHeight()); gl.glTranslated(0, 0, r.getBaseHeight());
glu.gluDisk(q, 0, or, LOD, 2); glu.gluDisk(q, 0, or, LOD, 2);
} else { // Draw a closing cap if there is no base
glu.gluQuadricOrientation(q, GLU.GLU_INSIDE);
glu.gluDisk(q, 0, ir, LOD, 2);
glu.gluQuadricOrientation(q, GLU.GLU_OUTSIDE);
gl.glTranslated(0, 0, r.getBaseHeight());
}
// Inner Cylinder
glu.gluCylinder(q, ir, ir, r.getInnerHeight(), LOD, 1);
//Upper Disc // Flange Cylinder
gl.glTranslated(0,0,r.getTotalHeight() - r.getFlangeHeight() * 2.0); if (r.getFlangeHeight() > 0) {
gl.glTranslated(0, 0, r.getInnerHeight());
glu.gluCylinder(q, or, or, r.getFlangeHeight(), LOD, 1); glu.gluCylinder(q, or, or, r.getFlangeHeight(), LOD, 1);
glu.gluQuadricOrientation(q, GLU.GLU_INSIDE); glu.gluQuadricOrientation(q, GLU.GLU_INSIDE);
glu.gluDisk(q, 0, or, LOD, 2); glu.gluDisk(q, 0, or, LOD, 2);
glu.gluQuadricOrientation(q, GLU.GLU_OUTSIDE); glu.gluQuadricOrientation(q, GLU.GLU_OUTSIDE);
gl.glTranslated(0,0,r.getFlangeHeight()); gl.glTranslated(0, 0, r.getFlangeHeight());
glu.gluDisk(q, 0, or, LOD, 2); glu.gluDisk(q, 0, or, LOD, 2);
} else { // Draw a closing cap if there is no flange
gl.glTranslated(0, 0, r.getInnerHeight());
glu.gluDisk(q, 0, ir, LOD, 2);
}
} }
} }

View File

@ -29,7 +29,7 @@ public class RailButtonShapes extends RocketComponentShape {
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) { public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
final RailButton btn = (RailButton)component; final RailButton btn = (RailButton)component;
final double baseHeight = btn.getStandoff(); final double baseHeight = btn.getBaseHeight();
final double innerHeight = btn.getInnerHeight(); final double innerHeight = btn.getInnerHeight();
final double flangeHeight = btn.getFlangeHeight(); final double flangeHeight = btn.getFlangeHeight();
@ -53,72 +53,73 @@ public class RailButtonShapes extends RocketComponentShape {
Path2D.Double path = new Path2D.Double(); Path2D.Double path = new Path2D.Double();
Path2D.Double pathInvis = new Path2D.Double(); // Path for the invisible triangles Path2D.Double pathInvis = new Path2D.Double(); // Path for the invisible triangles
{// central pillar {// base cylinder
if (baseHeight > 0) {
final double drawWidth = outerDiameter; final double drawWidth = outerDiameter;
final double drawHeight = outerDiameter*sinr; final double drawHeight = outerDiameter * sinr;
final Point2D.Double center = new Point2D.Double( loc.x, loc.y ); final Point2D.Double center = new Point2D.Double(loc.x, loc.y);
Point2D.Double lowerLeft = new Point2D.Double( center.x - outerRadius, center.y-outerRadius*sinr); Point2D.Double lowerLeft = new Point2D.Double(center.x - outerRadius, center.y - outerRadius * sinr);
path.append( new Ellipse2D.Double( lowerLeft.x, lowerLeft.y, drawWidth, drawHeight), false); path.append(new Ellipse2D.Double(lowerLeft.x, lowerLeft.y, drawWidth, drawHeight), false);
path.append( new Line2D.Double( lowerLeft.x, center.y, lowerLeft.x, (center.y+baseHeightcos) ), false); path.append(new Line2D.Double(lowerLeft.x, center.y, lowerLeft.x, (center.y + baseHeightcos)), false);
path.append( new Line2D.Double( (center.x+outerRadius), center.y, (center.x+outerRadius), (center.y+baseHeightcos) ), false); path.append(new Line2D.Double((center.x + outerRadius), center.y, (center.x + outerRadius), (center.y + baseHeightcos)), false);
path.append( new Ellipse2D.Double( lowerLeft.x, (lowerLeft.y+baseHeightcos), drawWidth, drawHeight), false); path.append(new Ellipse2D.Double(lowerLeft.x, (lowerLeft.y + baseHeightcos), drawWidth, drawHeight), false);
// Invisible rectangle // Invisible rectangle
double y_invis; double y_invis;
if (baseHeightcos >= 0) { if (baseHeightcos >= 0) {
y_invis = center.y; y_invis = center.y;
} } else {
else {
y_invis = center.y + baseHeightcos; y_invis = center.y + baseHeightcos;
} }
pathInvis.append(new Rectangle2D.Double(center.x-outerRadius, y_invis, drawWidth, Math.abs(baseHeightcos)), false); pathInvis.append(new Rectangle2D.Double(center.x - outerRadius, y_invis, drawWidth, Math.abs(baseHeightcos)), false);
}
} }
{// inner flange {// inner cylinder
final double drawWidth = innerDiameter; final double drawWidth = innerDiameter;
final double drawHeight = innerDiameter*sinr; final double drawHeight = innerDiameter * sinr;
final Point2D.Double center = new Point2D.Double( loc.x, loc.y + baseHeightcos); final Point2D.Double center = new Point2D.Double(loc.x, loc.y + baseHeightcos);
final Point2D.Double lowerLeft = new Point2D.Double( center.x - innerRadius, center.y-innerRadius*sinr); final Point2D.Double lowerLeft = new Point2D.Double(center.x - innerRadius, center.y - innerRadius * sinr);
path.append( new Ellipse2D.Double( lowerLeft.x, lowerLeft.y, drawWidth, drawHeight), false); path.append(new Ellipse2D.Double(lowerLeft.x, lowerLeft.y, drawWidth, drawHeight), false);
path.append( new Line2D.Double( lowerLeft.x, center.y, lowerLeft.x, (center.y+innerHeightcos) ), false); path.append(new Line2D.Double(lowerLeft.x, center.y, lowerLeft.x, (center.y + innerHeightcos)), false);
path.append( new Line2D.Double( (center.x+innerRadius), center.y, (center.x+innerRadius), (center.y+innerHeightcos) ), false); path.append(new Line2D.Double((center.x + innerRadius), center.y, (center.x + innerRadius), (center.y + innerHeightcos)), false);
path.append( new Ellipse2D.Double( lowerLeft.x, (lowerLeft.y+innerHeightcos), drawWidth, drawHeight), false); path.append(new Ellipse2D.Double(lowerLeft.x, (lowerLeft.y + innerHeightcos), drawWidth, drawHeight), false);
// Invisible rectangle // Invisible rectangle
double y_invis; double y_invis;
if (innerHeightcos >= 0) { if (innerHeightcos >= 0) {
y_invis = center.y; y_invis = center.y;
} } else {
else {
y_invis = center.y + innerHeightcos; y_invis = center.y + innerHeightcos;
} }
pathInvis.append(new Rectangle2D.Double(center.x-innerRadius, y_invis, drawWidth, Math.abs(innerHeightcos)), false); pathInvis.append(new Rectangle2D.Double(center.x - innerRadius, y_invis, drawWidth, Math.abs(innerHeightcos)), false);
} }
{// outer flange {// flange cylinder
if (flangeHeight > 0) {
final double drawWidth = outerDiameter; final double drawWidth = outerDiameter;
final double drawHeight = outerDiameter*sinr; final double drawHeight = outerDiameter * sinr;
final Point2D.Double center = new Point2D.Double( loc.x, loc.y+baseHeightcos+innerHeightcos); final Point2D.Double center = new Point2D.Double(loc.x, loc.y + baseHeightcos + innerHeightcos);
final Point2D.Double lowerLeft = new Point2D.Double( center.x - outerRadius, center.y-outerRadius*sinr); final Point2D.Double lowerLeft = new Point2D.Double(center.x - outerRadius, center.y - outerRadius * sinr);
path.append( new Ellipse2D.Double( lowerLeft.x, lowerLeft.y, drawWidth, drawHeight), false); path.append(new Ellipse2D.Double(lowerLeft.x, lowerLeft.y, drawWidth, drawHeight), false);
path.append( new Line2D.Double( lowerLeft.x, center.y, lowerLeft.x, (center.y+flangeHeightcos) ), false); path.append(new Line2D.Double(lowerLeft.x, center.y, lowerLeft.x, (center.y + flangeHeightcos)), false);
path.append( new Line2D.Double( (center.x+outerRadius), center.y, (center.x+outerRadius), (center.y+flangeHeightcos) ), false); path.append(new Line2D.Double((center.x + outerRadius), center.y, (center.x + outerRadius), (center.y + flangeHeightcos)), false);
path.append( new Ellipse2D.Double( lowerLeft.x, (lowerLeft.y+flangeHeightcos), drawWidth, drawHeight), false); path.append(new Ellipse2D.Double(lowerLeft.x, (lowerLeft.y + flangeHeightcos), drawWidth, drawHeight), false);
// Invisible rectangle // Invisible rectangle
double y_invis; double y_invis;
if (flangeHeightcos >= 0) { if (flangeHeightcos >= 0) {
y_invis = center.y; y_invis = center.y;
} } else {
else {
y_invis = center.y + flangeHeightcos; y_invis = center.y + flangeHeightcos;
} }
pathInvis.append(new Rectangle2D.Double(center.x-outerRadius, y_invis, drawWidth, Math.abs(flangeHeightcos)), false); pathInvis.append(new Rectangle2D.Double(center.x - outerRadius, y_invis, drawWidth, Math.abs(flangeHeightcos)), false);
}
} }
RocketComponentShape[] shapes = RocketComponentShape.toArray(new Shape[]{ path }, component); RocketComponentShape[] shapes = RocketComponentShape.toArray(new Shape[]{ path }, component);
@ -136,7 +137,7 @@ public class RailButtonShapes extends RocketComponentShape {
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) { public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
final RailButton btn = (RailButton)component; final RailButton btn = (RailButton)component;
final double baseHeight = btn.getStandoff(); final double baseHeight = btn.getBaseHeight();
final double innerHeight = btn.getInnerHeight(); final double innerHeight = btn.getInnerHeight();
final double flangeHeight = btn.getFlangeHeight(); final double flangeHeight = btn.getFlangeHeight();
@ -159,7 +160,9 @@ public class RailButtonShapes extends RocketComponentShape {
Path2D.Double path = new Path2D.Double(); Path2D.Double path = new Path2D.Double();
// base // base
path.append( getRotatedRectangle( loc.z, loc.y, outerRadius, baseHeight, combined_angle_rad), false ); if (baseHeight > 0) {
path.append(getRotatedRectangle(loc.z, loc.y, outerRadius, baseHeight, combined_angle_rad), false);
}
{// inner {// inner
final double delta_r = baseHeight; final double delta_r = baseHeight;
@ -167,11 +170,13 @@ public class RailButtonShapes extends RocketComponentShape {
final double delta_z = delta_r*sinr; final double delta_z = delta_r*sinr;
path.append( getRotatedRectangle( loc.z+delta_z, loc.y+delta_y, innerRadius, innerHeight, combined_angle_rad), false); path.append( getRotatedRectangle( loc.z+delta_z, loc.y+delta_y, innerRadius, innerHeight, combined_angle_rad), false);
} }
{// outer flange {// flange
if (flangeHeight > 0) {
final double delta_r = baseHeight + innerHeight; final double delta_r = baseHeight + innerHeight;
final double delta_y = delta_r*cosr; final double delta_y = delta_r * cosr;
final double delta_z = delta_r*sinr; final double delta_z = delta_r * sinr;
path.append( getRotatedRectangle( loc.z+delta_z, loc.y+delta_y, outerRadius, flangeHeight, combined_angle_rad), false); path.append(getRotatedRectangle(loc.z + delta_z, loc.y + delta_y, outerRadius, flangeHeight, combined_angle_rad), false);
}
} }
return RocketComponentShape.toArray( new Shape[]{ path }, component); return RocketComponentShape.toArray( new Shape[]{ path }, component);