Fix issue of export children pref
This commit is contained in:
parent
8e7c6afed3
commit
08c4d08393
@ -3,6 +3,7 @@ package net.sf.openrocket.document;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import net.sf.openrocket.file.wavefrontobj.export.OBJExportOptions;
|
||||
import net.sf.openrocket.rocketcomponent.*;
|
||||
import net.sf.openrocket.startup.Preferences;
|
||||
import net.sf.openrocket.util.StateChangeListener;
|
||||
@ -93,6 +94,7 @@ public class OpenRocketDocument implements ComponentChangeListener, StateChangeL
|
||||
private int savedID = -1;
|
||||
|
||||
private final StorageOptions storageOptions = new StorageOptions();
|
||||
private final OBJExportOptions objOptions;
|
||||
|
||||
private final DecalRegistry decalRegistry = new DecalRegistry();
|
||||
|
||||
@ -105,6 +107,7 @@ public class OpenRocketDocument implements ComponentChangeListener, StateChangeL
|
||||
*/
|
||||
OpenRocketDocument(Rocket rocket) {
|
||||
this.rocket = rocket;
|
||||
this.objOptions = prefs.loadOBJExportOptions(rocket);
|
||||
rocket.enableEvents();
|
||||
init();
|
||||
}
|
||||
@ -250,6 +253,10 @@ public class OpenRocketDocument implements ComponentChangeListener, StateChangeL
|
||||
public StorageOptions getDefaultStorageOptions() {
|
||||
return storageOptions;
|
||||
}
|
||||
|
||||
public OBJExportOptions getDefaultOBJOptions() {
|
||||
return objOptions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -128,10 +128,16 @@ public class OBJOptionChooser extends JPanel {
|
||||
this.LOD.setSelectedItem(opts.getLOD());
|
||||
}
|
||||
|
||||
public void storeOptions(OBJExportOptions opts) {
|
||||
/**
|
||||
* Store the options from this GUI in the given {@link OBJExportOptions} object.
|
||||
* @param opts The options to store the options in
|
||||
* @param alwaysStoreExportChildren if true, store the export children option even. If false, only store it if the
|
||||
* checkbox was not disabled.
|
||||
*/
|
||||
public void storeOptions(OBJExportOptions opts, boolean alwaysStoreExportChildren) {
|
||||
boolean onlyComponentAssemblies = isOnlyComponentAssembliesSelected(selectedComponents);
|
||||
// Don't save the state when the checkbox is set automatically due to component assemblies
|
||||
if (!onlyComponentAssemblies) {
|
||||
if (alwaysStoreExportChildren || !onlyComponentAssemblies) {
|
||||
opts.setExportChildren(exportChildren.isSelected());
|
||||
}
|
||||
opts.setExportAppearance(exportAppearance.isSelected());
|
||||
|
@ -1405,10 +1405,16 @@ public class BasicFrame extends JFrame {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Store the OBJ options
|
||||
if (objChooser != null) {
|
||||
OBJExportOptions selectedOptions = new OBJExportOptions(rocket);
|
||||
objChooser.storeOptions(selectedOptions);
|
||||
prefs.saveOBJExportOptions(selectedOptions);
|
||||
objChooser.storeOptions(document.getDefaultOBJOptions(), true);
|
||||
|
||||
// We need to separately store the preference options, because the export children option can be
|
||||
// automatically selected based on whether only component assemblies are selected. We don't want to
|
||||
// store that state in the preferences.
|
||||
OBJExportOptions prefOptions = new OBJExportOptions(rocket);
|
||||
objChooser.storeOptions(prefOptions, false);
|
||||
prefs.saveOBJExportOptions(prefOptions);
|
||||
}
|
||||
|
||||
File file = chooser.getSelectedFile();
|
||||
@ -1642,7 +1648,7 @@ public class BasicFrame extends JFrame {
|
||||
}
|
||||
|
||||
file = FileHelper.forceExtension(file, "obj");
|
||||
OBJExportOptions options = prefs.loadOBJExportOptions(rocket);
|
||||
OBJExportOptions options = document.getDefaultOBJOptions();
|
||||
boolean isExportAsSeparateFiles = options.isExportAsSeparateFiles();
|
||||
if (isExportAsSeparateFiles || FileHelper.confirmWrite(file, BasicFrame.this)) { // No overwrite warning for separate files
|
||||
return saveAsWavefrontOBJ(file);
|
||||
@ -1651,7 +1657,7 @@ public class BasicFrame extends JFrame {
|
||||
}
|
||||
|
||||
private boolean saveAsWavefrontOBJ(File file) {
|
||||
OBJExportOptions options = prefs.loadOBJExportOptions(rocket);
|
||||
OBJExportOptions options = document.getDefaultOBJOptions();
|
||||
return saveWavefrontOBJFile(file, options);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user