Merge pull request #1110 from SiboVG/issue-1070

[fixes #1070] Add backward compatibility OR 15.03
This commit is contained in:
Joe Pfeiffer 2022-02-11 09:13:05 -07:00 committed by GitHub
commit 669e17ae83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -3,6 +3,8 @@ package net.sf.openrocket.file.openrocket.savers;
import java.util.List;
import java.util.Locale;
import net.sf.openrocket.rocketcomponent.FinSet;
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
import net.sf.openrocket.util.MathUtil;
public class FinSetSaver extends ExternalComponentSaver {
@ -28,6 +30,22 @@ public class FinSetSaver extends ExternalComponentSaver {
elements.add("<tabheight>" + fins.getTabHeight() + "</tabheight>");
elements.add("<tablength>" + fins.getTabLength() + "</tablength>");
// TODO: delete this when no backward compatibility with OR 15.03 is needed anymore
String offset = "center";
double offsetVal = fins.getTabOffset();
switch (fins.getTabOffsetMethod()) {
case TOP:
offset = "front";
break;
case BOTTOM:
offset = "end";
break;
case MIDDLE:
offset = "center";
break;
}
elements.add("<tabposition relativeto=\"" + offset + "\">" +
offsetVal + "</tabposition>");
elements.add("<tabposition relativeto=\"" +
fins.getTabOffsetMethod().name().toLowerCase(Locale.ENGLISH) + "\">" +
fins.getTabOffset() + "</tabposition>");

View File

@ -83,6 +83,10 @@ public class RocketComponentSaver {
// no-op. Instance counts are set via named cluster configurations
} else {
emitInteger(elements, "instancecount", c.getInstanceCount());
// TODO: delete this when no backward compatibility with OR 15.03 is needed anymore
if (c instanceof FinSet || c instanceof TubeFinSet) {
emitInteger(elements, "fincount", c.getInstanceCount());
}
}
if (c instanceof LineInstanceable) {
@ -103,6 +107,13 @@ public class RocketComponentSaver {
final String angleMethod = anglePos.getAngleMethod().name().toLowerCase(Locale.ENGLISH);
final double angleOffset = anglePos.getAngleOffset()*180.0/Math.PI;
elements.add("<angleoffset method=\"" + angleMethod + "\">" + angleOffset + "</angleoffset>");
// TODO: delete this when no backward compatibility with OR 15.03 is needed anymore
if (c instanceof FinSet || c instanceof TubeFinSet) {
elements.add("<rotation>" + angleOffset + "</rotation>");
}
else if (!(c instanceof RailButton)) {
elements.add("<radialdirection>" + angleOffset + "</radialdirection>");
}
}
// Save position unless "AFTER"
@ -110,6 +121,8 @@ public class RocketComponentSaver {
// The type names are currently equivalent to the enum names except for case.
String axialMethod = c.getAxialMethod().name().toLowerCase(Locale.ENGLISH);
elements.add("<axialoffset method=\"" + axialMethod + "\">" + c.getAxialOffset() + "</axialoffset>");
// TODO: delete this when no backward compatibility with OR 15.03 is needed anymore
elements.add("<position type=\"" + axialMethod + "\">" + c.getAxialOffset() + "</position>");
}
// Overrides