Fin fillet UI complete, radius and material are saved to file and reloaded.

This commit is contained in:
Craig Earls 2014-12-27 20:11:09 -08:00
parent 90480faa24
commit bc28fc58c5
17 changed files with 211 additions and 99 deletions

View File

@ -1097,6 +1097,13 @@ TrapezoidFinSetCfg.lbl.plus = plus
TrapezoidFinSetCfg.tab.General = General
TrapezoidFinSetCfg.tab.Generalproperties = General properties
! Fin Fillets
FinSetCfg.lbl.Finfilletmaterial = Fillet material:
FinSetCfg.lbl.Filletradius = Fillet radius:
FinsetCfg.ttip.Finfillets1 = <HTML>Adds the predicted mass of fin fillets to the root of the fins.<br>
FinsetCfg.ttip.Finfillets2 = Assumes the fillet is concave and tangent to the body tube and fin.<br>
FinsetCfg.ttip.Finfillets3 = Zero radius will give no fillet.
! StorageOptionChooser
StorageOptChooser.lbl.Simdatatostore = Simulated data to store:
StorageOptChooser.rdbut.Allsimdata = All simulated data

View File

@ -207,7 +207,11 @@ class DocumentConfig {
setters.put("FinSet:tablength", new DoubleSetter(
Reflection.findMethod(FinSet.class, "setTabLength", double.class)));
setters.put("FinSet:tabposition", new FinTabPositionSetter());
setters.put("FinSet:filletradius", new DoubleSetter(
Reflection.findMethod(FinSet.class, "setFilletRadius", double.class)));
setters.put("FinSet:filletmaterial", new MaterialSetter(
Reflection.findMethod(FinSet.class, "setFilletMaterial", Material.class),
Material.Type.BULK));
// TrapezoidFinSet
setters.put("TrapezoidFinSet:rootchord", new DoubleSetter(
Reflection.findMethod(TrapezoidFinSet.class, "setRootChord", double.class)));

View File

@ -30,6 +30,9 @@ public class FinSetSaver extends ExternalComponentSaver {
fins.getTabShift() + "</tabposition>");
}
elements.add("<filletradius>" + fins.getFilletRadius() + "</filletradius>");
elements.add(materialParam("filletmaterial", fins.getFilletMaterial()));
}
}

View File

@ -5,6 +5,7 @@ import java.util.Collection;
import java.util.List;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.ArrayUtils;
import net.sf.openrocket.util.Coordinate;
@ -15,6 +16,7 @@ import net.sf.openrocket.util.Transformation;
public abstract class FinSet extends ExternalComponent {
private static final Translator trans = Application.getTranslator();
/**
* Maximum allowed cant of fins.
*/
@ -87,7 +89,7 @@ public abstract class FinSet extends ExternalComponent {
*/
protected Transformation baseRotation = Transformation.rotate_x(rotation);
/**
* Cant angle of fins.
*/
@ -96,19 +98,19 @@ public abstract class FinSet extends ExternalComponent {
/* Cached value: */
private Transformation cantRotation = null;
/**
* Thickness of the fins.
*/
protected double thickness = 0.003;
/**
* The cross-section shape of the fins.
*/
protected CrossSection crossSection = CrossSection.SQUARE;
/*
* Fin tab properties.
*/
@ -117,7 +119,13 @@ public abstract class FinSet extends ExternalComponent {
private double tabShift = 0;
private TabRelativePosition tabRelativePosition = TabRelativePosition.CENTER;
/*
* Fin fillet properties
*/
protected Material filletMaterial = null;
protected double filletRadius = 0;
// Cached fin area & CG. Validity of both must be checked using finArea!
// Fin area does not include fin tabs, CG does.
private double finArea = -1;
@ -132,10 +140,11 @@ public abstract class FinSet extends ExternalComponent {
*/
public FinSet() {
super(RocketComponent.Position.BOTTOM);
this.filletMaterial = Application.getPreferences().getDefaultComponentMaterial(this.getClass(), Material.Type.BULK);
}
/**
* Return the number of fins in the set.
* @return The number of fins.
@ -190,7 +199,7 @@ public abstract class FinSet extends ExternalComponent {
}
public double getCantAngle() {
return cantAngle;
}
@ -219,7 +228,7 @@ public abstract class FinSet extends ExternalComponent {
}
public double getThickness() {
return thickness;
}
@ -244,9 +253,9 @@ public abstract class FinSet extends ExternalComponent {
}
@Override
public void setRelativePosition(RocketComponent.Position position) {
super.setRelativePosition(position);
@ -261,8 +270,8 @@ public abstract class FinSet extends ExternalComponent {
}
public double getTabHeight() {
return tabHeight;
}
@ -307,7 +316,7 @@ public abstract class FinSet extends ExternalComponent {
if (this.tabRelativePosition == position)
return;
double front = getTabFrontEdge();
switch (position) {
case FRONT:
@ -369,8 +378,8 @@ public abstract class FinSet extends ExternalComponent {
}
/////////// Calculation methods ///////////
/**
@ -401,7 +410,7 @@ public abstract class FinSet extends ExternalComponent {
}
@Override
public double getComponentVolume() {
return fins * (getFinArea() + tabHeight * tabLength) * thickness *
@ -594,7 +603,7 @@ public abstract class FinSet extends ExternalComponent {
}
@Override
public void componentChanged(ComponentChangeEvent e) {
if (e.isAerodynamicChange()) {
@ -641,8 +650,8 @@ public abstract class FinSet extends ExternalComponent {
}
/**
* Return a list of coordinates defining the geometry of a single fin.
* The coordinates are the XY-coordinates of points defining the shape of a single fin,
@ -686,12 +695,12 @@ public abstract class FinSet extends ExternalComponent {
points[n++] = new Coordinate(x1, y);
if (add1)
points[n++] = new Coordinate(x1, 0);
return points;
}
/**
* Get the span of a single fin. That is, the length from the root to the tip of the fin.
* @return Span of a single fin.
@ -717,4 +726,38 @@ public abstract class FinSet extends ExternalComponent {
return super.copyFrom(c);
}
/*
* Handle fin fillet mass properties
*/
public Material getFilletMaterial() {
return filletMaterial;
}
public void setFilletMaterial(Material mat) {
if (mat.getType() != Material.Type.BULK) {
throw new IllegalArgumentException("ExternalComponent requires a bulk material" +
" type=" + mat.getType());
}
if (filletMaterial.equals(mat))
return;
filletMaterial = mat;
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
}
public double getFilletRadius() {
return filletRadius;
}
public void setFilletRadius(double r) {
if (MathUtil.equals(filletRadius, r))
return;
filletRadius = r;
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
}
}

View File

@ -25,9 +25,9 @@ public class MaterialModel extends AbstractListModel implements
private final String custom;
private final Component parentComponent;
private final Component parentUIComponent;
private final RocketComponent component;
private final RocketComponent rocketComponent;
private final Material.Type type;
private final Database<Material> database;
@ -44,8 +44,8 @@ public class MaterialModel extends AbstractListModel implements
public MaterialModel(Component parent, RocketComponent component, Material.Type type,
String name) {
this.parentComponent = parent;
this.component = component;
this.parentUIComponent = parent;
this.rocketComponent = component;
this.type = type;
this.custom = trans.get ("Material.CUSTOM");
@ -81,7 +81,7 @@ public class MaterialModel extends AbstractListModel implements
@Override
public Object getSelectedItem() {
return getMethod.invoke(component);
return getMethod.invoke(rocketComponent);
}
@Override
@ -98,7 +98,7 @@ public class MaterialModel extends AbstractListModel implements
@Override
public void run() {
CustomMaterialDialog dialog = new CustomMaterialDialog(
SwingUtilities.getWindowAncestor(parentComponent),
SwingUtilities.getWindowAncestor(parentUIComponent),
(Material) getSelectedItem(), true,
//// Define custom material
trans.get("MaterialModel.title.Defcustmat"));
@ -109,7 +109,7 @@ public class MaterialModel extends AbstractListModel implements
return;
Material material = dialog.getMaterial();
setMethod.invoke(component, material);
setMethod.invoke(rocketComponent, material);
if (dialog.isAddSelected()) {
database.add(material);
@ -119,7 +119,7 @@ public class MaterialModel extends AbstractListModel implements
} else if (item instanceof Material) {
setMethod.invoke(component, item);
setMethod.invoke(rocketComponent, item);
} else {
throw new IllegalArgumentException("Illegal item class " + item.getClass() +

View File

@ -98,7 +98,7 @@ public class BodyTubeConfig extends RocketComponentConfig {
panel.add(check, "skip, span 2, wrap");
//// Material
panel.add(materialPanel(new JPanel(new MigLayout()), Material.Type.BULK),
panel.add(materialPanel(Material.Type.BULK),
"cell 4 0, gapleft paragraph, aligny 0%, spany");
//// General and General properties

View File

@ -170,9 +170,10 @@ public class EllipticalFinSetConfig extends FinSetConfig {
//// Material
materialPanel(panel, Material.Type.BULK);
panel.add(materialPanel(Material.Type.BULK), "span, wrap");
panel.add(filletMaterialPanel(), "span, wrap");

View File

@ -1,16 +1,34 @@
package net.sf.openrocket.gui.configdialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SwingUtilities;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.SpinnerEditor;
import net.sf.openrocket.gui.adaptors.DoubleModel;
import net.sf.openrocket.gui.adaptors.EnumModel;
import net.sf.openrocket.gui.adaptors.MaterialModel;
import net.sf.openrocket.gui.components.BasicSlider;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.components.StyledLabel.Style;
import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.Markers;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.CenteringRing;
import net.sf.openrocket.rocketcomponent.Coaxial;
import net.sf.openrocket.rocketcomponent.FinSet;
@ -20,19 +38,9 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup;
import javax.swing.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
public abstract class FinSetConfig extends RocketComponentConfig {
private static final Logger log = LoggerFactory.getLogger(FinSetConfig.class);
@ -469,4 +477,40 @@ public abstract class FinSetConfig extends RocketComponentConfig {
return positionFromTop;
}
}
protected JPanel filletMaterialPanel(){
JPanel filletPanel=new JPanel(new MigLayout("", "[][65lp::][30lp::]"));
String tip = trans.get("FinsetCfg.ttip.Finfillets1") +
trans.get("FinsetCfg.ttip.Finfillets2") +
trans.get("FinsetCfg.ttip.Finfillets3");
filletPanel.setBorder(BorderFactory.createTitledBorder("Root Fillets"));
filletPanel.add(new JLabel(trans.get("FinSetCfg.lbl.Filletradius")));
DoubleModel m = new DoubleModel(component, "FilletRadius", UnitGroup.UNITS_LENGTH, 0);
JSpinner spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin));
spin.setToolTipText(tip);
filletPanel.add(spin, "growx, w 40");
UnitSelector us = new UnitSelector(m);
filletPanel.add(us, "growx");
us.setToolTipText(tip);
BasicSlider bs =new BasicSlider(m.getSliderModel(0, 10));
filletPanel.add(bs, "w 100lp, wrap para");
bs.setToolTipText(tip);
JLabel label = new JLabel(trans.get("FinSetCfg.lbl.Finfilletmaterial"));
label.setToolTipText(tip);
//// The component material affects the weight of the component.
label.setToolTipText(trans.get("RocketCompCfg.lbl.ttip.componentmaterialaffects"));
filletPanel.add(label, "spanx 4, wrap rel");
JComboBox combo = new JComboBox(new MaterialModel(filletPanel, component, Material.Type.BULK, "FilletMaterial"));
//// The component material affects the weight of the component.
combo.setToolTipText(trans.get("RocketCompCfg.combo.ttip.componentmaterialaffects"));
filletPanel.add(combo, "spanx 4, growx, wrap paragraph");
filletPanel.setToolTipText(tip);
return filletPanel;
}
}

View File

@ -24,9 +24,6 @@ import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.SpinnerEditor;
@ -55,6 +52,9 @@ import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.Coordinate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FreeformFinSetConfig extends FinSetConfig {
private static final Logger log = LoggerFactory.getLogger(FreeformFinSetConfig.class);
@ -187,9 +187,10 @@ public class FreeformFinSetConfig extends FinSetConfig {
//// Material
materialPanel(panel, Material.Type.BULK);
panel.add(materialPanel(Material.Type.BULK), "span, wrap");
panel.add(filletMaterialPanel(), "span, wrap");
mainPanel.add(panel, "aligny 20%");

View File

@ -168,7 +168,7 @@ public class InnerTubeConfig extends RocketComponentConfig {
"w 100lp, wrap");
//// Material
panel.add(materialPanel(new JPanel(new MigLayout()), Material.Type.BULK),
panel.add(materialPanel(Material.Type.BULK),
"cell 4 0, gapleft paragraph, aligny 0%, spany");
tabbedPane.insertTab(trans.get("ThicknessRingCompCfg.tab.General"), null, panel,

View File

@ -140,7 +140,7 @@ public class LaunchLugConfig extends RocketComponentConfig {
//// Material
materialPanel(panel, Material.Type.BULK);
panel.add(materialPanel( Material.Type.BULK), "span, wrap");
primary.add(panel, "grow");

View File

@ -155,7 +155,7 @@ public class NoseConeConfig extends RocketComponentConfig {
//// Material
materialPanel(panel2, Material.Type.BULK);
panel2.add(materialPanel( Material.Type.BULK), "span, wrap");
panel.add(panel2, "cell 4 0, gapleft paragraph, aligny 0%, spany");

View File

@ -152,7 +152,7 @@ public class RingComponentConfig extends RocketComponentConfig {
//// Material
JPanel sub = materialPanel(new JPanel(new MigLayout()), Material.Type.BULK);
JPanel sub = materialPanel( Material.Type.BULK);
if (component instanceof EngineBlock) {
final DescriptionArea desc = new DescriptionArea(6);

View File

@ -196,24 +196,34 @@ public class RocketComponentConfig extends JPanel {
}
protected JPanel materialPanel(JPanel panel, Material.Type type) {
protected JPanel materialPanel(Material.Type type) {
////Component material: and Component finish:
return materialPanel(panel, type, trans.get("RocketCompCfg.lbl.Componentmaterial"),
trans.get("RocketCompCfg.lbl.Componentfinish"));
return materialPanel(type,
trans.get("RocketCompCfg.lbl.Componentmaterial"),
trans.get("RocketCompCfg.lbl.Componentfinish"),
"Material");
}
protected JPanel materialPanel(JPanel panel, Material.Type type,
String materialString, String finishString) {
protected JPanel materialPanel(Material.Type type, String partName){
return materialPanel(type, trans.get("RocketCompCfg.lbl.Componentmaterial"),
trans.get("RocketCompCfg.lbl.Componentfinish"), partName);
}
protected JPanel materialPanel(Material.Type type,
String materialString,
String finishString,
String partName) {
JLabel label = new JLabel(materialString);
JPanel subPanel = new JPanel(new MigLayout());
JLabel label = new JLabel(materialString);
//// The component material affects the weight of the component.
label.setToolTipText(trans.get("RocketCompCfg.lbl.ttip.componentmaterialaffects"));
panel.add(label, "spanx 4, wrap rel");
subPanel.add(label, "spanx 4, wrap rel");
JComboBox combo = new JComboBox(new MaterialModel(panel, component, type));
JComboBox combo = new JComboBox(new MaterialModel(subPanel, component, type, partName));
//// The component material affects the weight of the component.
combo.setToolTipText(trans.get("RocketCompCfg.combo.ttip.componentmaterialaffects"));
panel.add(combo, "spanx 4, growx, wrap paragraph");
subPanel.add(combo, "spanx 4, growx, wrap paragraph");
if (component instanceof ExternalComponent) {
@ -223,11 +233,11 @@ public class RocketComponentConfig extends JPanel {
//// The value indicated is the average roughness height of the surface.
+ trans.get("RocketCompCfg.lbl.longA2");
label.setToolTipText(tip);
panel.add(label, "spanx 4, wmin 220lp, wrap rel");
subPanel.add(label, "spanx 4, wmin 220lp, wrap rel");
combo = new JComboBox(new EnumModel<ExternalComponent.Finish>(component, "Finish"));
combo.setToolTipText(tip);
panel.add(combo, "spanx 4, growx, split");
subPanel.add(combo, "spanx 4, growx, split");
//// Set for all
JButton button = new JButton(trans.get("RocketCompCfg.but.Setforall"));
@ -253,10 +263,9 @@ public class RocketComponentConfig extends JPanel {
}
}
});
panel.add(button, "wrap paragraph");
subPanel.add(button, "wrap paragraph");
}
return panel;
return subPanel;
}

View File

@ -49,7 +49,7 @@ public class ShockCordConfig extends RocketComponentConfig {
// Material
//// Shock cord material:
materialPanel(panel, Material.Type.LINE, trans.get("ShockCordCfg.lbl.Shockcordmaterial"), null);
panel.add(materialPanel(Material.Type.LINE, trans.get("ShockCordCfg.lbl.Shockcordmaterial"), null, "Material"), "span, wrap");

View File

@ -185,7 +185,7 @@ public class TransitionConfig extends RocketComponentConfig {
//// Material
materialPanel(panel2, Material.Type.BULK);
panel2.add(materialPanel(Material.Type.BULK), "span, wrap");
panel.add(panel2, "cell 4 0, gapleft paragraph, aligny 0%, spany");
//// General and General properties

View File

@ -163,6 +163,34 @@ public class TrapezoidFinSetConfig extends FinSetConfig {
"w 100lp, wrap paragraph");
//// Position
//// Position relative to:
panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Posrelativeto")));
combo = new JComboBox(
new EnumModel<RocketComponent.Position>(component, "RelativePosition",
new RocketComponent.Position[] {
RocketComponent.Position.TOP,
RocketComponent.Position.MIDDLE,
RocketComponent.Position.BOTTOM,
RocketComponent.Position.ABSOLUTE
}));
panel.add(combo, "spanx, growx, wrap");
//// plus
panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.plus")), "right");
m = new DoubleModel(component, "PositionValue", UnitGroup.UNITS_LENGTH);
spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin));
panel.add(spin, "growx");
panel.add(new UnitSelector(m), "growx");
panel.add(new BasicSlider(m.getSliderModel(
new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
new DoubleModel(component.getParent(), "Length"))),
"w 100lp, wrap para");
@ -196,43 +224,15 @@ public class TrapezoidFinSetConfig extends FinSetConfig {
panel.add(new BasicSlider(m.getSliderModel(0, 0.01)), "w 100lp, wrap para");
//// Position
//// Position relative to:
panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Posrelativeto")));
combo = new JComboBox(
new EnumModel<RocketComponent.Position>(component, "RelativePosition",
new RocketComponent.Position[] {
RocketComponent.Position.TOP,
RocketComponent.Position.MIDDLE,
RocketComponent.Position.BOTTOM,
RocketComponent.Position.ABSOLUTE
}));
panel.add(combo, "spanx, growx, wrap");
//// plus
panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.plus")), "right");
m = new DoubleModel(component, "PositionValue", UnitGroup.UNITS_LENGTH);
spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin));
panel.add(spin, "growx");
panel.add(new UnitSelector(m), "growx");
panel.add(new BasicSlider(m.getSliderModel(
new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
new DoubleModel(component.getParent(), "Length"))),
"w 100lp, wrap para");
//// Material
materialPanel(panel, Material.Type.BULK);
panel.add(materialPanel(Material.Type.BULK), "span, wrap");
mainPanel.add(panel, "aligny 20%");
panel.add(filletMaterialPanel(), "span, wrap");
//// General and General properties
tabbedPane.insertTab(trans.get("TrapezoidFinSetCfg.tab.General"), null, mainPanel,
trans.get("TrapezoidFinSetCfg.tab.Generalproperties"), 0);