From: kruland2607 Date: Fri, 13 Jan 2012 18:30:46 +0000 (+0000) Subject: Wired up computation of CP, CG, liftoff weight and stability to the configuration... X-Git-Tag: upstream/12.03~1^2~124 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=30ccae3338db5f4edc97a0a277db21209f8a8255;p=debian%2Fopenrocket Wired up computation of CP, CG, liftoff weight and stability to the configuration spinner. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@347 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/android/res/layout/openrocketviewer.xml b/android/res/layout/openrocketviewer.xml index e25ec6d8..25d7d9b4 100644 --- a/android/res/layout/openrocketviewer.xml +++ b/android/res/layout/openrocketviewer.xml @@ -83,7 +83,13 @@ + android:text="Lift off weight" /> + + + + - + + + + + + arg0, View arg1, + int arg2, long arg3) { + + String selectedConfigId = rocketDocument.getRocket().getMotorConfigurationIDs()[arg2]; + rocketConfiguration.setMotorConfigurationID(selectedConfigId); + Coordinate cp = aerodynamicCalculator.getWorstCP(rocketConfiguration, + new FlightConditions(rocketConfiguration), + new WarningSet()); + + Coordinate cg = massCalculator.getCG(rocketConfiguration, MassCalcType.LAUNCH_MASS); + + Unit lengthUnit = UnitGroup.UNITS_LENGTH.getDefaultUnit(); + Unit massUnit = UnitGroup.UNITS_MASS.getDefaultUnit(); + Unit stabilityUnit = UnitGroup.stabilityUnits(rocketConfiguration).getDefaultUnit(); + + ((TextView)findViewById(R.id.openrocketviewerCP)).setText(lengthUnit.toStringUnit(cp.x)); + ((TextView)findViewById(R.id.openrocketviewerCG)).setText(lengthUnit.toStringUnit(cg.x)); + ((TextView)findViewById(R.id.openrocketviewerLiftOffWeight)).setText(massUnit.toStringUnit(cg.weight)); + ((TextView)findViewById(R.id.openrocketviewerStabilityMargin)).setText(stabilityUnit.toStringUnit(cp.x-cg.x)); + + } + + /* (non-Javadoc) + * @see android.widget.AdapterView.OnItemSelectedListener#onNothingSelected(android.widget.AdapterView) + */ + @Override + public void onNothingSelected(AdapterView arg0) { + ((TextView)findViewById(R.id.openrocketviewerCP)).setText(""); + ((TextView)findViewById(R.id.openrocketviewerCG)).setText(""); + ((TextView)findViewById(R.id.openrocketviewerLiftOffWeight)).setText(""); + ((TextView)findViewById(R.id.openrocketviewerStabilityMargin)).setText(""); + } + + }); - Unit LengthUnit = UnitGroup.UNITS_LENGTH.getDefaultUnit(); - Unit MassUnit = UnitGroup.UNITS_MASS.getDefaultUnit(); + Unit lengthUnit = UnitGroup.UNITS_LENGTH.getDefaultUnit(); + Unit massUnit = UnitGroup.UNITS_MASS.getDefaultUnit(); Coordinate cg = RocketUtils.getCG(rocket, MassCalcType.NO_MOTORS); double length = RocketUtils.getLength(rocket); ((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)); - ((TextView)findViewById(R.id.openrocketviewerMass)).setText(MassUnit.toStringUnit(cg.weight)); + ((TextView)findViewById(R.id.openrocketviewerLength)).setText(lengthUnit.toStringUnit(length)); + ((TextView)findViewById(R.id.openrocketviewerMass)).setText(massUnit.toStringUnit(cg.weight)); ((TextView)findViewById(R.id.openrocketviewerStageCount)).setText(String.valueOf(rocket.getStageCount())); - ((TextView)findViewById(R.id.openrocketviewerComment)).setText(rocket.getComment()); + ArrayAdapter sims = new ArrayAdapter(this,android.R.layout.simple_list_item_2,rocketDocument.getSimulations()) { @Override