Добавленна поддержка отображения, сохранинения, и загрузки растворителя во вкладке факторнго эксперимента. Убрана галочка рАндомизировать по умолчанию

This commit is contained in:
2026-05-27 15:41:09 +05:00
parent a2bc606336
commit acf3ad0dd5
5 changed files with 110 additions and 26 deletions
+48 -20
View File
@@ -2,10 +2,9 @@
"""
Единый графический интерфейс для калькулятора сред и DoE
"""
from theme import Colors, Fonts, Spacing, ButtonStyles, get_full_stylesheet, apply_theme
from theme import Colors, Fonts, Spacing, ButtonStyles, get_full_stylesheet, apply_theme, TitleStyles
import sys
from typing import List, Dict, Optional
from PyQt5.QtWidgets import (
QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
QTabWidget, QGroupBox, QLabel, QPushButton, QTableWidget,
@@ -86,12 +85,8 @@ class MainWindow(QMainWindow):
# Заголовок
title = QLabel("Цифровой помощник биохимика")
title_font = QFont()
title_font.setPointSize(18)
title_font.setBold(True)
title.setFont(title_font)
title.setObjectName("mainTitle") # Стиль подтянется из theme
title.setAlignment(Qt.AlignCenter)
title.setStyleSheet("color: #2c3e50; padding: 10px;")
layout.addWidget(title)
# Вкладки
@@ -275,7 +270,7 @@ class MainWindow(QMainWindow):
)
self.info_label.setText(solvent_text)
self.info_label.setStyleSheet("background-color: #d5f5e3; padding: 8px; border-radius: 5px;")
print(result)
# Сохраняем результаты для передачи в DoE
self.last_medium_result = result
@@ -329,23 +324,47 @@ class MainWindow(QMainWindow):
factors_layout.addLayout(btn_layout)
factors_box.setLayout(factors_layout)
layout.addWidget(factors_box)
# Настройки эксперимента
settings_box = QGroupBox("Настройки эксперимента")
settings_layout = QHBoxLayout()
settings_layout.addWidget(QLabel("Центральных точек:"))
settings_layout = QVBoxLayout()
# Параметры среды (из калькулятора)
env_layout = QHBoxLayout()
env_layout.addWidget(QLabel("Общий объём:"))
self.exp_total_volume = QDoubleSpinBox()
self.exp_total_volume.setRange(0.001, 1000000)
self.exp_total_volume.setValue(100)
self.exp_total_volume.setSuffix(" ")
env_layout.addWidget(self.exp_total_volume)
self.exp_volume_unit = QComboBox()
self.exp_volume_unit.addItems(["мл", "л", "мкл", "нл"])
self.exp_volume_unit.setCurrentText("мл")
env_layout.addWidget(self.exp_volume_unit)
env_layout.addSpacing(20)
env_layout.addWidget(QLabel("Растворитель:"))
self.exp_solvent = QLineEdit("Вода")
env_layout.addWidget(self.exp_solvent)
env_layout.addStretch()
settings_layout.addLayout(env_layout)
# Настройки эксперимента
exp_layout = QHBoxLayout()
exp_layout.addWidget(QLabel("Центральных точек:"))
self.center_points_spin = QSpinBox()
self.center_points_spin.setRange(0, 10)
self.center_points_spin.setValue(3)
settings_layout.addWidget(self.center_points_spin)
settings_layout.addSpacing(20)
self.randomize_check = QCheckBox("Рэндомизировать порядок")
self.randomize_check.setChecked(True)
settings_layout.addWidget(self.randomize_check)
settings_layout.addStretch()
exp_layout.addWidget(self.center_points_spin)
exp_layout.addSpacing(20)
self.randomize_check = QCheckBox("Рандомизировать порядок")
self.randomize_check.setChecked(False)
exp_layout.addWidget(self.randomize_check)
exp_layout.addStretch()
settings_layout.addLayout(exp_layout)
settings_box.setLayout(settings_layout)
layout.addWidget(settings_box)
@@ -414,7 +433,11 @@ class MainWindow(QMainWindow):
# Очищаем таблицу факторов
self.factors_table.setRowCount(0)
self.exp_total_volume.setValue(result['total_volume'])
self.exp_volume_unit.setCurrentText(result['total_unit'])
self.exp_solvent.setText(result['solvent_name'])
for reagent in result['reagents']:
name = reagent['name']
if reagent.get('dilution_factor', 1.0) != 1.0:
@@ -906,7 +929,12 @@ class MainWindow(QMainWindow):
self.reagents_table.setItem(row, 4, QTableWidgetItem(str(reagent.dilution_factor)))
self.reagents_table.setItem(row, 5, QTableWidgetItem(""))
# Применяем данные факторов эксперимента
self.exp_total_volume.setValue(project.experiment_total_volume)
self.exp_volume_unit.setCurrentText(project.experiment_volume_unit)
self.exp_solvent.setText(project.experiment_solvent)
self.factors_table.setRowCount(0)
for factor in project.experiment_factors:
if factor.percentage is not None: