Archived
Attribute: Füllungs-Transparenz (nur Fläche), Schraffur-Auswahl ohne doppeltes 'Ohne', Platzierung nur bei sichtbarer Schraffur
This commit is contained in:
1 parent
73183cc307
commit
4b2e02b37a
8 files changed
+131
-4
No files matched your search
@@ -353,6 +353,8 @@ export const de = {
|
||||
"attr.color": "Farbe",
|
||||
"attr.weight": "Strichstärke (mm)",
|
||||
"attr.opacity": "Deckkraft",
|
||||
"attr.fillTransparency": "Füllungs-Transparenz",
|
||||
"attr.hatch.none": "Keine Schraffur",
|
||||
"attr.saturation": "Sättigung",
|
||||
"attr.brightness": "Helligkeit",
|
||||
"attr.contrast": "Kontrast",
|
||||
|
||||
@@ -351,6 +351,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"attr.color": "Color",
|
||||
"attr.weight": "Line weight (mm)",
|
||||
"attr.opacity": "Opacity",
|
||||
"attr.fillTransparency": "Fill transparency",
|
||||
"attr.hatch.none": "No hatch",
|
||||
"attr.saturation": "Saturation",
|
||||
"attr.brightness": "Brightness",
|
||||
"attr.contrast": "Contrast",
|
||||
|
||||
@@ -2068,6 +2068,12 @@ export interface Drawing2D {
|
||||
* Flächen). Der DXF-Export trägt sie nicht mit (bewusst, s. PENDENZEN.md).
|
||||
*/
|
||||
opacity?: number;
|
||||
/**
|
||||
* Transparenz NUR der Füllung/Schraffurfläche 0..1 (Default 1 = deckend) —
|
||||
* zusätzlich zu `opacity` (das Strich UND Füllung trifft). Der Umriss bleibt
|
||||
* dabei deckend (z. B. durchscheinende Fläche mit kräftiger Kontur).
|
||||
*/
|
||||
fillOpacity?: number;
|
||||
/**
|
||||
* Linienenden an OFFENEN Formen (Linie, offene Polylinie, Bogen, Spline,
|
||||
* Bezier) sowie an der Hinweislinie eines Textes. `start`/`end` beziehen
|
||||
|
||||
@@ -237,6 +237,9 @@ export function AttributesPanel() {
|
||||
if (next === "custom") host.onSetSelectionWeight(sel.weightMm);
|
||||
else host.onSetSelectionStrokeWeightSource(next);
|
||||
};
|
||||
// Die Ressource „Ohne" (Muster none) zeigt wie „Keine Schraffur" nichts an.
|
||||
const hatchPatternIsNone =
|
||||
project.hatches.find((h) => h.id === sel.effectiveHatchId)?.pattern === "none";
|
||||
const onHatchSourceChange = (next: UiSource) => {
|
||||
if (next === "custom") {
|
||||
host.onSetSelectionFill(sel.effectiveHatchId ?? project.hatches[0]?.id ?? null);
|
||||
@@ -659,22 +662,49 @@ export function AttributesPanel() {
|
||||
hatchUi,
|
||||
onHatchSourceChange,
|
||||
<Dropdown
|
||||
value={sel.effectiveHatchId ?? ""}
|
||||
value={hatchPatternIsNone ? "" : sel.effectiveHatchId ?? ""}
|
||||
disabled={!fillEditable}
|
||||
onChange={(v) => host.onSetSelectionFill(v || null)}
|
||||
options={[
|
||||
{ value: "", label: t("attr.none") },
|
||||
...project.hatches.map((h) => ({ value: h.id, label: h.name })),
|
||||
{ value: "", label: t("attr.hatch.none") },
|
||||
// Die Ressource „Ohne" (Muster none) wäre dasselbe wie „Keine Schraffur".
|
||||
...project.hatches
|
||||
.filter((h) => h.pattern !== "none")
|
||||
.map((h) => ({ value: h.id, label: h.name })),
|
||||
]}
|
||||
/>,
|
||||
)}
|
||||
|
||||
{/* Transparenz NUR der Füllung/Schraffurfläche (Umriss bleibt deckend);
|
||||
in Prozent: 0 % = deckend, 100 % = unsichtbar. */}
|
||||
{isDrawing && (
|
||||
<>
|
||||
<span className="attr-key">{t("attr.fillTransparency")}</span>
|
||||
<span className="attr-val">
|
||||
<input
|
||||
className="attr-num"
|
||||
style={{ width: 72 }}
|
||||
type="number"
|
||||
step={5}
|
||||
min={0}
|
||||
max={100}
|
||||
value={Math.round((1 - (drawing?.fillOpacity ?? 1)) * 100)}
|
||||
onChange={(e) => {
|
||||
const pct = Number(e.target.value);
|
||||
if (Number.isFinite(pct)) host.onSetSelectionFillOpacity(1 - Math.max(0, Math.min(100, pct)) / 100);
|
||||
}}
|
||||
/>
|
||||
<span className="attr-unit"> %</span>
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Schraffur-Platzierung an DIESEM Objekt (direkt unter der Schraffur-Auswahl): Winkel ersetzt den der
|
||||
Ressource, Massstab multipliziert sie, der Anker verschiebt das
|
||||
Musterraster (leer = Modellursprung, damit benachbarte Flächen
|
||||
dieselbe Phase teilen). Nur sinnvoll, wenn das Element überhaupt
|
||||
eine Schraffur zeigt. */}
|
||||
{isDrawing && sel.effectiveHatchId && (
|
||||
{isDrawing && sel.effectiveHatchId && !hatchPatternIsNone && (
|
||||
<>
|
||||
<span className="attr-key">{t("attr.hatch.angle")}</span>
|
||||
<span className="attr-val">
|
||||
|
||||
@@ -219,6 +219,11 @@ export interface PanelHostValue {
|
||||
* `type:"image"`), sonst No-op.
|
||||
*/
|
||||
onSetSelectionOpacity: (opacity: number) => void;
|
||||
/**
|
||||
* Setzt die Transparenz NUR der Füllung/Schraffur (`Drawing2D.fillOpacity`,
|
||||
* 0..1, 1 = deckend); der Umriss bleibt deckend. Wirkt nur auf 2D-Elemente.
|
||||
*/
|
||||
onSetSelectionFillOpacity: (opacity: number) => void;
|
||||
/**
|
||||
* Setzt eine oder mehrere Bildkorrektur-Werte (Sättigung/Helligkeit/
|
||||
* Kontrast/Graustufen) — wirkt NUR auf Kontext-Objekt-Bilder (`ContextImage`,
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// Füllungs-Transparenz (Drawing2D.fillOpacity): trifft NUR die Flächen-Primitive,
|
||||
// Umriss-Linien bleiben deckend; zusammen mit `opacity` multiplizieren sich beide.
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { generatePlan } from "./generatePlan";
|
||||
import type { Drawing2D, Project } from "../model/types";
|
||||
|
||||
const closed = (over: Partial<Drawing2D>): Drawing2D =>
|
||||
({
|
||||
id: "D",
|
||||
type: "drawing2d",
|
||||
levelId: "eg",
|
||||
categoryCode: "60",
|
||||
fillColor: "#336699",
|
||||
geom: { shape: "polyline", pts: [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 2 }, { x: 0, y: 2 }], closed: true },
|
||||
...over,
|
||||
}) as unknown as Drawing2D;
|
||||
|
||||
const project = (d: Drawing2D): Project =>
|
||||
({
|
||||
id: "t",
|
||||
name: "T",
|
||||
lineStyles: [],
|
||||
hatches: [{ id: "none", name: "Ohne", pattern: "none", scale: 1, angle: 0, color: "#111" }],
|
||||
components: [],
|
||||
wallTypes: [],
|
||||
drawingLevels: [
|
||||
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
|
||||
],
|
||||
layers: [{ code: "60", name: "Zeichnung", color: "#0a0a0a", lw: 0.25, visible: true, locked: false }],
|
||||
walls: [], doors: [], openings: [], ceilings: [], stairs: [], rooms: [],
|
||||
drawings2d: [d],
|
||||
context: [],
|
||||
}) as unknown as Project;
|
||||
|
||||
const prims = (d: Drawing2D) => generatePlan(project(d), "eg", new Set(["60"])).primitives;
|
||||
|
||||
describe("Füllungs-Transparenz", () => {
|
||||
it("macht nur das Polygon transparent, die Linien bleiben deckend", () => {
|
||||
const p = prims(closed({ fillOpacity: 0.4 }));
|
||||
const polys = p.filter((x) => x.kind === "polygon");
|
||||
const lines = p.filter((x) => x.kind === "line");
|
||||
expect(polys.length).toBeGreaterThan(0);
|
||||
expect(lines.length).toBeGreaterThan(0);
|
||||
expect(polys.every((x) => (x as { opacity?: number }).opacity === 0.4)).toBe(true);
|
||||
expect(lines.every((x) => (x as { opacity?: number }).opacity === undefined)).toBe(true);
|
||||
});
|
||||
|
||||
it("ohne fillOpacity bleibt alles unverändert", () => {
|
||||
const p = prims(closed({}));
|
||||
expect(p.filter((x) => x.kind === "polygon").every((x) => (x as { opacity?: number }).opacity === undefined)).toBe(true);
|
||||
});
|
||||
|
||||
it("multipliziert sich mit der Objekt-Deckkraft", () => {
|
||||
const p = prims(closed({ opacity: 0.5, fillOpacity: 0.5 }));
|
||||
const polys = p.filter((x) => x.kind === "polygon");
|
||||
expect(polys.every((x) => Math.abs(((x as { opacity?: number }).opacity ?? 1) - 0.25) < 1e-9)).toBe(true);
|
||||
const lines = p.filter((x) => x.kind === "line");
|
||||
expect(lines.every((x) => (x as { opacity?: number }).opacity === 0.5)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -208,6 +208,16 @@ export function addDrawing2D(
|
||||
: { ...p, opacity: (p.opacity ?? 1) * clamped };
|
||||
}
|
||||
}
|
||||
// Nur die FLÄCHE transparenter machen (Umriss/Linien bleiben deckend): die
|
||||
// Füllungs-Primitive sind die Polygone.
|
||||
const fo = d.fillOpacity;
|
||||
if (fo !== undefined && fo < 1) {
|
||||
const clampedFo = Math.max(0, fo);
|
||||
for (let i = start; i < out.length; i++) {
|
||||
const p = out[i];
|
||||
if (p.kind === "polygon") out[i] = { ...p, opacity: (p.opacity ?? 1) * clampedFo };
|
||||
}
|
||||
}
|
||||
if (cacheable) {
|
||||
drawingPrimCache.set(d, {
|
||||
lineStyles: project.lineStyles,
|
||||
|
||||
@@ -470,6 +470,17 @@ export function usePanelHostBase(opts: {
|
||||
if (selection?.kind === "drawing2d")
|
||||
setElementFillColor(selection.id, color);
|
||||
},
|
||||
onSetSelectionFillOpacity: (opacity) => {
|
||||
if (selection?.kind === "drawing2d")
|
||||
setProject((p) => ({
|
||||
...p,
|
||||
drawings2d: p.drawings2d.map((d) => {
|
||||
if (d.id !== selection.id) return d;
|
||||
const { fillOpacity: _old, ...rest } = d;
|
||||
return opacity >= 1 ? rest : { ...rest, fillOpacity: Math.max(0, opacity) };
|
||||
}),
|
||||
}));
|
||||
},
|
||||
onSetSelectionOpacity: (opacity) => {
|
||||
// Deckkraft eines 2D-Elements. Bei BILDERN bleibt es die Deckkraft der
|
||||
// Bildgeometrie (bestehendes Verhalten, eigenes Feld); bei allen
|
||||
|
||||
Reference in new issue
Block a user