Sammel-Commit für mehrere Wochen Arbeit seit dem letzten Commit-Stand (22.8.) — Details je Fund/Feature stehen datiert in PENDENZEN.md. - Stiftsatz-System (ArchiCAD-Stiftsatz-Vorbild): Bauteile/Ebenen/Element- Overrides wahlweise auf freie Farbe oder Stift+Stärke gekoppelt, eigene Palette-UI, 255-Stift-Standardpalette. - Wand-"+"-Kreuzung: vierte Wand an einem Knoten wurde nicht mitverschnitten (model/joins.ts). - 2D-Grundriss: Schnitt-vs-Ansicht-Entscheidung berücksichtigt jetzt wall.bottom/top-Override statt nur der rohen Wandhöhe. - Bulge/Bogensegmente in Polylinien (geometry/bulge.ts) inkl. Trim/Extend/ Offset/Fillet-Unterstützung. - Neue 2D-Befehle: Block/Blockdefinition, Leader, Polygon, Textpfad, Xline. - Kontext-Objekt-Kategorien (Ebenen-Zuordnung für importierte Gebäude/ Terrain-Meshes). - Element-Zwischenablage (Kopieren/Einfügen) für alle 3D-Elementarten. - swissBUILDINGS3D/DXF-Import-Fixes (Polyface-Mesh-Absturz, Georeferenzierung, anwählbare Kontext-Meshes im 3D-Viewport). - Dach-Schnittfugen im 3D-Live-Schnitt (render3d: roof_cut.rs neu). - Diverse kleinere Fixes/Ergänzungen in Grundriss-, Schnitt-, Ansichts- und 3D-Pipeline (siehe PENDENZEN.md für Einzelheiten). Verifiziert: tsc --noEmit sauber, vitest run 117/1206 grün, cargo test --package render3d 96/96 grün.
75 lines
2.8 KiB
TypeScript
75 lines
2.8 KiB
TypeScript
// `deriveSelection` für ein selektiertes Kontext-Objekt-Luftbild
|
|
// (`ContextImage`) muss `isImage`/`opacity`/`imageFilters` setzen, damit
|
|
// AttributesPanel.tsx seine (mit Drawing2D-Bildern geteilte) Deckkraft-Zeile
|
|
// + die neue Bildkorrektur-Sektion anzeigt (s. PENDENZEN.md „Bildschraffur:
|
|
// Bild-Filter"). `selectionInfo.ts` hatte bislang KEINE Tests — dieser Fokus-
|
|
// Test deckt nur den neuen Pfad ab, keine vollständige Modul-Abdeckung.
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
import { deriveSelection } from "./selectionInfo";
|
|
import type { Project } from "../model/types";
|
|
|
|
function projectWith(context: Project["context"]): Project {
|
|
return {
|
|
id: "t",
|
|
name: "T",
|
|
lineStyles: [],
|
|
hatches: [],
|
|
components: [],
|
|
wallTypes: [],
|
|
drawingLevels: [
|
|
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
|
|
],
|
|
layers: [],
|
|
walls: [],
|
|
doors: [],
|
|
openings: [],
|
|
ceilings: [],
|
|
stairs: [],
|
|
rooms: [],
|
|
drawings2d: [],
|
|
context,
|
|
} as unknown as Project;
|
|
}
|
|
|
|
describe("deriveSelection — Kontext-Objekt-Luftbild (ContextImage)", () => {
|
|
it("setzt isImage/opacity/imageFilters für ein Luftbild mit Filtern", () => {
|
|
const project = projectWith([
|
|
{
|
|
id: "IMG1",
|
|
type: "image",
|
|
name: "Luftbild",
|
|
src: "data:image/jpeg;base64,AAAA",
|
|
min: { x: 0, y: 0 },
|
|
max: { x: 10, y: 10 },
|
|
opacity: 0.8,
|
|
filters: { saturation: 0.5, brightness: 1.1, contrast: 1, grayscale: 0.2 },
|
|
},
|
|
]);
|
|
const sel = deriveSelection(project, [], null, null, null, null, null, null, null, null, "IMG1");
|
|
expect(sel?.kind).toBe("contextObject");
|
|
expect(sel?.isImage).toBe(true);
|
|
expect(sel?.opacity).toBe(0.8);
|
|
expect(sel?.imageFilters).toEqual({ saturation: 0.5, brightness: 1.1, contrast: 1, grayscale: 0.2 });
|
|
});
|
|
|
|
it("opacity fällt auf 1 zurück, wenn das Bild keine eigene Deckkraft trägt", () => {
|
|
const project = projectWith([
|
|
{ id: "IMG1", type: "image", name: "Luftbild", src: "x", min: { x: 0, y: 0 }, max: { x: 1, y: 1 } },
|
|
]);
|
|
const sel = deriveSelection(project, [], null, null, null, null, null, null, null, null, "IMG1");
|
|
expect(sel?.opacity).toBe(1);
|
|
expect(sel?.imageFilters).toBeUndefined();
|
|
});
|
|
|
|
it("isImage bleibt false/undefined für ein Nicht-Bild-Kontext-Objekt (z. B. importiertes Mesh)", () => {
|
|
const project = projectWith([
|
|
{ id: "M1", type: "importedMesh", name: "Haus", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2] },
|
|
]);
|
|
const sel = deriveSelection(project, [], null, null, null, null, null, null, null, null, "M1");
|
|
expect(sel?.isImage).toBeFalsy();
|
|
expect(sel?.opacity).toBeUndefined();
|
|
expect(sel?.imageFilters).toBeUndefined();
|
|
});
|
|
});
|