Skip to content

Commit d9c282f

Browse files
committed
remove modal
1 parent 0174b7b commit d9c282f

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

waveform_editor/shape_editor/coil_currents.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class CoilCurrents(Viewer):
1818
doc="List of tuples containing the checkboxes and sliders for the coil currents"
1919
)
2020
export_time = param.Number(doc="Time to export coil currents to")
21-
coil_export_valid = param.Boolean()
2221

2322
def __init__(self, main_gui, **params):
2423
super().__init__(**params)
@@ -36,26 +35,14 @@ def __init__(self, main_gui, **params):
3635
visible=self.param.coil_ui.rx.not_(),
3736
)
3837

39-
modal_text = pn.pane.Markdown("## Enter a time to store coil currents")
40-
modal_input = pn.widgets.FloatInput.from_param(self.param.export_time)
38+
export_time_input = pn.widgets.FloatInput.from_param(self.param.export_time)
4139
confirm_button = pn.widgets.Button(
4240
on_click=lambda event: self._store_coil_currents(),
43-
name="Store Coil Currents",
44-
disabled=self.param.coil_export_valid.rx.not_(),
45-
)
46-
modal_alert = pn.pane.Alert(
47-
"### Export time must be later than the end of any existing waveforms",
48-
alert_type="danger",
49-
visible=self.param.coil_export_valid.rx.not_(),
50-
)
51-
modal_content = pn.Column(modal_text, modal_input, modal_alert, confirm_button)
52-
self.modal = pn.Modal(modal_content, open=False)
53-
button_store = pn.widgets.Button(
54-
on_click=lambda event: self._open_modal(),
55-
name="Store Coil Currents",
41+
name="Save Currents as Waveforms",
42+
margin=30,
5643
)
5744
self.panel = pn.Column(
58-
pn.Row(button_store, no_ids_message),
45+
pn.Row(export_time_input, confirm_button, no_ids_message),
5946
guide_message,
6047
self.sliders_ui,
6148
self.modal,
@@ -113,16 +100,27 @@ def create_ui(self, pf_active):
113100
self.coil_ui = new_coil_ui
114101

115102
def _store_coil_currents(self):
116-
self.modal.hide()
117103
coil_currents = self._get_currents()
118104
config = self.main_gui.config
119105
new_waveforms_created = False
120106

107+
for i in range(len(self.coil_ui)):
108+
name = f"pf_active/coil({i + 1})/current/data"
109+
if name in self.main_gui.config.waveform_map:
110+
tendencies = self.main_gui.config[name].tendencies
111+
if tendencies:
112+
end_time = tendencies[-1].end
113+
if end_time >= self.export_time:
114+
pn.state.notifications.error(
115+
"Export time must be later than the end of any existing waveforms"
116+
)
117+
return
118+
121119
for i, current in enumerate(coil_currents):
122120
name = f"pf_active/coil({i + 1})/current/data"
123121
eps = 1e-100
124122
# Piecewise tendencies must contain at least two points
125-
new_piecewise = f"- {{type: piecewise, time: [{self.export_time - eps}, {self.export_time}], value: [{current}, {current}]}}"
123+
new_piecewise = f"- {{type: piecewise, time: [{self.export_time}, {self.export_time + eps}], value: [{current}, {current}]}}"
126124
if not name in config.waveform_map:
127125
group_name = "Coil Currents"
128126
if group_name not in config.groups:

0 commit comments

Comments
 (0)