implemented loading of stage parameters (and fixed stage xml writing
This commit is contained in:
parent
177b24a667
commit
8755777924
@ -406,6 +406,11 @@ class DocumentConfig {
|
||||
setters.put("Stage:separationdelay", new DoubleSetter(
|
||||
Reflection.findMethod(Stage.class, "getStageSeparationConfiguration"),
|
||||
Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationDelay", double.class)));
|
||||
setters.put("Stage:outside", new BooleanSetter(Reflection.findMethod(Stage.class, "setOutside", boolean.class)));
|
||||
setters.put("Stage:relativeto", new IntSetter(Reflection.findMethod(Stage.class, "setRelativeToStage", int.class)));
|
||||
setters.put("Stage:instancecount", new IntSetter(Reflection.findMethod(Stage.class, "setCount", int.class)));
|
||||
setters.put("Stage:radialoffset", new DoubleSetter(Reflection.findMethod(Stage.class, "setRadialPosition", double.class)));
|
||||
setters.put("Stage:angleoffset", new DoubleSetter(Reflection.findMethod(Stage.class, "setAngularPosition", double.class)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import net.sf.openrocket.rocketcomponent.InternalComponent;
|
||||
import net.sf.openrocket.rocketcomponent.LaunchLug;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
|
||||
import net.sf.openrocket.rocketcomponent.Stage;
|
||||
import net.sf.openrocket.rocketcomponent.TubeFinSet;
|
||||
|
||||
class PositionSetter implements Setter {
|
||||
@ -44,6 +45,9 @@ class PositionSetter implements Setter {
|
||||
} else if (c instanceof TubeFinSet) {
|
||||
((TubeFinSet) c).setRelativePosition(type);
|
||||
c.setPositionValue(pos);
|
||||
} else if (c instanceof Stage) {
|
||||
((Stage) c).setRelativePositionMethod(type);
|
||||
((Stage) c).setPositionValue(pos);
|
||||
} else {
|
||||
warnings.add(Warning.FILE_INVALID_PARAMETER);
|
||||
}
|
||||
|
@ -62,30 +62,33 @@ public class StageSaver extends ComponentAssemblySaver {
|
||||
|
||||
private Collection<? extends String> addStageReplicationParams(final Stage currentStage) {
|
||||
List<String> elementsToReturn = new ArrayList<String>();
|
||||
final String relTo_tag = "relativeto";
|
||||
final String outside_tag = "outside";
|
||||
final String instCt_tag = "instancecount";
|
||||
final String radoffs_tag = "radialoffset";
|
||||
final String startangle_tag = "angleoffset";
|
||||
|
||||
|
||||
if (null != currentStage) {
|
||||
|
||||
boolean outsideFlag = currentStage.getOutside();
|
||||
elementsToReturn.add("<outside=\"" + outsideFlag + "\">");
|
||||
int instanceCount = currentStage.getInstanceCount();
|
||||
elementsToReturn.add("<instanceCount=\"" + instanceCount + "\">");
|
||||
double radialOffset = currentStage.getRadialPosition();
|
||||
elementsToReturn.add("<radialOffset=\"" + radialOffset + "\">");
|
||||
double angularOffset = currentStage.getAngularPosition();
|
||||
elementsToReturn.add("<angleOffset=\"" + angularOffset + "\">");
|
||||
|
||||
// Save position unless "AFTER"
|
||||
if (currentStage.getRelativePosition() != RocketComponent.Position.AFTER) {
|
||||
// The type names are currently equivalent to the enum names except for case.
|
||||
String type = currentStage.getRelativePositionMethod().name().toLowerCase(Locale.ENGLISH);
|
||||
double axialOffset = currentStage.getAxialPosition();
|
||||
elementsToReturn.add("<position type=\"" + type + "\">" + axialOffset + "</position>");
|
||||
// position type and offset are saved in superclass
|
||||
// String type = currentStage.getRelativePositionMethod().name().toLowerCase(Locale.ENGLISH);
|
||||
// double axialOffset = currentStage.getAxialPosition();
|
||||
// elementsToReturn.add("<position type=\"" + type + "\">" + axialOffset + "</position>");
|
||||
int relativeTo = currentStage.getRelativeToStage();
|
||||
elementsToReturn.add("<relativeTo=\"" + relativeTo + "\">");
|
||||
elementsToReturn.add("<" + relTo_tag + ">" + relativeTo + "</" + relTo_tag + ">");
|
||||
}
|
||||
|
||||
// do not save
|
||||
double angularSeparation = Double.NaN; // doesn't need to be saved b/c it's derived from instanceCount
|
||||
boolean outsideFlag = currentStage.getOutside();
|
||||
elementsToReturn.add("<" + outside_tag + ">" + outsideFlag + "</" + outside_tag + ">");
|
||||
int instanceCount = currentStage.getInstanceCount();
|
||||
elementsToReturn.add("<" + instCt_tag + ">" + instanceCount + "</" + instCt_tag + ">");
|
||||
double radialOffset = currentStage.getRadialPosition();
|
||||
elementsToReturn.add("<" + radoffs_tag + ">" + radialOffset + "</" + radoffs_tag + ">");
|
||||
double angularOffset = currentStage.getAngularPosition();
|
||||
elementsToReturn.add("<" + startangle_tag + ">" + angularOffset + "</" + startangle_tag + ">");
|
||||
|
||||
}
|
||||
|
||||
return elementsToReturn;
|
||||
|
@ -28,7 +28,6 @@ public class StageSelectModel extends AbstractListModel<Stage> implements ComboB
|
||||
protected Stage sourceStage = null;
|
||||
protected ArrayList<Stage> displayValues = new ArrayList<Stage>();
|
||||
protected Stage selectedStage = null;
|
||||
protected int selectedStageIndex=-1; // index of stage in rocket, as returned by stage.getStageNumber();
|
||||
|
||||
//@SuppressWarnings("unchecked")
|
||||
public StageSelectModel( final Stage _stage, String nullText) {
|
||||
@ -91,20 +90,13 @@ public class StageSelectModel extends AbstractListModel<Stage> implements ComboB
|
||||
|
||||
if( newItem instanceof Stage ){
|
||||
Stage nextStage = (Stage) newItem;
|
||||
int nextStageIndex = nextStage.getStageNumber();
|
||||
|
||||
|
||||
if (nextStage.equals(this.selectedStage)){
|
||||
return; // i.e. no change
|
||||
}
|
||||
|
||||
this.selectedStage = nextStage;
|
||||
this.selectedStageIndex = nextStageIndex;
|
||||
this.sourceStage.setRelativeToStage(nextStageIndex);
|
||||
|
||||
// DEVEL
|
||||
int nextDisplayIndex = this.displayValues.indexOf(newItem);
|
||||
log.error("DEVEL success. set stage number to: "+nextDisplayIndex+" @"+nextStageIndex);
|
||||
log.error("DEVEL success. set stage number to: "+nextStage.getName()+" ="+nextStage.toString());
|
||||
this.selectedStage = nextStage;
|
||||
this.sourceStage.setRelativeToStage(nextStage.getStageNumber());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -134,7 +126,7 @@ public class StageSelectModel extends AbstractListModel<Stage> implements ComboB
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StageSelectModel["+this.selectedStage.getName()+" @"+this.selectedStageIndex+"]";
|
||||
return "StageSelectModel["+this.selectedStage.getName()+" ("+this.selectedStage.getStageNumber()+")]";
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user