Plot settings and version
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from copy import deepcopy
|
||||
|
||||
from PySide6.QtGui import QUndoCommand
|
||||
|
||||
from bedit_gui.simulation_models import SimulationPlotTab, SimulationRoot
|
||||
from bedit_gui.simulation_models import SimulationPlotSettings, SimulationPlotTab, SimulationRoot
|
||||
|
||||
ChangedCallback = Callable[[int], None]
|
||||
|
||||
@@ -95,3 +96,21 @@ class ChangeSimulationPlotXAxisCommand(QUndoCommand):
|
||||
def undo(self) -> None:
|
||||
self.root.plot_tabs[self.index].x_axis = self.old_x_axis
|
||||
self.changed(self.index)
|
||||
|
||||
|
||||
class ChangeSimulationPlotSettingsCommand(QUndoCommand):
|
||||
def __init__(self, root: SimulationRoot, index: int, settings: SimulationPlotSettings, changed: ChangedCallback) -> None:
|
||||
super().__init__("Change plot settings")
|
||||
self.root = root
|
||||
self.index = index
|
||||
self.old_settings = deepcopy(root.plot_tabs[index].settings)
|
||||
self.settings = deepcopy(settings)
|
||||
self.changed = changed
|
||||
|
||||
def redo(self) -> None:
|
||||
self.root.plot_tabs[self.index].settings = deepcopy(self.settings)
|
||||
self.changed(self.index)
|
||||
|
||||
def undo(self) -> None:
|
||||
self.root.plot_tabs[self.index].settings = deepcopy(self.old_settings)
|
||||
self.changed(self.index)
|
||||
|
||||
Reference in New Issue
Block a user