From 7c09dde2d1d6350c8bac83186cd9517afa46bc29 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 13 Nov 2024 11:13:31 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BE=D0=BA=D0=BD=D0=B0=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BA=20=D1=82=D0=B5=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=8C=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B0?= =?UTF-8?q?=D1=8E=D1=82=D1=81=D1=8F=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=BD=D0=BE=20=D0=B8=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D1=8E=D1=82=20=D0=B2=D1=81=D0=B5=20=D0=B3=D1=80?= =?UTF-8?q?=D0=B0=D1=84=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__pycache__/main.cpython-310.pyc | Bin 3470 -> 3618 bytes src/gui/__init__.py | 2 +- src/gui/__pycache__/__init__.cpython-310.pyc | Bin 286 -> 293 bytes src/gui/__pycache__/app.cpython-310.pyc | Bin 2826 -> 3117 bytes src/gui/app.py | 93 ++++++++++--------- src/main.py | 13 ++- 6 files changed, 60 insertions(+), 48 deletions(-) diff --git a/src/__pycache__/main.cpython-310.pyc b/src/__pycache__/main.cpython-310.pyc index 7efd1c4b273d027fa18ffcefe6179d9112345d09..644c0ae1b6d7fdcf6db471fa27f4a8b175b42086 100644 GIT binary patch delta 1354 zcmZ8h&2QX96!-XZ*6ZDDHXm(vQ?wNkbk!1?s^v>j3qozwLjftNpjL%(cBZ@DdhKL9 z$r5ms!}h=dkb+OZWy`-%iFn;S7X3w{ZD`D4^pVCWuTKpB4EPo1g70z*{Ijge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{>oY)J3l|#ni6B$~^#=xTHm>URKU`H(Oxv>!Jp~s;SO$ z5z3z6ELJ&+dGG{YKRe_*+0N9iUb|F2r|(=v3Mwm?Oh|DVf(;P3T`t2>62q^2Rl9xsF&b?a$2)A-rvkYTYI{k_!y%KsYARx&%45S}m<)iH zLBs^N0~cM>pn;XLU7nt&>{E#QIjkHT(Ic*I>o%dpEq`+Nwp6)H@d>yp z^Wi}vD|5sW328+UA4*?WX;l_K!l%B1Ny2 zj=IT2_fTM@z|4EuD6se=9)-RkZh%ePLWez46Z=LE9WYmBpCyBDK+2I4lX!X)+S=7A zP&G@ghz;CC!w|QHp?^ty1_o92%9Kf;m+OsWubzu&wR@1PLQ$sG$FWoisQ^L|^!oKm n>Zr)K`&oRD@^u1Qj#B_L3|DtZn|j2vT1IP$uF!@{%zys_I?flpO=@50SK4_P15rw@)q!Lrxzs_WQ1qtrR0}SoG=vtpLhzY diff --git a/src/gui/__pycache__/app.cpython-310.pyc b/src/gui/__pycache__/app.cpython-310.pyc index 603ef1e510187f8e4d5310ac98a9c890970e1a18..6d39a1298a84d88cf1962381995b33b481d059ed 100644 GIT binary patch literal 3117 zcmZ`*Uvt~W5yt@_2!bF*DNb71{o}N8XE;+!cIy0bCX=xfO_PUMaie5BgHd~f@J@?-oRs7HT?e3E*~bHO53TwhL^y(FPQuW;nVWlwm-~s&NbY5gJV=7PnKUi$XJOt-T6WyX zqP(57^Eio_^SL7e(R}WR=82nhWLJcbU9~0IY(=zA8FOUk#7TOxH(M3aDNEMm+U$)} z2XZ#MLcL%+w)NXTVMoq(-!&~IQ^60aVr)8Fqjad!{9&ppsW8|4T0WV`N}K502VZ`M zg}P9EX5z0(eLou(YNYpbTJ|t2w3fI-F^D>KriPSPNVJP8~a+9A8l?P9UX0ySvuB} zJlhx)`R0PztPY2peb|UF97@F}Dg(Ew>S*xc!ocHeWr}!Jn?+e$%xivw!g;(tpRAr% zTIT1b=6buA=_TP;^RF$wu>1NKOt53W+Fw=V)FcK#mf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A_*usdd@-K@byE7VS)A|J*7sSRW;jaNc+A5+wVrxwontLeyA4fS=wu#XK z#MIg*bxk3p@pI6=Yx~BuPSS9uR}>B>=K@A`86;x3-I(=ocU{~phE(6vi%TuDfQw6j zKp`h6vd!`v7!;)iR}`)b-m_rfa9=kd(Tp$H5uQAtl7$>Rr`8F~Zsni{I=91jtR2~(+ImMJ9hw$;05GRTQ5TDP6R!4~Y6}m`tJjJ9h{y(! z>qM@C^uq-s!lT;AnxC;;RfLEXe0|q;pL&bz-y`xi5dx&718n8#{18=d&|Lcjykw=` zp_%Bo5K*Ep^UBs43b?LT0?2vl89$ryEBM}r7}WdPgqLS=~-K!T3#I|pE{?G&MSE5tlRI;KS&K5u`Zjw zw&c)q-`V3Zrh|5z=8|(0agL6dWW>juKbWLhtx-K%>>Lrwhw-x!{&O0(<7_r;k0^?o zA|Dp~qN7vMd8%35#+)ai{YOH_POoT{4uCCbUS_h| zyngli7Qc3lU;XssYd82OSNYbBjY0LWzh+wHqX#%8@lRvia+tL6H?c9%qpY$BXW=Dj z+DTN$DW3IcYVi-PE;wt6pAidK7U!&s>IPglL4N;-FUr#RI0!)HuX6CR4V&;*9nH@u Y*A*d1==9tkstM5Hg`Xn=;QfF916j?<+W-In diff --git a/src/gui/app.py b/src/gui/app.py index ebfbf23..eb56b78 100644 --- a/src/gui/app.py +++ b/src/gui/app.py @@ -6,63 +6,68 @@ from src.OptAlgorithm import OptAlgorithm from src.gui import Plotter, settingsWindow -class graphWindow: - def __init__(self, path = None): - self.path = path - self._load_preset() - - def get_widget(self): - return self.plotter.widget +class tabWidgetGenerator: + def __init__(self): + self.UMLgenerator = Request(server_url='http://www.plantuml.com/plantuml/svg/') + self.uml_creator = UMLCreator(request_generator=self.UMLgenerator) + self.operator_params = read_json("params/operator_params.json") + self.system_params = read_json("params/system_params.json") + self.operSettings = settingsWindow("params\operator_params.json", 'Operator', self._update) + self.sysSettings = settingsWindow("params\system_params.json", 'System', self._update) + + self.paths = [] + self.plotters = [] + self.bool_dicts = [] + self.float_dicts = [] + self.timings_dicts = [] + self.modes = [] + + def get_widget(self, path): + self.paths.append(path) + self.plotters.append(Plotter(show_settings_func=self._show_settings)) + self._getParsedData(path) + self._update() + return self.plotters[-1].widget def _get_ideal_timings(self, opt: OptAlgorithm) -> list[float]: data = opt.Ts ideal_time = [data['tclose'], data['tgrow'], opt.getMarkOpen(), data["tmovement"]] return ideal_time - def _load_preset(self): - self.operator_params = read_json("params/operator_params.json") - self.system_params = read_json("params/system_params.json") - - generator = Request(server_url='http://www.plantuml.com/plantuml/svg/') - self.uml_creator = UMLCreator(request_generator=generator) - self.operSettings = settingsWindow("params\operator_params.json", 'Operator', self._update_settings) - self.sysSettings = settingsWindow("params\system_params.json", 'System', self._update_settings) - - self.plotter = Plotter(show_settings_func=self._show_settings) - - self.parser = DiagramParser(system_config=self.system_params) - self.parser.setData(self.path) - - self.bool_dict = self.parser.getBoolDict() - self.float_dict = self.parser.getFloatDict() - self.timings_dict = self.parser.getRealTimings() - self.mode = self.parser.getMode() - self._update_settings() + def _getParsedData(self, path): + parser = DiagramParser(system_config=self.system_params) + parser.setData(path) + self.bool_dicts.append(parser.getBoolDict()) + self.float_dicts.append(parser.getFloatDict()) + self.timings_dicts.append(parser.getRealTimings()) + self.modes.append(parser.getMode()) - def _update_settings(self, _ = None): + def _update(self, _ = None): self.operator_params = self.operSettings.getParams() self.system_params = self.sysSettings.getParams() - self.opt_algorithm = OptAlgorithm(operator_config=self.operator_params, system_config=self.system_params) - self.ideal_times = self._get_ideal_timings(self.opt_algorithm) + opt_algorithm = OptAlgorithm(operator_config=self.operator_params, system_config=self.system_params) + ideal_times = self._get_ideal_timings(opt_algorithm) + + for i in range (len(self.plotters)): + self.plotters[i].update_data(operator_config=self.operator_params, + system_config=self.system_params, + opt=opt_algorithm, + bool_dict=self.bool_dicts[i], + ideal_time=ideal_times, + float_dict=self.float_dicts[i], + mode = self.modes[i], + timings_dict=self.timings_dicts[i]) self.uml_creator.update_uml(operator_config=self.operator_params, system_config=self.system_params, - ideal_time=self.ideal_times, - bool_dict=self.bool_dict, - float_dict=self.float_dict, - mode = self.mode, - timings_dict=self.timings_dict) + ideal_time=ideal_times, + bool_dict=self.bool_dicts[i], + float_dict=self.float_dicts[i], + mode = self.modes[i], + timings_dict=self.timings_dicts[i]) - self.plotter.update_data(operator_config=self.operator_params, - system_config=self.system_params, - opt=self.opt_algorithm, - bool_dict=self.bool_dict, - ideal_time=self.ideal_times, - float_dict=self.float_dict, - mode = self.mode, - timings_dict=self.timings_dict) def _show_settings(self): self.operSettings.show() @@ -71,5 +76,7 @@ class graphWindow: if __name__ == '__main__': pg.mkQApp("Plotting") - temp = graphWindow("trace_samples/2024_11_08-19_30_49.csv") + temp = tabWidgetGenerator() + widget = temp.get_widget("trace_samples/2024_11_08-19_30_49.csv") + widget.show() pg.exec() \ No newline at end of file diff --git a/src/main.py b/src/main.py index 8bf2633..57f80b5 100644 --- a/src/main.py +++ b/src/main.py @@ -11,11 +11,12 @@ from PyQt5.QtWidgets import ( ) from PyQt5.QtCore import Qt, QThread, pyqtSignal, QObject, QFileSystemWatcher from PyQt5.QtGui import QIcon +from src.gui import qt_settings as qts # Импортируйте ваш класс `app` здесь # Предполагается, что класс `app` предоставляет интерфейс для отображения данных # Если `app` не предоставляет виджет, возможно, потребуется его модифицировать -from src.gui.app import graphWindow +from src.gui.app import tabWidgetGenerator class DirectoryWatcher(QObject): @@ -29,6 +30,7 @@ class DirectoryWatcher(QObject): self.watcher.addPath(self.directory_path) self.existing_files = set(os.listdir(self.directory_path)) self.watcher.directoryChanged.connect(self.on_directory_changed) + def on_directory_changed(self, _): try: @@ -50,10 +52,13 @@ class MainWindow(QMainWindow): self.setGeometry(100, 100, 800, 600) self.tabs = QTabWidget() + self.tabs.setStyleSheet(qts.dark_style) + self.tabGen = tabWidgetGenerator() self.setCentralWidget(self.tabs) # self.setWindowIcon(QIcon("path_to_icon.png")) self.start_directory_watcher(directory_to_watch) + def start_directory_watcher(self, directory_path): self.watcher_thread = QThread() @@ -66,14 +71,14 @@ class MainWindow(QMainWindow): self.watcher_thread.start() def handle_new_file(self, file_path): + time.sleep(0.2) file_name = os.path.basename(file_path) - app_instance = graphWindow(path=file_path) + tab_widget = self.tabGen.get_widget(path=file_path) tab = QWidget() layout = QVBoxLayout() - app_widget = app_instance.get_widget() - layout.addWidget(app_widget) + layout.addWidget(tab_widget) label = QLabel(f"{file_name}") label.setAlignment(Qt.AlignCenter)