Loading src/ips_fastran_gui/app/view_models/main_view_model.py +14 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ from pathlib import Path from typing import Any, Dict, List from blinker import signal from matplotlib.figure import Figure from nova.common.signals import Signal, ToolCommand, get_signal_id from nova.mvvm.interface import BindingInterface from pydantic import BaseModel, Field, ValidationError Loading @@ -26,12 +27,16 @@ class MainViewModel: self.model = model self.view_state = ViewState() self.figure = Figure(figsize=(8.0, 4.0)) self.ax = self.figure.subplots(1, 1) # here we create a bind that connects ViewModel with View. It returns a communicator object, # that allows to update View from ViewModel (by calling update_view). # self.model will be updated automatically on changes of connected fields in View, # but one also can provide a callback function if they want to react to those events # and/or process errors. self.config_bind = binding.new_bind() self.figure_bind = binding.new_bind() self.slurm_params_bind = binding.new_bind( self.model.slurm_params, callback_after_update=self.on_change_slurm_params ) Loading @@ -43,6 +48,9 @@ class MainViewModel: self.completion_signal = signal("ips_fastran_complete") self.completion_signal.connect(self.on_completion, weak=False) def get_figure(self) -> Figure: return self.figure def init_view(self) -> None: self.config_bind.update_in_view(self.model.config.model_dump_json(indent=2)) Loading Loading @@ -71,6 +79,8 @@ class MainViewModel: pass def on_completion(self, _sender: Any, output_path: Path) -> None: self.update_figure() self.view_state.results_disabled = False self.view_state_bind.update_in_view(self.view_state) Loading @@ -79,3 +89,7 @@ class MainViewModel: self.view_state.results_disabled = True self.view_state.active_tab = 2 self.view_state_bind.update_in_view(self.view_state) def update_figure(self) -> None: # TODO: draw the rest of the owl self.figure_bind.update_in_view(None) src/ips_fastran_gui/app/views/tab_content_panel.py +1 −1 Original line number Diff line number Diff line Loading @@ -31,4 +31,4 @@ class TabContentPanel: with vuetify.VWindowItem(value=2): ExecutionTab() with vuetify.VWindowItem(value=3): ResultsTab() ResultsTab(self.view_model) src/ips_fastran_gui/app/views/tabs/results_tab.py +13 −4 Original line number Diff line number Diff line """Module for the Slurm tab.""" from nova.trame.view.components import InputField from nova.trame.view.layouts import GridLayout from typing import Any from nova.trame.view.components.visualization import MatplotlibFigure from ips_fastran_gui.app.view_models.main_view_model import MainViewModel class ResultsTab: """Slurm view class.""" def __init__(self) -> None: def __init__(self, view_model: MainViewModel) -> None: self.view_model = view_model self.view_model.figure_bind.connect(self.update) self.create_ui() def create_ui(self) -> None: pass self.figure_view = MatplotlibFigure(self.view_model.get_figure()) def update(self, _: Any = None) -> None: self.figure_view.update() Loading
src/ips_fastran_gui/app/view_models/main_view_model.py +14 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ from pathlib import Path from typing import Any, Dict, List from blinker import signal from matplotlib.figure import Figure from nova.common.signals import Signal, ToolCommand, get_signal_id from nova.mvvm.interface import BindingInterface from pydantic import BaseModel, Field, ValidationError Loading @@ -26,12 +27,16 @@ class MainViewModel: self.model = model self.view_state = ViewState() self.figure = Figure(figsize=(8.0, 4.0)) self.ax = self.figure.subplots(1, 1) # here we create a bind that connects ViewModel with View. It returns a communicator object, # that allows to update View from ViewModel (by calling update_view). # self.model will be updated automatically on changes of connected fields in View, # but one also can provide a callback function if they want to react to those events # and/or process errors. self.config_bind = binding.new_bind() self.figure_bind = binding.new_bind() self.slurm_params_bind = binding.new_bind( self.model.slurm_params, callback_after_update=self.on_change_slurm_params ) Loading @@ -43,6 +48,9 @@ class MainViewModel: self.completion_signal = signal("ips_fastran_complete") self.completion_signal.connect(self.on_completion, weak=False) def get_figure(self) -> Figure: return self.figure def init_view(self) -> None: self.config_bind.update_in_view(self.model.config.model_dump_json(indent=2)) Loading Loading @@ -71,6 +79,8 @@ class MainViewModel: pass def on_completion(self, _sender: Any, output_path: Path) -> None: self.update_figure() self.view_state.results_disabled = False self.view_state_bind.update_in_view(self.view_state) Loading @@ -79,3 +89,7 @@ class MainViewModel: self.view_state.results_disabled = True self.view_state.active_tab = 2 self.view_state_bind.update_in_view(self.view_state) def update_figure(self) -> None: # TODO: draw the rest of the owl self.figure_bind.update_in_view(None)
src/ips_fastran_gui/app/views/tab_content_panel.py +1 −1 Original line number Diff line number Diff line Loading @@ -31,4 +31,4 @@ class TabContentPanel: with vuetify.VWindowItem(value=2): ExecutionTab() with vuetify.VWindowItem(value=3): ResultsTab() ResultsTab(self.view_model)
src/ips_fastran_gui/app/views/tabs/results_tab.py +13 −4 Original line number Diff line number Diff line """Module for the Slurm tab.""" from nova.trame.view.components import InputField from nova.trame.view.layouts import GridLayout from typing import Any from nova.trame.view.components.visualization import MatplotlibFigure from ips_fastran_gui.app.view_models.main_view_model import MainViewModel class ResultsTab: """Slurm view class.""" def __init__(self) -> None: def __init__(self, view_model: MainViewModel) -> None: self.view_model = view_model self.view_model.figure_bind.connect(self.update) self.create_ui() def create_ui(self) -> None: pass self.figure_view = MatplotlibFigure(self.view_model.get_figure()) def update(self, _: Any = None) -> None: self.figure_view.update()