Plot settings and version

This commit is contained in:
2026-08-02 11:54:38 +02:00
parent 51d01ad208
commit feba2c9798
10 changed files with 469 additions and 18 deletions

View File

@@ -2,13 +2,14 @@ from __future__ import annotations
from PySide6.QtCore import QObject, QPoint, Qt
from PySide6.QtGui import QUndoStack
from PySide6.QtWidgets import QInputDialog, QMenu, QTreeWidgetItem, QWidget
from PySide6.QtWidgets import QDialog, QInputDialog, QMenu, QTreeWidgetItem, QWidget
from bedit_gui.commands.simulation_plot_commands import AddSimulationPlotTabCommand, ChangeSimulationPlotSignalsCommand, ChangeSimulationPlotXAxisCommand, RemoveSimulationPlotTabCommand, RenameSimulationPlotTabCommand
from bedit_gui.commands.simulation_plot_commands import AddSimulationPlotTabCommand, ChangeSimulationPlotSettingsCommand, ChangeSimulationPlotSignalsCommand, ChangeSimulationPlotXAxisCommand, RemoveSimulationPlotTabCommand, RenameSimulationPlotTabCommand
from bedit_gui.controllers.simulation_file_controller import SimulationFileController
from bedit_gui.services.application_logging import get_logger
from bedit_gui.simulation_models import SimulationPlotTab
from bedit_gui.views.simulation_plot_widget import SimulationPlotWidget
from bedit_gui.views.dialogs.plot_settings_dialog import PlotSettingsDialog
from bedit_gui.views.simulation_window import SimulationWindow
logger = get_logger(__name__)
@@ -109,8 +110,10 @@ class SimulationPlotController(QObject):
while tabs.count():
tabs.removeTab(0)
if root is not None:
for tab in root.plot_tabs:
tabs.addTab(SimulationPlotWidget(tabs), tab.name)
for index, tab in enumerate(root.plot_tabs):
widget = SimulationPlotWidget(tabs)
widget.settings_requested.connect(lambda checked=False, tab_index=index: self._open_plot_settings(tab_index))
tabs.addTab(widget, tab.name)
tabs.addTab(QWidget(tabs), "+")
tabs.setCurrentIndex(selected_index if selected_index >= 0 else tabs.count() - 1)
finally:
@@ -222,6 +225,16 @@ class SimulationPlotController(QObject):
elif selected is use_time:
self.undo_stack.push(ChangeSimulationPlotXAxisCommand(root, self._active_tab, None, self._selection_changed))
def _open_plot_settings(self, index: int) -> None:
root = self.files.root
if root is None or not 0 <= index < len(root.plot_tabs):
return
dialog = PlotSettingsDialog(root.plot_tabs[index].settings, root.plot_tabs[index].signals, self.window)
if dialog.exec() == QDialog.DialogCode.Accepted:
settings = dialog.settings()
if settings != root.plot_tabs[index].settings:
self.undo_stack.push(ChangeSimulationPlotSettingsCommand(root, index, settings, self._selection_changed))
def _available_signals(self) -> list[str]:
root = self.files.root
if root is None:
@@ -242,7 +255,7 @@ class SimulationPlotController(QObject):
widget = self.window.ui.resultsTabWidget.widget(index)
if isinstance(widget, SimulationPlotWidget):
tab = root.plot_tabs[index]
widget.set_plot(root.results, tab.signals, tab.x_axis)
widget.set_plot(root.results, tab.signals, tab.x_axis, tab.settings)
def _set_undo_text(self, command: str) -> None:
self.window.ui.actionUndo.setText(f"Undo {command}" if command else "Undo")