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