dev: изменил отображение настроек, цветов, теперь их можно редактировать
This commit is contained in:
parent
37b9c30f12
commit
27d1cd63de
@ -51,7 +51,7 @@
|
|||||||
0.075
|
0.075
|
||||||
],
|
],
|
||||||
"time_capture": [
|
"time_capture": [
|
||||||
1000.0
|
100.0
|
||||||
],
|
],
|
||||||
"UML_time_scaler": [
|
"UML_time_scaler": [
|
||||||
1000.0
|
1000.0
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -34,15 +34,11 @@ class MainWindow(BaseMainWindow):
|
|||||||
self.select_dir_button.setFixedWidth(175)
|
self.select_dir_button.setFixedWidth(175)
|
||||||
self.report_button = QtWidgets.QPushButton("Generate report")
|
self.report_button = QtWidgets.QPushButton("Generate report")
|
||||||
self.report_button.setFixedWidth(175)
|
self.report_button.setFixedWidth(175)
|
||||||
self.rep_settings_button = QtWidgets.QPushButton("Report settings")
|
|
||||||
self.rep_settings_button.setFixedWidth(175)
|
|
||||||
self.rep_settings_button.setVisible(False)
|
|
||||||
button_layout = QtWidgets.QHBoxLayout()
|
button_layout = QtWidgets.QHBoxLayout()
|
||||||
button_layout.setSpacing(2)
|
button_layout.setSpacing(2)
|
||||||
button_layout.addWidget(self.settings_button)
|
button_layout.addWidget(self.settings_button)
|
||||||
button_layout.addWidget(self.select_dir_button)
|
button_layout.addWidget(self.select_dir_button)
|
||||||
button_layout.addWidget(self.report_button)
|
button_layout.addWidget(self.report_button)
|
||||||
button_layout.addWidget(self.rep_settings_button)
|
|
||||||
|
|
||||||
layout.addLayout(button_layout)
|
layout.addLayout(button_layout)
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
@ -94,11 +90,7 @@ class MainWindow(BaseMainWindow):
|
|||||||
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")
|
||||||
print(curve_items)
|
self.repSettings.build(reg_items, curve_items)
|
||||||
print(reg_items)
|
|
||||||
|
|
||||||
self.rep_settings_button.setVisible(True)
|
|
||||||
self.rep_settings_button.clicked.connect(lambda:self.repSettings.build(reg_items, curve_items))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -117,7 +117,8 @@ class PlotWidget(BasePlotWidget):
|
|||||||
curve.setZValue(10)
|
curve.setZValue(10)
|
||||||
plot_widget.addItem(curve)
|
plot_widget.addItem(curve)
|
||||||
curve_items["ideal"].setdefault(signal["name"], {})
|
curve_items["ideal"].setdefault(signal["name"], {})
|
||||||
curve_items["ideal"][signal["name"]][stage] = curve
|
curve_items["ideal"][signal["name"]].setdefault(stage, [])
|
||||||
|
curve_items["ideal"][signal["name"]][stage].append(curve)
|
||||||
|
|
||||||
def _add_real_signals(self,
|
def _add_real_signals(self,
|
||||||
plot_widget: pg.PlotWidget,
|
plot_widget: pg.PlotWidget,
|
||||||
|
|||||||
@ -7,10 +7,10 @@ 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:
|
||||||
|
self._clear()
|
||||||
param_tree = ParameterTree()
|
param_tree = ParameterTree()
|
||||||
layout = QtWidgets.QVBoxLayout()
|
layout = self.layout()
|
||||||
layout.addWidget(param_tree)
|
layout.addWidget(param_tree)
|
||||||
self.setLayout(layout)
|
|
||||||
|
|
||||||
body= [
|
body= [
|
||||||
self._generate_reg_params(reg_items),
|
self._generate_reg_params(reg_items),
|
||||||
@ -18,9 +18,20 @@ 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))
|
||||||
param_tree.setParameters(params, showTop=False)
|
param_tree.setParameters(params, showTop=False)
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
def _clear(self):
|
||||||
|
main = self.layout()
|
||||||
|
if self.layout() is not None:
|
||||||
|
while main.count():
|
||||||
|
child = main.takeAt(0)
|
||||||
|
if child.widget() is not None:
|
||||||
|
child.widget().deleteLater()
|
||||||
|
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': [
|
res = {'name': 'Sectors', 'type': 'group', 'children': [
|
||||||
@ -73,4 +84,47 @@ 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):
|
||||||
|
real_sectors = params.child("Sectors").child("Real sectors")
|
||||||
|
ideal_sectors = params.child("Sectors").child("Ideal sectors")
|
||||||
|
|
||||||
|
real_plots = params.child("Plots").child("Real plots")
|
||||||
|
ideal_plots = params.child("Plots").child("Ideal plots")
|
||||||
|
|
||||||
|
self._set_sector_settings(reg_items["real"], real_sectors)
|
||||||
|
self._set_sector_settings(reg_items["ideal"], ideal_sectors)
|
||||||
|
|
||||||
|
self._set_plot_settings(curve_items["real"], real_plots)
|
||||||
|
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:
|
||||||
|
for key, item in sectors.items():
|
||||||
|
sample = settings.child(key)
|
||||||
|
line_color = sample.child("Line color").value()
|
||||||
|
line_width = sample.child("Line thickness").value()
|
||||||
|
visibility = sample.child("Visibility").value()
|
||||||
|
fill_color = sample.child("Fill color").value()
|
||||||
|
|
||||||
|
pen = pg.mkPen(color=line_color, width=line_width)
|
||||||
|
brush=pg.mkBrush(fill_color)
|
||||||
|
for reg in item:
|
||||||
|
reg.setVisible(visibility)
|
||||||
|
reg.lines[0].setPen(pen)
|
||||||
|
reg.lines[1].setPen(pen)
|
||||||
|
reg.setBrush(brush)
|
||||||
|
|
||||||
|
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()
|
||||||
|
line_width = sample.child("Line thickness").value()
|
||||||
|
visibility = sample.child("Visibility").value()
|
||||||
|
pen = pg.mkPen(color=line_color, width=line_width)
|
||||||
|
if type(item) == list:
|
||||||
|
for curve in item:
|
||||||
|
curve.setVisible(visibility)
|
||||||
|
curve.setPen(pen)
|
||||||
|
else:
|
||||||
|
item.setVisible(visibility)
|
||||||
|
item.setPen(pen)
|
||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user