Merge branch 'unstable' into issue-1680
This commit is contained in:
commit
4cf85fe6f2
13
build.xml
13
build.xml
@ -45,12 +45,23 @@
|
|||||||
<target name="unittest" depends="unittest-core, unittest-swing">
|
<target name="unittest" depends="unittest-core, unittest-swing">
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="unittest-no-junit-report" depends="unittest-core, unittest-swing">
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="unittest-core" depends="jar-core">
|
<target name="unittest-core" depends="jar-core">
|
||||||
<ant dir="core" target="unittest" inheritAll="false" />
|
<ant dir="core" target="unittest" inheritAll="false" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="unittest-core-no-junit-report" depends="jar-core">
|
||||||
|
<ant dir="core" target="unittest" inheritAll="false" />
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="unittest-swing" depends="jar-swing">
|
<target name="unittest-swing" depends="jar-swing">
|
||||||
<ant dir="swing" target="unittest" inheritAll="false" />
|
<ant dir="swing" target="unittest-no-junit-report" inheritAll="false" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="unittest-swing-no-junit-report" depends="jar-swing">
|
||||||
|
<ant dir="swing" target="unittest-no-junit-report" inheritAll="false" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- CHECK -->
|
<!-- CHECK -->
|
||||||
|
@ -64,6 +64,8 @@ RocketPanel.lbl.Stability = Stability:
|
|||||||
RocketPanel.checkbox.ShowCGCP = Show CG/CP
|
RocketPanel.checkbox.ShowCGCP = Show CG/CP
|
||||||
RocketPanel.checkbox.ShowCGCP.ttip = Disabling this checkbox hides the CG and CP markings in the rocket view.
|
RocketPanel.checkbox.ShowCGCP.ttip = Disabling this checkbox hides the CG and CP markings in the rocket view.
|
||||||
RocketPanel.lbl.Stages = Stages:
|
RocketPanel.lbl.Stages = Stages:
|
||||||
|
RocketPanel.btn.Stages.Toggle.ttip = Toggle this button to activate or deactivate the corresponding stage in your design.
|
||||||
|
RocketPanel.btn.Stages.NoChildren.ttip = <html>This stages does not have any child components and is therefore marked as inactive.<br>Add components to the stage to activate it.</html>
|
||||||
RocketPanel.ttip.Rotation = Change the rocket's roll rotation (only affects the rocket view)
|
RocketPanel.ttip.Rotation = Change the rocket's roll rotation (only affects the rocket view)
|
||||||
|
|
||||||
! BasicFrame
|
! BasicFrame
|
||||||
|
@ -243,7 +243,9 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stages.get(stageNumber) != null && stages.get(stageNumber).active;
|
AxialStage stage = rocket.getStage(stageNumber);
|
||||||
|
return stage != null && stage.getChildCount() > 0 &&
|
||||||
|
stages.get(stageNumber) != null && stages.get(stageNumber).active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<RocketComponent> getAllComponents() {
|
public Collection<RocketComponent> getAllComponents() {
|
||||||
@ -380,7 +382,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
List<AxialStage> activeStages = new ArrayList<>();
|
List<AxialStage> activeStages = new ArrayList<>();
|
||||||
|
|
||||||
for (StageFlags flags : this.stages.values()) {
|
for (StageFlags flags : this.stages.values()) {
|
||||||
if (flags.active) {
|
if (isStageActive(flags.stageNumber)) {
|
||||||
AxialStage stage = rocket.getStage(flags.stageId);
|
AxialStage stage = rocket.getStage(flags.stageId);
|
||||||
if (stage == null) {
|
if (stage == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -393,13 +395,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getActiveStageCount() {
|
public int getActiveStageCount() {
|
||||||
int activeCount = 0;
|
return getActiveStages().size();
|
||||||
for (StageFlags cur : this.stages.values()) {
|
|
||||||
if (cur.active) {
|
|
||||||
activeCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return activeCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -408,8 +404,8 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
public AxialStage getBottomStage() {
|
public AxialStage getBottomStage() {
|
||||||
AxialStage bottomStage = null;
|
AxialStage bottomStage = null;
|
||||||
for (StageFlags curFlags : this.stages.values()) {
|
for (StageFlags curFlags : this.stages.values()) {
|
||||||
if (curFlags.active) {
|
if (isStageActive(curFlags.stageNumber)) {
|
||||||
bottomStage = rocket.getStage(curFlags.stageId);
|
bottomStage = rocket.getStage( curFlags.stageNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bottomStage;
|
return bottomStage;
|
||||||
|
@ -47,6 +47,26 @@ public class BarrowmanCalculatorTest {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test a completely empty rocket.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEmptyRocket() {
|
||||||
|
// First test completely empty rocket
|
||||||
|
Rocket rocket = new Rocket();
|
||||||
|
FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||||
|
BarrowmanCalculator calc = new BarrowmanCalculator();
|
||||||
|
FlightConditions conditions = new FlightConditions(config);
|
||||||
|
WarningSet warnings = new WarningSet();
|
||||||
|
|
||||||
|
Coordinate cp_calc = calc.getCP(config, conditions, warnings);
|
||||||
|
|
||||||
|
assertEquals(" Empty rocket CNa value is incorrect:", 0.0, cp_calc.weight , 0.0);
|
||||||
|
assertEquals(" Empty rocket cp x value is incorrect:", 0.0, cp_calc.x , 0.0);
|
||||||
|
assertEquals(" Empty rocket cp y value is incorrect:", 0.0, cp_calc.y , 0.0);
|
||||||
|
assertEquals(" Empty rocket cp z value is incorrect:", 0.0, cp_calc.z , 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCPSimpleDry() {
|
public void testCPSimpleDry() {
|
||||||
Rocket rocket = TestRockets.makeEstesAlphaIII();
|
Rocket rocket = TestRockets.makeEstesAlphaIII();
|
||||||
@ -351,4 +371,67 @@ public class BarrowmanCalculatorTest {
|
|||||||
assertEquals(" Alpha III With Pods rocket cp z value is incorrect:", cpNoPods.z, cpPods.z, EPSILON);
|
assertEquals(" Alpha III With Pods rocket cp z value is incorrect:", cpNoPods.z, cpPods.z, EPSILON);
|
||||||
assertEquals(" Alpha III With Pods rocket CNa value is incorrect:", cpPods.weight, cpNoPods.weight - 3.91572, EPSILON);
|
assertEquals(" Alpha III With Pods rocket CNa value is incorrect:", cpPods.weight, cpNoPods.weight - 3.91572, EPSILON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether adding extra empty stages has an effect.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEmptyStages() {
|
||||||
|
// Reference rocket
|
||||||
|
Rocket rocketRef = TestRockets.makeEstesAlphaIII();
|
||||||
|
FlightConfiguration configRef = rocketRef.getSelectedConfiguration();
|
||||||
|
BarrowmanCalculator calcRef = new BarrowmanCalculator();
|
||||||
|
FlightConditions conditionsRef = new FlightConditions(configRef);
|
||||||
|
WarningSet warnings = new WarningSet();
|
||||||
|
|
||||||
|
Coordinate cp_calcRef = calcRef.getCP(configRef, conditionsRef, warnings);
|
||||||
|
|
||||||
|
// First test with adding an empty stage in the front of the design
|
||||||
|
Rocket rocketFront = TestRockets.makeEstesAlphaIII();
|
||||||
|
AxialStage stage1 = new AxialStage(); // To be placed in front of the design
|
||||||
|
rocketFront.addChild(stage1, 0);
|
||||||
|
FlightConfiguration configFront = rocketFront.getSelectedConfiguration();
|
||||||
|
BarrowmanCalculator calcFront = new BarrowmanCalculator();
|
||||||
|
FlightConditions conditionsFront = new FlightConditions(configFront);
|
||||||
|
warnings = new WarningSet();
|
||||||
|
|
||||||
|
Coordinate cp_calcFront = calcFront.getCP(configFront, conditionsFront, warnings);
|
||||||
|
|
||||||
|
assertEquals(" Estes Alpha III with front empty stage CNa value is incorrect:", cp_calcRef.weight, cp_calcFront.weight , EPSILON);
|
||||||
|
assertEquals(" Estes Alpha III with front empty stage cp x value is incorrect:", cp_calcRef.x, cp_calcFront.x , EPSILON);
|
||||||
|
assertEquals(" Estes Alpha III with front empty stage cp y value is incorrect:", cp_calcRef.y, cp_calcFront.y , EPSILON);
|
||||||
|
assertEquals(" Estes Alpha III with front empty stage cp z value is incorrect:", cp_calcRef.z, cp_calcFront.z , EPSILON);
|
||||||
|
|
||||||
|
// Now test with adding an empty stage in the rear of the design
|
||||||
|
Rocket rocketRear = TestRockets.makeEstesAlphaIII();
|
||||||
|
AxialStage stage2 = new AxialStage(); // To be placed in the rear of the design
|
||||||
|
rocketRear.addChild(stage2);
|
||||||
|
FlightConfiguration configRear = rocketRear.getSelectedConfiguration();
|
||||||
|
BarrowmanCalculator calcRear = new BarrowmanCalculator();
|
||||||
|
FlightConditions conditionsRear = new FlightConditions(configRear);
|
||||||
|
warnings = new WarningSet();
|
||||||
|
|
||||||
|
Coordinate cp_calcRear = calcRear.getCP(configRear, conditionsRear, warnings);
|
||||||
|
|
||||||
|
assertEquals(" Estes Alpha III with rear empty stage CNa value is incorrect:", cp_calcRef.weight, cp_calcRear.weight , EPSILON);
|
||||||
|
assertEquals(" Estes Alpha III with rear empty stage cp x value is incorrect:", cp_calcRef.x, cp_calcRear.x , EPSILON);
|
||||||
|
assertEquals(" Estes Alpha III with rear empty stage cp y value is incorrect:", cp_calcRef.y, cp_calcRear.y , EPSILON);
|
||||||
|
assertEquals(" Estes Alpha III with rear empty stage cp z value is incorrect:", cp_calcRef.z, cp_calcRear.z , EPSILON);
|
||||||
|
|
||||||
|
// Test with multiple empty stages
|
||||||
|
Rocket rocketMulti = rocketFront;
|
||||||
|
AxialStage stage3 = new AxialStage(); // To be placed in the rear of the design
|
||||||
|
rocketMulti.addChild(stage3);
|
||||||
|
FlightConfiguration configMulti = rocketMulti.getSelectedConfiguration();
|
||||||
|
BarrowmanCalculator calcMulti = new BarrowmanCalculator();
|
||||||
|
FlightConditions conditionsMulti = new FlightConditions(configMulti);
|
||||||
|
warnings = new WarningSet();
|
||||||
|
|
||||||
|
Coordinate cp_calcMulti = calcMulti.getCP(configMulti, conditionsMulti, warnings);
|
||||||
|
|
||||||
|
assertEquals(" Estes Alpha III with multiple empty stages CNa value is incorrect:", cp_calcRef.weight, cp_calcMulti.weight , EPSILON);
|
||||||
|
assertEquals(" Estes Alpha III with multiple empty stages cp x value is incorrect:", cp_calcRef.x, cp_calcMulti.x , EPSILON);
|
||||||
|
assertEquals(" Estes Alpha III with multiple empty stages cp y value is incorrect:", cp_calcRef.y, cp_calcMulti.y , EPSILON);
|
||||||
|
assertEquals(" Estes Alpha III with multiple empty stages cp z value is incorrect:", cp_calcRef.z, cp_calcMulti.z , EPSILON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,29 @@ public class MassCalculatorTest extends BaseTestCase {
|
|||||||
// tolerance for compared double test results
|
// tolerance for compared double test results
|
||||||
private static final double EPSILON = 0.00000001; // note: this precision matches MathUtil.java
|
private static final double EPSILON = 0.00000001; // note: this precision matches MathUtil.java
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmptyRocket() {
|
||||||
|
Rocket rocket = new Rocket();
|
||||||
|
FlightConfiguration config = rocket.getEmptyConfiguration();
|
||||||
|
|
||||||
|
final RigidBody actualStructure = MassCalculator.calculateStructure(config);
|
||||||
|
final double actualRocketDryMass = actualStructure.cm.weight;
|
||||||
|
final Coordinate actualRocketDryCM = actualStructure.cm;
|
||||||
|
|
||||||
|
assertEquals(" Empty Rocket Empty Mass is incorrect: ", 0, actualRocketDryMass, 0);
|
||||||
|
|
||||||
|
Coordinate expCM = new Coordinate(0, 0, 0, 0);
|
||||||
|
assertEquals("Empty Rocket CM.x is incorrect: ", expCM.x, actualRocketDryCM.x, 0);
|
||||||
|
assertEquals("Empty Rocket CM.y is incorrect: ", expCM.y, actualRocketDryCM.y, 0);
|
||||||
|
assertEquals("Empty Rocket CM.z is incorrect: ", expCM.z, actualRocketDryCM.z, 0);
|
||||||
|
assertEquals("Empty Rocket CM is incorrect: ", expCM, actualRocketDryCM);
|
||||||
|
|
||||||
|
double actualMOIrot = actualStructure.getRotationalInertia();
|
||||||
|
double actualMOIlong = actualStructure.getLongitudinalInertia();
|
||||||
|
assertEquals("Empty Rocket Rotational MOI calculated incorrectly: ", 0, actualMOIrot, 0);
|
||||||
|
assertEquals("Empty Rocket Longitudinal MOI calculated incorrectly: ", 0, actualMOIlong, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAlphaIIIStructure() {
|
public void testAlphaIIIStructure() {
|
||||||
Rocket rocket = TestRockets.makeEstesAlphaIII();
|
Rocket rocket = TestRockets.makeEstesAlphaIII();
|
||||||
@ -1145,4 +1168,68 @@ public class MassCalculatorTest extends BaseTestCase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmptyStages() {
|
||||||
|
Rocket rocketRef = TestRockets.makeEstesAlphaIII(); // Reference rocket
|
||||||
|
FlightConfiguration configRef = rocketRef.getEmptyConfiguration();
|
||||||
|
configRef.setAllStages();
|
||||||
|
|
||||||
|
final RigidBody structureRef = MassCalculator.calculateStructure(configRef);
|
||||||
|
final double rocketDryMassRef = structureRef.cm.weight;
|
||||||
|
final Coordinate rocketDryCMRef = structureRef.cm;
|
||||||
|
|
||||||
|
Rocket rocket = TestRockets.makeEstesAlphaIII();
|
||||||
|
AxialStage stage1 = new AxialStage(); // To be added to the front of the rocket
|
||||||
|
AxialStage stage2 = new AxialStage(); // To be added to the rear of the rocket
|
||||||
|
rocket.addChild(stage1, 0);
|
||||||
|
rocket.addChild(stage2);
|
||||||
|
FlightConfiguration config = rocket.getEmptyConfiguration();
|
||||||
|
config.setAllStages();
|
||||||
|
|
||||||
|
final RigidBody structure = MassCalculator.calculateStructure(config);
|
||||||
|
final double rocketDryMass = structure.cm.weight;
|
||||||
|
final Coordinate rocketDryCM = structure.cm;
|
||||||
|
|
||||||
|
assertEquals(" Empty Stages Rocket Empty Mass is incorrect: ", rocketDryMassRef, rocketDryMass, EPSILON);
|
||||||
|
|
||||||
|
assertEquals("Empty Stages Rocket CM.x is incorrect: ", rocketDryCMRef.x, rocketDryCM.x, EPSILON);
|
||||||
|
assertEquals("Empty Stages Rocket CM.y is incorrect: ", rocketDryCMRef.y, rocketDryCM.y, EPSILON);
|
||||||
|
assertEquals("Empty Stages Rocket CM.z is incorrect: ", rocketDryCMRef.z, rocketDryCM.z, EPSILON);
|
||||||
|
assertEquals("Empty Stages Rocket CM is incorrect: ", rocketDryCMRef, rocketDryCM);
|
||||||
|
|
||||||
|
double MOIrotRef = structureRef.getRotationalInertia();
|
||||||
|
double MOIlongRef = structureRef.getLongitudinalInertia();
|
||||||
|
|
||||||
|
double MOIrot = structure.getRotationalInertia();
|
||||||
|
double MOIlong = structure.getLongitudinalInertia();
|
||||||
|
assertEquals("Empty Stages Rocket Rotational MOI calculated incorrectly: ", MOIrotRef, MOIrot, EPSILON);
|
||||||
|
assertEquals("Empty Stages Rocket Longitudinal MOI calculated incorrectly: ", MOIlongRef, MOIlong, EPSILON);
|
||||||
|
|
||||||
|
// if we use a mass override, setting to same mass, we should get same result
|
||||||
|
AxialStage sustainerRef = (AxialStage) rocketRef.getChild(0);
|
||||||
|
sustainerRef.setSubcomponentsOverridden(true);
|
||||||
|
sustainerRef.setMassOverridden(true);
|
||||||
|
sustainerRef.setOverrideMass(rocketDryMassRef);
|
||||||
|
|
||||||
|
AxialStage sustainer = (AxialStage) rocket.getChild(0);
|
||||||
|
sustainer.setSubcomponentsOverridden(true);
|
||||||
|
sustainer.setMassOverridden(true);
|
||||||
|
sustainer.setOverrideMass(rocketDryMass);
|
||||||
|
|
||||||
|
final RigidBody overrideStructureRef = MassCalculator.calculateStructure(configRef);
|
||||||
|
final Coordinate overrideRocketDryCMRef = overrideStructureRef.cm;
|
||||||
|
|
||||||
|
final RigidBody overrideStructure = MassCalculator.calculateStructure(config);
|
||||||
|
final Coordinate overrideRocketDryCM = overrideStructure.cm;
|
||||||
|
|
||||||
|
assertEquals("Empty Stages Rocket Override CM is incorrect: ", overrideRocketDryCMRef, overrideRocketDryCM);
|
||||||
|
|
||||||
|
double overrideMOIrotRef = overrideStructureRef.getRotationalInertia();
|
||||||
|
double overrideMOIlongRef = overrideStructureRef.getLongitudinalInertia();
|
||||||
|
double overrideMOIrot = overrideStructure.getRotationalInertia();
|
||||||
|
double overrideMOIlong = overrideStructure.getLongitudinalInertia();
|
||||||
|
assertEquals("Empty Stages Rocket Rotational MOI calculated incorrectly: ", overrideMOIrotRef, overrideMOIrot, EPSILON);
|
||||||
|
assertEquals("Empty Stages Rocket Longitudinal MOI calculated incorrectly: ", overrideMOIlongRef, overrideMOIlong, EPSILON);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,21 @@ import javax.swing.JToggleButton;
|
|||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorToggleButton;
|
import net.sf.openrocket.gui.widgets.SelectColorToggleButton;
|
||||||
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
import net.sf.openrocket.rocketcomponent.BodyTube;
|
import net.sf.openrocket.rocketcomponent.BodyTube;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class StageSelector extends JPanel implements StateChangeListener {
|
public class StageSelector extends JPanel implements StateChangeListener {
|
||||||
|
|
||||||
|
private static final Translator trans = Application.getTranslator();
|
||||||
private final Rocket rocket;
|
private final Rocket rocket;
|
||||||
|
|
||||||
private List<JToggleButton> buttons = new ArrayList<JToggleButton>();
|
private List<JToggleButton> buttons = new ArrayList<JToggleButton>();
|
||||||
@ -64,6 +67,13 @@ public class StageSelector extends JPanel implements StateChangeListener {
|
|||||||
|
|
||||||
public StageAction(final AxialStage stage) {
|
public StageAction(final AxialStage stage) {
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
|
if (this.stage.getChildCount() == 0) {
|
||||||
|
putValue(SHORT_DESCRIPTION, trans.get("RocketPanel.btn.Stages.NoChildren.ttip"));
|
||||||
|
setEnabled(false);
|
||||||
|
} else {
|
||||||
|
putValue(SHORT_DESCRIPTION, trans.get("RocketPanel.btn.Stages.Toggle.ttip"));
|
||||||
|
}
|
||||||
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,6 +87,15 @@ public class StageSelector extends JPanel implements StateChangeListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// Don't toggle the state if the stage has no children (and is therefore inactive)
|
||||||
|
if (stage.getChildCount() == 0) {
|
||||||
|
putValue(SHORT_DESCRIPTION, trans.get("RocketPanel.btn.Stages.NoChildren.ttip"));
|
||||||
|
setEnabled(false);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
setEnabled(true);
|
||||||
|
putValue(SHORT_DESCRIPTION, trans.get("RocketPanel.btn.Stages.Toggle.ttip"));
|
||||||
|
}
|
||||||
rocket.getSelectedConfiguration().toggleStage(stage.getStageNumber());
|
rocket.getSelectedConfiguration().toggleStage(stage.getStageNumber());
|
||||||
rocket.fireComponentChangeEvent(ComponentChangeEvent.AEROMASS_CHANGE | ComponentChangeEvent.MOTOR_CHANGE );
|
rocket.fireComponentChangeEvent(ComponentChangeEvent.AEROMASS_CHANGE | ComponentChangeEvent.MOTOR_CHANGE );
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import net.sf.openrocket.motor.Manufacturer;
|
|||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
import net.sf.openrocket.unit.Unit;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||||
|
|
||||||
@ -64,8 +65,18 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
* updates: motorDiameters, diameterLabels
|
* updates: motorDiameters, diameterLabels
|
||||||
*/
|
*/
|
||||||
private static void scaleDiameterLabels(){
|
private static void scaleDiameterLabels(){
|
||||||
|
Unit unit = UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit();
|
||||||
for( int i = 0; i < motorDiameters.length; i++ ) {
|
for( int i = 0; i < motorDiameters.length; i++ ) {
|
||||||
diameterLabels.put( i, new JLabel(UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit().toString(motorDiameters[i])));
|
// Round the labels, because for imperial units, the labels can otherwise overlap
|
||||||
|
double diam = unit.toUnit(motorDiameters[i]);
|
||||||
|
double diamRounded = unit.round(diam * 10) / 10; // 10 multiplication for 2-decimal precision
|
||||||
|
diam = unit.fromUnit(diamRounded);
|
||||||
|
String formatted = unit.toString(diam);
|
||||||
|
// Remove the leading zero for numbers between 0 and 1
|
||||||
|
if (diamRounded > 0 && diamRounded < 1) {
|
||||||
|
formatted = formatted.substring(1);
|
||||||
|
}
|
||||||
|
diameterLabels.put( i, new JLabel(formatted));
|
||||||
}
|
}
|
||||||
diameterLabels.get( motorDiameters.length-1).setText("+");
|
diameterLabels.get( motorDiameters.length-1).setText("+");
|
||||||
}
|
}
|
||||||
@ -96,6 +107,7 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
final JSpinner maxLengthSpinner;
|
final JSpinner maxLengthSpinner;
|
||||||
final UnitSelector maxLengthUnitSelect;
|
final UnitSelector maxLengthUnitSelect;
|
||||||
private boolean limitDiameter = false;
|
private boolean limitDiameter = false;
|
||||||
|
boolean limitByLength = false;
|
||||||
private Double mountDiameter = null;
|
private Double mountDiameter = null;
|
||||||
|
|
||||||
|
|
||||||
@ -113,7 +125,7 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
List<Manufacturer> unselectedManusFromPreferences = ((SwingPreferences) Application.getPreferences()).getExcludedMotorManufacturers();
|
List<Manufacturer> unselectedManusFromPreferences = ((SwingPreferences) Application.getPreferences()).getExcludedMotorManufacturers();
|
||||||
filter.setExcludedManufacturers(unselectedManusFromPreferences);
|
filter.setExcludedManufacturers(unselectedManusFromPreferences);
|
||||||
|
|
||||||
boolean limitByLengthPref = ((SwingPreferences) Application.getPreferences()).getBoolean("motorFilterLimitLength", false);
|
limitByLength = ((SwingPreferences) Application.getPreferences()).getBoolean("motorFilterLimitLength", false);
|
||||||
limitDiameter = ((SwingPreferences) Application.getPreferences()).getBoolean("motorFilterLimitDiameter", false);
|
limitDiameter = ((SwingPreferences) Application.getPreferences()).getBoolean("motorFilterLimitDiameter", false);
|
||||||
|
|
||||||
//// Hide used motor files
|
//// Hide used motor files
|
||||||
@ -239,9 +251,10 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
// Motor Dimension selection
|
// Motor Dimension selection
|
||||||
{
|
{
|
||||||
sub.add( new JLabel(trans.get("TCMotorSelPan.Diameter")), "split 2, wrap");
|
sub.add( new JLabel(trans.get("TCMotorSelPan.Diameter")), "split 2, wrap");
|
||||||
limitDiameterCheckBox = new JCheckBox( trans.get("TCMotorSelPan.checkbox.limitdiameter"));
|
final BooleanModel limitByDiameterModel = new BooleanModel(limitDiameter);
|
||||||
|
limitDiameterCheckBox = new JCheckBox(limitByDiameterModel);
|
||||||
|
limitDiameterCheckBox.setText(trans.get("TCMotorSelPan.checkbox.limitdiameter"));
|
||||||
GUIUtil.changeFontSize(limitDiameterCheckBox, -1);
|
GUIUtil.changeFontSize(limitDiameterCheckBox, -1);
|
||||||
limitDiameterCheckBox.setSelected(limitDiameter);
|
|
||||||
limitDiameterCheckBox.addActionListener(new ActionListener(){
|
limitDiameterCheckBox.addActionListener(new ActionListener(){
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@ -273,12 +286,13 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
sub.add( diameterSlider, "growx, wrap");
|
sub.add( diameterSlider, "growx, wrap");
|
||||||
|
limitByDiameterModel.addEnableComponent(diameterSlider, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // length selection
|
{ // length selection
|
||||||
|
|
||||||
sub.add( new JLabel(trans.get("TCMotorSelPan.Length")), "split 2, wrap");
|
sub.add( new JLabel(trans.get("TCMotorSelPan.Length")), "split 2, wrap");
|
||||||
final BooleanModel limitByLengthModel = new BooleanModel(limitByLengthPref);
|
final BooleanModel limitByLengthModel = new BooleanModel(limitByLength);
|
||||||
limitByLengthCheckBox = new JCheckBox( limitByLengthModel );
|
limitByLengthCheckBox = new JCheckBox( limitByLengthModel );
|
||||||
limitByLengthCheckBox.setText( trans.get("TCMotorSelPan.checkbox.limitlength"));
|
limitByLengthCheckBox.setText( trans.get("TCMotorSelPan.checkbox.limitlength"));
|
||||||
GUIUtil.changeFontSize(limitByLengthCheckBox, -1);
|
GUIUtil.changeFontSize(limitByLengthCheckBox, -1);
|
||||||
@ -286,7 +300,7 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
limitByLengthCheckBox.addActionListener(new ActionListener() {
|
limitByLengthCheckBox.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
//boolean limitByLength = limitByLengthCheckBox.isSelected();
|
limitByLength = limitByLengthCheckBox.isSelected();
|
||||||
MotorFilterPanel.this.setLimitLength();
|
MotorFilterPanel.this.setLimitLength();
|
||||||
onSelectionChanged();
|
onSelectionChanged();
|
||||||
}
|
}
|
||||||
@ -326,9 +340,6 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
|
|
||||||
lengthSlider = new MultiSlider(MultiSlider.HORIZONTAL,0, 1000, 0, 1000);
|
lengthSlider = new MultiSlider(MultiSlider.HORIZONTAL,0, 1000, 0, 1000);
|
||||||
lengthSlider.setBounded(true); // thumbs cannot cross
|
lengthSlider.setBounded(true); // thumbs cannot cross
|
||||||
lengthSlider.setMajorTickSpacing(100);
|
|
||||||
lengthSlider.setPaintTicks(true);
|
|
||||||
lengthSlider.setLabelTable(diameterLabels);
|
|
||||||
lengthSlider.addChangeListener( new ChangeListener() {
|
lengthSlider.addChangeListener( new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(ChangeEvent e) {
|
public void stateChanged(ChangeEvent e) {
|
||||||
@ -371,7 +382,6 @@ public abstract class MotorFilterPanel extends JPanel {
|
|||||||
minLengthUnitSelect.setSelectedUnit(UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit());
|
minLengthUnitSelect.setSelectedUnit(UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit());
|
||||||
maxLengthUnitSelect.setSelectedUnit(UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit());
|
maxLengthUnitSelect.setSelectedUnit(UnitGroup.UNITS_MOTOR_DIMENSIONS.getDefaultUnit());
|
||||||
|
|
||||||
boolean limitByLength = limitByLengthCheckBox.isSelected();
|
|
||||||
((SwingPreferences) Application.getPreferences()).putBoolean("motorFilterLimitLength", limitByLength);
|
((SwingPreferences) Application.getPreferences()).putBoolean("motorFilterLimitLength", limitByLength);
|
||||||
if ( mountLength != null & limitByLength ) {
|
if ( mountLength != null & limitByLength ) {
|
||||||
lengthSlider.setValueAt(1, (int) Math.min(1000,Math.round(1000*mountLength)));
|
lengthSlider.setValueAt(1, (int) Math.min(1000,Math.round(1000*mountLength)));
|
||||||
|
@ -1006,7 +1006,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
*/
|
*/
|
||||||
public void takeTheSpotlight() {
|
public void takeTheSpotlight() {
|
||||||
simulationTable.requestFocusInWindow();
|
simulationTable.requestFocusInWindow();
|
||||||
if (simulationTable.getSelectedRows().length > 0) {
|
if (simulationTable.getRowCount() == 0 || simulationTable.getSelectedRows().length > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (previousSelection == null || previousSelection.length == 0) {
|
if (previousSelection == null || previousSelection.length == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user