Removed the "include decals" storage option - they will always be
included when saving as ork file. Fixed saving rocksim files - they are just plain files and have no references to decals.
This commit is contained in:
parent
7db51b9b65
commit
e516f99a8f
@ -1061,8 +1061,6 @@ StorageOptChooser.lbl.seconds = seconds
|
|||||||
StorageOptChooser.rdbut.Onlyprimfig = Only primary figures
|
StorageOptChooser.rdbut.Onlyprimfig = Only primary figures
|
||||||
StorageOptChooser.lbl.longC1 = <html>Store only the values shown in the summary table.<br>
|
StorageOptChooser.lbl.longC1 = <html>Store only the values shown in the summary table.<br>
|
||||||
StorageOptChooser.lbl.longC2 = This results in the smallest files.
|
StorageOptChooser.lbl.longC2 = This results in the smallest files.
|
||||||
StorageOptChooser.checkbox.IncludeDecals = Include decals
|
|
||||||
StorageOptChooser.lbl.IncludeDecals = "Including decals will produce a compressed zip file"
|
|
||||||
StorageOptChooser.lbl.longD1 = An estimate on how large the resulting file would be with the present options.
|
StorageOptChooser.lbl.longD1 = An estimate on how large the resulting file would be with the present options.
|
||||||
StorageOptChooser.ttip.Saveopt = Save options
|
StorageOptChooser.ttip.Saveopt = Save options
|
||||||
StorageOptChooser.lbl.Estfilesize = Estimated file size:
|
StorageOptChooser.lbl.Estfilesize = Estimated file size:
|
||||||
|
@ -14,8 +14,6 @@ public class StorageOptions implements Cloneable {
|
|||||||
|
|
||||||
private FileType fileType = FileType.OPENROCKET;
|
private FileType fileType = FileType.OPENROCKET;
|
||||||
|
|
||||||
private boolean includeDecals = false;
|
|
||||||
|
|
||||||
private double simulationTimeSkip = SIMULATION_DATA_NONE;
|
private double simulationTimeSkip = SIMULATION_DATA_NONE;
|
||||||
|
|
||||||
private boolean explicitlySet = false;
|
private boolean explicitlySet = false;
|
||||||
@ -28,14 +26,6 @@ public class StorageOptions implements Cloneable {
|
|||||||
this.fileType = fileType;
|
this.fileType = fileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeDecals() {
|
|
||||||
return includeDecals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIncludeDecals(boolean includeDecals) {
|
|
||||||
this.includeDecals = includeDecals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getSimulationTimeSkip() {
|
public double getSimulationTimeSkip() {
|
||||||
return simulationTimeSkip;
|
return simulationTimeSkip;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,6 @@ public class GeneralRocketLoader {
|
|||||||
}
|
}
|
||||||
if (entry.getName().matches(".*\\.[oO][rR][kK]$")) {
|
if (entry.getName().matches(".*\\.[oO][rR][kK]$")) {
|
||||||
OpenRocketDocument doc = loadFromStream(in, motorFinder);
|
OpenRocketDocument doc = loadFromStream(in, motorFinder);
|
||||||
doc.getDefaultStorageOptions().setIncludeDecals(true);
|
|
||||||
doc.getDecalRegistry().setIsZipFile(true);
|
doc.getDecalRegistry().setIsZipFile(true);
|
||||||
return doc;
|
return doc;
|
||||||
} else if ( entry.getName().matches(".*\\.[rR][kK][tT]$")) {
|
} else if ( entry.getName().matches(".*\\.[rR][kK][tT]$")) {
|
||||||
|
@ -18,6 +18,7 @@ import net.sf.openrocket.appearance.AppearanceBuilder;
|
|||||||
import net.sf.openrocket.appearance.Decal;
|
import net.sf.openrocket.appearance.Decal;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.document.StorageOptions;
|
import net.sf.openrocket.document.StorageOptions;
|
||||||
|
import net.sf.openrocket.document.StorageOptions.FileType;
|
||||||
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
||||||
import net.sf.openrocket.file.rocksim.export.RocksimSaver;
|
import net.sf.openrocket.file.rocksim.export.RocksimSaver;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
@ -229,6 +230,11 @@ public class GeneralRocketSaver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now we have to loop through all the components and update their names.
|
// Now we have to loop through all the components and update their names.
|
||||||
|
// FIXME - we probably don't want to modify the existing document.
|
||||||
|
// Suppose the user has been using a couple of decal files from the file system.
|
||||||
|
// He currently is editing some decal files, but decides to do an itermediate save.
|
||||||
|
// The saved file should contain references to the decal copied into the zip container,
|
||||||
|
// however, the currently open document should still be looking at the filesystem copy.
|
||||||
for( RocketComponent c : document.getRocket() ) {
|
for( RocketComponent c : document.getRocket() ) {
|
||||||
|
|
||||||
if ( c.getAppearance() == null ) {
|
if ( c.getAppearance() == null ) {
|
||||||
@ -248,7 +254,23 @@ public class GeneralRocketSaver {
|
|||||||
c.setAppearance(builder.getAppearance());
|
c.setAppearance(builder.getAppearance());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String,InputStream> decalMap = new HashMap<String,InputStream>();
|
||||||
|
for( Map.Entry<String, InputStream> image : decals.entrySet() ) {
|
||||||
|
|
||||||
|
String newName = decalNameNormalization.get(image.getKey());
|
||||||
|
decalMap.put(newName, image.getValue());
|
||||||
|
}
|
||||||
|
if ( options.getFileType() == FileType.OPENROCKET ) {
|
||||||
|
saveAllPartsZipFile(fileName, output, document, options, decalMap);
|
||||||
|
} else {
|
||||||
|
saveInternal(output, document, options);
|
||||||
|
output.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveAllPartsZipFile(String fileName, OutputStream output, OpenRocketDocument document, StorageOptions options, Map<String,InputStream> decals) throws IOException {
|
||||||
|
|
||||||
// Open a zip stream to write to.
|
// Open a zip stream to write to.
|
||||||
ZipOutputStream zos = new ZipOutputStream(output);
|
ZipOutputStream zos = new ZipOutputStream(output);
|
||||||
zos.setLevel(9);
|
zos.setLevel(9);
|
||||||
@ -265,8 +287,8 @@ public class GeneralRocketSaver {
|
|||||||
|
|
||||||
for( Map.Entry<String, InputStream> image : decals.entrySet() ) {
|
for( Map.Entry<String, InputStream> image : decals.entrySet() ) {
|
||||||
|
|
||||||
String newName = decalNameNormalization.get(image.getKey());
|
String name = image.getKey();
|
||||||
ZipEntry decal = new ZipEntry(newName);
|
ZipEntry decal = new ZipEntry(name);
|
||||||
zos.putNextEntry(decal);
|
zos.putNextEntry(decal);
|
||||||
|
|
||||||
InputStream is = image.getValue();
|
InputStream is = image.getValue();
|
||||||
|
@ -62,7 +62,6 @@ public class RocksimSaver extends RocketSaver {
|
|||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, "UTF-8"));
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, "UTF-8"));
|
||||||
writer.write(marshalToRocksim(doc));
|
writer.write(marshalToRocksim(doc));
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,8 +39,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
|
|
||||||
private JSpinner timeSpinner;
|
private JSpinner timeSpinner;
|
||||||
|
|
||||||
private JCheckBox decalButton;
|
|
||||||
|
|
||||||
private JLabel estimateLabel;
|
private JLabel estimateLabel;
|
||||||
|
|
||||||
|
|
||||||
@ -122,14 +120,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
noneButton.addActionListener(actionUpdater);
|
noneButton.addActionListener(actionUpdater);
|
||||||
this.add(noneButton, "spanx, wrap 20lp");
|
this.add(noneButton, "spanx, wrap 20lp");
|
||||||
|
|
||||||
//// Save decals
|
|
||||||
// FIXME - should we hide this if there are no decals?
|
|
||||||
decalButton = new JCheckBox(trans.get("StorageOptChooser.checkbox.IncludeDecals"));
|
|
||||||
decalButton.setToolTipText(trans.get("StorageOptChooser.lbl.IncludeDecals"));
|
|
||||||
decalButton.addActionListener(actionUpdater);
|
|
||||||
this.add(decalButton, "spanx, wrap para");
|
|
||||||
|
|
||||||
|
|
||||||
// Estimate is updated in loadOptions(opts)
|
// Estimate is updated in loadOptions(opts)
|
||||||
estimateLabel = new JLabel("");
|
estimateLabel = new JLabel("");
|
||||||
//// An estimate on how large the resulting file would
|
//// An estimate on how large the resulting file would
|
||||||
@ -167,8 +157,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
timeSpinner.setValue(t);
|
timeSpinner.setValue(t);
|
||||||
artificialEvent = false;
|
artificialEvent = false;
|
||||||
|
|
||||||
decalButton.setSelected(opts.isIncludeDecals());
|
|
||||||
|
|
||||||
updateEstimate();
|
updateEstimate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,8 +174,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
|
|
||||||
opts.setSimulationTimeSkip(t);
|
opts.setSimulationTimeSkip(t);
|
||||||
|
|
||||||
opts.setIncludeDecals(decalButton.isSelected());
|
|
||||||
|
|
||||||
opts.setExplicitlySet(true);
|
opts.setExplicitlySet(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user