[Bugfix] Fixed several Config Id-Simulation Display Issues
- Initial selected configuration is the last loaded - Correctly loads the correct config Id for each simulation - Can correctly display the Config Id for each sim. (both in table, and edit)
This commit is contained in:
parent
040c451a3d
commit
defcf24c86
@ -252,6 +252,10 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
|||||||
|
|
||||||
public void addSimulation(Simulation simulation) {
|
public void addSimulation(Simulation simulation) {
|
||||||
simulations.add(simulation);
|
simulations.add(simulation);
|
||||||
|
FlightConfigurationID simId = simulation.getId();
|
||||||
|
if( !rocket.containsFlightConfigurationID( simId )){
|
||||||
|
rocket.createFlightConfiguration(simId);
|
||||||
|
}
|
||||||
fireDocumentChangeEvent(new SimulationChangeEvent(simulation));
|
fireDocumentChangeEvent(new SimulationChangeEvent(simulation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,12 +632,12 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSimulationDetail(){
|
public String toSimulationDetail(){
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
str.append(">> Dumping simulation list:\n");
|
str.append(">> Dumping simulation list:\n");
|
||||||
int simNum = 0;
|
int simNum = 0;
|
||||||
for( Simulation s : this.simulations ){
|
for( Simulation s : this.simulations ){
|
||||||
str.append(String.format(" [%d] %s \n", simNum, s.getName(), s.getOptions().getId().toShortKey() ));
|
str.append(String.format(" [%d] %s (%s) \n", simNum, s.getName(), s.getOptions().getId().toShortKey() ));
|
||||||
simNum++;
|
simNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import net.sf.openrocket.formatting.RocketDescriptor;
|
|||||||
import net.sf.openrocket.masscalc.MassCalculator;
|
import net.sf.openrocket.masscalc.MassCalculator;
|
||||||
import net.sf.openrocket.motor.MotorInstance;
|
import net.sf.openrocket.motor.MotorInstance;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationID;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.simulation.BasicEventSimulationEngine;
|
import net.sf.openrocket.simulation.BasicEventSimulationEngine;
|
||||||
import net.sf.openrocket.simulation.DefaultSimulationOptionFactory;
|
import net.sf.openrocket.simulation.DefaultSimulationOptionFactory;
|
||||||
@ -114,7 +115,8 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
DefaultSimulationOptionFactory f = Application.getInjector().getInstance(DefaultSimulationOptionFactory.class);
|
DefaultSimulationOptionFactory f = Application.getInjector().getInstance(DefaultSimulationOptionFactory.class);
|
||||||
options.copyConditionsFrom(f.getDefault());
|
options.copyConditionsFrom(f.getDefault());
|
||||||
|
|
||||||
options.setFlightConfigurationId(rocket.getDefaultConfiguration().getFlightConfigurationID());
|
FlightConfigurationID fcid = rocket.getDefaultConfiguration().getFlightConfigurationID();
|
||||||
|
options.setFlightConfigurationId(fcid);
|
||||||
options.addChangeListener(new ConditionListener());
|
options.addChangeListener(new ConditionListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,8 +172,11 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
mutex.verify();
|
mutex.verify();
|
||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
//
|
public FlightConfigurationID getId(){
|
||||||
|
return this.options.getFlightConfigurationId();
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Return a newly created Configuration for this simulation. The configuration
|
// * Return a newly created Configuration for this simulation. The configuration
|
||||||
// * has the motor ID set and all stages active.
|
// * has the motor ID set and all stages active.
|
||||||
@ -515,4 +520,5 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,13 @@ class ComponentParameterHandler extends AbstractElementHandler {
|
|||||||
}
|
}
|
||||||
return new MotorConfigurationHandler((Rocket) component, context);
|
return new MotorConfigurationHandler((Rocket) component, context);
|
||||||
}
|
}
|
||||||
|
if (element.equals("flightconfiguration")) {
|
||||||
|
if (!(component instanceof Rocket)) {
|
||||||
|
warnings.add(Warning.fromString("Illegal component defined for flight configuration."));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new MotorConfigurationHandler((Rocket) component, context);
|
||||||
|
}
|
||||||
if ( element.equals("deploymentconfiguration")) {
|
if ( element.equals("deploymentconfiguration")) {
|
||||||
if ( !(component instanceof RecoveryDevice) ) {
|
if ( !(component instanceof RecoveryDevice) ) {
|
||||||
warnings.add(Warning.fromString("Illegal component defined as recovery device."));
|
warnings.add(Warning.fromString("Illegal component defined as recovery device."));
|
||||||
|
@ -50,11 +50,9 @@ class SimulationConditionsHandler extends AbstractElementHandler {
|
|||||||
|
|
||||||
|
|
||||||
if (element.equals("configid")) {
|
if (element.equals("configid")) {
|
||||||
if (content.equals("")) {
|
// the ID constructor is designed to always return a valid value
|
||||||
conditions.setFlightConfigurationId(null);
|
FlightConfigurationID idToSet= new FlightConfigurationID(content);
|
||||||
} else {
|
conditions.setFlightConfigurationId(idToSet);
|
||||||
conditions.setFlightConfigurationId(new FlightConfigurationID(content));
|
|
||||||
}
|
|
||||||
} else if (element.equals("launchrodlength")) {
|
} else if (element.equals("launchrodlength")) {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal launch rod length defined, ignoring.");
|
warnings.add("Illegal launch rod length defined, ignoring.");
|
||||||
|
@ -73,7 +73,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
* @param _fcid the ID this configuration should have.
|
* @param _fcid the ID this configuration should have.
|
||||||
* @param rocket the rocket
|
* @param rocket the rocket
|
||||||
*/
|
*/
|
||||||
public FlightConfiguration(final FlightConfigurationID _fcid, Rocket rocket ) {
|
public FlightConfiguration(final Rocket rocket, final FlightConfigurationID _fcid ) {
|
||||||
if( null == _fcid){
|
if( null == _fcid){
|
||||||
this.fcid = new FlightConfigurationID();
|
this.fcid = new FlightConfigurationID();
|
||||||
}else{
|
}else{
|
||||||
@ -456,7 +456,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public FlightConfiguration clone() {
|
public FlightConfiguration clone() {
|
||||||
FlightConfiguration config = new FlightConfiguration( this.fcid, this.getRocket() );
|
FlightConfiguration config = new FlightConfiguration( this.getRocket(), this.fcid );
|
||||||
config.listenerList = new ArrayList<EventListener>();
|
config.listenerList = new ArrayList<EventListener>();
|
||||||
config.stages.putAll( (Map<Integer, StageFlags>) this.stages);
|
config.stages.putAll( (Map<Integer, StageFlags>) this.stages);
|
||||||
config.motors.populate( this.motors );
|
config.motors.populate( this.motors );
|
||||||
|
@ -12,11 +12,10 @@ public final class FlightConfigurationID implements Comparable<FlightConfigurati
|
|||||||
|
|
||||||
private final static long DEFAULT_MOST_SIG_BITS = 0xF4F2F1F0;
|
private final static long DEFAULT_MOST_SIG_BITS = 0xF4F2F1F0;
|
||||||
private final static UUID ERROR_CONFIGURATION_UUID = new UUID( DEFAULT_MOST_SIG_BITS, 2489);
|
private final static UUID ERROR_CONFIGURATION_UUID = new UUID( DEFAULT_MOST_SIG_BITS, 2489);
|
||||||
// private final static String DEFAULT_CONFIGURATION_KEYTEXT = "default_configuration_6602";
|
private final static String ERROR_KEY_NAME = "<Error_Key>";
|
||||||
private final static UUID DEFAULT_VALUE_UUID = new UUID( DEFAULT_MOST_SIG_BITS, 5676);
|
private final static UUID DEFAULT_VALUE_UUID = new UUID( DEFAULT_MOST_SIG_BITS, 5676);
|
||||||
|
|
||||||
public final static FlightConfigurationID ERROR_CONFIGURATION_FCID = new FlightConfigurationID( FlightConfigurationID.ERROR_CONFIGURATION_UUID);
|
public final static FlightConfigurationID ERROR_CONFIGURATION_FCID = new FlightConfigurationID( FlightConfigurationID.ERROR_CONFIGURATION_UUID);
|
||||||
// public final static FlightConfigurationID DEFAULT_CONFIGURATION_FCID = new FlightConfigurationID( FlightConfigurationID.DEFAULT_CONFIGURATION_KEYTEXT );
|
|
||||||
public final static FlightConfigurationID DEFAULT_VALUE_FCID = new FlightConfigurationID( FlightConfigurationID.DEFAULT_VALUE_UUID );
|
public final static FlightConfigurationID DEFAULT_VALUE_FCID = new FlightConfigurationID( FlightConfigurationID.DEFAULT_VALUE_UUID );
|
||||||
|
|
||||||
public FlightConfigurationID() {
|
public FlightConfigurationID() {
|
||||||
@ -24,8 +23,12 @@ public final class FlightConfigurationID implements Comparable<FlightConfigurati
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfigurationID(final String _str) {
|
public FlightConfigurationID(final String _str) {
|
||||||
|
if("".equals(_str)){
|
||||||
|
this.key = UUID.randomUUID();
|
||||||
|
}else{
|
||||||
this.key = UUID.fromString( _str);
|
this.key = UUID.fromString( _str);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FlightConfigurationID(final UUID _val) {
|
public FlightConfigurationID(final UUID _val) {
|
||||||
if (null == _val){
|
if (null == _val){
|
||||||
@ -46,7 +49,11 @@ public final class FlightConfigurationID implements Comparable<FlightConfigurati
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toShortKey(){
|
public String toShortKey(){
|
||||||
|
if( isValid()){
|
||||||
return this.key.toString().substring(0,8);
|
return this.key.toString().substring(0,8);
|
||||||
|
}else{
|
||||||
|
return ERROR_KEY_NAME;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullKeyText(){
|
public String getFullKeyText(){
|
||||||
@ -62,8 +69,11 @@ public final class FlightConfigurationID implements Comparable<FlightConfigurati
|
|||||||
return this.key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasError(){
|
||||||
|
return (ERROR_CONFIGURATION_UUID == this.key);
|
||||||
|
}
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return (this.key != ERROR_CONFIGURATION_UUID);
|
return !hasError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,8 +112,25 @@ public class ParameterSet<E extends FlightConfigurableParameter<E>> implements F
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public E get(final int index) {
|
||||||
|
if( 0 > index){
|
||||||
|
throw new ArrayIndexOutOfBoundsException("Attempt to retrieve a configurable parameter by an index less than zero: "+index);
|
||||||
|
}
|
||||||
|
if(( 0 > index) || ( this.map.size() <= index )){
|
||||||
|
throw new ArrayIndexOutOfBoundsException("Attempt to retrieve a configurable parameter with an index larger "
|
||||||
|
+" than the stored values: "+index+"/"+this.map.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<FlightConfigurationID> ids = this.getSortedConfigurationIDs();
|
||||||
|
FlightConfigurationID selectedId = ids.get(index);
|
||||||
|
return this.map.get(selectedId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public E get(FlightConfigurationID id) {
|
public E get(FlightConfigurationID id) {
|
||||||
|
if( id.hasError() ){
|
||||||
|
throw new NullPointerException("Attempted to retrieve a parameter with an error key!");
|
||||||
|
}
|
||||||
E toReturn;
|
E toReturn;
|
||||||
if (map.containsKey(id)) {
|
if (map.containsKey(id)) {
|
||||||
toReturn = map.get(id);
|
toReturn = map.get(id);
|
||||||
@ -224,7 +241,7 @@ public class ParameterSet<E extends FlightConfigurableParameter<E>> implements F
|
|||||||
if( this.isDefault(inst)){
|
if( this.isDefault(inst)){
|
||||||
shortKey = "*"+shortKey+"*";
|
shortKey = "*"+shortKey+"*";
|
||||||
}
|
}
|
||||||
buf.append(String.format(" >> [%s]= %s\n", shortKey, inst.toString() ));
|
buf.append(String.format(" >> [%s]= %s\n", shortKey, inst ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
|
@ -84,7 +84,7 @@ public class Rocket extends RocketComponent {
|
|||||||
treeModID = modID;
|
treeModID = modID;
|
||||||
functionalModID = modID;
|
functionalModID = modID;
|
||||||
|
|
||||||
FlightConfiguration defaultConfiguration = new FlightConfiguration( null, this);
|
FlightConfiguration defaultConfiguration = new FlightConfiguration( this, null);
|
||||||
this.configSet = new FlightConfigurationSet(this, ComponentChangeEvent.CONFIG_CHANGE, defaultConfiguration);
|
this.configSet = new FlightConfigurationSet(this, ComponentChangeEvent.CONFIG_CHANGE, defaultConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,12 +520,15 @@ public class Rocket extends RocketComponent {
|
|||||||
|
|
||||||
public FlightConfiguration createFlightConfiguration( final FlightConfigurationID fcid) {
|
public FlightConfiguration createFlightConfiguration( final FlightConfigurationID fcid) {
|
||||||
checkState();
|
checkState();
|
||||||
if( configSet.containsKey(fcid)){
|
if( fcid.hasError() ){
|
||||||
|
throw new NullPointerException("Attempted to create a flightConfiguration from an error key!");
|
||||||
|
}else if( configSet.containsKey(fcid)){
|
||||||
return this.configSet.get(fcid);
|
return this.configSet.get(fcid);
|
||||||
}else{
|
}else{
|
||||||
FlightConfiguration nextConfig = new FlightConfiguration(fcid, this);
|
FlightConfiguration nextConfig = new FlightConfiguration(this, fcid);
|
||||||
this.configSet.set(fcid, nextConfig);
|
this.configSet.set(fcid, nextConfig);
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
this.configSet.setDefault( nextConfig);
|
||||||
|
fireComponentChangeEvent(ComponentChangeEvent.TREE_CHANGE);
|
||||||
return nextConfig;
|
return nextConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -552,8 +555,9 @@ public class Rocket extends RocketComponent {
|
|||||||
*/
|
*/
|
||||||
public void removeFlightConfigurationID(FlightConfigurationID fcid) {
|
public void removeFlightConfigurationID(FlightConfigurationID fcid) {
|
||||||
checkState();
|
checkState();
|
||||||
if (fcid == null)
|
if( fcid.hasError() ){
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get current configuration:
|
// Get current configuration:
|
||||||
this.configSet.set(fcid, null);
|
this.configSet.set(fcid, null);
|
||||||
@ -569,8 +573,10 @@ public class Rocket extends RocketComponent {
|
|||||||
*/
|
*/
|
||||||
public boolean containsFlightConfigurationID(FlightConfigurationID id) {
|
public boolean containsFlightConfigurationID(FlightConfigurationID id) {
|
||||||
checkState();
|
checkState();
|
||||||
FlightConfiguration config = configSet.get( id);
|
if( id.hasError() ){
|
||||||
return (null != config);
|
return false;
|
||||||
|
}
|
||||||
|
return configSet.containsKey( id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -582,8 +588,9 @@ public class Rocket extends RocketComponent {
|
|||||||
*/
|
*/
|
||||||
public boolean hasMotors(FlightConfigurationID fcid) {
|
public boolean hasMotors(FlightConfigurationID fcid) {
|
||||||
checkState();
|
checkState();
|
||||||
if (fcid == null)
|
if( fcid.hasError() ){
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Iterator<RocketComponent> iterator = this.iterator();
|
Iterator<RocketComponent> iterator = this.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@ -608,24 +615,34 @@ public class Rocket extends RocketComponent {
|
|||||||
* @param id the flight configuration id
|
* @param id the flight configuration id
|
||||||
* @return a FlightConfiguration instance
|
* @return a FlightConfiguration instance
|
||||||
*/
|
*/
|
||||||
public FlightConfiguration getFlightConfiguration(final FlightConfigurationID id) {
|
public FlightConfiguration getFlightConfiguration(final FlightConfigurationID fcid) {
|
||||||
checkState();
|
checkState();
|
||||||
return this.configSet.get(id);
|
return this.createFlightConfiguration(fcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a flight configuration. If the supplied index is out of bounds, an exception is thrown.
|
||||||
|
*
|
||||||
|
* @param id the flight configuration index number
|
||||||
|
* @return a FlightConfiguration instance
|
||||||
|
*/
|
||||||
|
public FlightConfiguration getFlightConfiguration(final int configIndex) {
|
||||||
|
checkState();
|
||||||
|
return this.configSet.get(configIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setDefaultConfiguration(final FlightConfigurationID fcid) {
|
public void setDefaultConfiguration(final FlightConfigurationID fcid) {
|
||||||
checkState();
|
checkState();
|
||||||
if ( null == fcid ){
|
|
||||||
// silently ignore
|
if( fcid.hasError() ){
|
||||||
|
log.error("attempt to set a 'fcid = config' with a error fcid. Ignored.", new IllegalArgumentException("error id:"+fcid));
|
||||||
return;
|
return;
|
||||||
}else if( this.configSet.containsKey(fcid)){
|
}else if( this.configSet.containsKey(fcid)){
|
||||||
configSet.setDefault( configSet.get(fcid));
|
configSet.setDefault( configSet.get(fcid));
|
||||||
}else{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate the given ID and flight configuration.
|
* Associate the given ID and flight configuration.
|
||||||
@ -636,18 +653,19 @@ public class Rocket extends RocketComponent {
|
|||||||
*/
|
*/
|
||||||
public void setFlightConfiguration(final FlightConfigurationID fcid, FlightConfiguration newConfig) {
|
public void setFlightConfiguration(final FlightConfigurationID fcid, FlightConfiguration newConfig) {
|
||||||
checkState();
|
checkState();
|
||||||
if (( null == fcid ) || (null == newConfig)){
|
if( fcid.hasError() ){
|
||||||
// silently ignore
|
log.error("attempt to set a 'fcid = config' with a error fcid. Ignored.", new IllegalArgumentException("error id:"+fcid));
|
||||||
return;
|
return;
|
||||||
}else{
|
|
||||||
configSet.set(fcid, newConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null == newConfig){
|
||||||
|
newConfig = createFlightConfiguration(fcid);
|
||||||
|
}
|
||||||
|
configSet.set(fcid, newConfig);
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////// Obligatory component information
|
//////// Obligatory component information
|
||||||
@Override
|
@Override
|
||||||
public String getComponentName() {
|
public String getComponentName() {
|
||||||
|
@ -65,8 +65,8 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
FlightData flightData = new FlightData();
|
FlightData flightData = new FlightData();
|
||||||
|
|
||||||
// Set up rocket configuration
|
// Set up rocket configuration
|
||||||
FlightConfiguration configuration = setupConfiguration(simulationConditions);
|
this.fcid = simulationConditions.getConfigurationID();
|
||||||
this.fcid = configuration.getFlightConfigurationID();
|
FlightConfiguration configuration = simulationConditions.getRocket().getFlightConfiguration( this.fcid);
|
||||||
|
|
||||||
List<MotorInstance> activeMotors = configuration.getActiveMotors();
|
List<MotorInstance> activeMotors = configuration.getActiveMotors();
|
||||||
if ( activeMotors.isEmpty() ) {
|
if ( activeMotors.isEmpty() ) {
|
||||||
@ -247,21 +247,6 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
return status.getFlightData();
|
return status.getFlightData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a rocket configuration from the launch conditions.
|
|
||||||
*
|
|
||||||
* @param simulation the launch conditions.
|
|
||||||
* @return a rocket configuration with all stages attached.
|
|
||||||
*/
|
|
||||||
private FlightConfiguration setupConfiguration(SimulationConditions simulation) {
|
|
||||||
FlightConfiguration configuration = new FlightConfiguration(simulation.getMotorConfigurationID(), simulation.getRocket());
|
|
||||||
configuration.setAllStages();
|
|
||||||
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles events occurring during the flight from the event queue.
|
* Handles events occurring during the flight from the event queue.
|
||||||
* Each event that has occurred before or at the current simulation time is
|
* Each event that has occurred before or at the current simulation time is
|
||||||
|
@ -119,6 +119,10 @@ public class SimulationConditions implements Monitorable, Cloneable {
|
|||||||
return configID;
|
return configID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FlightConfigurationID getConfigurationID() {
|
||||||
|
return configID;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFlightConfigurationID(FlightConfigurationID _fcid) {
|
public void setFlightConfigurationID(FlightConfigurationID _fcid) {
|
||||||
this.configID = _fcid;
|
this.configID = _fcid;
|
||||||
this.modID++;
|
this.modID++;
|
||||||
|
@ -51,7 +51,7 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
protected final Preferences preferences = Application.getPreferences();
|
protected final Preferences preferences = Application.getPreferences();
|
||||||
|
|
||||||
private final Rocket rocket;
|
private final Rocket rocket;
|
||||||
private FlightConfigurationID configId = null;
|
private FlightConfigurationID configId = FlightConfigurationID.ERROR_CONFIGURATION_FCID;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: When adding/modifying parameters, they must also be added to the
|
* NOTE: When adding/modifying parameters, they must also be added to the
|
||||||
@ -100,7 +100,7 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfigurationID getFlightConfiguratioId() {
|
public FlightConfigurationID getFlightConfigurationId() {
|
||||||
return getId();
|
return getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,16 +109,17 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the motor configuration ID. This must be a valid motor configuration ID of
|
* Set the motor configuration ID. If this id does not yet exist, it will be created.
|
||||||
* the rocket, otherwise the configuration is set to <code>null</code>.
|
|
||||||
*
|
*
|
||||||
* @param id the configuration to set.
|
* @param id the configuration to set.
|
||||||
*/
|
*/
|
||||||
public void setFlightConfigurationId(FlightConfigurationID fcid) {
|
public void setFlightConfigurationId(FlightConfigurationID fcid) {
|
||||||
if (! fcid.isValid() ){
|
if ( null == fcid ){
|
||||||
return; // error
|
throw new NullPointerException("Attempted to set a null Config id in simulation options. Not allowed!");
|
||||||
|
}else if ( fcid.hasError() ){
|
||||||
|
throw new IllegalArgumentException("Attempted to set the configuration to an error id. Not Allowed!");
|
||||||
}else if (!rocket.containsFlightConfigurationID(fcid)){
|
}else if (!rocket.containsFlightConfigurationID(fcid)){
|
||||||
return;
|
rocket.createFlightConfiguration(fcid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fcid.equals(this.configId)){
|
if( fcid.equals(this.configId)){
|
||||||
|
@ -48,6 +48,8 @@ import net.sf.openrocket.gui.simulation.SimulationRunDialog;
|
|||||||
import net.sf.openrocket.gui.simulation.SimulationWarningDialog;
|
import net.sf.openrocket.gui.simulation.SimulationWarningDialog;
|
||||||
import net.sf.openrocket.gui.util.Icons;
|
import net.sf.openrocket.gui.util.Icons;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationID;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
@ -126,6 +128,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
if (selection.length == 0) {
|
if (selection.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Simulation[] sims = new Simulation[selection.length];
|
Simulation[] sims = new Simulation[selection.length];
|
||||||
for (int i = 0; i < selection.length; i++) {
|
for (int i = 0; i < selection.length; i++) {
|
||||||
selection[i] = simulationTable.convertRowIndexToModel(selection[i]);
|
selection[i] = simulationTable.convertRowIndexToModel(selection[i]);
|
||||||
@ -333,10 +336,13 @@ public class SimulationPanel extends JPanel {
|
|||||||
new Column(trans.get("simpanel.col.Configuration")) {
|
new Column(trans.get("simpanel.col.Configuration")) {
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row) {
|
public Object getValueAt(int row) {
|
||||||
if (row < 0 || row >= document.getSimulationCount())
|
if (row < 0 || row >= document.getSimulationCount()){
|
||||||
return null;
|
return null;
|
||||||
FlightConfiguration c = new FlightConfiguration( null, document.getSimulation(row).getRocket());
|
}
|
||||||
return descriptor.format(c.getRocket(), c.getFlightConfigurationID());
|
|
||||||
|
Rocket rkt = document.getRocket();
|
||||||
|
FlightConfigurationID fcid = document.getSimulation(row).getId();
|
||||||
|
return descriptor.format( rkt, fcid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -124,7 +124,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
|
|
||||||
private void addConfiguration() {
|
private void addConfiguration() {
|
||||||
FlightConfigurationID newFCID = new FlightConfigurationID();
|
FlightConfigurationID newFCID = new FlightConfigurationID();
|
||||||
FlightConfiguration newConfig = new FlightConfiguration( newFCID, rocket );
|
FlightConfiguration newConfig = new FlightConfiguration( rocket, newFCID );
|
||||||
|
|
||||||
rocket.setFlightConfiguration(newFCID, newConfig);
|
rocket.setFlightConfiguration(newFCID, newConfig);
|
||||||
|
|
||||||
|
@ -309,6 +309,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
ParameterSetModel<FlightConfiguration> psm = new ParameterSetModel<FlightConfiguration>( configuration.getRocket().getConfigurationSet());
|
ParameterSetModel<FlightConfiguration> psm = new ParameterSetModel<FlightConfiguration>( configuration.getRocket().getConfigurationSet());
|
||||||
JComboBox<FlightConfiguration> flightConfigurationComboBox = new JComboBox<FlightConfiguration>(psm);
|
JComboBox<FlightConfiguration> flightConfigurationComboBox = new JComboBox<FlightConfiguration>(psm);
|
||||||
add(flightConfigurationComboBox, "wrap, width 16%, wmin 100");
|
add(flightConfigurationComboBox, "wrap, width 16%, wmin 100");
|
||||||
|
|
||||||
flightConfigurationComboBox.addActionListener(new ActionListener(){
|
flightConfigurationComboBox.addActionListener(new ActionListener(){
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent ae) {
|
public void actionPerformed(ActionEvent ae) {
|
||||||
@ -320,10 +321,6 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
document.getRocket().getConfigurationSet().setDefault( newConfig);
|
document.getRocket().getConfigurationSet().setDefault( newConfig);
|
||||||
updateExtras();
|
updateExtras();
|
||||||
updateFigures();
|
updateFigures();
|
||||||
// fireChangeEvent();
|
|
||||||
|
|
||||||
System.err.println(" processing actionevent for flight config combo box... cmd: "+ae.getActionCommand());
|
|
||||||
System.err.println(" seld key: "+newConfig);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -25,6 +25,7 @@ import net.sf.openrocket.gui.adaptors.ParameterSetModel;
|
|||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationID;
|
||||||
import net.sf.openrocket.simulation.SimulationOptions;
|
import net.sf.openrocket.simulation.SimulationOptions;
|
||||||
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
@ -36,7 +37,6 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
private final Simulation[] simulation;
|
private final Simulation[] simulation;
|
||||||
private final OpenRocketDocument document;
|
private final OpenRocketDocument document;
|
||||||
private final SimulationOptions conditions;
|
private final SimulationOptions conditions;
|
||||||
private final FlightConfiguration configuration;
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
JPanel cards;
|
JPanel cards;
|
||||||
@ -50,7 +50,6 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
this.parentWindow = parent;
|
this.parentWindow = parent;
|
||||||
this.simulation = sims;
|
this.simulation = sims;
|
||||||
this.conditions = simulation[0].getOptions();
|
this.conditions = simulation[0].getOptions();
|
||||||
configuration = simulation[0].getRocket().getDefaultConfiguration();
|
|
||||||
|
|
||||||
this.cards = new JPanel(new CardLayout());
|
this.cards = new JPanel(new CardLayout());
|
||||||
this.add(cards);
|
this.add(cards);
|
||||||
@ -150,18 +149,22 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
label.setToolTipText(trans.get("simedtdlg.lbl.ttip.Flightcfg"));
|
label.setToolTipText(trans.get("simedtdlg.lbl.ttip.Flightcfg"));
|
||||||
panel.add(label, "growx 0, gapright para");
|
panel.add(label, "growx 0, gapright para");
|
||||||
|
|
||||||
ParameterSetModel<FlightConfiguration> psm = new ParameterSetModel<FlightConfiguration>( configuration.getRocket().getConfigurationSet());
|
ParameterSetModel<FlightConfiguration> psm = new ParameterSetModel<FlightConfiguration>( document.getRocket().getConfigurationSet());
|
||||||
JComboBox<FlightConfiguration> combo = new JComboBox<FlightConfiguration>(psm);
|
final JComboBox<FlightConfiguration> configCombo = new JComboBox<FlightConfiguration>(psm);
|
||||||
|
FlightConfiguration config = document.getRocket().getFlightConfiguration(simulation[0].getId());
|
||||||
|
configCombo.setSelectedItem( config );
|
||||||
|
|
||||||
//// Select the motor configuration to use.
|
//// Select the motor configuration to use.
|
||||||
combo.setToolTipText(trans.get("simedtdlg.combo.ttip.Flightcfg"));
|
configCombo.setToolTipText(trans.get("simedtdlg.combo.ttip.Flightcfg"));
|
||||||
combo.addActionListener(new ActionListener() {
|
configCombo.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
conditions.setFlightConfigurationId(configuration.getFlightConfigurationID());
|
FlightConfiguration config = (FlightConfiguration) configCombo.getSelectedItem();
|
||||||
|
FlightConfigurationID id = config.getFlightConfigurationID();
|
||||||
|
conditions.setFlightConfigurationId( id );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(combo, "span");
|
panel.add(configCombo, "span");
|
||||||
|
|
||||||
panel.add(new JPanel(), "growx, wrap");
|
panel.add(new JPanel(), "growx, wrap");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user