Changed to using Import/Export file menu functions to handle RockSim

formatted files.  Save & Save As will only save in ork format.
This commit is contained in:
Kevin Ruland 2015-11-21 21:37:57 -06:00
parent e8167ac159
commit 4924773c3a
9 changed files with 473 additions and 443 deletions

View File

@ -258,9 +258,7 @@ pref.dlg.tab.Design = Design
pref.dlg.tab.Simulation = Simulation
pref.dlg.tab.Launch = Launch
pref.dlg.tab.Miscellaneousoptions = Miscellaneous options
pref.dlg.lbl.RockSimWarning = Show warning when saving in RockSim format
pref.dlg.lbl.FileExtensionWarning = Show warning when saving with unusual file name extension
pref.dlg.tab.Graphics = Graphics
pref.dlg.lbl.DecalEditor = Graphics Editor
@ -1138,13 +1136,11 @@ FinsetCfg.ttip.Finfillets2 = Assumes the fillet is concave and tangent to the bo
FinsetCfg.ttip.Finfillets3 = Zero radius will give no fillet.
! Save RKT Warning Dialog
SaveRktWarningDialog.txt1="The RockSim file format does not support all features of OpenRocket."
SaveRktWarningDialog.txt2="Do you want to save in RockSim .RKT format or OpenRocket .ORK format?"
SaveRktWarningDialog.btn.rkt="Save as RKT"
SaveRktWarningDialog.btn.ork="Save as ORK"
SaveRktWarningDialog.txt1=Exporting to RockSim file format does not support all features of OpenRocket.
SaveRktWarningDialog.donotshow=Do not show this dialog again
! SaveExtensionWarningDialog
SaveExtensionWarningDialog.txt="The file format {} usually has the extension {}"
saveAs.openrocket.title=Save as OpenRocket ork file
saveAs.rocksim.title=Export as RockSim rkt file
! StorageOptionChooser
StorageOptChooser.lbl.Simdatatostore = Simulated data to store:
@ -1213,26 +1209,30 @@ main.menu.file.desc = File-handling related tasks
main.menu.file.new = New
main.menu.file.new.desc = Create a new rocket design
main.menu.file.open = Open...
BasicFrame.item.Openrocketdesign = Open a rocket design
main.menu.file.open.desc = Open a rocket design
main.menu.file.openRecent = Open Recent...
BasicFrame.item.Openrecentrocketdesign = Open a recent rocket design
main.menu.file.openExample = Open example...
BasicFrame.item.Openexamplerocketdesign = Open an example rocket design
main.menu.file.openRecent.desc = Open a recent rocket design
main.menu.file.openExample = Open Example...
main.menu.file.openExample.desc = Open an example rocket design
main.menu.file.save = Save
BasicFrame.item.SavecurRocketdesign = Save the current rocket design
main.menu.file.save.desc = Save the current rocket design
main.menu.file.saveAs = Save as...
BasicFrame.item.SavecurRocketdesnewfile = Save the current rocket design to a new file
main.menu.file.saveAs.desc = Save the current rocket design to a new file
main.menu.file.import = Import...
main.menu.file.import.desc = Import model from RockSim rkt file
main.menu.file.export = Export...
main.menu.file.export.desc = Export model to RockSim rkt file
main.menu.file.print = Print / Export PDF...
main.menu.file.print.desc = Print or save as PDF the parts list and fin templates
main.menu.file.close = Close
BasicFrame.item.Closedesign = Close the current rocket design
main.menu.file.close.desc = Close the current rocket design
main.menu.file.quit = Quit
BasicFrame.item.Quitprogram = Quit the program
main.menu.file.quit.desc = Quit the program
main.menu.file.exportDecal = Export Decal
main.menu.file.exportDecal.desc = Export a decal from the current rocket design to a file for editing.
main.menu.edit = Edit
BasicFrame.menu.Rocketedt = Rocket editing
main.menu.edit.desc = Rocket editing
main.menu.edit.undo = Undo
main.menu.edit.undo.desc = Undo the previous operation
main.menu.edit.redo = Redo

View File

@ -4,9 +4,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.document.StorageOptions;
import net.sf.openrocket.document.StorageOptions.FileType;
import net.sf.openrocket.file.AbstractRocketLoader;
import net.sf.openrocket.file.DocumentLoadingContext;
import net.sf.openrocket.file.RocketLoadException;
@ -15,11 +21,6 @@ import net.sf.openrocket.simulation.FlightDataBranch;
import net.sf.openrocket.simulation.FlightDataType;
import net.sf.openrocket.simulation.extension.SimulationExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Class that loads a rocket definition from an OpenRocket rocket file.
@ -70,7 +71,7 @@ public class OpenRocketLoader extends AbstractRocketLoader {
List<Double> list = branch.get(FlightDataType.TYPE_TIME);
if (list == null)
continue;
double previousTime = Double.NaN;
for (double time : list) {
if (time - previousTime < timeSkip)
@ -81,6 +82,7 @@ public class OpenRocketLoader extends AbstractRocketLoader {
timeSkip = Math.rint(timeSkip * 100) / 100;
doc.getDefaultStorageOptions().setSimulationTimeSkip(timeSkip);
doc.getDefaultStorageOptions().setExplicitlySet(false);
doc.getDefaultStorageOptions().setFileType(FileType.OPENROCKET);
// Call simulation extensions
for (Simulation sim : doc.getSimulations()) {

View File

@ -6,14 +6,15 @@ package net.sf.openrocket.file.rocksim.importt;
import java.io.IOException;
import java.io.InputStream;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import net.sf.openrocket.document.StorageOptions.FileType;
import net.sf.openrocket.file.AbstractRocketLoader;
import net.sf.openrocket.file.DocumentLoadingContext;
import net.sf.openrocket.file.RocketLoadException;
import net.sf.openrocket.file.simplesax.SimpleSAX;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* This class is the main entry point for Rocksim design file imported to OpenRocket. Currently only Rocksim v9
* file formats are supported, although it is possible that v8 formats will work for most components.
@ -52,5 +53,6 @@ public class RocksimLoader extends AbstractRocketLoader {
context.getOpenRocketDocument().setFile(null);
context.getOpenRocketDocument().clearUndo();
context.getOpenRocketDocument().getDefaultStorageOptions().setFileType(FileType.ROCKSIM);
}
}

View File

@ -62,7 +62,6 @@ public abstract class Preferences implements ChangeSource {
public static final String PREFERRED_THRUST_CURVE_MOTOR_NODE = "preferredThrustCurveMotors";
private static final String AUTO_OPEN_LAST_DESIGN = "AUTO_OPEN_LAST_DESIGN";
private static final String SHOW_ROCKSIM_FORMAT_WARNING = "SHOW_ROCKSIM_FORMAT_WARNING";
private static final String SHOW_FILE_EXTENSION_WARNING = "SHOW_FILE_EXTENSION_WARNING";
//Preferences related to 3D graphics
public static final String OPENGL_ENABLED = "OpenGL_Is_Enabled";
@ -172,14 +171,6 @@ public abstract class Preferences implements ChangeSource {
this.putBoolean(SHOW_ROCKSIM_FORMAT_WARNING, check);
}
public final boolean getShowFileExtensionWarning() {
return this.getBoolean(SHOW_FILE_EXTENSION_WARNING, true);
}
public final void setShowFileExtensionWarning(boolean check) {
this.putBoolean(SHOW_FILE_EXTENSION_WARNING, check);
}
public final double getDefaultMach() {
return Application.getPreferences().getChoice(Preferences.DEFAULT_MACH_NUMBER, 0.9, 0.3);
}

View File

@ -231,17 +231,7 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
});
this.add(rocksimWarningDialogBox,"spanx, wrap");
//// Extension Format warning dialog
final JCheckBox extensionWarningDialoBox = new JCheckBox(trans.get("pref.dlg.lbl.FileExtensionWarning"));
extensionWarningDialoBox.setSelected(preferences.getShowFileExtensionWarning());
extensionWarningDialoBox.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
preferences.setShowFileExtensionWarning(extensionWarningDialoBox.isSelected());
}
});
this.add(extensionWarningDialoBox,"spanx, wrap");
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
package net.sf.openrocket.gui;
package net.sf.openrocket.gui.main;
import java.awt.Window;
import java.awt.event.ActionEvent;

View File

@ -1,4 +1,4 @@
package net.sf.openrocket.gui;
package net.sf.openrocket.gui.main;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

View File

@ -117,7 +117,9 @@ public final class FileHelper {
* @return the resulting file
*/
public static File forceExtension(File original, String extension) {
if ( original == null ) {
return null;
}
if (!original.getName().toLowerCase(Locale.ENGLISH).endsWith(extension.toLowerCase(Locale.ENGLISH))) {
log.debug("File name does not contain extension, adding '" + extension + "'");
String name = original.getAbsolutePath();