import { useState } from 'react'
import Icon from './Icon'
import GeschossDialog from './GeschossDialog'
import GeschossSettingsDialog from './GeschossSettingsDialog'
function GeschossBadge({ name }) {
return {name}
}
function ZeichnungsebeneRow({ z, active, mode, onClick, onToggleVisible, onSettings }) {
// Eye-State auch fuer die aktive Zeichnungsebene anzeigen (User-Intention)
const eyeShown = mode !== 'active'
const isGeschoss = !!z.isGeschoss
return (
{z.name}
{isGeschoss && (
+{(z.okff ?? 0).toFixed(2)}
)}
{isGeschoss && }
{isGeschoss && z.hasClipping && (
)}
{eyeShown ? (
) : (
)}
)
}
const MODES = [
{ value: 'all', label: 'Alle anzeigen' },
{ value: 'active', label: 'Nur aktive' },
{ value: 'grey', label: 'Andere grau' },
{ value: 'grey_locked', label: 'Andere grau & gesperrt' },
]
export default function GeschossManager({
zeichnungsebenen, activeId, onActiveChange, onChange, recalcOkff,
mode, onModeChange,
}) {
const [dialogOpen, setDialogOpen] = useState(false)
const [settingsFor, setSettingsFor] = useState(null) // Geschoss-Objekt oder null
const sorted = [...zeichnungsebenen].reverse()
const gesamthoehe = zeichnungsebenen
.filter(z => z.isGeschoss)
.reduce((s, z) => s + (z.hoehe ?? 0), 0)
const addQuick = () => {
const newZ = {
id: `z_${Date.now()}`,
name: `Neu ${zeichnungsebenen.length + 1}`,
isGeschoss: false,
visible: true,
}
onChange([...zeichnungsebenen, newZ])
}
const toggleVisible = (id) => {
onChange(zeichnungsebenen.map(z => z.id === id ? { ...z, visible: !(z.visible !== false) } : z))
}
return (
<>
Sichtbarkeit
Gebäudehöhe
{gesamthoehe.toFixed(2)} m
{sorted.map(z => (
onActiveChange(z.id)}
onToggleVisible={() => toggleVisible(z.id)}
onSettings={() => setSettingsFor(z)}
/>
))}
{dialogOpen && (
{ onChange(updated); setDialogOpen(false) }}
onClose={() => setDialogOpen(false)}
/>
)}
{settingsFor && (
{
onChange(zeichnungsebenen.map(z => z.id === updated.id ? updated : z))
setSettingsFor(null)
}}
onClose={() => setSettingsFor(null)}
/>
)}
>
)
}