Skip to content
Draft
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 41 additions & 51 deletions waveform_editor/gui/shape_editor/shape_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,61 +66,41 @@ def __init__(self, main_gui):
)
Comment thread
SBlokhuizen marked this conversation as resolved.

# UI Configuration
disabled_expr = (
(
self.plasma_shape.param.has_shape.rx.not_()
& self.nice_settings.param.is_inverse_mode.rx()
)
| self.plasma_properties.param.has_properties.rx.not_()
| self.nice_settings.param.are_required_filled.rx.not_()
)

button_start = pn.widgets.Button(
name="Run",
button_type="primary",
icon="player-play",
on_click=self.submit,
description=pn.bind(
lambda disabled: (
"Cannot run: missing required inputs"
if disabled
else "Run simulation"
),
disabled_expr,
),
disabled=disabled_expr,
margin=(10, 0, 2, 0),
)
button_start.disabled = (
(
self.plasma_shape.param.has_shape.rx.not_()
& self.nice_settings.param.is_inverse_mode.rx()
)
| self.plasma_properties.param.has_properties.rx.not_()
| self.nice_settings.param.are_required_filled.rx.not_()
)
Comment thread
ioan-alexandra marked this conversation as resolved.
button_stop = pn.widgets.Button(
name="Stop",
button_type="danger",
icon="player-stop",
on_click=self.stop_nice,
margin=(10, 10, 2, 0),
)
nice_mode_radio = nice_mode_toggle(self.nice_settings, margin=(10, 0, 2, 0))
settings_modal = SettingsModal(self.nice_plotter)
mode_widget = nice_mode_toggle(self.nice_settings, margin=(10, 0, 2, 0))
buttons = pn.Row(
nice_mode_radio,
mode_widget,
pn.Spacer(sizing_mode="stretch_width"),
button_stop,
button_start,
)
settings_modal = SettingsModal(self.nice_plotter)

# Accordion does not allow dynamic titles, so use separate card for each option
options = pn.Column(
self._create_card(
self.plasma_shape,
"Plasma Shape",
is_valid=self.plasma_shape.param.has_shape,
visible=self.nice_settings.param.is_inverse_mode.rx(),
),
self._create_card(
pn.Column(self.plasma_properties, self.nice_plotter.profiles_pane),
"Plasma Properties",
is_valid=self.plasma_properties.param.has_properties,
),
self._create_card(self.coil_currents, "Coil Currents"),
settings_options = pn.Column()
Comment thread
ioan-alexandra marked this conversation as resolved.
Outdated

options = pn.bind(
self._create_options_tabs, self.nice_settings.param.is_inverse_mode
)
menu = pn.Column(buttons, self.terminal, sizing_mode="stretch_width")
self.panel = pn.Row(
Expand All @@ -129,11 +109,29 @@ def __init__(self, main_gui):
),
pn.Column(
menu,
settings_options,
options,
sizing_mode="stretch_both",
),
)

def _create_options_tabs(self, is_inverse_mode):
items = []
if is_inverse_mode:
items.append(("Shape", self.plasma_shape))
items.append(
(
"Properties",
pn.Column(self.plasma_properties, self.nice_plotter.profiles_pane),
)
)
items.append(("Coils", self.coil_currents))
return pn.Tabs(
*items,
sizing_mode="stretch_width",
stylesheets=[".bk-tab { flex: 1; text-align: center; }"],
)

def _create_card(self, panel_object, title, is_valid=None, visible=True):
Comment thread
ioan-alexandra marked this conversation as resolved.
Outdated
"""Create a collapsed card containing a panel object and a title.

Expand Down Expand Up @@ -170,34 +168,26 @@ def _load_slice(self, uri, ids_name, time=0):
except Exception as e:
pn.state.notifications.error(str(e))

@param.depends("nice_settings.md_pf_active.uri", watch=True)
@param.depends("nice_settings.md_pf_active", watch=True)
def _load_pf_active(self):
self.pf_active = self._load_slice(
self.nice_settings.md_pf_active.uri, "pf_active"
)
self.pf_active = self._load_slice(self.nice_settings.md_pf_active, "pf_active")
self.nice_plotter.pf_active = self.pf_active
self.coil_currents.create_ui(self.pf_active)
self.nice_settings.md_pf_active.loaded = self.pf_active is not None

@param.depends("nice_settings.md_pf_passive.uri", watch=True)
@param.depends("nice_settings.md_pf_passive", watch=True)
def _load_pf_passive(self):
self.pf_passive = self._load_slice(
self.nice_settings.md_pf_passive.uri, "pf_passive"
self.nice_settings.md_pf_passive, "pf_passive"
)
self.nice_settings.md_pf_passive.loaded = self.pf_passive is not None

@param.depends("nice_settings.md_wall.uri", watch=True)
@param.depends("nice_settings.md_wall", watch=True)
def _load_wall(self):
self.wall = self._load_slice(self.nice_settings.md_wall.uri, "wall")
self.wall = self._load_slice(self.nice_settings.md_wall, "wall")
self.nice_plotter.wall = self.wall
self.nice_settings.md_wall.loaded = self.wall is not None

@param.depends("nice_settings.md_iron_core.uri", watch=True)
@param.depends("nice_settings.md_iron_core", watch=True)
def _load_iron_core(self):
self.iron_core = self._load_slice(
self.nice_settings.md_iron_core.uri, "iron_core"
)
self.nice_settings.md_iron_core.loaded = self.iron_core is not None
self.iron_core = self._load_slice(self.nice_settings.md_iron_core, "iron_core")
Comment thread
ioan-alexandra marked this conversation as resolved.
Outdated

def _create_equilibrium(self):
"""Create an empty equilibrium IDS and fill the plasma shape parameters and
Expand Down
Loading