chore: добавил описание функций в новый класс
This commit is contained in:
parent
27d1cd63de
commit
b73eba7f7e
Binary file not shown.
@ -26,7 +26,7 @@ class DirectoryMonitor(BaseDirectoryMonitor):
|
||||
|
||||
def update_settings(self, data: list[dict]) -> None:
|
||||
self.stop()
|
||||
operator_params, system_params = data
|
||||
_, system_params = data
|
||||
self._directory_path = system_params['trace_storage_path'][0]
|
||||
self._update_time = system_params['monitor_update_period'][0]
|
||||
self._init_state()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -9,7 +9,7 @@ from gui.reportGui import ReportSettings
|
||||
|
||||
class MainWindow(BaseMainWindow):
|
||||
def __init__(self,
|
||||
controller: Optional[BaseController] = None):
|
||||
controller: Optional[BaseController] = None) -> None:
|
||||
super().__init__()
|
||||
self._controller = controller
|
||||
self.initUI()
|
||||
@ -61,11 +61,13 @@ class MainWindow(BaseMainWindow):
|
||||
for i in range(0, tab_count-2):
|
||||
self._close_tab(i)
|
||||
|
||||
def keyPressEvent(self, a0):
|
||||
def keyPressEvent(self, a0) -> None:
|
||||
if a0.key() == Qt.Key_F5:
|
||||
pass
|
||||
tab_count = self.tabWidget.count()
|
||||
for i in range(0, tab_count):
|
||||
self._close_tab(i)
|
||||
|
||||
def _show_settings(self):
|
||||
def _show_settings(self) -> None:
|
||||
self.operSettings.show()
|
||||
self.sysSettings.show()
|
||||
|
||||
@ -86,7 +88,7 @@ class MainWindow(BaseMainWindow):
|
||||
if folder_path:
|
||||
self._controller.open_custom_file(folder_path)
|
||||
|
||||
def _report_window(self):
|
||||
def _report_window(self) -> None:
|
||||
tab = self.tabWidget.currentWidget()
|
||||
reg_items = tab.property("reg_items")
|
||||
curve_items = tab.property("curve_items")
|
||||
|
||||
@ -270,8 +270,8 @@ class PlotWidget(BasePlotWidget):
|
||||
Создает набор виджетов по предоставленному списку данных.
|
||||
Предполагается, что data — это список элементов вида:
|
||||
[
|
||||
[dataframe, points_pocket, tesla_time],
|
||||
[dataframe, points_pocket, tesla_time],
|
||||
[dataframe, points_pocket, useful_data],
|
||||
[dataframe, points_pocket, useful_data],
|
||||
...
|
||||
]
|
||||
"""
|
||||
|
||||
@ -7,6 +7,7 @@ from PyQt5 import QtWidgets
|
||||
class ReportSettings(QtWidgets.QWidget):
|
||||
|
||||
def build(self, reg_items: dict, curve_items: dict) -> None:
|
||||
"""Создает ParameterTree для элементов всех графиков выбранной вкладки"""
|
||||
self._clear()
|
||||
param_tree = ParameterTree()
|
||||
layout = self.layout()
|
||||
@ -18,11 +19,17 @@ class ReportSettings(QtWidgets.QWidget):
|
||||
]
|
||||
# Добавляем параметры в дерево
|
||||
params = Parameter.create(name='params', type='group', children=body)
|
||||
params.sigTreeStateChanged.connect(lambda: self._update_settings(reg_items, curve_items, params))
|
||||
params.sigTreeStateChanged.connect(
|
||||
lambda: self._update_settings(reg_items, curve_items, params)
|
||||
)
|
||||
param_tree.setParameters(params, showTop=False)
|
||||
self.show()
|
||||
|
||||
def _clear(self):
|
||||
def _clear(self) -> None:
|
||||
"""
|
||||
Приводит виджет в готовое к работе состояние.
|
||||
Удаляет все содержимое, если имеется
|
||||
"""
|
||||
main = self.layout()
|
||||
if self.layout() is not None:
|
||||
while main.count():
|
||||
@ -32,7 +39,10 @@ class ReportSettings(QtWidgets.QWidget):
|
||||
else:
|
||||
self.setLayout(QtWidgets.QVBoxLayout())
|
||||
|
||||
def _generate_reg_params(self, reg_items: dict) -> dict:
|
||||
def _generate_reg_params(self,
|
||||
reg_items: dict) -> dict:
|
||||
|
||||
"""Созадет реальные и идеальные секторы"""
|
||||
|
||||
res = {'name': 'Sectors', 'type': 'group', 'children': [
|
||||
{'name': 'Real sectors', 'type': 'group', 'children': self._create_samples(reg_items["real"])},
|
||||
@ -40,7 +50,10 @@ class ReportSettings(QtWidgets.QWidget):
|
||||
]}
|
||||
return res
|
||||
|
||||
def _generate_curve_params(self, curve_items: dict) -> dict:
|
||||
def _generate_curve_params(self,
|
||||
curve_items: dict) -> dict:
|
||||
|
||||
"""Создает реальные и идеальные линии графиков"""
|
||||
|
||||
res = {'name': 'Plots', 'type': 'group', 'children': [
|
||||
{'name': 'Real plots', 'type': 'group', 'children': self._create_samples(curve_items["real"])},
|
||||
@ -48,15 +61,22 @@ class ReportSettings(QtWidgets.QWidget):
|
||||
]}
|
||||
return res
|
||||
|
||||
def _create_ideal_curves(self, curve: dict) -> list[dict]:
|
||||
"""Создаем секторы с этапами циклограммы"""
|
||||
def _create_ideal_curves(self,
|
||||
curve: dict) -> list[dict]:
|
||||
|
||||
"""Создает секторы с этапами циклограммы"""
|
||||
|
||||
res = []
|
||||
for key, item in curve.items():
|
||||
param = {'name': key, 'type': 'group', 'children': self._create_samples(item)}
|
||||
res.append(param)
|
||||
return res
|
||||
|
||||
def _create_samples(self, sector: dict) -> list[dict]:
|
||||
def _create_samples(self,
|
||||
sector: dict) -> list[dict]:
|
||||
|
||||
"""Создает список представленных элементов с их параметрами"""
|
||||
|
||||
res = []
|
||||
for key, item in sector.items():
|
||||
sample = item[0] if type(item) == list else item
|
||||
@ -64,8 +84,11 @@ class ReportSettings(QtWidgets.QWidget):
|
||||
res.append(param)
|
||||
return res
|
||||
|
||||
def _create_settings(self, item: Union[pg.LinearRegionItem, pg.PlotDataItem]) -> list[dict]:
|
||||
"""Настройки для элемента"""
|
||||
def _create_settings(self,
|
||||
item: Union[pg.LinearRegionItem, pg.PlotDataItem]) -> list[dict]:
|
||||
|
||||
"""Получает настройки для элемента"""
|
||||
|
||||
if type(item) == pg.LinearRegionItem:
|
||||
pen = item.lines[0].pen
|
||||
brush = item.brush
|
||||
@ -84,7 +107,13 @@ class ReportSettings(QtWidgets.QWidget):
|
||||
{'name': 'Fill color', 'type': 'color', 'value': fill_color},
|
||||
]
|
||||
|
||||
def _update_settings(self, reg_items: dict, curve_items: dict, params: Parameter):
|
||||
def _update_settings(self,
|
||||
reg_items: dict,
|
||||
curve_items: dict,
|
||||
params: Parameter) -> None:
|
||||
|
||||
"""Задает параметры элементов в соответствии с paramTree"""
|
||||
|
||||
real_sectors = params.child("Sectors").child("Real sectors")
|
||||
ideal_sectors = params.child("Sectors").child("Ideal sectors")
|
||||
|
||||
@ -98,7 +127,12 @@ class ReportSettings(QtWidgets.QWidget):
|
||||
for key, item_dict in curve_items["ideal"].items():
|
||||
self._set_plot_settings(item_dict, ideal_plots.child(key))
|
||||
|
||||
def _set_sector_settings(self, sectors: dict, settings: Parameter) -> None:
|
||||
def _set_sector_settings(self,
|
||||
sectors: dict,
|
||||
settings: Parameter) -> None:
|
||||
|
||||
"""Задает параметры секторов в соответствии с настройками"""
|
||||
|
||||
for key, item in sectors.items():
|
||||
sample = settings.child(key)
|
||||
line_color = sample.child("Line color").value()
|
||||
@ -114,7 +148,12 @@ class ReportSettings(QtWidgets.QWidget):
|
||||
reg.lines[1].setPen(pen)
|
||||
reg.setBrush(brush)
|
||||
|
||||
def _set_plot_settings(self, curves:dict, settings: Parameter) -> None:
|
||||
def _set_plot_settings(self,
|
||||
curves:dict,
|
||||
settings: Parameter) -> None:
|
||||
|
||||
"""Задает параметры кривых в соответствии с настройками"""
|
||||
|
||||
for key, item in curves.items():
|
||||
sample = settings.child(key)
|
||||
line_color = sample.child("Line color").value()
|
||||
|
||||
@ -12,7 +12,6 @@ class settingsWindow(QWidget):
|
||||
def __init__(self, path: str, name: str, upd_func: Callable[[], None]):
|
||||
"""
|
||||
Окно настроек для редактирования параметров.
|
||||
|
||||
:param path: Путь к файлу настроек (JSON).
|
||||
:param name: Название набора настроек.
|
||||
:param upd_func: Функция обновления (коллбэк).
|
||||
|
||||
Loading…
Reference in New Issue
Block a user