From: kruland2607 Date: Wed, 11 Jan 2012 14:56:40 +0000 (+0000) Subject: Modified RocketUtils.getCG to take a MassCalcType parameter. In the OpenRocketViewer... X-Git-Tag: upstream/12.03~1^2~131 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=af1d906fb182377429dcc3cb0bf731f11bac79f2;p=debian%2Fopenrocket Modified RocketUtils.getCG to take a MassCalcType parameter. In the OpenRocketViewer, calculate mass empty. Changed the order of the fields in the openrocketviewer layout. Added a spinner for the configurations stored in the ork file - though this still needs to have motors wired in. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@340 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/android/res/layout/openrocketviewer.xml b/android/res/layout/openrocketviewer.xml index 8ddc4c4f..e25ec6d8 100644 --- a/android/res/layout/openrocketviewer.xml +++ b/android/res/layout/openrocketviewer.xml @@ -34,10 +34,10 @@ + android:text="Designer" /> @@ -45,10 +45,10 @@ + android:text="Length" /> @@ -56,10 +56,10 @@ + android:text="Empty Mass" /> @@ -67,41 +67,35 @@ + android:text="Stage Count" /> - - + android:id="@+id/openrocketviewerConfigurationSpinner" + /> + + android:layout_height="match_parent" + android:text="Comment" /> + android:text="CG" /> - - spinnerAdapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item); + for( String config: motorConfigs ) { + spinnerAdapter.add(rocket.getMotorConfigurationNameOrDescription(config)); + } + + configurationSpinner.setAdapter(spinnerAdapter); + Unit LengthUnit = UnitGroup.UNITS_LENGTH.getDefaultUnit(); Unit MassUnit = UnitGroup.UNITS_MASS.getDefaultUnit(); - Coordinate cg = RocketUtils.getCG(rocket); + Coordinate cg = RocketUtils.getCG(rocket, MassCalcType.NO_MOTORS); double length = RocketUtils.getLength(rocket); - ((TextView) findViewById(R.id.openrocketviewerRocketName)).setText( rocket.getName()); ((TextView)findViewById(R.id.openrocketviewerDesigner)).setText(rocket.getDesigner()); ((TextView)findViewById(R.id.openrocketviewerCG)).setText(LengthUnit.toStringUnit(cg.x) ); ((TextView)findViewById(R.id.openrocketviewerLength)).setText(LengthUnit.toStringUnit(length)); diff --git a/core/src/net/sf/openrocket/rocketcomponent/RocketUtils.java b/core/src/net/sf/openrocket/rocketcomponent/RocketUtils.java index 2e4b63b8..71360b9a 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RocketUtils.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RocketUtils.java @@ -25,9 +25,9 @@ public abstract class RocketUtils { return length; } - public static Coordinate getCG(Rocket rocket) { + public static Coordinate getCG(Rocket rocket, MassCalcType calcType) { MassCalculator massCalculator = new BasicMassCalculator(); - Coordinate cg = massCalculator.getCG(rocket.getDefaultConfiguration(), MassCalcType.LAUNCH_MASS); + Coordinate cg = massCalculator.getCG(rocket.getDefaultConfiguration(), calcType); return cg; }