Save reference to document in rocket

This commit is contained in:
SiboVG 2024-08-08 12:05:41 +02:00
parent 00acb8b68f
commit 7472ad7c8c
2 changed files with 20 additions and 1 deletions

View File

@ -110,6 +110,7 @@ public class OpenRocketDocument implements ComponentChangeListener, StateChangeL
*/
OpenRocketDocument(Rocket rocket) {
this.rocket = rocket;
rocket.setDocument(this);
this.objOptions = prefs.loadOBJExportOptions(rocket);
rocket.enableEvents();
init();

View File

@ -3,6 +3,7 @@ package info.openrocket.core.rocketcomponent;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import info.openrocket.core.document.OpenRocketDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -51,6 +52,7 @@ public class Rocket extends ComponentAssembly {
private boolean eventsEnabled = false;
private OpenRocketDocument document;
private ReferenceType refType = ReferenceType.MAXIMUM; // Set in constructor
private double customReferenceLength = DEFAULT_REFERENCE_LENGTH;
@ -191,7 +193,23 @@ public class Rocket extends ComponentAssembly {
public int getFunctionalModID() {
return functionalModID;
}
/**
* Return the OpenRocketDocument that this rocket is part of, or null if it is not part of any document.
* @return the document, or null
*/
public OpenRocketDocument getDocument() {
return document;
}
/**
* Set the OpenRocketDocument that this rocket is part of.
* @param document the document
*/
public void setDocument(OpenRocketDocument document) {
this.document = document;
}
public Collection<AxialStage> getStageList() {
return this.stageMap.values();
}