-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlauncher.py
More file actions
125 lines (98 loc) · 4.26 KB
/
Copy pathlauncher.py
File metadata and controls
125 lines (98 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python3
## @file launcher.py
# @brief Fast-start entry point for LibuLux Studio.
#
# This launcher shows a splash screen IMMEDIATELY before any heavy
# imports (PyTorch, PyVista, etc.) to provide instant visual feedback.
import sys
import os
# Ensure project root is in path
project_root = os.path.dirname(os.path.abspath(__file__))
if project_root not in sys.path:
sys.path.insert(0, project_root)
def main():
"""Fast-start main with early splash screen."""
# =========================================================================
# PHASE 1: Minimal imports for splash (< 100ms)
# =========================================================================
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QSurfaceFormat
# Setup OpenGL before QApplication
QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts)
fmt = QSurfaceFormat()
fmt.setDepthBufferSize(24)
fmt.setStencilBufferSize(8)
fmt.setVersion(3, 2)
fmt.setProfile(QSurfaceFormat.OpenGLContextProfile.CompatibilityProfile)
QSurfaceFormat.setDefaultFormat(fmt)
# Create app
app = QApplication(sys.argv)
# =========================================================================
# PHASE 2: Show splash IMMEDIATELY (before heavy imports)
# =========================================================================
from app.gui.splash import LibuLuxSplash
splash = LibuLuxSplash()
splash.show()
splash.update_state(5, "Starting...")
app.processEvents()
# =========================================================================
# PHASE 3: Heavy imports with progress updates
# =========================================================================
# Logger (lightweight)
splash.update_state(10, "Initializing logging...")
app.processEvents()
from app.radiance.core.logger import logger, LogLevel
# Theme loading
splash.update_state(20, "Loading theme...")
app.processEvents()
from PyQt6.QtCore import QFile, QTextStream
from PyQt6.QtGui import QIcon
from app.runtime_helpers import get_theme_path, get_icon_path
theme_path = str(get_theme_path())
file = QFile(theme_path)
if file.open(QFile.OpenModeFlag.ReadOnly | QFile.OpenModeFlag.Text):
stream = QTextStream(file)
app.setStyleSheet(stream.readAll())
file.close()
# Pre-load heavy modules with progress feedback
# These imports are intentionally "unused" here - they pre-cache modules
# so main_window.py loads instantly (modules already in sys.modules)
splash.update_state(30, "Loading application state...")
app.processEvents()
from app.gui.state import AppState # noqa: F401
splash.update_state(40, "Loading 3D visualization engine...")
app.processEvents()
from app.gui.tabs.visualizer import VisualizerTab # noqa: F401
splash.update_state(55, "Loading vision AI models...")
app.processEvents()
from app.gui.tabs.vision import VisionTab # noqa: F401
splash.update_state(70, "Loading editor components...")
app.processEvents()
from app.gui.tabs.editor import EditorTab, LandingPage # noqa: F401
splash.update_state(80, "Loading wizards...")
app.processEvents()
from app.gui.wizards import ProjectCreationWizard # noqa: F401
# Import main window (now all deps are loaded)
splash.update_state(90, "Initializing main window...")
app.processEvents()
from app.gui.main_window import LibuLuxWindow
# =========================================================================
# PHASE 4: Create and show main window
# =========================================================================
splash.update_state(95, "Starting LibuLux Studio...")
app.processEvents()
window = LibuLuxWindow()
window.setWindowIcon(QIcon(str(get_icon_path())))
splash.update_state(100, "Ready!")
app.processEvents()
# Show window maximized and close splash
window.showMaximized()
splash.finish(window)
logger.log(LogLevel.INFO, "LibuLux Studio started successfully.")
# Start event loop
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
sys.exit(app.exec())
if __name__ == "__main__":
main()