From 2c401c47fcf726095889e89e13b52dbf5560cf56 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Tue, 19 Jul 2022 13:14:44 +0200 Subject: [PATCH 1/4] Implement rail button presets --- core/resources/l10n/messages.properties | 6 +- core/resources/l10n/messages_nl.properties | 2 +- core/resources/l10n/messages_ru.properties | 2 +- .../sf/openrocket/preset/ComponentPreset.java | 35 ++-- .../preset/ComponentPresetFactory.java | 5 +- .../preset/loader/RailButtonLoader.java | 2 +- .../preset/xml/OpenRocketComponentLoader.java | 4 +- .../openrocket/preset/xml/ParachuteDTO.java | 6 +- .../openrocket/preset/xml/RailButtonDTO.java | 88 ++++++---- .../rocketcomponent/ExternalComponent.java | 4 +- .../openrocket/rocketcomponent/Parachute.java | 4 +- .../rocketcomponent/RailButton.java | 60 +++++++ .../legacy_components/RailButton_Database.orc | 153 ++++++++++++++++++ .../gui/preset/PresetEditorDialog.java | 12 +- 14 files changed, 324 insertions(+), 59 deletions(-) create mode 100644 swing/resources-src/datafiles/legacy_components/RailButton_Database.orc diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 7d81f82eb..ad77afbd9 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -2112,19 +2112,23 @@ table.column.AftShoulderDiameter = Aft Shoulder Diameter table.column.ForeShoulderLength = Fore Shoulder Length table.column.ForeShoulderDiameter = Fore Shoulder Diameter table.column.ForeOuterDiameter = Fore Outer Diameter -table.column.StandoffHeight = Standoff Height +table.column.BaseHeight = Base Height table.column.FlangeHeight = Flange Height +table.column.ScrewHeight = Screw Height table.column.Shape = Shape table.column.Material = Material table.column.Finish = Finish table.column.Thickness = Thickness table.column.Filled = Filled table.column.Mass = Mass +table.column.ScrewMass = Screw Mass +table.column.NutMass = Nut Mass table.column.Diameter = Diameter table.column.Sides = Sides table.column.LineCount = Line Count table.column.LineLength = Line Length table.column.LineMaterial = Line Material +table.column.CD = Drag Coefficient ! Edit Decal Dialog EditDecalDialog.title = Edit decal diff --git a/core/resources/l10n/messages_nl.properties b/core/resources/l10n/messages_nl.properties index 78365b1c9..21f98665c 100644 --- a/core/resources/l10n/messages_nl.properties +++ b/core/resources/l10n/messages_nl.properties @@ -2003,7 +2003,7 @@ table.column.AftShoulderDiameter = Achteste Schouderdiameter table.column.ForeShoulderLength = Voorste Schouderlengte table.column.ForeShoulderDiameter = Voorste Schouderdiameter table.column.ForeOuterDiameter = Voorste Buitendiameter -table.column.StandoffHeight = Standoff Hoogte +table.column.BaseHeight = Standoff Hoogte table.column.FlangeHeight = Flens Hoogte table.column.Shape = Vorm table.column.Material = Materiaal diff --git a/core/resources/l10n/messages_ru.properties b/core/resources/l10n/messages_ru.properties index 1688fc775..a7f3195d4 100644 --- a/core/resources/l10n/messages_ru.properties +++ b/core/resources/l10n/messages_ru.properties @@ -2115,7 +2115,7 @@ table.column.AftShoulderDiameter = \u0414\u0438\u0430\u043C\u0435\u0442\u0440 \u table.column.ForeShoulderLength = \u0414\u043B\u0438\u043D\u0430 \u043F\u0435\u0440\u0435\u0434\u043D\u0435\u0439 \u043C\u0443\u0444\u0442\u044B table.column.ForeShoulderDiameter = \u0414\u0438\u0430\u043C\u0435\u0442\u0440 \u043F\u0435\u0440\u0435\u0434\u043D\u0435\u0439 \u043C\u0443\u0444\u0442\u044B table.column.ForeOuterDiameter = \u0412\u043D\u0435\u0448\u043D\u0438\u0439 \u0434\u0438\u0430\u043C\u0435\u0442\u0440 \u043F\u0435\u0440\u0435\u0434\u043D\u0435\u0439 \u043C\u0443\u0444\u0442\u044B -table.column.StandoffHeight = \u0412\u044B\u0441\u043E\u0442\u0430 \u0437\u0430\u0437\u043E\u0440\u0430 +table.column.BaseHeight = \u0412\u044B\u0441\u043E\u0442\u0430 \u0437\u0430\u0437\u043E\u0440\u0430 table.column.FlangeHeight = \u0412\u044B\u0441\u043E\u0442\u0430 \u0444\u043B\u0430\u043D\u0446\u0430 table.column.Shape = \u0424\u043E\u0440\u043C\u0430 table.column.Material = \u041C\u0430\u0442\u0435\u0440\u0438\u0430\u043B diff --git a/core/src/net/sf/openrocket/preset/ComponentPreset.java b/core/src/net/sf/openrocket/preset/ComponentPreset.java index ecc28441a..51e48ec8b 100644 --- a/core/src/net/sf/openrocket/preset/ComponentPreset.java +++ b/core/src/net/sf/openrocket/preset/ComponentPreset.java @@ -129,12 +129,17 @@ public class ComponentPreset implements Comparable, Serializabl ComponentPreset.MANUFACTURER, ComponentPreset.PARTNO, ComponentPreset.DESCRIPTION, - // these are optional / secondary parameters. Probably not necessary to include. - //ComponentPreset.BASE_HEIGHT, - //ComponentPreset.FLANGE_HEIGHT, - //ComponentPreset.INNER_DIAMETER, + ComponentPreset.BASE_HEIGHT, + ComponentPreset.FLANGE_HEIGHT, + //ComponentPreset.SCREW_HEIGHT, // Add this later when we implement screws in the rail button + ComponentPreset.HEIGHT, + ComponentPreset.INNER_DIAMETER, ComponentPreset.OUTER_DIAMETER, - ComponentPreset.HEIGHT }), + ComponentPreset.MASS, + ComponentPreset.SCREW_MASS, + ComponentPreset.NUT_MASS, + ComponentPreset.CD, + ComponentPreset.FINISH }), STREAMER(new TypedKey[] { ComponentPreset.LEGACY, @@ -160,7 +165,7 @@ public class ComponentPreset implements Comparable, Serializabl ComponentPreset.LINE_COUNT, ComponentPreset.LINE_LENGTH, ComponentPreset.LINE_MATERIAL, - ComponentPreset.PARACHUTE_CD, + ComponentPreset.CD, ComponentPreset.PACKED_DIAMETER, ComponentPreset.PACKED_LENGTH }); @@ -206,6 +211,7 @@ public class ComponentPreset implements Comparable, Serializabl public final static TypedKey AFT_SHOULDER_LENGTH = new TypedKey("AftShoulderLength", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey AFT_SHOULDER_DIAMETER = new TypedKey("AftShoulderDiameter", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey AFT_OUTER_DIAMETER = new TypedKey("AftOuterDiameter", Double.class, UnitGroup.UNITS_LENGTH); + public static final TypedKey CD = new TypedKey("DragCoefficient", Double.class, UnitGroup.UNITS_COEFFICIENT); public final static TypedKey SHAPE = new TypedKey("Shape", Shape.class); public final static TypedKey MATERIAL = new TypedKey("Material", Material.class); public final static TypedKey FINISH = new TypedKey("Finish", Finish.class); @@ -214,8 +220,13 @@ public class ComponentPreset implements Comparable, Serializabl public final static TypedKey MASS = new TypedKey("Mass", Double.class, UnitGroup.UNITS_MASS); public final static TypedKey DIAMETER = new TypedKey("Diameter", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey IMAGE = new TypedKey("Image", byte[].class); - public final static TypedKey STANDOFF_HEIGHT = new TypedKey("StandoffHeight", Double.class, UnitGroup.UNITS_LENGTH); + + // RAIL BUTTON SPECIFIC + public final static TypedKey BASE_HEIGHT = new TypedKey("BaseHeight", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey FLANGE_HEIGHT = new TypedKey("FlangeHeight", Double.class, UnitGroup.UNITS_LENGTH); + public final static TypedKey SCREW_HEIGHT = new TypedKey("ScrewHeight", Double.class, UnitGroup.UNITS_LENGTH); + public final static TypedKey SCREW_MASS = new TypedKey("ScrewMass", Double.class, UnitGroup.UNITS_MASS); + public final static TypedKey NUT_MASS = new TypedKey("NutMass", Double.class, UnitGroup.UNITS_MASS); // PARACHUTE SPECIFIC // Parachute Manufacturer declaration see: MANUFACTURER @@ -225,7 +236,7 @@ public class ComponentPreset implements Comparable, Serializabl // Parachute diameter declaration see: DIAMETER public final static TypedKey SPILL_DIA = new TypedKey("SpillDia", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey SURFACE_AREA = new TypedKey("SurfaceArea", Double.class, UnitGroup.UNITS_LENGTH); - public static final TypedKey PARACHUTE_CD = new TypedKey("DragCoefficient", Double.class, UnitGroup.UNITS_COEFFICIENT); + // Parachute canopy material declaration see: MATERIAL public final static TypedKey SIDES = new TypedKey("Sides", Integer.class); public final static TypedKey LINE_COUNT = new TypedKey("LineCount", Integer.class); @@ -251,8 +262,9 @@ public class ComponentPreset implements Comparable, Serializabl AFT_SHOULDER_LENGTH, FORE_SHOULDER_DIAMETER, FORE_SHOULDER_LENGTH, - STANDOFF_HEIGHT, + BASE_HEIGHT, FLANGE_HEIGHT, + SCREW_HEIGHT, SHAPE, THICKNESS, FILLED, @@ -262,6 +274,8 @@ public class ComponentPreset implements Comparable, Serializabl LINE_LENGTH, LINE_MATERIAL, MASS, + SCREW_MASS, + NUT_MASS, FINISH, MATERIAL )); @@ -411,6 +425,9 @@ public class ComponentPreset implements Comparable, Serializabl os.writeDouble(d); } else if (key.getType() == String.class) { String s = (String) value; + if (s == null) { + s = ""; + } os.writeBytes(s); } else if (key.getType() == Manufacturer.class) { String s = ((Manufacturer) value).getSimpleName(); diff --git a/core/src/net/sf/openrocket/preset/ComponentPresetFactory.java b/core/src/net/sf/openrocket/preset/ComponentPresetFactory.java index 77ecc3691..26cb79696 100644 --- a/core/src/net/sf/openrocket/preset/ComponentPresetFactory.java +++ b/core/src/net/sf/openrocket/preset/ComponentPresetFactory.java @@ -113,13 +113,13 @@ public abstract class ComponentPresetFactory { } - private static void makeRailButton(InvalidComponentPresetException exceptions, ComponentPreset preset) throws InvalidComponentPresetException { + private static void makeRailButton(InvalidComponentPresetException exceptions, ComponentPreset preset) { checkRequiredFields(exceptions, preset, HEIGHT); checkRequiredFields(exceptions, preset, OUTER_DIAMETER); checkRequiredFields(exceptions, preset, INNER_DIAMETER); checkRequiredFields(exceptions, preset, FLANGE_HEIGHT); - checkRequiredFields(exceptions, preset, STANDOFF_HEIGHT); + checkRequiredFields(exceptions, preset, BASE_HEIGHT); if (preset.has(MASS)) { double mass = preset.get(MASS); @@ -271,7 +271,6 @@ public abstract class ComponentPresetFactory { if (hasOd) { outerRadius = preset.get(OUTER_DIAMETER) / 2.0; - thickness = 0; if (hasId) { innerRadius = preset.get(INNER_DIAMETER) / 2.0; thickness = outerRadius - innerRadius; diff --git a/core/src/net/sf/openrocket/preset/loader/RailButtonLoader.java b/core/src/net/sf/openrocket/preset/loader/RailButtonLoader.java index 5980ed0c5..7c92b6c75 100644 --- a/core/src/net/sf/openrocket/preset/loader/RailButtonLoader.java +++ b/core/src/net/sf/openrocket/preset/loader/RailButtonLoader.java @@ -13,7 +13,7 @@ public class RailButtonLoader extends BaseComponentLoader { fileColumns.add(new DoubleUnitColumnParser("OD","Units",ComponentPreset.OUTER_DIAMETER)); fileColumns.add(new DoubleUnitColumnParser("Height","Units",ComponentPreset.HEIGHT)); fileColumns.add(new DoubleUnitColumnParser("Flange Height", "Units", ComponentPreset.FLANGE_HEIGHT)); - fileColumns.add(new DoubleUnitColumnParser("Standoff Height", "Units", ComponentPreset.STANDOFF_HEIGHT)); + fileColumns.add(new DoubleUnitColumnParser("Standoff Height", "Units", ComponentPreset.BASE_HEIGHT)); } diff --git a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentLoader.java b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentLoader.java index 9cbeced10..32bfc25d0 100644 --- a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentLoader.java +++ b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentLoader.java @@ -34,9 +34,7 @@ public class OpenRocketComponentLoader implements Loader { presets = (new OpenRocketComponentSaver().unmarshalFromOpenRocketComponent( new InputStreamReader (stream))).asComponentPresets(); log.debug("ComponentPreset file " + filename + " contained " + presets.size() + " presets"); return presets; - } catch (JAXBException e) { - throw new BugException("Unable to parse file: "+ filename, e); - } catch (InvalidComponentPresetException e) { + } catch (JAXBException | InvalidComponentPresetException e) { throw new BugException("Unable to parse file: "+ filename, e); } diff --git a/core/src/net/sf/openrocket/preset/xml/ParachuteDTO.java b/core/src/net/sf/openrocket/preset/xml/ParachuteDTO.java index 6ebd20e86..844c8372e 100644 --- a/core/src/net/sf/openrocket/preset/xml/ParachuteDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/ParachuteDTO.java @@ -146,8 +146,8 @@ public class ParachuteDTO extends BaseComponentDTO { if ( preset.has(ComponentPreset.PACKED_LENGTH)) { setPackedLength(preset.get(ComponentPreset.PACKED_LENGTH)); } - if ( preset.has(ComponentPreset.PARACHUTE_CD)) { - setDragCoefficient(preset.get(ComponentPreset.PARACHUTE_CD)); + if ( preset.has(ComponentPreset.CD)) { + setDragCoefficient(preset.get(ComponentPreset.CD)); } if ( preset.has(ComponentPreset.LINE_MATERIAL)) { setLineMaterial(new AnnotatedMaterialDTO(preset.get(ComponentPreset.LINE_MATERIAL))); @@ -174,7 +174,7 @@ public class ParachuteDTO extends BaseComponentDTO { props.put(ComponentPreset.PACKED_LENGTH, this.getPackedLength()); } if ( this.dragCoefficient != null ) { - props.put(ComponentPreset.PARACHUTE_CD, this.getDragCoefficient()); + props.put(ComponentPreset.CD, this.getDragCoefficient()); } props.put(ComponentPreset.LINE_COUNT, this.getLineCount()); if ( this.lineLength != null ) { diff --git a/core/src/net/sf/openrocket/preset/xml/RailButtonDTO.java b/core/src/net/sf/openrocket/preset/xml/RailButtonDTO.java index aa4f37bdc..fdf025aff 100644 --- a/core/src/net/sf/openrocket/preset/xml/RailButtonDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/RailButtonDTO.java @@ -19,16 +19,22 @@ import java.util.List; @XmlAccessorType(XmlAccessType.FIELD) public class RailButtonDTO extends BaseComponentDTO { - @XmlElement(name = "InsideDiameter") - private AnnotatedLengthDTO insideDiameter; - @XmlElement(name = "OutsideDiameter") - private AnnotatedLengthDTO outsideDiameter; + @XmlElement(name = "InnerDiameter") + private AnnotatedLengthDTO innerDiameter; + @XmlElement(name = "OuterDiameter") + private AnnotatedLengthDTO outerDiameter; @XmlElement(name = "Height") private AnnotatedLengthDTO height; - @XmlElement(name = "StandoffHeight") - private AnnotatedLengthDTO standoffHeight; + @XmlElement(name = "BaseHeight") + private AnnotatedLengthDTO baseHeight; @XmlElement(name = "FlangeHeight") private AnnotatedLengthDTO flangeHeight; + @XmlElement(name = "ScrewHeight") + private AnnotatedLengthDTO screwHeight; + @XmlElement(name = "ScrewMass") + private AnnotatedMassDTO screwMass; + @XmlElement(name = "NutMass") + private AnnotatedMassDTO nutMass; /** * Default constructor. @@ -48,32 +54,35 @@ public class RailButtonDTO extends BaseComponentDTO { setInsideDiameter(preset.get(ComponentPreset.INNER_DIAMETER)); setOutsideDiameter(preset.get(ComponentPreset.OUTER_DIAMETER)); setHeight(preset.get(ComponentPreset.HEIGHT)); - setStandoffHeight(preset.get(ComponentPreset.STANDOFF_HEIGHT)); + setBaseHeight(preset.get(ComponentPreset.BASE_HEIGHT)); setFlangeHeight(preset.get(ComponentPreset.FLANGE_HEIGHT)); + setScrewHeight(preset.get(ComponentPreset.SCREW_HEIGHT)); + setScrewMass(preset.get(ComponentPreset.SCREW_MASS)); + setNutMass(preset.get(ComponentPreset.NUT_MASS)); } - public double getInsideDiameter() { - return insideDiameter.getValue(); + public double getInnerDiameter() { + return innerDiameter.getValue(); } - public void setInsideDiameter( final AnnotatedLengthDTO theLength ) { - insideDiameter = theLength; + public void setInnerDiameter(final AnnotatedLengthDTO theLength ) { + innerDiameter = theLength; } public void setInsideDiameter(final double theId) { - insideDiameter = new AnnotatedLengthDTO(theId); + innerDiameter = new AnnotatedLengthDTO(theId); } - public double getOutsideDiameter() { - return outsideDiameter.getValue(); + public double getOuterDiameter() { + return outerDiameter.getValue(); } - public void setOutsideDiameter(final AnnotatedLengthDTO theOd) { - outsideDiameter = theOd; + public void setOuterDiameter(final AnnotatedLengthDTO theOd) { + outerDiameter = theOd; } public void setOutsideDiameter(final double theOd) { - outsideDiameter = new AnnotatedLengthDTO(theOd); + outerDiameter = new AnnotatedLengthDTO(theOd); } public double getHeight() { @@ -88,16 +97,12 @@ public class RailButtonDTO extends BaseComponentDTO { height = new AnnotatedLengthDTO(theHeight); } - public double getStandoffHeight() { - return standoffHeight.getValue(); + public double getBaseHeight() { + return baseHeight.getValue(); } - public void setStandoffHeight(final AnnotatedLengthDTO theStandoffHeight) { - standoffHeight = theStandoffHeight; - } - - public void setStandoffHeight(final double theStandoffHeight) { - standoffHeight = new AnnotatedLengthDTO(theStandoffHeight); + public void setBaseHeight(final double theBaseHeight) { + baseHeight = new AnnotatedLengthDTO(theBaseHeight); } public double getFlangeHeight() { @@ -112,6 +117,30 @@ public class RailButtonDTO extends BaseComponentDTO { flangeHeight = new AnnotatedLengthDTO(theFlangeHeight); } + public double getScrewHeight() { + return screwHeight.getValue(); + } + + public void setScrewHeight(final double screwHeight) { + this.screwHeight = new AnnotatedLengthDTO(screwHeight); + } + + public double getScrewMass() { + return screwMass.getValue(); + } + + public void setScrewMass(double screwMass) { + this.screwMass = new AnnotatedMassDTO(screwMass); + } + + public double getNutMass() { + return nutMass.getValue(); + } + + public void setNutMass(double nutMass) { + this.nutMass = new AnnotatedMassDTO(nutMass); + } + @Override public ComponentPreset asComponentPreset(Boolean legacy, java.util.List materials) throws InvalidComponentPresetException { return asComponentPreset(legacy, ComponentPreset.Type.RAIL_BUTTON, materials); @@ -121,11 +150,14 @@ public class RailButtonDTO extends BaseComponentDTO { TypedPropertyMap props = new TypedPropertyMap(); props.put(ComponentPreset.LEGACY, legacy); addProps(props, materials); - props.put(ComponentPreset.INNER_DIAMETER, this.getInsideDiameter()); - props.put(ComponentPreset.OUTER_DIAMETER, this.getOutsideDiameter()); + props.put(ComponentPreset.INNER_DIAMETER, this.getInnerDiameter()); + props.put(ComponentPreset.OUTER_DIAMETER, this.getOuterDiameter()); props.put(ComponentPreset.HEIGHT, this.getHeight()); - props.put(ComponentPreset.STANDOFF_HEIGHT, this.getStandoffHeight()); + props.put(ComponentPreset.BASE_HEIGHT, this.getBaseHeight()); props.put(ComponentPreset.FLANGE_HEIGHT, this.getFlangeHeight()); + props.put(ComponentPreset.SCREW_HEIGHT, this.getScrewHeight()); + props.put(ComponentPreset.SCREW_MASS, this.getScrewMass()); + props.put(ComponentPreset.NUT_MASS, this.getNutMass()); props.put(ComponentPreset.TYPE, type); return ComponentPresetFactory.create(props); diff --git a/core/src/net/sf/openrocket/rocketcomponent/ExternalComponent.java b/core/src/net/sf/openrocket/rocketcomponent/ExternalComponent.java index c97a04ce7..ac2aeaf96 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/ExternalComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/ExternalComponent.java @@ -144,7 +144,9 @@ public abstract class ExternalComponent extends RocketComponent { protected void loadFromPreset(ComponentPreset preset) { super.loadFromPreset(preset); - // Surface finish is left unchanged + if (preset.has(ComponentPreset.FINISH)) { + setFinish(preset.get(ComponentPreset.FINISH)); + } if (preset.has(ComponentPreset.MATERIAL)) { Material mat = preset.get(ComponentPreset.MATERIAL); diff --git a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java index 28174f894..8a2fbf43b 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java @@ -178,9 +178,9 @@ public class Parachute extends RecoveryDevice { this.diameter = DEFAULT_DIAMETER; } // // Set preset parachute drag coefficient - if ((preset.has(ComponentPreset.PARACHUTE_CD)) && preset.get(ComponentPreset.PARACHUTE_CD) > 0){ + if ((preset.has(ComponentPreset.CD)) && preset.get(ComponentPreset.CD) > 0){ cdAutomatic = false; - cd = preset.get(ComponentPreset.PARACHUTE_CD); + cd = preset.get(ComponentPreset.CD); } else { cdAutomatic = true; cd = Parachute.DEFAULT_CD; diff --git a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java index a5b0e08fa..f76ee3e87 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java @@ -51,6 +51,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, protected double innerDiameter_m; protected double flangeHeight_m; protected double standoff_m; + protected double screwHeight_m; // This has no effect at the moment; is for future use. protected final static double MINIMUM_STANDOFF= 0.001; @@ -90,6 +91,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setStandoff( _standoff); this.setInstanceSeparation( od*2); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); + this.screwHeight_m = 0; 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 } @@ -149,6 +151,10 @@ public class RailButton extends ExternalComponent implements AnglePositionable, public double getFlangeHeight() { return this.flangeHeight_m; } + + public double getScrewHeight() { + return this.screwHeight_m; + } public void setStandoff(double newStandoff){ @@ -161,6 +167,16 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.standoff_m = Math.max( newStandoff, RailButton.MINIMUM_STANDOFF ); } + public void setScrewHeight(double height) { + for (RocketComponent listener : configListeners) { + if (listener instanceof RailButton) { + ((RailButton) listener).setScrewHeight(height); + } + } + + this.screwHeight_m = Math.max(height, 0); + } + public void setInnerDiameter(double newID ){ for (RocketComponent listener : configListeners) { if (listener instanceof RailButton) { @@ -417,4 +433,48 @@ public class RailButton extends ExternalComponent implements AnglePositionable, return false; } + @Override + protected void loadFromPreset(ComponentPreset preset) { + super.loadFromPreset(preset); + if (preset.has(ComponentPreset.OUTER_DIAMETER)) { + this.outerDiameter_m = preset.get(ComponentPreset.OUTER_DIAMETER); + } + if (preset.has(ComponentPreset.INNER_DIAMETER)) { + this.innerDiameter_m = preset.get(ComponentPreset.INNER_DIAMETER); + } + if (preset.has(ComponentPreset.HEIGHT)) { + this.totalHeight_m = preset.get(ComponentPreset.HEIGHT); + } + if (preset.has(ComponentPreset.FLANGE_HEIGHT)) { + this.flangeHeight_m = preset.get(ComponentPreset.FLANGE_HEIGHT); + } + if (preset.has(ComponentPreset.BASE_HEIGHT)) { + this.standoff_m = preset.get(ComponentPreset.BASE_HEIGHT); + } + if (preset.has(ComponentPreset.CD) && preset.get(ComponentPreset.CD) > 0) { + setCDOverridden(true); + setOverrideCD(preset.get(ComponentPreset.CD)); + } + + double totalMass = 0; + boolean massOverridden = false; + if (preset.has(ComponentPreset.MASS)) { + massOverridden = true; + totalMass += preset.get(ComponentPreset.MASS); + } + if (preset.has(ComponentPreset.SCREW_MASS)) { + massOverridden = true; + totalMass += preset.get(ComponentPreset.SCREW_MASS); + } + if (preset.has(ComponentPreset.NUT_MASS)) { + massOverridden = true; + totalMass += preset.get(ComponentPreset.NUT_MASS); + } + if (massOverridden) { + setMassOverridden(true); + setOverrideMass(totalMass); + } + + fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); + } } diff --git a/swing/resources-src/datafiles/legacy_components/RailButton_Database.orc b/swing/resources-src/datafiles/legacy_components/RailButton_Database.orc new file mode 100644 index 000000000..bca582abd --- /dev/null +++ b/swing/resources-src/datafiles/legacy_components/RailButton_Database.orc @@ -0,0 +1,153 @@ + + + + + 0.1 + + + + + Delrin + 1420 + BULK + + + + Nylon + 1150 + BULK + + + + + + + + Binder Design-Rail Button Supply House + Std 1010 RB + Standard 1010 Rail Button, Countersunk 8-32 Screw, and T-Nut + Delrin + Polished + 0.4375 + 0.2285 + 0.2975 + 0.0730 + 0.0730 + 0.0000 + + 0.445 + 1.395 + 1.025 + + + + Binder Design-Rail Button Supply House + Std 1515 RB + Standard 1515 Rail Button, Countersunk 10-32 Screw, and T-Nut + Delrin + Polished + 0.6200 + 0.2995 + .4495 + 0.125 + 0.125 + 0.0000 + + 1.465 + 3.365 + 2.675 + + + + Rail-Buttons.com + RB-Micro + 2 Piece Micro Rail Button with 2-56 Screw (10mm Rail) + Nylon + Polished + .1650 + .1195 + 0.1595 + 0.041 + 0.0000 + 0.0465 + + 0.01 + 0.04 + + + + + Rail-Buttons.com + 1PMB + 1 Piece Mini Rail Button with Countersunk 6-32 Screw + Delrin + Polished + .249 + .193 + 0.205 + 0.0380 + 0.0380 + 0.0000 + + 0.090 + 0.415 + + + + + Rail-Buttons.com + RB-10-D + 3 Piece 1010 Rail Button with 8-32 Screw + Delrin + Polished + .278 + .154 + 0.270 + 0.060 + 0.060 + 0.115 + + 0.305 + 1.715 + + + + + Rail-Buttons.com + 1P1010DLX + 1 Piece 1010 Rail Button with Countersunk 8-32 Screw + Delrin + Polished + .3725 + .2480 + 0.305 + 0.078 + 0.078 + 0.0000 + + 0.320 + 1.235 + + + + + Rail-Buttons.com + RB1515S + 1 Piece 1515 Rail Button, Countersunk 10-32 Screw, and T-Nut + Delrin + Polished + 0.49 + 0.29 + 0.56 + 0.1875 + 0.1875 + 0.0000 + + 1.355 + 2.720 + + + + + + diff --git a/swing/src/net/sf/openrocket/gui/preset/PresetEditorDialog.java b/swing/src/net/sf/openrocket/gui/preset/PresetEditorDialog.java index 1aad92e50..788884047 100644 --- a/swing/src/net/sf/openrocket/gui/preset/PresetEditorDialog.java +++ b/swing/src/net/sf/openrocket/gui/preset/PresetEditorDialog.java @@ -1582,8 +1582,8 @@ public class PresetEditorDialog extends JDialog implements ItemListener { rbHeight.setValue(preset.get(ComponentPreset.HEIGHT)); rbHeight.setCurrentUnit(UnitGroup.UNITS_LENGTH.getDefaultUnit()); } - if (preset.has(ComponentPreset.STANDOFF_HEIGHT)) { - rbStandoffHeight.setValue(preset.get(ComponentPreset.STANDOFF_HEIGHT)); + if (preset.has(ComponentPreset.BASE_HEIGHT)) { + rbStandoffHeight.setValue(preset.get(ComponentPreset.BASE_HEIGHT)); rbStandoffHeight.setCurrentUnit(UnitGroup.UNITS_LENGTH.getDefaultUnit()); } if (preset.has(ComponentPreset.FLANGE_HEIGHT)) { @@ -1610,8 +1610,8 @@ public class PresetEditorDialog extends JDialog implements ItemListener { pcDiameter.setValue(preset.get(ComponentPreset.DIAMETER)); pcDiameter.setCurrentUnit(UnitGroup.UNITS_LENGTH.getDefaultUnit()); } - if (preset.has(ComponentPreset.PARACHUTE_CD)) { - pcDragCoefficient.setValue(preset.get(ComponentPreset.PARACHUTE_CD)); + if (preset.has(ComponentPreset.CD)) { + pcDragCoefficient.setValue(preset.get(ComponentPreset.CD)); pcDragCoefficient.setCurrentUnit(UnitGroup.UNITS_COEFFICIENT.getDefaultUnit()); } setMaterial(materialChooser, preset, matHolder, Material.Type.SURFACE, ComponentPreset.MATERIAL); @@ -2132,7 +2132,7 @@ public class PresetEditorDialog extends JDialog implements ItemListener { props.put(ComponentPreset.TYPE, ComponentPreset.Type.RAIL_BUTTON); props.put(ComponentPreset.OUTER_DIAMETER, rbOuterDia.getValue()); props.put(ComponentPreset.INNER_DIAMETER, rbInnerDia.getValue()); - props.put(ComponentPreset.STANDOFF_HEIGHT, rbStandoffHeight.getValue()); + props.put(ComponentPreset.BASE_HEIGHT, rbStandoffHeight.getValue()); props.put(ComponentPreset.FLANGE_HEIGHT, rbFlangeHeight.getValue()); props.put(ComponentPreset.DESCRIPTION, rbDescTextField.getText()); props.put(ComponentPreset.PARTNO, rbPartNoTextField.getText()); @@ -2179,7 +2179,7 @@ public class PresetEditorDialog extends JDialog implements ItemListener { props.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer(mfgTextField.getText())); props.put(ComponentPreset.PARTNO, pcPartNoTextField.getText()); props.put(ComponentPreset.DESCRIPTION, pcDescTextField.getText()); - props.put(ComponentPreset.PARACHUTE_CD, pcDragCoefficient.getValue()); + props.put(ComponentPreset.CD, pcDragCoefficient.getValue()); Material material = (Material) materialChooser.getSelectedItem(); if (material != null) { props.put(ComponentPreset.MATERIAL, material); From 57ee3bb177fd9eb388ac0dbf9112615aeda6ccb7 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Tue, 19 Jul 2022 13:27:09 +0200 Subject: [PATCH 2/4] Clear rail button presets after change --- .../net/sf/openrocket/rocketcomponent/RailButton.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java index a93b562a4..794e639f1 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java @@ -160,6 +160,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.baseHeight_m = Math.max(newBaseHeight, 0); this.baseHeight_m = Math.min(this.baseHeight_m, this.totalHeight_m - this.flangeHeight_m); + clearPreset(); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); } @@ -172,6 +173,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.flangeHeight_m = Math.max(newFlangeHeight, 0); this.flangeHeight_m = Math.min(this.flangeHeight_m, this.totalHeight_m - this.baseHeight_m); + clearPreset(); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); } @@ -183,6 +185,8 @@ public class RailButton extends ExternalComponent implements AnglePositionable, } this.screwHeight_m = Math.max(height, 0); + clearPreset(); + fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); } public void setInnerDiameter(double newID ){ @@ -193,6 +197,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, } this.innerDiameter_m = Math.min(newID, this.outerDiameter_m); + clearPreset(); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); } @@ -207,6 +212,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.outerDiameter_m = newOD; setInnerDiameter(this.innerDiameter_m); + clearPreset(); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); } @@ -219,6 +225,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.totalHeight_m = Math.max(newHeight, this.flangeHeight_m + this.baseHeight_m); + clearPreset(); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); } @@ -449,7 +456,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.flangeHeight_m = preset.get(ComponentPreset.FLANGE_HEIGHT); } if (preset.has(ComponentPreset.BASE_HEIGHT)) { - this.standoff_m = preset.get(ComponentPreset.BASE_HEIGHT); + this.baseHeight_m = preset.get(ComponentPreset.BASE_HEIGHT); } if (preset.has(ComponentPreset.CD) && preset.get(ComponentPreset.CD) > 0) { setCDOverridden(true); From 11f5e4b09921f41b5f1c609f683309f5266b5fca Mon Sep 17 00:00:00 2001 From: SiboVG Date: Tue, 19 Jul 2022 13:29:16 +0200 Subject: [PATCH 3/4] Change instance separation distance to better default --- .../openrocket/gui/configdialog/RocketComponentConfig.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java index 30f169bf9..9ffc91f97 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java @@ -369,7 +369,11 @@ public class RocketComponentConfig extends JPanel { separationSpinner.setEditor(new SpinnerEditor(separationSpinner)); panel.add(separationSpinner, "growx"); panel.add(new UnitSelector(separationModel), "growx"); - panel.add(new BasicSlider(separationModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap para"); + double maxSeparationDistance = 0.1; + if (component.getParent() != null && component.getParent().getLength() > 0) { + maxSeparationDistance = component.getParent().getLength(); + } + panel.add(new BasicSlider(separationModel.getSliderModel(0, 0.001, maxSeparationDistance)), "w 100lp, wrap para"); } return panel; } From e1e3f89041b51ba96a3cad7e4d8928a516740194 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Tue, 19 Jul 2022 19:29:58 +0200 Subject: [PATCH 4/4] Don't include finish --- core/src/net/sf/openrocket/preset/ComponentPreset.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/net/sf/openrocket/preset/ComponentPreset.java b/core/src/net/sf/openrocket/preset/ComponentPreset.java index 51e48ec8b..b92c4fcaa 100644 --- a/core/src/net/sf/openrocket/preset/ComponentPreset.java +++ b/core/src/net/sf/openrocket/preset/ComponentPreset.java @@ -138,8 +138,7 @@ public class ComponentPreset implements Comparable, Serializabl ComponentPreset.MASS, ComponentPreset.SCREW_MASS, ComponentPreset.NUT_MASS, - ComponentPreset.CD, - ComponentPreset.FINISH }), + ComponentPreset.CD }), STREAMER(new TypedKey[] { ComponentPreset.LEGACY,