cdi-stools 0.3.1__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/CHANGELOG.md +20 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/PKG-INFO +1 -1
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/pyproject.toml +1 -1
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/__init__.py +1 -1
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/bcdi_gui.py +322 -7
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/LICENSE +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/README.md +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/CDI_ST_logo.png +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/__main__.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/bcdi_core.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/facets.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_autophase_infer.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_autophase_model.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_autophase_train.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_data_generator.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_dataset.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_demo.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_experimental_loader.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_gui_tabs.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_phase_model.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_phase_retrieval.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_train.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/nn_visualize.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/ortho.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/recon.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/requirements.txt +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/trainlog.py +0 -0
- {cdi_stools-0.3.1 → cdi_stools-0.3.2}/src/cdi_st/viz3d.py +0 -0
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.2] - 2026-11-08
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- The launcher window was missing: `main()` opened the simulation window
|
|
8
|
+
directly, so the data-analysis tabs were unreachable from the installed
|
|
9
|
+
package. The v0.3.0 rewrite of `bcdi_gui.py` had dropped `Launcher`,
|
|
10
|
+
`CDIStSplash`, `MW_Analysis` and `ReportsDialog`. All four are restored, and
|
|
11
|
+
`MW_Sim` keeps its Reports & Suggestions button.
|
|
12
|
+
|
|
13
|
+
## [0.3.1] - 2026-11-08
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `ModuleNotFoundError: No module named 'bcdi_core'` on launch. The modules
|
|
18
|
+
imported each other as top-level names, which works when the files sit
|
|
19
|
+
together in one folder but not from inside the `cdi_st` package. Imports are
|
|
20
|
+
now package-relative, with a fallback so the files still run directly from a
|
|
21
|
+
plain folder.
|
|
22
|
+
|
|
3
23
|
## [0.3.0] - 2026-11-08
|
|
4
24
|
|
|
5
25
|
Faceted particles, photon-budget noise, detector/sample space, standalone phase
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cdi-stools
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Coherent Diffraction Imaging Simulation Tools — BCDI simulation and NN-based phase retrieval
|
|
5
5
|
Project-URL: Homepage, https://github.com/SAIDIsoufiane/CDI-St
|
|
6
6
|
Project-URL: Documentation, https://github.com/SAIDIsoufiane/CDI-St#readme
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cdi-stools"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.2"
|
|
8
8
|
description = "Coherent Diffraction Imaging Simulation Tools — BCDI simulation and NN-based phase retrieval"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import sys,tempfile,os
|
|
1
|
+
import sys,tempfile,os,time
|
|
2
2
|
import numpy as np
|
|
3
3
|
from collections import Counter
|
|
4
|
-
from PyQt6.QtCore import Qt,QThread,pyqtSignal,QUrl,QSize,QTimer
|
|
5
|
-
from PyQt6.QtGui import QPalette,QColor,QFont
|
|
4
|
+
from PyQt6.QtCore import Qt,QThread,pyqtSignal,QUrl,QSize,QTimer,QRect
|
|
5
|
+
from PyQt6.QtGui import QPalette,QColor,QFont,QPixmap,QPainter,QBrush,QPen
|
|
6
6
|
from PyQt6.QtWidgets import (QApplication,QMainWindow,QWidget,QTabWidget,QVBoxLayout,QHBoxLayout,
|
|
7
7
|
QFormLayout,QGridLayout,QGroupBox,QLabel,QPushButton,QComboBox,QSpinBox,QDoubleSpinBox,
|
|
8
8
|
QLineEdit,QTableWidget,QTableWidgetItem,QHeaderView,QProgressBar,QMessageBox,QStatusBar,
|
|
9
|
-
QSplitter,QPlainTextEdit,QFrame,QCheckBox,QScrollArea,QFileDialog)
|
|
9
|
+
QSplitter,QPlainTextEdit,QFrame,QCheckBox,QScrollArea,QFileDialog,QSplashScreen)
|
|
10
10
|
try:
|
|
11
11
|
from PyQt6.QtWebEngineWidgets import QWebEngineView; _HAS_WEB=True
|
|
12
12
|
except: _HAS_WEB=False
|
|
@@ -27,6 +27,11 @@ else: # run from a plain folder
|
|
|
27
27
|
add_experimental_noise,export_measurement,load_cif_as_preset,find_preset,default_shape_for_material,
|
|
28
28
|
compatible_shapes,cells_for_size_nm,to_frame,offset_report)
|
|
29
29
|
import facets
|
|
30
|
+
try:
|
|
31
|
+
if __package__: from .nn_gui_tabs import T_Gen,T4,T4_Sup,T5,T6
|
|
32
|
+
else: from nn_gui_tabs import T_Gen,T4,T4_Sup,T5,T6
|
|
33
|
+
_HAS_NN=True
|
|
34
|
+
except Exception: _HAS_NN=False
|
|
30
35
|
|
|
31
36
|
QSS="""QMainWindow,QWidget{background:#0d1117;color:#e6edf3;font-family:'Segoe UI','Consolas',sans-serif;font-size:10pt}
|
|
32
37
|
QTabWidget::pane{border:1px solid #30363d;background:#0d1117;top:-1px}QTabBar::tab{background:#161b22;color:#8b949e;padding:10px 22px;margin-right:2px;border:1px solid #30363d;border-bottom:none;border-top-left-radius:6px;border-top-right-radius:6px;font-weight:600;min-width:140px}QTabBar::tab:selected{background:#0d1117;color:#4f98a3;border-bottom:2px solid #4f98a3}QTabBar::tab:disabled{color:#30363d}
|
|
@@ -486,24 +491,334 @@ class T3(QWidget):
|
|
|
486
491
|
self.c1.draw();self.c2.draw()
|
|
487
492
|
|
|
488
493
|
# ======================= MAIN =======================
|
|
489
|
-
class
|
|
494
|
+
class ReportsDialog(QWidget):
|
|
495
|
+
RECIPIENT = "saidisoufiane@hotmail.com"
|
|
496
|
+
def __init__(self,parent=None):
|
|
497
|
+
super().__init__(parent,Qt.WindowType.Dialog)
|
|
498
|
+
self.setWindowTitle("Reports & Suggestions");self.setFixedSize(480,360);self.setStyleSheet(QSS)
|
|
499
|
+
v=QVBoxLayout(self);v.setContentsMargins(16,16,16,16);v.setSpacing(10)
|
|
500
|
+
title=QLabel("Reports & Suggestions");title.setStyleSheet("color:#4f98a3;font-size:14pt;font-weight:700");v.addWidget(title)
|
|
501
|
+
info=QLabel("<span style='color:#8b949e;font-size:9pt'>"
|
|
502
|
+
"Both fields are required. "
|
|
503
|
+
"Your default mail client will open with the message ready to send."
|
|
504
|
+
"</span>")
|
|
505
|
+
info.setWordWrap(True);v.addWidget(info)
|
|
506
|
+
v.addWidget(QLabel("Your email:"));self.email_le=QLineEdit();self.email_le.setPlaceholderText("you@example.com");v.addWidget(self.email_le)
|
|
507
|
+
v.addWidget(QLabel("Message:"));self.msg_te=QPlainTextEdit();self.msg_te.setPlaceholderText("Describe the issue or suggestion...");self.msg_te.setMinimumHeight(140);v.addWidget(self.msg_te,1)
|
|
508
|
+
self.status=QLabel("");self.status.setWordWrap(True);self.status.setStyleSheet("font-size:9pt");v.addWidget(self.status)
|
|
509
|
+
br=QHBoxLayout();br.addStretch()
|
|
510
|
+
cancel=QPushButton("Cancel");cancel.setStyleSheet("background:#30363d;padding:7px 14px");cancel.clicked.connect(self.close);br.addWidget(cancel)
|
|
511
|
+
send=QPushButton("Send");send.setStyleSheet("background:#238636;padding:7px 18px;font-weight:600");send.clicked.connect(self._send);br.addWidget(send)
|
|
512
|
+
v.addLayout(br)
|
|
513
|
+
def _validate_email(self,e):
|
|
514
|
+
import re
|
|
515
|
+
return bool(re.match(r"^[^@\s]+@[^@\s]+\.[^@\s]+$",e))
|
|
516
|
+
def _send(self):
|
|
517
|
+
email=self.email_le.text().strip();msg=self.msg_te.toPlainText().strip()
|
|
518
|
+
if not email:
|
|
519
|
+
self.status.setText("<span style='color:#da3633'>Email is required.</span>");return
|
|
520
|
+
if not self._validate_email(email):
|
|
521
|
+
self.status.setText("<span style='color:#da3633'>Please enter a valid email address.</span>");return
|
|
522
|
+
if not msg:
|
|
523
|
+
self.status.setText("<span style='color:#da3633'>Message is required.</span>");return
|
|
524
|
+
# Open the user's default mail client via mailto:
|
|
525
|
+
import urllib.parse,webbrowser
|
|
526
|
+
subject=urllib.parse.quote(f"BCDI Software - Report from {email}")
|
|
527
|
+
body=urllib.parse.quote(f"From: {email}\n\n{msg}")
|
|
528
|
+
url=f"mailto:{self.RECIPIENT}?subject={subject}&body={body}"
|
|
529
|
+
try:
|
|
530
|
+
webbrowser.open(url,new=1)
|
|
531
|
+
self.status.setText(
|
|
532
|
+
f"<span style='color:#3fb950'>\u2713 Opening your mail client. "
|
|
533
|
+
f"Click 'Send' there to deliver the message to {self.RECIPIENT}.</span>"
|
|
534
|
+
)
|
|
535
|
+
QTimer.singleShot(2500,self.close)
|
|
536
|
+
except Exception as e:
|
|
537
|
+
# Fallback: copy mailto URL to clipboard
|
|
538
|
+
try:
|
|
539
|
+
cb=QApplication.clipboard();cb.setText(f"To: {self.RECIPIENT}\nFrom: {email}\n\n{msg}")
|
|
540
|
+
self.status.setText(
|
|
541
|
+
f"<span style='color:#f0883e'>Could not open mail client automatically. "
|
|
542
|
+
f"The message has been copied to clipboard \u2014 please paste it into "
|
|
543
|
+
f"an email to {self.RECIPIENT}.</span>"
|
|
544
|
+
)
|
|
545
|
+
except Exception as e2:
|
|
546
|
+
self.status.setText(f"<span style='color:#da3633'>Failed: {e2}</span>")
|
|
547
|
+
|
|
548
|
+
def _make_reports_button(parent):
|
|
549
|
+
btn=QPushButton("Reports && Suggestions",parent)
|
|
550
|
+
# 60% smaller than the previous version: smaller padding, smaller font, smaller height
|
|
551
|
+
btn.setStyleSheet(
|
|
552
|
+
"background:#1f6feb;color:#fff;padding:1px 6px;border-radius:3px;"
|
|
553
|
+
"font-size:7pt;font-weight:600;border:none"
|
|
554
|
+
)
|
|
555
|
+
btn.setToolTip("Send feedback or report a bug")
|
|
556
|
+
btn.setFixedHeight(16)
|
|
557
|
+
btn.adjustSize()
|
|
558
|
+
btn._dialog=None
|
|
559
|
+
def _open():
|
|
560
|
+
if btn._dialog is None or not btn._dialog.isVisible():
|
|
561
|
+
btn._dialog=ReportsDialog(parent)
|
|
562
|
+
btn._dialog.show();btn._dialog.raise_();btn._dialog.activateWindow()
|
|
563
|
+
btn.clicked.connect(_open)
|
|
564
|
+
return btn
|
|
565
|
+
|
|
566
|
+
class MW_Sim(QMainWindow):
|
|
490
567
|
def __init__(self):
|
|
491
|
-
super().__init__();self.setWindowTitle("BCDI
|
|
568
|
+
super().__init__();self.setWindowTitle("BCDI Simulation");self.resize(1500,960);self.setMinimumSize(1200,800)
|
|
492
569
|
self.tabs=QTabWidget();self.tabs.setDocumentMode(True);self.t1=T1();self.t2=T2();self.t3=T3()
|
|
493
570
|
self.tabs.addTab(self.t1," 1 Material ");self.tabs.addTab(self.t2," 2 Beam ");self.tabs.addTab(self.t3," 3 Results ")
|
|
494
571
|
self.tabs.setTabEnabled(1,False);self.tabs.setTabEnabled(2,False);self.setCentralWidget(self.tabs)
|
|
495
572
|
sb=QStatusBar();self.setStatusBar(sb);sb.showMessage("Build lattice first.")
|
|
496
573
|
self.t1.built.connect(self._ob);self.t1.nb.clicked.connect(lambda:self.tabs.setCurrentIndex(1))
|
|
497
574
|
self.t2.sim_req.connect(self._os);self.t2.nb.clicked.connect(lambda:self.tabs.setCurrentIndex(2));self._sw=None
|
|
575
|
+
self.report_btn=_make_reports_button(self);self._reposition_reports()
|
|
576
|
+
def resizeEvent(self,e):
|
|
577
|
+
super().resizeEvent(e);self._reposition_reports()
|
|
578
|
+
def _reposition_reports(self):
|
|
579
|
+
m=10;h=self.statusBar().height() if self.statusBar() else 0
|
|
580
|
+
self.report_btn.move(self.width()-self.report_btn.width()-m,self.height()-self.report_btn.height()-h-m);self.report_btn.raise_()
|
|
498
581
|
def _ob(self,c,b): self.t2.sc(c,b);self.tabs.setTabEnabled(1,True)
|
|
499
582
|
def _os(self,p):
|
|
500
583
|
self._sw=SW(p['config'],p['builder'],p['hkl']);self._sw.progress.connect(self.t2.pg.setValue);self._sw.log.connect(self.t2.lg.appendPlainText)
|
|
501
584
|
self._sw.done.connect(self._sd);self._sw.failed.connect(self._sf);self._sw.start()
|
|
502
585
|
def _sd(self,s,r,d): self.t2.sb_.setEnabled(True);self.t2.nb.setEnabled(True);self.t3.display(s,r,s.config);self.tabs.setTabEnabled(2,True)
|
|
503
586
|
def _sf(self,m): self.t2.sb_.setEnabled(True);self.t2.lg.appendPlainText(f"FAIL: {m}")
|
|
587
|
+
|
|
588
|
+
class MW_Analysis(QMainWindow):
|
|
589
|
+
def __init__(self,parent=None):
|
|
590
|
+
super().__init__(parent);self.setWindowTitle("BCDI Data Analysis");self.resize(1500,960);self.setMinimumSize(1200,800)
|
|
591
|
+
if not _HAS_NN:
|
|
592
|
+
QMessageBox.critical(self,"Missing module",
|
|
593
|
+
"The data analysis module (nn_gui_tabs) is not available. "
|
|
594
|
+
"Make sure all NN-related files are present.")
|
|
595
|
+
QTimer.singleShot(0,self.close);return
|
|
596
|
+
central=QWidget();vl=QVBoxLayout(central);vl.setContentsMargins(0,0,0,0);vl.setSpacing(0)
|
|
597
|
+
self.tabs=QTabWidget();self.tabs.setDocumentMode(True)
|
|
598
|
+
self.tg=T_Gen();self.t4=T4();self.t4s=T4_Sup();self.t5=T5();self.t6=T6()
|
|
599
|
+
self.tabs.addTab(self.tg,"Generate Data")
|
|
600
|
+
self.tabs.addTab(self.t4,"AutoPhase_NN")
|
|
601
|
+
self.tabs.addTab(self.t4s,"CDI_NN")
|
|
602
|
+
self.tabs.addTab(self.t5,"Reconstruction")
|
|
603
|
+
self.tabs.addTab(self.t6,"3D Viewer")
|
|
604
|
+
self.t5.recon_done.connect(self.t6.set_result)
|
|
605
|
+
vl.addWidget(self.tabs,1)
|
|
606
|
+
self.setCentralWidget(central)
|
|
607
|
+
sb=QStatusBar();self.setStatusBar(sb);sb.showMessage("Generate training data, train models, then run reconstruction.")
|
|
608
|
+
# Reports button bottom-right
|
|
609
|
+
self.report_btn=_make_reports_button(self)
|
|
610
|
+
self._reposition_reports()
|
|
611
|
+
def resizeEvent(self,e):
|
|
612
|
+
super().resizeEvent(e);self._reposition_reports()
|
|
613
|
+
def _reposition_reports(self):
|
|
614
|
+
if hasattr(self,'report_btn'):
|
|
615
|
+
margin=10;sb_h=self.statusBar().height() if self.statusBar() else 0
|
|
616
|
+
self.report_btn.move(self.width()-self.report_btn.width()-margin,
|
|
617
|
+
self.height()-self.report_btn.height()-sb_h-margin)
|
|
618
|
+
self.report_btn.raise_()
|
|
619
|
+
|
|
620
|
+
def _logo_path():
|
|
621
|
+
here = os.path.dirname(os.path.abspath(__file__))
|
|
622
|
+
candidates = [
|
|
623
|
+
os.path.join(here, "CDI_ST_logo.png"),
|
|
624
|
+
os.path.join(here, "CDI_NN_logo.png"),
|
|
625
|
+
os.path.join(here, "logo.png"),
|
|
626
|
+
]
|
|
627
|
+
for c in candidates:
|
|
628
|
+
if os.path.exists(c):
|
|
629
|
+
return c
|
|
630
|
+
return None
|
|
631
|
+
|
|
632
|
+
class CDIStSplash(QSplashScreen):
|
|
633
|
+
def __init__(self):
|
|
634
|
+
# Build the splash pixmap: logo image + space below for loading bar
|
|
635
|
+
logo = _logo_path()
|
|
636
|
+
if logo is not None:
|
|
637
|
+
base_pix = QPixmap(logo)
|
|
638
|
+
if base_pix.isNull():
|
|
639
|
+
base_pix = self._fallback_pixmap()
|
|
640
|
+
else:
|
|
641
|
+
base_pix = self._fallback_pixmap()
|
|
642
|
+
# Scale to a reasonable splash size if needed
|
|
643
|
+
if base_pix.width() > 700:
|
|
644
|
+
base_pix = base_pix.scaledToWidth(700, Qt.TransformationMode.SmoothTransformation)
|
|
645
|
+
# Create a final pixmap with extra space for the loading bar + status text
|
|
646
|
+
BAR_H = 64 # extra height below the logo for bar + text
|
|
647
|
+
full = QPixmap(base_pix.width(), base_pix.height() + BAR_H)
|
|
648
|
+
full.fill(QColor("#0d1117")) # dark background matching app theme
|
|
649
|
+
p = QPainter(full)
|
|
650
|
+
p.drawPixmap(0, 0, base_pix)
|
|
651
|
+
p.end()
|
|
652
|
+
super().__init__(full, Qt.WindowType.WindowStaysOnTopHint)
|
|
653
|
+
self.setFixedSize(full.size())
|
|
654
|
+
self._logo_h = base_pix.height()
|
|
655
|
+
self._bar_h = BAR_H
|
|
656
|
+
self._progress = 0
|
|
657
|
+
self._status = "Loading..."
|
|
658
|
+
# Loading bar overlay (drawn in drawContents)
|
|
659
|
+
def _fallback_pixmap(self):
|
|
660
|
+
pix = QPixmap(640, 280)
|
|
661
|
+
pix.fill(QColor("#0d1117"))
|
|
662
|
+
p = QPainter(pix)
|
|
663
|
+
# Title
|
|
664
|
+
p.setPen(QColor("#e6edf3"))
|
|
665
|
+
f = QFont(); f.setPointSize(48); f.setBold(True); f.setLetterSpacing(QFont.SpacingType.AbsoluteSpacing, 4)
|
|
666
|
+
p.setFont(f)
|
|
667
|
+
p.drawText(QRect(0, 50, 640, 80), Qt.AlignmentFlag.AlignCenter, "CDI-ST")
|
|
668
|
+
# Subtitle
|
|
669
|
+
p.setPen(QColor("#8b949e"))
|
|
670
|
+
f2 = QFont(); f2.setPointSize(13)
|
|
671
|
+
p.setFont(f2)
|
|
672
|
+
p.drawText(QRect(0, 150, 640, 30), Qt.AlignmentFlag.AlignCenter,
|
|
673
|
+
"Coherent Diffraction Imaging Simulation Tools")
|
|
674
|
+
p.end()
|
|
675
|
+
return pix
|
|
676
|
+
def set_progress(self, value, status=""):
|
|
677
|
+
self._progress = max(0, min(100, int(value)))
|
|
678
|
+
if status:
|
|
679
|
+
self._status = status
|
|
680
|
+
self.repaint()
|
|
681
|
+
def drawContents(self, painter):
|
|
682
|
+
# Draw loading bar + status text in the strip below the logo
|
|
683
|
+
w = self.width()
|
|
684
|
+
bar_y_top = self._logo_h + 18
|
|
685
|
+
bar_x = 40
|
|
686
|
+
bar_w = w - 80
|
|
687
|
+
bar_h = 8
|
|
688
|
+
# Track
|
|
689
|
+
painter.setBrush(QBrush(QColor("#161b22")))
|
|
690
|
+
painter.setPen(QPen(QColor("#30363d"), 1))
|
|
691
|
+
painter.drawRoundedRect(bar_x, bar_y_top, bar_w, bar_h, 3, 3)
|
|
692
|
+
# Filled portion
|
|
693
|
+
if self._progress > 0:
|
|
694
|
+
painter.setBrush(QBrush(QColor("#4f98a3")))
|
|
695
|
+
painter.setPen(Qt.PenStyle.NoPen)
|
|
696
|
+
painter.drawRoundedRect(bar_x, bar_y_top, int(bar_w * self._progress / 100.0), bar_h, 3, 3)
|
|
697
|
+
# Status text
|
|
698
|
+
painter.setPen(QColor("#8b949e"))
|
|
699
|
+
f = QFont(); f.setPointSize(9)
|
|
700
|
+
painter.setFont(f)
|
|
701
|
+
painter.drawText(
|
|
702
|
+
QRect(bar_x, bar_y_top + bar_h + 6, bar_w, 18),
|
|
703
|
+
Qt.AlignmentFlag.AlignCenter,
|
|
704
|
+
self._status
|
|
705
|
+
)
|
|
706
|
+
|
|
707
|
+
class Launcher(QMainWindow):
|
|
708
|
+
def __init__(self):
|
|
709
|
+
super().__init__()
|
|
710
|
+
self.setWindowTitle("CDI-ST")
|
|
711
|
+
# Sized so the 678x340 logo fits at a reasonable scale
|
|
712
|
+
self.setFixedSize(560, 540)
|
|
713
|
+
self.sim_window = None
|
|
714
|
+
self.analysis_window = None
|
|
715
|
+
central = QWidget()
|
|
716
|
+
central.setStyleSheet("background:#0d1117")
|
|
717
|
+
v = QVBoxLayout(central)
|
|
718
|
+
v.setContentsMargins(20, 16, 20, 14)
|
|
719
|
+
v.setSpacing(12)
|
|
720
|
+
# Logo image at the top (matches splash screen)
|
|
721
|
+
logo = _logo_path()
|
|
722
|
+
if logo is not None:
|
|
723
|
+
pix = QPixmap(logo)
|
|
724
|
+
if not pix.isNull():
|
|
725
|
+
# Scale so it fits in the launcher width comfortably
|
|
726
|
+
pix = pix.scaledToWidth(520, Qt.TransformationMode.SmoothTransformation)
|
|
727
|
+
logo_label = QLabel()
|
|
728
|
+
logo_label.setPixmap(pix)
|
|
729
|
+
logo_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
730
|
+
logo_label.setStyleSheet("background:transparent")
|
|
731
|
+
v.addWidget(logo_label)
|
|
732
|
+
else:
|
|
733
|
+
self._add_text_header(v)
|
|
734
|
+
else:
|
|
735
|
+
self._add_text_header(v)
|
|
736
|
+
v.addSpacing(6)
|
|
737
|
+
choose = QLabel("Choose a module:")
|
|
738
|
+
choose.setStyleSheet("color:#e6edf3;font-size:10pt;background:transparent")
|
|
739
|
+
v.addWidget(choose)
|
|
740
|
+
# Mode buttons (no tooltips — labels are self-explanatory)
|
|
741
|
+
sim_btn = QPushButton("BCDI Simulation")
|
|
742
|
+
sim_btn.setStyleSheet(
|
|
743
|
+
"background:#238636;color:#fff;padding:14px;border-radius:6px;"
|
|
744
|
+
"font-size:11pt;font-weight:600;text-align:center"
|
|
745
|
+
)
|
|
746
|
+
sim_btn.setMinimumHeight(48)
|
|
747
|
+
sim_btn.clicked.connect(self._open_sim)
|
|
748
|
+
v.addWidget(sim_btn)
|
|
749
|
+
ana_btn = QPushButton("BCDI Data Analysis")
|
|
750
|
+
ana_btn.setStyleSheet(
|
|
751
|
+
"background:#1f6feb;color:#fff;padding:14px;border-radius:6px;"
|
|
752
|
+
"font-size:11pt;font-weight:600;text-align:center"
|
|
753
|
+
)
|
|
754
|
+
ana_btn.setMinimumHeight(48)
|
|
755
|
+
ana_btn.clicked.connect(self._open_analysis)
|
|
756
|
+
v.addWidget(ana_btn)
|
|
757
|
+
v.addSpacing(4)
|
|
758
|
+
# Exit button (smaller, red)
|
|
759
|
+
exit_btn = QPushButton("Exit")
|
|
760
|
+
exit_btn.setStyleSheet(
|
|
761
|
+
"background:#da3633;color:#fff;padding:8px;border-radius:5px;"
|
|
762
|
+
"font-size:10pt;font-weight:600"
|
|
763
|
+
)
|
|
764
|
+
exit_btn.clicked.connect(self._exit_app)
|
|
765
|
+
v.addWidget(exit_btn)
|
|
766
|
+
v.addStretch()
|
|
767
|
+
self.setCentralWidget(central)
|
|
768
|
+
# Software credit bottom-right (small grey)
|
|
769
|
+
self.credit = QLabel("Software developed by Soufiane SAIDI", self)
|
|
770
|
+
self.credit.setStyleSheet(
|
|
771
|
+
"color:#6e7681;font-size:8pt;background:transparent"
|
|
772
|
+
)
|
|
773
|
+
self.credit.adjustSize()
|
|
774
|
+
self._reposition_credit()
|
|
775
|
+
def _add_text_header(self, layout):
|
|
776
|
+
title = QLabel("CDI-ST")
|
|
777
|
+
title.setStyleSheet(
|
|
778
|
+
"color:#e6edf3;font-size:32pt;font-weight:700;"
|
|
779
|
+
"background:transparent;letter-spacing:2px"
|
|
780
|
+
)
|
|
781
|
+
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
782
|
+
layout.addWidget(title)
|
|
783
|
+
sub = QLabel("Coherent Diffraction Imaging Simulation Tools")
|
|
784
|
+
sub.setStyleSheet("color:#8b949e;font-size:10pt;background:transparent")
|
|
785
|
+
sub.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
786
|
+
layout.addWidget(sub)
|
|
787
|
+
def resizeEvent(self, e):
|
|
788
|
+
super().resizeEvent(e)
|
|
789
|
+
self._reposition_credit()
|
|
790
|
+
def _reposition_credit(self):
|
|
791
|
+
if hasattr(self, 'credit'):
|
|
792
|
+
margin = 8
|
|
793
|
+
self.credit.move(
|
|
794
|
+
self.width() - self.credit.width() - margin,
|
|
795
|
+
self.height() - self.credit.height() - margin
|
|
796
|
+
)
|
|
797
|
+
self.credit.raise_()
|
|
798
|
+
def _open_sim(self):
|
|
799
|
+
if self.sim_window is None or not self.sim_window.isVisible():
|
|
800
|
+
self.sim_window = MW_Sim(); self.sim_window.show()
|
|
801
|
+
else:
|
|
802
|
+
self.sim_window.raise_(); self.sim_window.activateWindow()
|
|
803
|
+
def _open_analysis(self):
|
|
804
|
+
if self.analysis_window is None or not self.analysis_window.isVisible():
|
|
805
|
+
self.analysis_window = MW_Analysis(); self.analysis_window.show()
|
|
806
|
+
else:
|
|
807
|
+
self.analysis_window.raise_(); self.analysis_window.activateWindow()
|
|
808
|
+
def _exit_app(self):
|
|
809
|
+
if self.sim_window is not None: self.sim_window.close()
|
|
810
|
+
if self.analysis_window is not None: self.analysis_window.close()
|
|
811
|
+
QApplication.quit()
|
|
812
|
+
|
|
813
|
+
MW=MW_Sim
|
|
814
|
+
|
|
504
815
|
def main():
|
|
505
816
|
app=QApplication(sys.argv);app.setStyle("Fusion");pal=QPalette()
|
|
506
817
|
for r,c in[(QPalette.ColorRole.Window,"#0d1117"),(QPalette.ColorRole.WindowText,"#e6edf3"),(QPalette.ColorRole.Base,"#0d1117"),(QPalette.ColorRole.AlternateBase,"#161b22"),(QPalette.ColorRole.Text,"#e6edf3"),(QPalette.ColorRole.Button,"#21262d"),(QPalette.ColorRole.ButtonText,"#e6edf3"),(QPalette.ColorRole.Highlight,"#1f6feb"),(QPalette.ColorRole.HighlightedText,"#ffffff")]:
|
|
507
818
|
pal.setColor(r,QColor(c))
|
|
508
|
-
app.setPalette(pal);app.setStyleSheet(QSS)
|
|
819
|
+
app.setPalette(pal);app.setStyleSheet(QSS)
|
|
820
|
+
sp=CDIStSplash();sp.show();app.processEvents()
|
|
821
|
+
for pct,msg in[(10,"Initializing Qt..."),(30,"Loading core modules..."),(55,"Loading NN modules..."),(80,"Preparing UI..."),(100,"Ready")]:
|
|
822
|
+
sp.set_progress(pct,msg);app.processEvents();time.sleep(0.18)
|
|
823
|
+
win=Launcher();win.show();sp.finish(win);sys.exit(app.exec())
|
|
509
824
|
if __name__=="__main__": main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|