]> git.gag.com Git - debian/openrocket/commitdiff
Modified RocketUtils.getCG to take a MassCalcType parameter. In the OpenRocketViewer...
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Wed, 11 Jan 2012 14:56:40 +0000 (14:56 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Wed, 11 Jan 2012 14:56:40 +0000 (14:56 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@340 180e2498-e6e9-4542-8430-84ac67f01cd8

android/res/layout/openrocketviewer.xml
android/src/net/sf/openrocket/android/rocket/OpenRocketViewer.java
core/src/net/sf/openrocket/rocketcomponent/RocketUtils.java

index 8ddc4c4f135cb4ddcf1cdae79c6ee26a68861cdd..e25ec6d8b97aed7df08bbeb5d7d13ff12817b9b4 100644 (file)
                     <TextView\r
                         android:layout_width="match_parent"\r
                         android:layout_height="match_parent"\r
-                        android:text="Rocket Name" />\r
+                        android:text="Designer" />\r
 \r
                     <TextView\r
-                        android:id="@+id/openrocketviewerRocketName"\r
+                        android:id="@+id/openrocketviewerDesigner"\r
                         android:layout_width="match_parent"\r
                         android:layout_height="wrap_content"\r
                         android:text="" />\r
                     <TextView\r
                         android:layout_width="match_parent"\r
                         android:layout_height="match_parent"\r
-                        android:text="Designer" />\r
+                        android:text="Length" />\r
 \r
                     <TextView\r
-                        android:id="@+id/openrocketviewerDesigner"\r
+                        android:id="@+id/openrocketviewerLength"\r
                         android:layout_width="match_parent"\r
                         android:layout_height="wrap_content"\r
                         android:text="" />\r
                     <TextView\r
                         android:layout_width="match_parent"\r
                         android:layout_height="match_parent"\r
-                        android:text="CG" />\r
+                        android:text="Empty Mass" />\r
 \r
                     <TextView\r
-                        android:id="@+id/openrocketviewerCG"\r
+                        android:id="@+id/openrocketviewerMass"\r
                         android:layout_width="match_parent"\r
                         android:layout_height="wrap_content"\r
                         android:text="" />\r
                     <TextView\r
                         android:layout_width="match_parent"\r
                         android:layout_height="match_parent"\r
-                        android:text="Length" />\r
+                        android:text="Stage Count" />\r
 \r
                     <TextView\r
-                        android:id="@+id/openrocketviewerLength"\r
+                        android:id="@+id/openrocketviewerStageCount"\r
                         android:layout_width="match_parent"\r
                         android:layout_height="wrap_content"\r
                         android:text="" />\r
 \r
-                    <TextView\r
-                        android:layout_width="match_parent"\r
+                    <Spinner android:layout_width="match_parent"\r
                         android:layout_height="match_parent"\r
-                        android:text="Mass" />\r
-\r
+                        android:id="@+id/openrocketviewerConfigurationSpinner" \r
+                        />\r
+                    \r
                     <TextView\r
-                        android:id="@+id/openrocketviewerMass"\r
                         android:layout_width="match_parent"\r
-                        android:layout_height="wrap_content"\r
-                        android:text="" />\r
+                        android:layout_height="match_parent"\r
+                        android:text="Comment" />\r
 \r
                     <TextView\r
                         android:layout_width="match_parent"\r
                         android:layout_height="match_parent"\r
-                        android:text="Stage Count" />\r
+                        android:text="CG" />\r
 \r
                     <TextView\r
-                        android:id="@+id/openrocketviewerStageCount"\r
+                        android:id="@+id/openrocketviewerCG"\r
                         android:layout_width="match_parent"\r
                         android:layout_height="wrap_content"\r
                         android:text="" />\r
 \r
-                    <TextView\r
-                        android:layout_width="match_parent"\r
-                        android:layout_height="match_parent"\r
-                        android:text="Comment" />\r
-\r
                     <TextView\r
                         android:id="@+id/openrocketviewerComment"\r
                         android:layout_width="match_parent"\r
index ad2d3e057dd96578bd124d3d25c2f7465caf3cb3..b7d201ab260a15a275d2935dd93e514c248d10c6 100644 (file)
@@ -11,6 +11,7 @@ import net.sf.openrocket.android.rocket.RocketComponentTreeAdapter.RocketCompone
 import net.sf.openrocket.android.simulation.SimulationViewer;\r
 import net.sf.openrocket.document.OpenRocketDocument;\r
 import net.sf.openrocket.document.Simulation;\r
+import net.sf.openrocket.masscalc.MassCalculator.MassCalcType;\r
 import net.sf.openrocket.rocketcomponent.Rocket;\r
 import net.sf.openrocket.rocketcomponent.RocketComponent;\r
 import net.sf.openrocket.rocketcomponent.RocketUtils;\r
@@ -40,6 +41,7 @@ import android.widget.AdapterView.OnItemClickListener;
 import android.widget.ArrayAdapter;\r
 import android.widget.ListAdapter;\r
 import android.widget.ListView;\r
+import android.widget.Spinner;\r
 import android.widget.TabHost;\r
 import android.widget.TextView;\r
 \r
@@ -51,6 +53,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
 \r
        private ProgressDialog progress;\r
 \r
+       private Spinner configurationSpinner;\r
        private TreeViewList componentTree;\r
        private ListView simulationList;\r
 \r
@@ -94,7 +97,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
                spec.setIndicator("Simulations");\r
                tabs.addTab(spec);      \r
 \r
-               \r
+               configurationSpinner = (Spinner) findViewById(R.id.openrocketviewerConfigurationSpinner);\r
                componentTree = (TreeViewList) findViewById(R.id.openrocketviewerComponentTree);\r
                simulationList = (ListView) findViewById(R.id.openrocketviewerSimulationList);\r
 \r
@@ -176,12 +179,19 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
 \r
                setTitle(rocket.getName());\r
 \r
+               String[] motorConfigs = rocket.getMotorConfigurationIDs();\r
+               ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item);\r
+               for( String config: motorConfigs ) {\r
+                       spinnerAdapter.add(rocket.getMotorConfigurationNameOrDescription(config));\r
+               }\r
+               \r
+               configurationSpinner.setAdapter(spinnerAdapter);\r
+               \r
                Unit LengthUnit = UnitGroup.UNITS_LENGTH.getDefaultUnit();\r
                Unit MassUnit = UnitGroup.UNITS_MASS.getDefaultUnit();\r
 \r
-               Coordinate cg = RocketUtils.getCG(rocket);\r
+               Coordinate cg = RocketUtils.getCG(rocket, MassCalcType.NO_MOTORS);\r
                double length = RocketUtils.getLength(rocket);\r
-               ((TextView) findViewById(R.id.openrocketviewerRocketName)).setText( rocket.getName());\r
                ((TextView)findViewById(R.id.openrocketviewerDesigner)).setText(rocket.getDesigner());\r
                ((TextView)findViewById(R.id.openrocketviewerCG)).setText(LengthUnit.toStringUnit(cg.x) );\r
                ((TextView)findViewById(R.id.openrocketviewerLength)).setText(LengthUnit.toStringUnit(length));\r
index 2e4b63b8a43296eca57d6e87ec44ed57b689723a..71360b9a22b3e76419faf105bc8e66e94a664011 100644 (file)
@@ -25,9 +25,9 @@ public abstract class RocketUtils {
                return length;\r
        }\r
 \r
-       public static Coordinate getCG(Rocket rocket) {\r
+       public static Coordinate getCG(Rocket rocket, MassCalcType calcType) {\r
                MassCalculator massCalculator = new BasicMassCalculator();\r
-               Coordinate cg = massCalculator.getCG(rocket.getDefaultConfiguration(), MassCalcType.LAUNCH_MASS);\r
+               Coordinate cg = massCalculator.getCG(rocket.getDefaultConfiguration(), calcType);\r
                return cg;\r
        }\r
        \r