Source code for wolfhece._simtools2d_manager
"""
Companion manager for Tools 2D (CPU/Fortran Wolf2D) menus and actions.
Extracted from PyDraw.WolfMapViewer.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import wx
from .PyTranslate import _
if TYPE_CHECKING:
from .PyDraw import WolfMapViewer
[docs]
class SimTools2DManager:
"""Manages the Tools 2D (CPU) menu and associated actions."""
def __init__(self, viewer: 'WolfMapViewer') -> None:
# ------------------------------------------------------------------
# Menu build
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# Action handlers
# ------------------------------------------------------------------
[docs]
def _wolf2d_model(self):
"""Return wolfparent cast as Wolf2DModel, or None with error log if wrong type."""
from .PyGui import Wolf2DModel
v = self._viewer
if not isinstance(v.wolfparent, Wolf2DModel):
logging.error(_('This is not a 2D model'))
return None
return v.wolfparent
[docs]
def _on_parameters(self, event: wx.MenuEvent) -> None:
model = self._wolf2d_model()
if model is not None:
model.show_properties()
[docs]
def _on_reset_mask(self, event: wx.MenuEvent) -> None:
model = self._wolf2d_model()
if model is not None:
model.sim.force_mask()
[docs]
def _on_zbin2hbin(self, event: wx.MenuEvent) -> None:
model = self._wolf2d_model()
if model is not None and model.sim._zbin is not None:
model.sim.zbin2hbin()
model.sim.hbin.reset_plot()
[docs]
def _on_hbin2zbin(self, event: wx.MenuEvent) -> None:
model = self._wolf2d_model()
if model is not None and model.sim._hbin is not None:
model.sim.hbin2zbin()
model.sim.zbin.reset_plot()
[docs]
def _on_zbinb2hbinb(self, event: wx.MenuEvent) -> None:
model = self._wolf2d_model()
if model is not None and model.sim._zbinb is not None:
model.sim.zbinb2hbinb()
model.sim.hbinb.reset_plot()
[docs]
def _on_hbinb2zbinb(self, event: wx.MenuEvent) -> None:
model = self._wolf2d_model()
if model is not None and model.sim._hbinb is not None:
model.sim.hbinb2zbinb()
model.sim.zbinb.reset_plot()