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.
This commit is contained in:
parent
16334ca53a
commit
e766449e15
@ -31,17 +31,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Rocket Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/openrocketviewerRocketName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -53,17 +42,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="CG" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/openrocketviewerCG"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -78,7 +56,7 @@
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Mass" />
|
||||
android:text="Empty Mass" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/openrocketviewerMass"
|
||||
@ -97,11 +75,27 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
<Spinner android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/openrocketviewerConfigurationSpinner"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Comment" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="CG" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/openrocketviewerCG"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/openrocketviewerComment"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -11,6 +11,7 @@ import net.sf.openrocket.android.rocket.RocketComponentTreeAdapter.RocketCompone
|
||||
import net.sf.openrocket.android.simulation.SimulationViewer;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
import net.sf.openrocket.masscalc.MassCalculator.MassCalcType;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.RocketUtils;
|
||||
@ -40,6 +41,7 @@ import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -51,6 +53,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
|
||||
private ProgressDialog progress;
|
||||
|
||||
private Spinner configurationSpinner;
|
||||
private TreeViewList componentTree;
|
||||
private ListView simulationList;
|
||||
|
||||
@ -94,7 +97,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
spec.setIndicator("Simulations");
|
||||
tabs.addTab(spec);
|
||||
|
||||
|
||||
configurationSpinner = (Spinner) findViewById(R.id.openrocketviewerConfigurationSpinner);
|
||||
componentTree = (TreeViewList) findViewById(R.id.openrocketviewerComponentTree);
|
||||
simulationList = (ListView) findViewById(R.id.openrocketviewerSimulationList);
|
||||
|
||||
@ -176,12 +179,19 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
|
||||
setTitle(rocket.getName());
|
||||
|
||||
String[] motorConfigs = rocket.getMotorConfigurationIDs();
|
||||
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(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));
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user