fuck yeah!
This commit is contained in:
parent
ccb53d9091
commit
da10f5e132
44 changed files with 3260 additions and 448 deletions
159
views/control_panel.py
Normal file
159
views/control_panel.py
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
"""
|
||||
Панель управления - выбор даты, спектра, загрузка изображений
|
||||
"""
|
||||
|
||||
from PySide6.QtWidgets import (
|
||||
QWidget, QVBoxLayout, QHBoxLayout, QGroupBox,
|
||||
QComboBox, QDateEdit, QTimeEdit, QPushButton,
|
||||
QLabel, QProgressBar, QFrame
|
||||
)
|
||||
from PySide6.QtCore import Qt, QDateTime, Signal
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class ControlPanel(QWidget):
|
||||
"""Панель управления для выбора параметров загрузки"""
|
||||
|
||||
load_image_requested = Signal(int, datetime) # source_id, date
|
||||
|
||||
def __init__(self, controller):
|
||||
super().__init__()
|
||||
self.controller = controller
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
"""Инициализация UI"""
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setSpacing(10)
|
||||
layout.setContentsMargins(5, 5, 5, 5)
|
||||
|
||||
# Группа выбора спектра
|
||||
spectrum_group = QGroupBox("🌞 Спектральный канал")
|
||||
spectrum_layout = QVBoxLayout(spectrum_group)
|
||||
|
||||
self.spectrum_combo = QComboBox()
|
||||
self.spectrum_combo.setMinimumHeight(30)
|
||||
self.populate_spectrums()
|
||||
spectrum_layout.addWidget(self.spectrum_combo)
|
||||
|
||||
layout.addWidget(spectrum_group)
|
||||
|
||||
# Группа выбора даты и времени
|
||||
date_group = QGroupBox("📅 Дата и время (UTC)")
|
||||
date_layout = QVBoxLayout(date_group)
|
||||
|
||||
# Дата
|
||||
date_label = QLabel("Дата:")
|
||||
date_layout.addWidget(date_label)
|
||||
|
||||
self.date_edit = QDateEdit()
|
||||
self.date_edit.setDateTime(QDateTime.currentDateTime())
|
||||
self.date_edit.setCalendarPopup(True)
|
||||
self.date_edit.setMinimumHeight(30)
|
||||
date_layout.addWidget(self.date_edit)
|
||||
|
||||
# Время
|
||||
time_label = QLabel("Время:")
|
||||
date_layout.addWidget(time_label)
|
||||
|
||||
self.time_edit = QTimeEdit()
|
||||
self.time_edit.setTime(QDateTime.currentDateTime().time())
|
||||
self.time_edit.setMinimumHeight(30)
|
||||
date_layout.addWidget(self.time_edit)
|
||||
|
||||
# Кнопки быстрого выбора
|
||||
quick_layout = QHBoxLayout()
|
||||
|
||||
now_button = QPushButton("Сейчас")
|
||||
now_button.setMinimumHeight(30)
|
||||
now_button.clicked.connect(self.set_now)
|
||||
quick_layout.addWidget(now_button)
|
||||
|
||||
today_button = QPushButton("Сегодня")
|
||||
today_button.setMinimumHeight(30)
|
||||
today_button.clicked.connect(self.set_today)
|
||||
quick_layout.addWidget(today_button)
|
||||
|
||||
date_layout.addLayout(quick_layout)
|
||||
|
||||
layout.addWidget(date_group)
|
||||
|
||||
# Кнопка загрузки
|
||||
self.load_button = QPushButton("📥 Загрузить изображение")
|
||||
self.load_button.setMinimumHeight(40)
|
||||
self.load_button.clicked.connect(self.request_load_image)
|
||||
self.load_button.setStyleSheet("""
|
||||
QPushButton {
|
||||
background-color: #2ecc71;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #27ae60;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #555;
|
||||
}
|
||||
""")
|
||||
layout.addWidget(self.load_button)
|
||||
|
||||
# Прогресс бар (для загрузки)
|
||||
self.progress_bar = QProgressBar()
|
||||
self.progress_bar.setVisible(False)
|
||||
self.progress_bar.setMinimumHeight(20)
|
||||
layout.addWidget(self.progress_bar)
|
||||
|
||||
# Информационная метка
|
||||
self.info_label = QLabel("Выберите спектральный канал и дату")
|
||||
self.info_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.info_label.setStyleSheet("color: #888; font-size: 11px; padding: 5px;")
|
||||
layout.addWidget(self.info_label)
|
||||
|
||||
def populate_spectrums(self):
|
||||
"""Заполняет список доступных спектров"""
|
||||
from models.api_model import HelioviewerAPI
|
||||
|
||||
sources = HelioviewerAPI.get_available_sources()
|
||||
for source_id, info in sources.items():
|
||||
display_text = f"{info['observatory']} - {info['name']} ({info['wavelength']})"
|
||||
self.spectrum_combo.addItem(display_text, source_id)
|
||||
|
||||
def get_selected_source_id(self) -> int:
|
||||
"""Возвращает ID выбранного источника"""
|
||||
return self.spectrum_combo.currentData()
|
||||
|
||||
def get_selected_datetime(self) -> datetime:
|
||||
"""Возвращает выбранную дату и время"""
|
||||
qdatetime = QDateTime(self.date_edit.date(), self.time_edit.time())
|
||||
return qdatetime.toPython()
|
||||
|
||||
def set_now(self):
|
||||
"""Устанавливает текущее время"""
|
||||
now = QDateTime.currentDateTime()
|
||||
self.date_edit.setDate(now.date())
|
||||
self.time_edit.setTime(now.time())
|
||||
|
||||
def set_today(self):
|
||||
"""Устанавливает сегодняшнюю дату"""
|
||||
self.date_edit.setDate(QDateTime.currentDateTime().date())
|
||||
|
||||
def request_load_image(self):
|
||||
"""Запрашивает загрузку изображения"""
|
||||
source_id = self.get_selected_source_id()
|
||||
date = self.get_selected_datetime()
|
||||
self.load_image_requested.emit(source_id, date)
|
||||
|
||||
def show_progress(self, show: bool):
|
||||
"""Показывает/скрывает прогресс бар"""
|
||||
self.progress_bar.setVisible(show)
|
||||
self.load_button.setEnabled(not show)
|
||||
self.info_label.setText("Загрузка..." if show else "Готово")
|
||||
|
||||
def update_progress(self, value: int, maximum: int):
|
||||
"""Обновляет прогресс"""
|
||||
self.progress_bar.setRange(0, maximum)
|
||||
self.progress_bar.setValue(value)
|
||||
self.info_label.setText(f"Загрузка: {int(value/maximum*100)}%")
|
||||
Loading…
Add table
Add a link
Reference in a new issue