| import React, { useRef, useEffect, useState, useCallback } from 'react'; |
| import { useLeva, useZoom, useGlyphRenderer, useConfigs, useKeyboardNavigation } from './hooks'; |
| import { ConfigDisplay, MapContainer, ErrorDisplay, LoadingDisplay, LiveUMAPPanel } from './components'; |
| import { useDebugUMAPStore } from './store'; |
| import './styles/index.css'; |
|
|
| |
| |
| |
| const DebugUMAP = () => { |
| console.log('DebugUMAP: Composant rendu'); |
| const svgRef = useRef(null); |
| const [svgReady, setSvgReady] = useState(false); |
| const [showLivePanel, setShowLivePanel] = useState(true); |
|
|
| const error = useDebugUMAPStore((state) => state.error); |
| const loading = useDebugUMAPStore((state) => state.loading); |
| const baseGlyphSize = useDebugUMAPStore((state) => state.baseGlyphSize); |
| const darkMode = useDebugUMAPStore((state) => state.darkMode); |
| const setLiveResult = useDebugUMAPStore((state) => state.setLiveResult); |
|
|
| |
| useConfigs(); |
|
|
| |
| useEffect(() => { |
| if (svgRef.current && !svgReady) { |
| console.log('DebugUMAP: SVG détecté, marqué comme prêt'); |
| setSvgReady(true); |
| } |
| }, [svgReady]); |
|
|
| |
| useGlyphRenderer({ svgRef, enabled: svgReady }); |
|
|
| |
| const { resetZoom } = useZoom(svgRef, baseGlyphSize, svgReady, darkMode); |
|
|
| |
| useLeva({ onResetZoom: resetZoom }); |
|
|
| |
| useKeyboardNavigation(); |
|
|
| |
| const handleLiveResult = useCallback((result) => { |
| console.log('✅ Résultat UMAP reçu:', result); |
| setLiveResult(result); |
| }, [setLiveResult]); |
|
|
| |
| if (loading) { |
| return <LoadingDisplay />; |
| } |
|
|
| if (error) { |
| return <ErrorDisplay error={error} />; |
| } |
|
|
| return ( |
| <div className={`debug-umap-container ${darkMode ? 'dark-mode' : ''}`}> |
| <ConfigDisplay /> |
| <MapContainer ref={svgRef} /> |
| |
| {/* Panneau de calcul UMAP en direct */} |
| {showLivePanel && ( |
| <LiveUMAPPanel onResult={handleLiveResult} /> |
| )} |
| |
| {/* Bouton pour afficher/masquer le panneau */} |
| <button |
| onClick={() => setShowLivePanel(!showLivePanel)} |
| style={{ |
| position: 'fixed', |
| bottom: '20px', |
| right: '20px', |
| padding: '12px 20px', |
| background: '#4CAF50', |
| color: 'white', |
| border: 'none', |
| borderRadius: '6px', |
| cursor: 'pointer', |
| fontSize: '14px', |
| fontWeight: '600', |
| zIndex: 10001, |
| boxShadow: '0 2px 8px rgba(0,0,0,0.2)' |
| }} |
| > |
| {showLivePanel ? '🙈 Hide Live UMAP' : '🧪 Show Live UMAP'} |
| </button> |
| </div> |
| ); |
| }; |
|
|
| export default DebugUMAP; |
|
|