Compare commits
2 Commits
74b65eee5d
...
afcbb1abdc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afcbb1abdc | ||
|
|
acbbc33fdb |
Binary file not shown.
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from typing import Union
|
||||
|
||||
from utils.base.base import BaseController
|
||||
|
||||
@ -9,6 +10,8 @@ class Controller(BaseController):
|
||||
signal_widgets = pyqtSignal(list)
|
||||
signal_settings = pyqtSignal(list)
|
||||
signal_open_file = pyqtSignal(str)
|
||||
signal_statusBar = pyqtSignal(int)
|
||||
signal_statusText = pyqtSignal(str)
|
||||
signal_raport_mode = pyqtSignal()
|
||||
signal_seeking_mode = pyqtSignal()
|
||||
signal_update_plots = pyqtSignal()
|
||||
@ -31,5 +34,10 @@ class Controller(BaseController):
|
||||
def update_plots(self) -> None:
|
||||
self.signal_update_plots.emit()
|
||||
|
||||
def update_status(self, msg: Union[str, float, int]) -> None:
|
||||
if type(msg) == float or type(msg) == int:
|
||||
self.signal_statusBar.emit(int(msg))
|
||||
else:
|
||||
self.signal_statusText.emit(msg)
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import pandas as pd
|
||||
import time
|
||||
|
||||
from typing import Union
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
@ -15,19 +16,26 @@ class Mediator(BaseMediator):
|
||||
data: Union[list[str], list[pd.DataFrame], list[list], list[QWidget]]):
|
||||
|
||||
if issubclass(source.__class__, BaseDirectoryMonitor):
|
||||
self.update_status("CSV found! Calculating...")
|
||||
self._converter.convert_data(data)
|
||||
|
||||
if issubclass(source.__class__, BaseDataConverter):
|
||||
self.update_status(0.5)
|
||||
self._passportFormer.form_passports(data)
|
||||
|
||||
if issubclass(source.__class__, BasePointPassportFormer):
|
||||
self.update_status(1)
|
||||
self._plot.build(data)
|
||||
|
||||
if issubclass(source.__class__, BasePlotWidget):
|
||||
self.update_status(100)
|
||||
self._controller.send_widgets(data)
|
||||
|
||||
def update_settings(self, settings: list[dict]):
|
||||
self._monitor.update_settings(settings)
|
||||
self._passportFormer.update_settings(settings)
|
||||
|
||||
def update_status(self, msg: Union[str, float]) -> None:
|
||||
self._controller.update_status(msg)
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -3,6 +3,7 @@ from typing import Optional
|
||||
from PyQt5 import QtWidgets
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QPixmap, QIcon
|
||||
from PyQt5.QtWidgets import QSizePolicy as QSP
|
||||
|
||||
from utils.base.base import BaseMainWindow, BaseController
|
||||
from gui.settings_window import SystemSettings, OperatorSettings
|
||||
@ -30,7 +31,7 @@ class MainWindow(BaseMainWindow):
|
||||
self.operSettings = OperatorSettings("params/operator_params.json", 'Operator', self._upd_settings)
|
||||
self.sysSettings = SystemSettings("params/system_params.json", 'System', self._upd_settings)
|
||||
self.repSettings = ReportSettings()
|
||||
self.statusBar().showMessage("Ready")
|
||||
|
||||
|
||||
self._clear()
|
||||
self.resize(800,800)
|
||||
@ -61,6 +62,8 @@ class MainWindow(BaseMainWindow):
|
||||
mainLayout.addWidget(label, alignment=Qt.AlignCenter)
|
||||
mainLayout.addWidget(button_widget)
|
||||
|
||||
self._init_statusBar()
|
||||
|
||||
def _init_dock_widgets(self) -> None:
|
||||
"""
|
||||
Инициализация док-виджетов для настроек.
|
||||
@ -132,7 +135,41 @@ class MainWindow(BaseMainWindow):
|
||||
settings_menu.addAction(operator_settings)
|
||||
settings_menu.addAction(view_settings)
|
||||
|
||||
|
||||
def _init_statusBar(self) -> None:
|
||||
# Создание пользовательского виджета для StatusBar
|
||||
note_widget = QtWidgets.QWidget()
|
||||
note_layout = QtWidgets.QHBoxLayout(note_widget)
|
||||
note_layout.setContentsMargins(10, 1, 10, 1)
|
||||
note_layout.setSpacing(15) # Устанавливаем расстояние между элементами
|
||||
|
||||
# Создание QLabel и QProgressBar
|
||||
self.mode_label = QtWidgets.QLabel()
|
||||
self.note_label = QtWidgets.QLabel()
|
||||
self.progress_bar = QtWidgets.QProgressBar()
|
||||
self.progress_bar.setRange(0, 100)
|
||||
self.progress_bar.setValue(0)
|
||||
self.progress_bar.setMinimumWidth(250)
|
||||
self.progress_bar.setMaximumHeight(10)
|
||||
self.progress_bar.setTextVisible(False)
|
||||
|
||||
# Создание QSpacerItem
|
||||
|
||||
# Установка политики размеров
|
||||
self.mode_label.setSizePolicy(QSP.Policy.Preferred, QSP.Policy.Preferred)
|
||||
self.note_label.setSizePolicy(QSP.Policy.MinimumExpanding, QSP.Policy.Preferred)
|
||||
self.progress_bar.setSizePolicy(QSP.Policy.Fixed, QSP.Policy.Preferred)
|
||||
|
||||
# Добавление виджетов в макет
|
||||
note_layout.addWidget(self.mode_label)
|
||||
note_layout.addWidget(self.note_label)
|
||||
note_layout.addStretch(1)
|
||||
note_layout.addWidget(self.progress_bar)
|
||||
|
||||
# Установка политики размеров для note_widget
|
||||
note_widget.setSizePolicy(QSP.Policy.Expanding, QSP.Policy.Preferred)
|
||||
|
||||
# Добавление пользовательского виджета в StatusBar как Permanent Widget
|
||||
self.statusBar().addPermanentWidget(note_widget, 1)
|
||||
|
||||
def _toggle_visibility(self, body:QtWidgets.QDockWidget = None) -> None:
|
||||
"""
|
||||
@ -167,10 +204,9 @@ class MainWindow(BaseMainWindow):
|
||||
button_widget = QtWidgets.QWidget()
|
||||
button_widget.setLayout(button_layout)
|
||||
|
||||
title = QtWidgets.QLabel("online mode")
|
||||
self.mode_label.setText("online mode")
|
||||
self._central_layout.addWidget(self.tabWidget)
|
||||
self._central_layout.addWidget(button_widget)
|
||||
self._central_layout.addWidget(title, alignment=Qt.AlignRight)
|
||||
self._controller.seeking_mode()
|
||||
|
||||
def _init_raportUI(self) -> None:
|
||||
@ -193,10 +229,9 @@ class MainWindow(BaseMainWindow):
|
||||
button_widget = QtWidgets.QWidget()
|
||||
button_widget.setLayout(button_layout)
|
||||
|
||||
title = QtWidgets.QLabel("raport mode")
|
||||
self.mode_label.setText("raport mode")
|
||||
self._central_layout.addWidget(self.tabWidget)
|
||||
self._central_layout.addWidget(button_widget)
|
||||
self._central_layout.addWidget(title, alignment=Qt.AlignRight)
|
||||
|
||||
self._controller.raport_mode()
|
||||
|
||||
@ -219,6 +254,8 @@ class MainWindow(BaseMainWindow):
|
||||
for i in range(0, tab_count-10):
|
||||
self._close_tab(i)
|
||||
|
||||
self.update_stateLabel("Done!")
|
||||
|
||||
def keyPressEvent(self, a0) -> None:
|
||||
if a0.key() == Qt.Key_F5:
|
||||
tab_count = self.tabWidget.count()
|
||||
@ -231,6 +268,14 @@ class MainWindow(BaseMainWindow):
|
||||
self.repSettings.close()
|
||||
super().closeEvent(a0)
|
||||
|
||||
def update_progressBar(self, percent:int) -> None:
|
||||
if percent > 100: percent = 100
|
||||
self.progress_bar.setValue(percent)
|
||||
|
||||
def update_stateLabel(self, msg: str = None) -> None:
|
||||
self.note_label.setText(msg)
|
||||
self.note_label.adjustSize()
|
||||
|
||||
def _transfer_settings(self) -> None:
|
||||
self.tabWidget.clear()
|
||||
operator_params = self.operSettings.getParams()
|
||||
|
||||
@ -199,7 +199,12 @@ class PlotWidget(BasePlotWidget):
|
||||
|
||||
dat_is_none = dataframe is None
|
||||
|
||||
if not dat_is_none: dataframe_headers = dataframe.columns.tolist()
|
||||
widget_steps = len(self._plt_channels)
|
||||
|
||||
if not dat_is_none:
|
||||
dataframe_headers = dataframe.columns.tolist()
|
||||
point_steps = len(points_pocket)
|
||||
else: point_steps = 1
|
||||
|
||||
for widget_num, (channel, description) in enumerate(self._plt_channels.items()):
|
||||
plot_item, legend = self._init_plot_item(title=channel)
|
||||
@ -299,6 +304,9 @@ class PlotWidget(BasePlotWidget):
|
||||
worst_perf = curr_perf
|
||||
worst_timeframe = point_timeframe
|
||||
|
||||
# Считаем прогресс
|
||||
self._update_status(widget_steps, point_steps, widget_num, cur_point)
|
||||
|
||||
# Добавляем реальные сигналы
|
||||
if not dat_is_none:
|
||||
self._add_real_signals(plot_item, dataframe, description["Real_signals"], legend, curve_items)
|
||||
@ -333,7 +341,8 @@ class PlotWidget(BasePlotWidget):
|
||||
]
|
||||
"""
|
||||
try:
|
||||
widgets_datapack = [self._build_widget(data_sample) for data_sample in data]
|
||||
self._datalen = len(data)
|
||||
widgets_datapack = [self._build_widget(data_sample) for self._datastep, data_sample in enumerate(data)]
|
||||
except:
|
||||
tb = sys.exc_info()[2]
|
||||
tbinfo = traceback.format_tb(tb)[0]
|
||||
@ -343,5 +352,19 @@ class PlotWidget(BasePlotWidget):
|
||||
finally:
|
||||
self._mediator.notify(self, widgets_datapack)
|
||||
|
||||
def _update_status(self, widgsteps:int, pointsteps:int, cur_widg:int, cur_point:int):
|
||||
if self._datalen != 0:
|
||||
sycle_start = self._datastep/self._datalen*100 + 1
|
||||
period1 = 100/self._datalen
|
||||
else:
|
||||
sycle_start = 1
|
||||
period1 = 100
|
||||
|
||||
period2 = period1/widgsteps if widgsteps != 0 else period1
|
||||
period3 = period2/pointsteps if pointsteps != 0 else period2
|
||||
|
||||
progress = sycle_start + period2*cur_widg + period3*cur_point
|
||||
self._mediator.update_status(progress)
|
||||
|
||||
|
||||
|
||||
@ -24,6 +24,8 @@ def main():
|
||||
window.show()
|
||||
|
||||
controller.signal_widgets.connect(window.show_plot_tabs)
|
||||
controller.signal_statusBar.connect(window.update_progressBar)
|
||||
controller.signal_statusText.connect(window.update_stateLabel)
|
||||
controller.signal_settings.connect(mediator.update_settings)
|
||||
controller.signal_open_file.connect(monitor.custom_csv_extract_only)
|
||||
controller.signal_raport_mode.connect(monitor.start_raport)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -40,6 +40,9 @@ class BaseMediator:
|
||||
def update_settings (self, data: list[dict]):
|
||||
...
|
||||
|
||||
def update_status(self, msg: Union[str, float]) -> None:
|
||||
...
|
||||
|
||||
class BaseDirectoryMonitor:
|
||||
|
||||
update_timer = QTimer()
|
||||
@ -356,6 +359,9 @@ class BaseController(QObject):
|
||||
|
||||
def update_plots(self) -> None:
|
||||
...
|
||||
|
||||
def update_status(self, msg: Union[str, float]) -> None:
|
||||
...
|
||||
|
||||
class BaseIdealDataBuilder(OptAlgorithm):
|
||||
|
||||
|
||||
@ -263,7 +263,9 @@ QDockWidget::close-button, QDockWidget::float-button {
|
||||
}
|
||||
|
||||
QDockWidget::close-button:hover, QDockWidget::float-button:hover {
|
||||
border: none;
|
||||
background-color: #FFD700 ;
|
||||
icon-size: 18px;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -321,6 +323,12 @@ QTableView QScrollBar::handle:vertical {
|
||||
}
|
||||
*/
|
||||
|
||||
QProgressBar {
|
||||
border: 2px solid grey;
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/*
|
||||
------------------------------------------------------
|
||||
Завершение стиля
|
||||
|
||||
Loading…
Reference in New Issue
Block a user