Add radial positioning shock cord
This commit is contained in:
parent
eddaae88ff
commit
c1281a6951
@ -1066,6 +1066,11 @@ ShockCordCfg.lbl.Posrelativeto = Position relative to:
|
||||
ShockCordCfg.lbl.plus = plus
|
||||
ShockCordCfg.lbl.Packedlength = Packed length:
|
||||
ShockCordCfg.lbl.Packeddiam = Packed diameter:
|
||||
ShockCordCfg.tab.Radialpos = Radial position
|
||||
ShockCordCfg.tab.ttip.Radialpos = Radial position configuration
|
||||
ShockCordCfg.lbl.Radialdistance = Radial distance:
|
||||
ShockCordCfg.lbl.Radialdirection = Radial direction:
|
||||
ShockCordCfg.but.Reset = Reset
|
||||
ShockCordCfg.tab.General = General
|
||||
ShockCordCfg.tab.ttip.General = General properties
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
package net.sf.openrocket.gui.configdialog;
|
||||
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.*;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
@ -15,11 +12,16 @@ import net.sf.openrocket.gui.components.BasicSlider;
|
||||
import net.sf.openrocket.gui.components.UnitSelector;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.rocketcomponent.MassComponent;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.ShockCord;
|
||||
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.unit.UnitGroup;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ShockCordConfig extends RocketComponentConfig {
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
@ -114,11 +116,56 @@ public class ShockCordConfig extends RocketComponentConfig {
|
||||
|
||||
|
||||
//// General and General properties
|
||||
tabbedPane.insertTab(trans.get("ShockCordCfg.tab.General"), null, panel, trans.get("ShockCordCfg.tab.ttip.General"), 0);
|
||||
// tabbedPane.insertTab("Radial position", null, positionTab(),
|
||||
// "Radial position configuration", 1);
|
||||
tabbedPane.insertTab(trans.get("ShockCordCfg.tab.General"), null, panel,
|
||||
trans.get("ShockCordCfg.tab.ttip.General"), 0);
|
||||
//// Radial position and Radial position configuration
|
||||
tabbedPane.insertTab(trans.get("ShockCordCfg.tab.Radialpos"), null, positionTab(),
|
||||
trans.get("ShockCordCfg.tab.ttip.Radialpos"), 1);
|
||||
tabbedPane.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
// TODO: LOW: there is a lot of duplicate code here with other mass components... (e.g. in MassComponentConfig or ParachuteConfig)
|
||||
protected JPanel positionTab() {
|
||||
JPanel panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::]", ""));
|
||||
|
||||
//// Radial position
|
||||
//// Radial distance:
|
||||
panel.add(new JLabel(trans.get("ShockCordCfg.lbl.Radialdistance")));
|
||||
|
||||
DoubleModel m = new DoubleModel(component, "RadialPosition", UnitGroup.UNITS_LENGTH, 0);
|
||||
|
||||
JSpinner 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(0, 0.1, 1.0)), "w 100lp, wrap");
|
||||
|
||||
|
||||
//// Radial direction:
|
||||
panel.add(new JLabel(trans.get("ShockCordCfg.lbl.Radialdirection")));
|
||||
|
||||
m = new DoubleModel(component, "RadialDirection", UnitGroup.UNITS_ANGLE);
|
||||
|
||||
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(-Math.PI, Math.PI)), "w 100lp, wrap");
|
||||
|
||||
|
||||
//// Reset button
|
||||
JButton button = new JButton(trans.get("ShockCordCfg.but.Reset"));
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
((ShockCord) component).setRadialDirection(0.0);
|
||||
((ShockCord) component).setRadialPosition(0.0);
|
||||
}
|
||||
});
|
||||
panel.add(button, "spanx, right");
|
||||
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package net.sf.openrocket.gui.rocketfigure;
|
||||
|
||||
import net.sf.openrocket.rocketcomponent.MassComponent;
|
||||
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.ShockCord;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.Transformation;
|
||||
|
||||
@ -13,17 +16,20 @@ import java.awt.geom.RoundRectangle2D;
|
||||
public class ShockCordShapes extends RocketComponentShape {
|
||||
|
||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
||||
|
||||
|
||||
net.sf.openrocket.rocketcomponent.MassObject massObj = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
||||
final ShockCord massObj = (ShockCord)component;
|
||||
|
||||
double length = massObj.getLength();
|
||||
double radius = massObj.getRadius();
|
||||
double arc = Math.min(length, 2*radius) * 0.7;
|
||||
final double radialDistance = massObj.getRadialPosition();
|
||||
final double radialAngleRadians = massObj.getRadialDirection();
|
||||
|
||||
Coordinate start = transformation.transform(Coordinate.ZERO);
|
||||
final Coordinate localPosition = new Coordinate(0,
|
||||
radialDistance * Math.cos(radialAngleRadians),
|
||||
radialDistance * Math.sin(radialAngleRadians));
|
||||
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||
Shape[] s = new Shape[1];
|
||||
s[0] = new RoundRectangle2D.Double(start.x,(start.y-radius),
|
||||
s[0] = new RoundRectangle2D.Double(renderPosition.x,(renderPosition.y-radius),
|
||||
length,2*radius,arc,arc);
|
||||
|
||||
return RocketComponentShape.toArray(addSymbol(s), component);
|
||||
@ -31,15 +37,20 @@ public class ShockCordShapes extends RocketComponentShape {
|
||||
|
||||
|
||||
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
|
||||
final ShockCord massObj = (ShockCord)component;
|
||||
|
||||
net.sf.openrocket.rocketcomponent.MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
||||
double or = massObj.getRadius();
|
||||
final double radialDistance = massObj.getRadialPosition();
|
||||
final double radialAngleRadians = massObj.getRadialDirection();
|
||||
|
||||
double or = tube.getRadius();
|
||||
final Coordinate localPosition = new Coordinate(0,
|
||||
radialDistance * Math.cos(radialAngleRadians),
|
||||
radialDistance * Math.sin(radialAngleRadians));
|
||||
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||
|
||||
Shape[] s = new Shape[1];
|
||||
Coordinate start = transformation.transform(Coordinate.ZERO);
|
||||
|
||||
s[0] = new Ellipse2D.Double((start.z-or),(start.y-or),2*or,2*or);
|
||||
s[0] = new Ellipse2D.Double((renderPosition.z-or),(renderPosition.y-or),2*or,2*or);
|
||||
|
||||
// Coordinate[] start = transformation.transform(tube.toAbsolute(instanceOffset));
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user