Commit 7ca89f8b authored by Tong Zhang's avatar Tong Zhang
Browse files

ENH: Support export physics model to a FLAME lattice file.

parent 38dcbfe1
......@@ -29,6 +29,7 @@ from mpl4qt.widgets import MatplotlibBaseWidget
from phantasy import MachinePortal
from phantasy_ui import BaseAppForm
from phantasy_ui import milli_sleep
from phantasy_ui import get_save_filename
from phantasy_ui.widgets import ElementWidget
from phantasy_ui.widgets import LatticeWidget
from phantasy_apps.allison_scanner.data import draw_beam_ellipse_with_params
......@@ -470,6 +471,27 @@ class MyAppWindow(BaseAppForm, Ui_MainWindow):
self.elemlist_cbb.setCurrentIndex(self.elemlist_cbb.count() - 1)
self.elemlist_cbb.currentTextChanged.emit(self.elemlist_cbb.currentText())
@pyqtSlot()
def onExportLatfile(self):
"""Export FLAME lattice file from the model.
"""
filename, ext = get_save_filename(self,
caption="Choose a file to save",
cdir='.',
type_filter="Lattice File (*.lat)")
if filename is None:
return
try:
self.fm.generate_latfile(latfile=filename)
except:
QMessageBox.warning(self, "Export Lattice File",
"Failed to export model as a FLAME lattice file.",
QMessageBox.Ok, QMessageBox.Ok)
else:
QMessageBox.information(self, "Export Lattice File",
f"Export FLAME lattice file to {filename}.",
QMessageBox.Ok, QMessageBox.Ok)
if __name__ == "__main__":
from PyQt5.QtWidgets import QApplication
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment