Merge [272] Varianten (mit Umbau-Panel zusammengeführt, Import selectionRenovationIds aus state/renovationHook)
This commit is contained in:
73 files changed
+2979
-100
No files matched your search
+13
-1
@@ -244,6 +244,15 @@ export default function App() {
|
||||
// localStorage + reconcile). Bei jeder Änderung zurückspeichern.
|
||||
const layout = useStore((s) => s.layout);
|
||||
const setLayout = useStore((s) => s.setLayout);
|
||||
// [272] Panel öffnen auf Wunsch eines Bausteins ohne Zugriff aufs Layout (Chip „Variante: …“ der Statusleiste).
|
||||
useEffect(() => {
|
||||
const on = (e: Event) => {
|
||||
const id = (e as CustomEvent<string>).detail;
|
||||
if (typeof id === "string" && id) setLayout((l) => revealPanel(l, id, { x: 96, y: 96, w: 520, h: 680 }));
|
||||
};
|
||||
window.addEventListener("dossier:reveal-panel", on);
|
||||
return () => window.removeEventListener("dossier:reveal-panel", on);
|
||||
}, [setLayout]);
|
||||
const modeFor = useStore((s) => s.modeFor);
|
||||
const setModeFor = useStore((s) => s.setModeFor);
|
||||
useEffect(() => {
|
||||
@@ -406,7 +415,7 @@ export default function App() {
|
||||
);
|
||||
const {
|
||||
projectFileInputRef, projectTemplateFileInputRef, openImportForFile, onSaveProject, onSaveProjectAs, onRestoreBackup,
|
||||
onNewProject, onNewProjectFromSample, onNewProjectFromComplexSample, onNewProjectFromWettbewerbSample, onNewProjectFromUmbauSample, onNewProjectFromTemplate,
|
||||
onNewProject, onNewProjectFromSample, onNewProjectFromComplexSample, onNewProjectFromWettbewerbSample, onNewProjectFromUmbauSample, onNewProjectFromVariantenSample, onNewProjectFromTemplate,
|
||||
onProjectTemplateFileChosen, onExportIfc, onExportObj, onExportStl, onOpenProject, onProjectFileChosen,
|
||||
} = files;
|
||||
|
||||
@@ -716,6 +725,7 @@ export default function App() {
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromVariantenSample,
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
@@ -734,6 +744,8 @@ export default function App() {
|
||||
onOpenSettings: () => openSettings(),
|
||||
onOpenBcf: () => setLayout((l) => revealPanel(l, "bcf")),
|
||||
onOpenHistory: () => setLayout((l) => revealPanel(l, "history")),
|
||||
// [272] Panel „Varianten“ (auch vom Chip der Statusleiste über `dossier:reveal-panel`).
|
||||
onOpenDesignOptions: () => setLayout((l) => revealPanel(l, "design-options", { x: 96, y: 96, w: 520, h: 680 })),
|
||||
applyScale,
|
||||
fitPlan,
|
||||
fitSelection,
|
||||
|
||||
+32
-2
@@ -21,6 +21,9 @@
|
||||
// --model-view <Name> wählt eine Modelldarstellung (eigene Stufe oder grob/mittel/fein) [173]
|
||||
// --renovation <Filter> Umbaufilter (bestand, abbruch, neubau, umbauplan, endzustand oder eigener)
|
||||
// mit --phase <Etappe> (Name oder id); auch für axo, model3d und kennzahlen [271]
|
||||
// --options "Dachform=B,Fassade=A" Variantenkombination (Satz=Variante, Namen oder ids;
|
||||
// fehlende Sätze: Hauptvariante); für alle Ausgaben (plan, section, elevation, axo,
|
||||
// model3d, kennzahlen, dxf, ifc, obj …); `designoptions` vergleicht alle Kombinationen [272]
|
||||
// --hide <Code|Name,…> blendet Klassen aus (z. B. --hide "Schatten,Auto-Bemassung") [180]
|
||||
// --snapshot <Name|id> übernimmt Geschoss, Massstab, Vorlage und Sichtbarkeit eines Ausschnitts [207]
|
||||
// dossier-cli <projekt.obp> axo [--view southeast|southwest|northeast|northwest|iso|…] [--projection iso|military|military30]
|
||||
@@ -145,6 +148,12 @@ import {
|
||||
viewportLevelPlan,
|
||||
generateAxoPlan,
|
||||
renovationFilterList,
|
||||
parseCombination,
|
||||
designOptionSets,
|
||||
projectWithCombination,
|
||||
compareDesignOptions,
|
||||
compareDesignOptionsCsv,
|
||||
buildVariantenSampleProject,
|
||||
buildUmbauSampleProject,
|
||||
type AxoOptions,
|
||||
planToRenderScene,
|
||||
@@ -258,6 +267,7 @@ function loadProject(path: string, args: Args): Project {
|
||||
if (path === ":musterhaus-komplex") return buildComplexSampleProject();
|
||||
if (path === ":wettbewerb") return buildWettbewerbSampleProject();
|
||||
if (path === ":umbau") return buildUmbauSampleProject();
|
||||
if (path === ":varianten") return buildVariantenSampleProject();
|
||||
if (path === ":gross") return buildBigSampleProject({ floors: Number(args.flags.get("floors") ?? 8), apartments: Number(args.flags.get("apartments") ?? 15) });
|
||||
let text: string;
|
||||
try {
|
||||
@@ -631,7 +641,7 @@ function importParsedDrawing(base: Project, parsed: ReturnType<typeof parseDxf>,
|
||||
/** Liest Eingabe nach Endung in ein Projekt: obp direkt, dxf/dwg als 2D-Zeichnung + Meshes, ifc als Kontext-Meshes (`--elements`: Bauteile). */
|
||||
async function importAny(path: string, args: Args): Promise<Project> {
|
||||
const ext = extOf(path);
|
||||
if (ext === "obp" || ext === "json" || path === ":beispiel" || path === ":musterhaus-komplex" || path === ":wettbewerb" || path === ":umbau") return loadProject(path, args);
|
||||
if (ext === "obp" || ext === "json" || path === ":beispiel" || path === ":musterhaus-komplex" || path === ":wettbewerb" || path === ":umbau" || path === ":varianten") return loadProject(path, args);
|
||||
let bytes: Uint8Array;
|
||||
try {
|
||||
bytes = new Uint8Array(readFileSync(path));
|
||||
@@ -1049,7 +1059,7 @@ async function importSyntheticContext(base: Project, args: Args, rows: Array<[st
|
||||
}
|
||||
|
||||
/** Befehle, die eine Ausgabe-Datei erzeugen (für die Anonymitäts-Prüfung einer Wettbewerbs-Abgabe, [208]). */
|
||||
const EXPORT_COMMANDS = new Set(["plan", "section", "elevation", "axo", "dxf", "dwg", "ifc", "obj", "stl", "glb", "gltf", "step", "stp", "schedule", "kennzahlen", "raumprogramm", "render", "blend", "model3d"]);
|
||||
const EXPORT_COMMANDS = new Set(["plan", "section", "elevation", "axo", "dxf", "dwg", "ifc", "obj", "stl", "glb", "gltf", "step", "stp", "schedule", "kennzahlen", "designoptions", "raumprogramm", "render", "blend", "model3d"]);
|
||||
|
||||
/**
|
||||
* [208] Anonyme Abgabe: vor einem Export den Freitext prüfen. Treffer stehen auf stderr; ohne `--ignore-anonymity`
|
||||
@@ -1078,6 +1088,17 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
const scale = Number(args.flags.get("scale") ?? 100);
|
||||
const blocked = anonymityGate(project, file, command, args);
|
||||
if (blocked !== 0) return blocked;
|
||||
// [272] `--options "Dachform=B,Fassade=A"`: diese Variantenkombination gilt für alle Ausgaben (wird zur Hauptkombination).
|
||||
const optSpec = args.flags.get("options");
|
||||
if (optSpec && optSpec !== "true") {
|
||||
const combo = parseCombination(project, optSpec);
|
||||
const asked = optSpec.split(/[,;]/).filter((s) => s.trim()).length;
|
||||
if (Object.keys(combo).length !== asked) {
|
||||
const known = designOptionSets(project).map((s) => `${s.name}=${s.options.map((o) => o.name).join("|")}`).join(", ");
|
||||
fail(`Variante nicht gefunden: ${optSpec} (vorhanden: ${known || "keine Variantensätze"})`);
|
||||
}
|
||||
project = projectWithCombination(project, combo);
|
||||
}
|
||||
// [257] `bench --context`: vorher synthetische Kontext-Importe (Kataster, Höhenlinien, Gebäudenetze) ins Projekt laden.
|
||||
const contextRows: Array<[string, number]> = [];
|
||||
if (command === "bench" && args.flags.has("context")) {
|
||||
@@ -1341,6 +1362,15 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
out(args, JSON.stringify({ kennzahlen: k, raumprogramm: prog, baurecht, erdarbeiten }, null, 2), `${exportProjectName(project) || "projekt"}-kennzahlen.json`);
|
||||
return 0;
|
||||
}
|
||||
case "designoptions": {
|
||||
// [272] Varianten-Vergleich: Kennzahlen und Kosten je Kombination; --format json|csv, --renovation wie kennzahlen.
|
||||
const ren = renovationFlags(project, args)?.renovation ?? "";
|
||||
const stem = `${exportProjectName(project) || "projekt"}-varianten`;
|
||||
if ((args.flags.get("format") ?? "json") === "csv") {
|
||||
out(args, compareDesignOptionsCsv(project, ["Kombination", "GF m2", "HNF m2", "GV m3", "Fussabdruck m2", "AZ", "UEZ", "Kosten CHF"], ren), `${stem}.csv`);
|
||||
} else out(args, JSON.stringify(compareDesignOptions(project, ren), null, 2), `${stem}.json`);
|
||||
return 0;
|
||||
}
|
||||
case "raumprogramm": {
|
||||
// Raumprogramm: [--import tabelle.xlsx|ods|csv [--sheet Name|Nr] [--mode replace|append]] [--tolerance 5]
|
||||
// [--generate] [--format json|csv|svg|pdf] [--out datei] [--save projekt.obp]
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// [272] Befehle „Variante zuweisen …“ und „In Variante kopieren …“: Ziel als Satz=Variante, Name, Nummer oder H, ein Schritt.
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { designOptionCommand, designOptionCopyCommand, designOptionSelectionIds, parseDesignOptionTarget } from "./designOption";
|
||||
import type { CommandContext } from "../types";
|
||||
import { sampleProject } from "../../model/sampleProject";
|
||||
import { buildVariantenSampleProject } from "../../model/sampleProjectVarianten";
|
||||
import { applyOps } from "../../core/ops";
|
||||
import { withDocument } from "../../core/document";
|
||||
import type { Project } from "../../model/types";
|
||||
|
||||
function ctx(project: Project, sel: Partial<CommandContext["selection"]>): CommandContext {
|
||||
return {
|
||||
project,
|
||||
level: project.drawingLevels[0],
|
||||
defaultCategoryCode: "20",
|
||||
activeLineStyleId: "solid",
|
||||
activeWallTypeId: "aw",
|
||||
lastPoint: null,
|
||||
selection: { wallIds: [], drawingId: null, ...sel },
|
||||
};
|
||||
}
|
||||
|
||||
describe("[272] variante", () => {
|
||||
it("ohne Satz oder ohne Auswahl: Hinweis statt Start", () => {
|
||||
expect(designOptionCommand.precondition?.(ctx(sampleProject, { wallIds: ["W1"] }))).toBe("cmd.designOption.needsSet");
|
||||
const p = buildVariantenSampleProject();
|
||||
expect(designOptionCommand.precondition?.(ctx(p, {}))).toBe("cmd.designOption.needsSelection");
|
||||
expect(designOptionCommand.precondition?.(ctx(p, { wallIds: ["W1"] }))).toBeNull();
|
||||
});
|
||||
|
||||
it("Ziel lesen: Satz=Variante, Name, Nummer, H; Unbekanntes/Mehrdeutiges = undefined", () => {
|
||||
const p = buildVariantenSampleProject();
|
||||
expect(parseDesignOptionTarget(p, "Dachform=B Satteldach")).toEqual({ set: "dachform", option: "b" });
|
||||
expect(parseDesignOptionTarget(p, "b bandfenster")).toEqual({ set: "fassade", option: "b" });
|
||||
expect(parseDesignOptionTarget(p, "2")).toEqual({ set: "dachform", option: "b" });
|
||||
expect(parseDesignOptionTarget(p, "H")).toBeNull();
|
||||
expect(parseDesignOptionTarget(p, "a")).toBeUndefined();
|
||||
expect(parseDesignOptionTarget(p, "99")).toBeUndefined();
|
||||
expect(parseDesignOptionTarget(p, "")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("weist alle gewählten Elemente samt 2D in einem Schritt zu; kopiert in eine Variante", () => {
|
||||
const p = buildVariantenSampleProject();
|
||||
const c = ctx(p, { wallIds: ["W1"], openingIds: ["O1"], drawingIds: [] });
|
||||
expect(designOptionSelectionIds(c.selection)).toEqual(["W1", "O1"]);
|
||||
const [, res] = designOptionCommand.onInput(designOptionCommand.init(), { kind: "text", text: "Fassade=B Bandfenster" }, c);
|
||||
expect(res.done).toBe(true);
|
||||
const q = withDocument(p, () => applyOps(p, res.commit!.toOps(p)));
|
||||
expect(q.walls.find((w) => w.id === "W1")?.designOption).toEqual({ set: "fassade", option: "b" });
|
||||
expect(q.openings?.find((o) => o.id === "O1")?.designOption).toEqual({ set: "fassade", option: "b" });
|
||||
// Unbekanntes Ziel: bleibt im Befehl.
|
||||
const [, r2] = designOptionCommand.onInput(designOptionCommand.init(), { kind: "text", text: "quatsch" }, c);
|
||||
expect(r2.done).toBeFalsy();
|
||||
const [, r3] = designOptionCopyCommand.onInput(designOptionCopyCommand.init(), { kind: "option", id: "main" }, c);
|
||||
expect(r3.done).toBe(true);
|
||||
expect(r3.commit).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
// [272] Befehle „Variante zuweisen …“ (`designOption`, Kürzel `variante`) und „In Variante kopieren …“
|
||||
// (`designOptionCopy`, Kürzel `variantekopieren`): die gewählten Elemente gehören danach der Variante (bzw. Kopien davon) —
|
||||
// in einem Undo-Schritt. Ziel getippt als „Dachform=B“, als Variantenname („B Satteldach“, eindeutig über alle Sätze) oder
|
||||
// als Nummer der Liste „Satz: Variante“ (1, 2, …); Option H = Hauptmodell. Ohne Auswahl oder ohne Variantensatz kein Start.
|
||||
|
||||
import { assignDesignOptionOps, copyToDesignOptionOps, designOptionSets, designOptionTargets, opsMutation, parseCombination } from "../../core";
|
||||
import type { Project } from "../../model/types";
|
||||
import type { Command, CommandContext, CommandResult, CommandSelection, CommandState } from "../types";
|
||||
import { renovationSelectionIds } from "./renovation";
|
||||
|
||||
/** Gewählte Elemente, die einer Variante angehören können (Bauteile, Räume, 2D-Zeichnungen samt Bibliotheksobjekten). */
|
||||
export function designOptionSelectionIds(sel: CommandSelection): string[] {
|
||||
const drawings = sel.drawingIds ?? (sel.drawingId ? [sel.drawingId] : []);
|
||||
return [...renovationSelectionIds(sel), ...drawings];
|
||||
}
|
||||
|
||||
/** Ziel aus getipptem Text: `null` = Hauptmodell, `undefined` = unbekannt. */
|
||||
export function parseDesignOptionTarget(project: Project, text: string): { set: string; option: string } | null | undefined {
|
||||
const q = text.trim().toLowerCase();
|
||||
if (!q) return undefined;
|
||||
if (q === "h" || q === "haupt" || q === "hauptmodell" || q === "main") return null;
|
||||
const targets = designOptionTargets(project);
|
||||
const n = Number(q);
|
||||
if (Number.isInteger(n) && n >= 1 && n <= targets.length) {
|
||||
const [set, option] = targets[n - 1].key.split("/");
|
||||
return { set, option };
|
||||
}
|
||||
if (q.includes("=")) {
|
||||
const c = parseCombination(project, q);
|
||||
const [set, option] = Object.entries(c)[0] ?? [];
|
||||
return set ? { set, option } : undefined;
|
||||
}
|
||||
// Variantenname oder „Satz: Variante“, eindeutig über alle Sätze.
|
||||
const hits: { set: string; option: string }[] = [];
|
||||
for (const s of designOptionSets(project)) {
|
||||
for (const o of s.options) {
|
||||
const name = o.name.trim().toLowerCase();
|
||||
if (name === q || o.id.toLowerCase() === q || `${s.name}: ${o.name}`.toLowerCase() === q) hits.push({ set: s.id, option: o.id });
|
||||
}
|
||||
}
|
||||
return hits.length === 1 ? hits[0] : undefined;
|
||||
}
|
||||
|
||||
const idle = (): CommandState => ({ phase: "pick", lastPoint: null });
|
||||
const done = (commit?: CommandResult["commit"]): [CommandState, CommandResult] => [idle(), { draft: null, done: true, ...(commit ? { commit } : {}) }];
|
||||
|
||||
function makeCommand(copy: boolean): Command {
|
||||
const key = copy ? "designOptionCopy" : "designOption";
|
||||
return {
|
||||
name: key,
|
||||
labelKey: copy ? "cmd.designOptionCopy.label" : "cmd.designOption.label",
|
||||
prompt: () => (copy ? "cmd.designOptionCopy.prompt" : "cmd.designOption.prompt"),
|
||||
accepts: () => ["option", "text"],
|
||||
options: () => [{ id: "main", labelKey: "designOption.main", key: "H" }],
|
||||
precondition: (ctx: CommandContext) => {
|
||||
if (!designOptionSets(ctx.project).length) return "cmd.designOption.needsSet";
|
||||
return designOptionSelectionIds(ctx.selection).length === 0 ? "cmd.designOption.needsSelection" : null;
|
||||
},
|
||||
init: idle,
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const text = input.kind === "option" ? (input.id === "main" ? "h" : input.id) : input.kind === "text" ? input.text : "";
|
||||
const target = parseDesignOptionTarget(ctx.project, text);
|
||||
if (target === undefined) return [state, { draft: null }];
|
||||
const ids = designOptionSelectionIds(ctx.selection);
|
||||
if (ids.length === 0) return done();
|
||||
return done(opsMutation((p) => (copy ? copyToDesignOptionOps(p, ids, target) : assignDesignOptionOps(p, ids, target))));
|
||||
},
|
||||
onMove: (state): [CommandState, CommandResult] => [state, { draft: null }],
|
||||
onConfirm: (): [CommandState, CommandResult] => done(),
|
||||
onCancel: (): [CommandState, CommandResult] => done(),
|
||||
};
|
||||
}
|
||||
|
||||
export const designOptionCommand: Command = makeCommand(false);
|
||||
export const designOptionCopyCommand: Command = makeCommand(true);
|
||||
@@ -48,6 +48,7 @@ import { mirrorCommand, moveCommand, rotateCommand } from "./cmds/transform";
|
||||
import { scaleCommand } from "./cmds/scale";
|
||||
import { explodeCommand } from "./cmds/explode";
|
||||
import { renovationCommand } from "./cmds/renovation";
|
||||
import { designOptionCommand, designOptionCopyCommand } from "./cmds/designOption";
|
||||
import { dimdetachCommand } from "./cmds/dimdetach";
|
||||
import { autodimCommand } from "./cmds/autodim";
|
||||
import { gridCommand } from "./cmds/grid";
|
||||
@@ -134,6 +135,8 @@ export const COMMANDS: Record<string, Command> = {
|
||||
scale: scaleCommand,
|
||||
explode: explodeCommand,
|
||||
renovation: renovationCommand,
|
||||
designOption: designOptionCommand,
|
||||
designOptionCopy: designOptionCopyCommand,
|
||||
dimdetach: dimdetachCommand,
|
||||
autodim: autodimCommand,
|
||||
grid: gridCommand,
|
||||
@@ -286,6 +289,8 @@ export const ALIASES: Record<string, string> = {
|
||||
x: "explode",
|
||||
aufloesen: "explode",
|
||||
umbau: "renovation",
|
||||
variante: "designOption",
|
||||
variantekopieren: "designOptionCopy",
|
||||
bml: "dimdetach",
|
||||
bemassungloesen: "dimdetach",
|
||||
ab: "autodim",
|
||||
|
||||
@@ -172,7 +172,9 @@ export type LoadFileResult =
|
||||
| { ok: false; error: string };
|
||||
|
||||
/** Wurzel-Abfragen des Kerns (`queries.rs::run_root`). */
|
||||
export type RootQueryName = "penRebakeOps" | "penDeleteOps" | "penSeedOps" | "standardsMergeOps" | "standardsUpdatePlan" | "standardsUpdateOps" | "folderPdfPages" | "layoutTitleBlock" | "translatePatch" | "translateOps" | "selectionFilterPatch";
|
||||
export type RootQueryName = "penRebakeOps" | "penDeleteOps" | "penSeedOps" | "standardsMergeOps" | "standardsUpdatePlan" | "standardsUpdateOps" | "folderPdfPages" | "layoutTitleBlock" | "translatePatch" | "translateOps" | "selectionFilterPatch"
|
||||
// [272] Varianten (`design_options.rs`)
|
||||
| "designOptionAcceptOps" | "designOptionDeleteOps" | "designOptionAssignOps" | "designOptionCopyOps";
|
||||
|
||||
/** Abfragen des Kerns (`queries.rs`). */
|
||||
export type QueryName =
|
||||
@@ -182,6 +184,8 @@ export type QueryName =
|
||||
| "kennzahlen"
|
||||
| "areaTable"
|
||||
| "renovationFilters"
|
||||
| "designOptionInfo"
|
||||
| "designOptionCompare"
|
||||
| "costEstimate"
|
||||
| "costDefaults"
|
||||
| "programCompare"
|
||||
|
||||
@@ -128,3 +128,12 @@ export {
|
||||
} from "../model/renovation";
|
||||
export type { RenovationFilterEntry, RenovationCollection } from "../model/renovation";
|
||||
export { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
|
||||
// [272] Varianten: Sätze, Kombinationen, Zuweisen/Kopieren/Übernehmen (Regeln im Kern `design_options.rs`, Sichtbarkeit `renovation.rs`)
|
||||
export {
|
||||
DESIGN_OPTION_COLLECTIONS, designOptionSets, primaryOption, resolveCombination, levelCombination, combinationLabel, combinationSuffix, combinationSpec,
|
||||
parseCombination, showsInCombination, designOptionLabel, designOptionSelection, designOptionIds, commonDesignOption, parseTarget, designOptionTargets,
|
||||
assignDesignOptionOps, copyToDesignOptionOps, acceptDesignOptionOps, deleteDesignOptionOps, nextOptionName, addDesignOptionSetOps, addDesignOptionOps,
|
||||
renameDesignOptionSetOps, renameDesignOptionOps, setPrimaryOptionOps, setLevelCombinationOps, compareDesignOptions, compareDesignOptionsCsv, projectWithCombination,
|
||||
} from "../model/designOptions";
|
||||
export type { Combination, DesignOptionCompareRow, DesignOptionCollection } from "../model/designOptions";
|
||||
export { buildVariantenSampleProject } from "../model/sampleProjectVarianten";
|
||||
+10
-5
@@ -17,14 +17,14 @@ import { t } from "../i18n/translate";
|
||||
import { legendPlan, legendPrintSvg } from "./legendSvg";
|
||||
import { categoryLayerGroups, enablePdfLayers, type PdfLayers } from "./pdfLayers";
|
||||
import { generatePlan, type Plan } from "../plan/generatePlan";
|
||||
import { snapshotMono, snapshotOverrideRuleIds, snapshotTemplate, viewportLevelPlan, viewportSnapshotPlan } from "../plan/viewportPlan";
|
||||
import { snapshotMono, snapshotOverrideRuleIds, snapshotTemplate, viewportDesignOptions, viewportLevelPlan, viewportSnapshotPlan } from "../plan/viewportPlan";
|
||||
import { isDoc3dSnapshot } from "../plan/toAxo";
|
||||
import { planToPrintSvg } from "./planToPrintSvg";
|
||||
import { drawTablesPdf, PDF_TABLE_FONT, sheetTables } from "./sheetTable";
|
||||
import { applyPdfInfo, finishPdfBytes } from "./pdfInfo";
|
||||
import { ensurePdfFonts, PDF_DEFAULT_FONT, prepareSvgFonts, setPdfFont } from "./pdfFonts";
|
||||
import { imageGeometry } from "../model/layoutImages";
|
||||
import { posterHeaderItems, viewportScaleLabel } from "../model/posterTemplates";
|
||||
import { posterHeaderItems, viewportScaleLabel, viewportVariantLabel } from "../model/posterTemplates";
|
||||
import { collectVisibleCodes } from "../model/types";
|
||||
import {
|
||||
effectiveSheetSizeMm,
|
||||
@@ -181,11 +181,12 @@ function drawImagesPdf(doc: jsPDF, layout: Layout): void {
|
||||
}
|
||||
|
||||
/** Massstabsangabe unter jedem Viewport ([208], Master `viewportScaleLabels`). */
|
||||
function drawScaleLabelsPdf(doc: jsPDF, project: Project, layout: Layout, sheet: { w: number; h: number }, scaleOverride?: number): void {
|
||||
function drawScaleLabelsPdf(doc: jsPDF, project: Project, layout: Layout, sheet: { w: number; h: number }, scaleOverride?: number, withScale = true): void {
|
||||
doc.setTextColor(17, 17, 17);
|
||||
setPdfFont(doc, PDF_DEFAULT_FONT);
|
||||
for (const vp of layout.viewports) {
|
||||
const l = viewportScaleLabel(project, vp, sheet, scaleOverride);
|
||||
// [272] Ohne Massstabsangaben nur der Titelzusatz der Varianten.
|
||||
const l = withScale ? viewportScaleLabel(project, vp, sheet, scaleOverride) : viewportVariantLabel(project, vp, sheet);
|
||||
if (!l) continue;
|
||||
doc.setFontSize(l.sizeMm * MM_TO_PT);
|
||||
doc.text(l.text, l.x, l.y);
|
||||
@@ -232,7 +233,9 @@ async function renderPage(
|
||||
const ruleIds = snapshotOverrideRuleIds(project, snap);
|
||||
const template = snapshotTemplate(project, snap);
|
||||
// [266] 3D-Ausschnitt: 3D-Dokument aus dem Kern (`viewportSnapshotPlan`).
|
||||
const planOf = (visible: Set<string>) => (isDoc3dSnapshot(snap) ? viewportSnapshotPlan(project, snap, visible, scaleN, true) : viewportLevelPlan(project, snap.activeLevelId, visible, snap.detail, scaleN, true, snapshotMono(project, snap), ruleIds, template, snap.modelViewOptionId));
|
||||
// [272] Variantenkombination des Ausschnitts/Viewports.
|
||||
const dopts = viewportDesignOptions(snap, vp);
|
||||
const planOf = (visible: Set<string>) => (isDoc3dSnapshot(snap) ? viewportSnapshotPlan(project, snap, visible, scaleN, true, vp) : viewportLevelPlan(project, snap.activeLevelId, visible, snap.detail, scaleN, true, snapshotMono(project, snap), ruleIds, template, snap.modelViewOptionId, dopts));
|
||||
// [208] Eigene Bildmitte (Plakat): Ausschnitt um die Mitte; was darüber hinausgeht, schneidet der Rahmen ab.
|
||||
const centered = viewportCenterBounds(vp, scaleN);
|
||||
const draw = async (plan: Plan, transparent: boolean, bounds?: Plan["bounds"]) => {
|
||||
@@ -278,6 +281,8 @@ async function renderPage(
|
||||
// Massstab je Viewport ([208]).
|
||||
if (master?.viewportScaleLabels) {
|
||||
await inLayer(ctx, t("pdfLayers.frame"), () => drawScaleLabelsPdf(doc, project, layout, { w: widthMm, h: heightMm }, ctx.scaleOverride));
|
||||
} else if (project.designOptionSets?.length) {
|
||||
await inLayer(ctx, t("pdfLayers.frame"), () => drawScaleLabelsPdf(doc, project, layout, { w: widthMm, h: heightMm }, ctx.scaleOverride, false));
|
||||
}
|
||||
|
||||
// Legenden ([82]): live aus den Viewports (oder Handauswahl), Muster vom Kern-Schraffurgenerator.
|
||||
|
||||
@@ -4746,6 +4746,51 @@ export const de = {
|
||||
"cmd.renovation.label": "Umbau-Status setzen …",
|
||||
"cmd.renovation.prompt": "Umbau-Status der Auswahl",
|
||||
"cmd.renovation.needsSelection": "Zuerst Bauteile wählen, dann den Umbau-Status setzen.",
|
||||
// [272] Varianten (Archicad „Design Options“)
|
||||
"file.newFromVariantenSample": "Neu aus Vorlage: Beispiel Varianten",
|
||||
"menu.native.newFromVariantenSample": "Beispiel Varianten",
|
||||
"designOption.label": "Variante",
|
||||
"designOption.title": "Varianten",
|
||||
"designOption.main": "Hauptmodell",
|
||||
"designOption.fromSnapshot": "wie Ausschnitt",
|
||||
"designOption.short": "Variante: {combination}",
|
||||
"designOption.hint": "Kombination dieser Ansicht: {combination} · Neue Elemente: {draw}",
|
||||
"designOption.primaryCombination": "Hauptvarianten",
|
||||
"designOption.viewCombination": "Kombination dieser Ansicht",
|
||||
"designOption.drawIn": "Neue Elemente zeichnen in",
|
||||
"designOption.set": "Variantensatz",
|
||||
"designOption.option": "Variante",
|
||||
"designOption.primary": "Hauptvariante",
|
||||
"designOption.count": "Elemente in dieser Variante",
|
||||
"designOption.sets.title": "Variantensätze",
|
||||
"designOption.sets.hint": "Ein Satz (z. B. „Dachform“) hat Varianten (A, B, …); jedes Element gehört zum Hauptmodell oder zu genau einer Variante. Jede Ansicht, jeder Ausschnitt und jeder Viewport zeigt je Satz eine Variante (Vorgabe: die Hauptvariante).",
|
||||
"designOption.sets.empty": "Keine Variantensätze: alle Elemente gehören zum Hauptmodell.",
|
||||
"designOption.set.add": "Satz hinzufügen",
|
||||
"designOption.set.new": "Name des neuen Satzes",
|
||||
"designOption.set.placeholder": "z. B. Dachform",
|
||||
"designOption.set.defaultName": "Satz {n}",
|
||||
"designOption.set.delete": "Satz samt seinen Elementen löschen",
|
||||
"designOption.option.add": "Variante hinzufügen",
|
||||
"designOption.option.delete": "Variante samt ihren Elementen löschen",
|
||||
"designOption.accept": "Übernehmen",
|
||||
"designOption.accept.hint": "Variante übernehmen: ihre Elemente gehen ins Hauptmodell, die übrigen Varianten des Satzes werden gelöscht (ein Undo-Schritt).",
|
||||
"designOption.compare.title": "Varianten-Vergleich",
|
||||
"designOption.compare.combination": "Kombination",
|
||||
"designOption.compare.footprint": "Fussabdruck m²",
|
||||
"designOption.compare.cost": "Kosten CHF",
|
||||
"designOption.compare.csv": "Vergleich als CSV",
|
||||
"designOption.selection": "Auswahl ({n} Elemente)",
|
||||
"designOption.assign": "Zuweisen",
|
||||
"designOption.copy": "Kopieren in …",
|
||||
"designOption.compare.show": "Vergleich öffnen",
|
||||
"designOption.compare.hide": "Vergleich schliessen",
|
||||
"resources.tab.designOptions": "Varianten",
|
||||
"cmd.designOption.label": "Variante zuweisen …",
|
||||
"cmd.designOption.prompt": "Ziel-Variante (z. B. Dachform=B, Variantenname oder Nummer; H = Hauptmodell)",
|
||||
"cmd.designOptionCopy.label": "In Variante kopieren …",
|
||||
"cmd.designOptionCopy.prompt": "Kopieren in Variante (z. B. Dachform=B, Variantenname oder Nummer; H = Hauptmodell)",
|
||||
"cmd.designOption.needsSelection": "Zuerst Elemente wählen, dann die Variante wählen.",
|
||||
"cmd.designOption.needsSet": "Das Projekt hat noch keinen Variantensatz (Ressourcen › Varianten).",
|
||||
} as const;
|
||||
|
||||
export type TranslationKey = keyof typeof de;
|
||||
@@ -4732,4 +4732,49 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.renovation.label": "Set renovation status …",
|
||||
"cmd.renovation.prompt": "Renovation status of the selection",
|
||||
"cmd.renovation.needsSelection": "Select elements first, then set the renovation status.",
|
||||
// [272] Design options
|
||||
"file.newFromVariantenSample": "New from template: design options example",
|
||||
"menu.native.newFromVariantenSample": "Design options example",
|
||||
"designOption.label": "Design option",
|
||||
"designOption.title": "Design options",
|
||||
"designOption.main": "Main model",
|
||||
"designOption.fromSnapshot": "as view",
|
||||
"designOption.short": "Option: {combination}",
|
||||
"designOption.hint": "Combination of this view: {combination} · New elements: {draw}",
|
||||
"designOption.primaryCombination": "primary options",
|
||||
"designOption.viewCombination": "Combination of this view",
|
||||
"designOption.drawIn": "Draw new elements in",
|
||||
"designOption.set": "Option set",
|
||||
"designOption.option": "Option",
|
||||
"designOption.primary": "Primary option",
|
||||
"designOption.count": "Elements in this option",
|
||||
"designOption.sets.title": "Option sets",
|
||||
"designOption.sets.hint": "A set (e.g. “Roof shape”) has options (A, B, …); every element belongs to the main model or to exactly one option. Every view, saved view and viewport shows one option per set (default: the primary option).",
|
||||
"designOption.sets.empty": "No option sets: all elements belong to the main model.",
|
||||
"designOption.set.add": "Add set",
|
||||
"designOption.set.new": "Name of the new set",
|
||||
"designOption.set.placeholder": "e.g. Roof shape",
|
||||
"designOption.set.defaultName": "Set {n}",
|
||||
"designOption.set.delete": "Delete set with its elements",
|
||||
"designOption.option.add": "Add option",
|
||||
"designOption.option.delete": "Delete option with its elements",
|
||||
"designOption.accept": "Accept",
|
||||
"designOption.accept.hint": "Accept option: its elements move to the main model, the other options of the set are deleted (one undo step).",
|
||||
"designOption.compare.title": "Option comparison",
|
||||
"designOption.compare.combination": "Combination",
|
||||
"designOption.compare.footprint": "Footprint m²",
|
||||
"designOption.compare.cost": "Cost CHF",
|
||||
"designOption.compare.csv": "Comparison as CSV",
|
||||
"designOption.selection": "Selection ({n} elements)",
|
||||
"designOption.assign": "Assign",
|
||||
"designOption.copy": "Copy to …",
|
||||
"designOption.compare.show": "Open comparison",
|
||||
"designOption.compare.hide": "Close comparison",
|
||||
"resources.tab.designOptions": "Design options",
|
||||
"cmd.designOption.label": "Assign design option …",
|
||||
"cmd.designOption.prompt": "Target option (e.g. Roof=B, option name or number; H = main model)",
|
||||
"cmd.designOptionCopy.label": "Copy to design option …",
|
||||
"cmd.designOptionCopy.prompt": "Copy into option (e.g. Roof=B, option name or number; H = main model)",
|
||||
"cmd.designOption.needsSelection": "Select elements first, then choose the option.",
|
||||
"cmd.designOption.needsSet": "The project has no option set yet (Resources › Design options).",
|
||||
};
|
||||
@@ -0,0 +1,137 @@
|
||||
// [272] Varianten: Kombinationen lesen, Sätze/Varianten anlegen, Zuweisen/Kopieren/Übernehmen/Löschen über den Kern,
|
||||
// Grundriss/Schnitt/3D/Kennzahlen je Kombination am Varianten-Beispiel, Vergleich und CSV, CLI-Kombination.
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyOps } from "../core/ops";
|
||||
import {
|
||||
acceptDesignOptionOps, addDesignOptionOps, addDesignOptionSetOps, assignDesignOptionOps, combinationLabel, combinationSpec, combinationSuffix, commonDesignOption,
|
||||
compareDesignOptions, compareDesignOptionsCsv, copyToDesignOptionOps, deleteDesignOptionOps, levelCombination, nextOptionName, parseCombination, projectWithCombination,
|
||||
resolveCombination, setLevelCombinationOps, setPrimaryOptionOps, showsInCombination,
|
||||
} from "./designOptions";
|
||||
import { buildVariantenSampleProject } from "./sampleProjectVarianten";
|
||||
import { sampleProject } from "./sampleProject";
|
||||
import { generatePlan } from "../plan/generatePlan";
|
||||
import { computeKennzahlen } from "../analysis/kennzahlen";
|
||||
import { projectToModel3d, projectToModel3dParts } from "../plan/toWalls3d";
|
||||
import { withDocument } from "../core/document";
|
||||
import type { Project } from "./types";
|
||||
|
||||
const ALL = new Set(["20", "21", "30", "31", "40", "60"]);
|
||||
|
||||
/** Ids der Öffnungen/Dächer im Grundriss des OG bzw. EG einer Projekt-Fassung. */
|
||||
function planIds(p: Project, level: string): Set<string> {
|
||||
return withDocument(p, () => {
|
||||
const out = new Set<string>();
|
||||
for (const x of generatePlan(p, level, ALL).primitives) {
|
||||
const r = x as { openingId?: string; roofId?: string };
|
||||
if (r.openingId) out.add(r.openingId);
|
||||
if (r.roofId) out.add(r.roofId);
|
||||
}
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
||||
describe("[272] Varianten", () => {
|
||||
it("Kombination: Hauptvarianten, gespeicherte Wahl, Namen, Text", () => {
|
||||
const p = buildVariantenSampleProject();
|
||||
expect(resolveCombination(p)).toEqual({ dachform: "a", fassade: "a" });
|
||||
expect(resolveCombination(p, { dachform: "b", weg: "x" }, { fassade: "z" })).toEqual({ dachform: "b", fassade: "a" });
|
||||
expect(combinationLabel(p, { dachform: "b", fassade: "a" })).toBe("Dachform B Satteldach, Fassade A Lochfenster");
|
||||
expect(combinationSuffix(p, { dachform: "b", fassade: "a" })).toBe("Dachform B Satteldach");
|
||||
expect(combinationSuffix(p, {})).toBe("");
|
||||
expect(parseCombination(p, "dachform=b satteldach; Fassade = B Bandfenster, Unsinn")).toEqual({ dachform: "b", fassade: "b" });
|
||||
expect(combinationSpec(p, { dachform: "b" })).toBe("Dachform=B Satteldach");
|
||||
expect(showsInCombination({ dachform: "a" }, { set: "dachform", option: "b" })).toBe(false);
|
||||
expect(showsInCombination({ dachform: "a" }, undefined)).toBe(true);
|
||||
expect(showsInCombination({ dachform: "a" }, { set: "weg", option: "b" })).toBe(true);
|
||||
});
|
||||
|
||||
it("Sätze und Varianten anlegen, Hauptvariante, Kombination der Ebene (ohne Hauptvariante gespeichert)", () => {
|
||||
const { ops, id } = addDesignOptionSetOps(sampleProject, "Dachform");
|
||||
let p = applyOps(sampleProject, ops);
|
||||
expect(p.designOptionSets?.[0]).toMatchObject({ id, name: "Dachform", primary: "a" });
|
||||
p = applyOps(p, addDesignOptionOps(p, id));
|
||||
expect(p.designOptionSets?.[0].options.map((o) => o.name)).toEqual(["A", "B", "C"]);
|
||||
expect(nextOptionName(p.designOptionSets?.[0])).toBe("D");
|
||||
p = applyOps(p, setLevelCombinationOps(p, "eg", id, "b"));
|
||||
expect(p.drawingLevels.find((l) => l.id === "eg")?.designOptions).toEqual({ [id]: "b" });
|
||||
expect(levelCombination(p, p.drawingLevels.find((l) => l.id === "eg"))[id]).toBe("b");
|
||||
p = applyOps(p, setLevelCombinationOps(p, "eg", id, "a"));
|
||||
expect(p.drawingLevels.find((l) => l.id === "eg")).not.toHaveProperty("designOptions");
|
||||
p = applyOps(p, setPrimaryOptionOps(p, id, "b"));
|
||||
expect(p.designOptionSets?.[0].primary).toBe("b");
|
||||
expect(setPrimaryOptionOps(p, id, "zz")).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("Grundriss je Kombination: Dächer und Fenster der anderen Variante fehlen", () => {
|
||||
const p = buildVariantenSampleProject();
|
||||
const a = planIds(p, "eg");
|
||||
expect(a.has("O2")).toBe(true);
|
||||
expect(a.has("O-band")).toBe(false);
|
||||
const q = applyOps(p, setLevelCombinationOps(p, "eg", "fassade", "b"));
|
||||
const b = planIds(q, "eg");
|
||||
expect(b.has("O2")).toBe(false);
|
||||
expect(b.has("O-band")).toBe(true);
|
||||
});
|
||||
|
||||
it("3D und Kennzahlen je Kombination; Teil-Cache aus bei Varianten", () => {
|
||||
const p = buildVariantenSampleProject();
|
||||
withDocument(p, () => {
|
||||
expect(projectToModel3dParts(p)).toBeNull();
|
||||
const roofs = (opts?: Record<string, string>) => JSON.stringify(projectToModel3d(p, opts ? { hide: { designOptions: opts } } : {}));
|
||||
expect(roofs()).not.toEqual(roofs({ dachform: "b" }));
|
||||
});
|
||||
const ka = withDocument(p, () => computeKennzahlen(p));
|
||||
const pb = projectWithCombination(p, { dachform: "b" });
|
||||
const kb = withDocument(pb, () => computeKennzahlen(pb));
|
||||
expect(ka.gv).not.toBeCloseTo(kb.gv, 3);
|
||||
});
|
||||
|
||||
it("Vergleich: alle Kombinationen, Hauptkombination zuerst, CSV mit Kopf", () => {
|
||||
const p = buildVariantenSampleProject();
|
||||
const rows = withDocument(p, () => compareDesignOptions(p));
|
||||
expect(rows).toHaveLength(4);
|
||||
expect(rows[0].primary).toBe(true);
|
||||
expect(rows[0].label).toBe("Dachform A Flachdach, Fassade A Lochfenster");
|
||||
expect(new Set(rows.map((r) => r.gv)).size).toBeGreaterThan(1);
|
||||
expect(rows.every((r) => Number.isFinite(r.cost) && r.cost > 0)).toBe(true);
|
||||
const csv = withDocument(p, () => compareDesignOptionsCsv(p, ["Kombination", "GF", "HNF", "GV", "Fussabdruck", "AZ", "ÜZ", "Kosten"]));
|
||||
expect(csv.split("\n")[0]).toBe("Kombination;GF;HNF;GV;Fussabdruck;AZ;ÜZ;Kosten");
|
||||
expect(csv.trim().split("\n")).toHaveLength(5);
|
||||
expect(compareDesignOptions(sampleProject)).toEqual([]);
|
||||
});
|
||||
|
||||
it("Zuweisen (Mehrfachauswahl, ein Schritt), gemeinsamer Wert, Kopieren, Übernehmen, Löschen", () => {
|
||||
const p = buildVariantenSampleProject();
|
||||
withDocument(p, () => {
|
||||
const ops = assignDesignOptionOps(p, ["W1", "W2", "nix"], { set: "fassade", option: "b" });
|
||||
expect(ops).toHaveLength(2);
|
||||
const q = applyOps(p, ops);
|
||||
expect(commonDesignOption(q, ["W1", "W2"])).toBe("fassade/b");
|
||||
expect(commonDesignOption(q, ["W1", "W3"])).toBe("mixed");
|
||||
expect(commonDesignOption(q, ["W3"])).toBe("");
|
||||
const copy = copyToDesignOptionOps(p, ["W3"], { set: "fassade", option: "b" }, "k");
|
||||
const c = applyOps(p, copy);
|
||||
const w = c.walls.find((x) => x.id.startsWith("k-"));
|
||||
expect(w?.designOption).toEqual({ set: "fassade", option: "b" });
|
||||
expect((c.openings ?? []).filter((o) => o.hostWallId === w?.id).length).toBeGreaterThan(0);
|
||||
});
|
||||
// Übernehmen: B Satteldach bleibt (ohne Variante), Flachdach weg, Satz weg.
|
||||
const acc = withDocument(p, () => applyOps(p, acceptDesignOptionOps(p, "dachform", "b")));
|
||||
expect(acc.roofs?.map((r) => r.id)).toEqual(["RF1"]);
|
||||
expect(acc.roofs?.[0]).not.toHaveProperty("designOption");
|
||||
expect(acc.designOptionSets?.map((s) => s.id)).toEqual(["fassade"]);
|
||||
// Satz löschen: alle Fenster beider Fassaden-Varianten weg.
|
||||
const del = withDocument(p, () => applyOps(p, deleteDesignOptionOps(p, "fassade")));
|
||||
expect((del.openings ?? []).some((o) => o.id === "O2" || o.id === "O-band")).toBe(false);
|
||||
});
|
||||
|
||||
it("CLI-Kombination: gewählte Varianten werden Hauptvarianten, gespeicherte Wahlen entfallen", () => {
|
||||
const p0 = buildVariantenSampleProject();
|
||||
const p = { ...p0, drawingLevels: p0.drawingLevels.map((l) => (l.id === "eg" ? { ...l, designOptions: { dachform: "a", fassade: "b" } } : l)) };
|
||||
const q = projectWithCombination(p, { dachform: "b" });
|
||||
expect(q.designOptionSets?.find((s) => s.id === "dachform")?.primary).toBe("b");
|
||||
expect(q.drawingLevels.find((l) => l.id === "eg")?.designOptions).toEqual({ fassade: "b" });
|
||||
expect(projectWithCombination(p, {})).toBe(p);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,301 @@
|
||||
// [272] Varianten (Archicad „Design Options“): Variantensätze mit Varianten, Elemente im Hauptmodell oder in genau einer
|
||||
// Variante, je Ebene/Ausschnitt/Viewport eine Kombination. Was sichtbar ist, entscheidet der Kern (`renovation.rs`, ein Ort
|
||||
// mit dem Umbaufilter; Modell und Ops in `design_options.rs`); hier nur, was die Oberfläche zum Lesen und Setzen braucht.
|
||||
|
||||
import type { CoreOp } from "../core/ops";
|
||||
import { documentFor } from "../core/document";
|
||||
import { patchItem, setField } from "../core/opsBuild";
|
||||
import type { DesignOption, DesignOptionRef, DesignOptionSet, DrawingLevel, Project } from "./types";
|
||||
|
||||
/** Listen, deren Elemente einer Variante angehören können (gleich wie `design_options::COLLECTIONS`). */
|
||||
export const DESIGN_OPTION_COLLECTIONS = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d"] as const;
|
||||
export type DesignOptionCollection = (typeof DESIGN_OPTION_COLLECTIONS)[number];
|
||||
|
||||
/** Kombination: Satz-Id → Varianten-Id. */
|
||||
export type Combination = Record<string, string>;
|
||||
|
||||
/** Variantensätze des Projekts. */
|
||||
export function designOptionSets(project: Project): readonly DesignOptionSet[] {
|
||||
return project.designOptionSets ?? [];
|
||||
}
|
||||
|
||||
/** Hauptvariante eines Satzes (`primary`, sonst die erste). */
|
||||
export function primaryOption(s: DesignOptionSet): string | undefined {
|
||||
return s.primary && s.options.some((o) => o.id === s.primary) ? s.primary : s.options[0]?.id;
|
||||
}
|
||||
|
||||
/** Wirksame Kombination: Hauptvarianten, darüber die gespeicherten Wahlen (spätere gehen vor; unbekannte übergangen). */
|
||||
export function resolveCombination(project: Project, ...stored: (Combination | undefined | null)[]): Combination {
|
||||
const out: Combination = {};
|
||||
for (const s of designOptionSets(project)) {
|
||||
const p = primaryOption(s);
|
||||
if (p) out[s.id] = p;
|
||||
}
|
||||
for (const m of stored) {
|
||||
for (const [k, v] of Object.entries(m ?? {})) {
|
||||
const s = designOptionSets(project).find((x) => x.id === k);
|
||||
if (s?.options.some((o) => o.id === v)) out[k] = v;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Kombination einer Ebene (`DrawingLevel.designOptions` über den Hauptvarianten). */
|
||||
export function levelCombination(project: Project, level: DrawingLevel | undefined): Combination {
|
||||
return resolveCombination(project, level?.designOptions);
|
||||
}
|
||||
|
||||
/** Lesbarer Name „Dachform B, Fassade A“ (nur Sätze mit Varianten). */
|
||||
export function combinationLabel(project: Project, c: Combination): string {
|
||||
const parts: string[] = [];
|
||||
for (const s of designOptionSets(project)) {
|
||||
const o = s.options.find((x) => x.id === c[s.id]);
|
||||
if (o) parts.push(`${s.name} ${o.name}`.trim());
|
||||
}
|
||||
return parts.join(", ");
|
||||
}
|
||||
|
||||
/** Kurzname nur der Varianten, die von der Hauptvariante abweichen (Titelzusatz im Blatt); leer = Hauptkombination. */
|
||||
export function combinationSuffix(project: Project, c: Combination | undefined | null): string {
|
||||
if (!c) return "";
|
||||
const full = resolveCombination(project, c);
|
||||
const prim = resolveCombination(project);
|
||||
const diff: Combination = {};
|
||||
for (const [k, v] of Object.entries(full)) if (prim[k] !== v) diff[k] = v;
|
||||
return combinationLabel(project, diff);
|
||||
}
|
||||
|
||||
/** Text „Satz=Variante,…“ (Namen) einer Kombination — Format der CLI `--options`. */
|
||||
export function combinationSpec(project: Project, c: Combination): string {
|
||||
const parts: string[] = [];
|
||||
for (const s of designOptionSets(project)) {
|
||||
const o = s.options.find((x) => x.id === c[s.id]);
|
||||
if (o) parts.push(`${s.name}=${o.name}`);
|
||||
}
|
||||
return parts.join(",");
|
||||
}
|
||||
|
||||
/** Liest „Dachform=B,Fassade=A“ (Ids oder Namen, ohne Gross-/Kleinschreibung); Unbekanntes übergangen. */
|
||||
export function parseCombination(project: Project, spec: string): Combination {
|
||||
const out: Combination = {};
|
||||
for (const part of spec.split(/[,;]/)) {
|
||||
const i = part.indexOf("=");
|
||||
if (i <= 0) continue;
|
||||
const k = part.slice(0, i).trim().toLowerCase();
|
||||
const v = part.slice(i + 1).trim().toLowerCase();
|
||||
const s = designOptionSets(project).find((x) => x.id.toLowerCase() === k || x.name.trim().toLowerCase() === k);
|
||||
const o = s?.options.find((x) => x.id.toLowerCase() === v || x.name.trim().toLowerCase() === v);
|
||||
if (s && o) out[s.id] = o.id;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Erscheint ein Element mit dieser Zugehörigkeit in der Kombination? (Gleiche Regel wie `Combination::shows` im Kern.) */
|
||||
export function showsInCombination(c: Combination, r: DesignOptionRef | undefined | null): boolean {
|
||||
if (!r) return true;
|
||||
const chosen = c[r.set];
|
||||
return chosen === undefined || chosen === r.option;
|
||||
}
|
||||
|
||||
/** Name „Dachform: B“ einer Zugehörigkeit; leer = Hauptmodell. */
|
||||
export function designOptionLabel(project: Project, r: DesignOptionRef | undefined | null): string {
|
||||
if (!r) return "";
|
||||
const s = designOptionSets(project).find((x) => x.id === r.set);
|
||||
const o = s?.options.find((x) => x.id === r.option);
|
||||
return s && o ? `${s.name}: ${o.name}` : "";
|
||||
}
|
||||
|
||||
/** Auswahl je Liste (ids), wie der Kern sie für Zuweisen/Kopieren nimmt. */
|
||||
export function designOptionSelection(project: Project, ids: Iterable<string>): Record<string, string[]> {
|
||||
const set = new Set(ids);
|
||||
const out: Record<string, string[]> = {};
|
||||
for (const c of DESIGN_OPTION_COLLECTIONS) {
|
||||
const hit = ((project[c] ?? []) as { id: string }[]).filter((e) => set.has(e.id)).map((e) => e.id);
|
||||
if (hit.length) out[c] = hit;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Ids der Auswahl, die einer Variante angehören können. */
|
||||
export function designOptionIds(project: Project, ids: Iterable<string>): string[] {
|
||||
return Object.values(designOptionSelection(project, ids)).flat();
|
||||
}
|
||||
|
||||
/** Gemeinsame Zugehörigkeit der Elemente `ids` als `"set/option"` (`""` = Hauptmodell, `"mixed"`, `null` ohne Elemente). */
|
||||
export function commonDesignOption(project: Project, ids: Iterable<string>): string | "mixed" | null {
|
||||
const set = new Set(ids);
|
||||
let out: string | null = null;
|
||||
for (const c of DESIGN_OPTION_COLLECTIONS) {
|
||||
for (const e of (project[c] ?? []) as { id: string; designOption?: DesignOptionRef }[]) {
|
||||
if (!set.has(e.id)) continue;
|
||||
const k = e.designOption ? `${e.designOption.set}/${e.designOption.option}` : "";
|
||||
if (out === null) out = k;
|
||||
else if (out !== k) return "mixed";
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Ziel aus `"set/option"` (`""` = Hauptmodell). */
|
||||
export function parseTarget(key: string): { set: string; option: string } | null {
|
||||
const i = key.indexOf("/");
|
||||
return i > 0 ? { set: key.slice(0, i), option: key.slice(i + 1) } : null;
|
||||
}
|
||||
|
||||
/** Alle Ziele „Satz: Variante“ für Auswahllisten (`key` = `"set/option"`). */
|
||||
export function designOptionTargets(project: Project): { key: string; label: string }[] {
|
||||
const out: { key: string; label: string }[] = [];
|
||||
for (const s of designOptionSets(project)) for (const o of s.options) out.push({ key: `${s.id}/${o.id}`, label: `${s.name}: ${o.name}` });
|
||||
return out;
|
||||
}
|
||||
|
||||
// ── Ops ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
/** Ops: Variante zuweisen (`null` = Hauptmodell) für die Auswahl (Kern `design_options::assign_ops`; ein Undo-Schritt). */
|
||||
export function assignDesignOptionOps(project: Project, ids: Iterable<string>, target: { set: string; option: string } | null): CoreOp[] {
|
||||
const sel = designOptionSelection(project, ids);
|
||||
if (!Object.keys(sel).length) return [];
|
||||
return documentFor(project).queryRoot<CoreOp[]>("designOptionAssignOps", JSON.stringify({ ...(target ?? {}), sel }));
|
||||
}
|
||||
|
||||
/** Ops: Kopien der Auswahl in die Variante (`null` = Hauptmodell); Öffnungen gewählter Wände wandern mit. */
|
||||
export function copyToDesignOptionOps(project: Project, ids: Iterable<string>, target: { set: string; option: string } | null, stamp = `v${Date.now().toString(36)}`): CoreOp[] {
|
||||
const sel = designOptionSelection(project, ids);
|
||||
if (!Object.keys(sel).length) return [];
|
||||
return documentFor(project).queryRoot<CoreOp[]>("designOptionCopyOps", JSON.stringify({ ...(target ?? {}), sel, stamp }));
|
||||
}
|
||||
|
||||
/** Ops: „Variante übernehmen“ — ihre Elemente ins Hauptmodell, die übrigen Varianten des Satzes gelöscht, Satz weg. */
|
||||
export function acceptDesignOptionOps(project: Project, set: string, option: string): CoreOp[] {
|
||||
return documentFor(project).queryRoot<CoreOp[]>("designOptionAcceptOps", JSON.stringify({ set, option }));
|
||||
}
|
||||
|
||||
/** Ops: Satz (ohne `option`) bzw. Variante löschen samt ihren Elementen. */
|
||||
export function deleteDesignOptionOps(project: Project, set: string, option?: string): CoreOp[] {
|
||||
return documentFor(project).queryRoot<CoreOp[]>("designOptionDeleteOps", JSON.stringify(option ? { set, option } : { set }));
|
||||
}
|
||||
|
||||
/** Nächste freie Id mit Präfix. */
|
||||
function freeId(used: Iterable<string>, prefix: string): string {
|
||||
const u = new Set(used);
|
||||
let i = u.size + 1;
|
||||
while (u.has(`${prefix}${i}`)) i++;
|
||||
return `${prefix}${i}`;
|
||||
}
|
||||
|
||||
/** Variantenname „A“, „B“, … (nächster freier Buchstabe). */
|
||||
export function nextOptionName(s: DesignOptionSet | undefined): string {
|
||||
const used = new Set((s?.options ?? []).map((o) => o.name.trim().toUpperCase()));
|
||||
for (let i = 0; i < 26; i++) {
|
||||
const n = String.fromCharCode(65 + i);
|
||||
if (!used.has(n)) return n;
|
||||
}
|
||||
return String((s?.options.length ?? 0) + 1);
|
||||
}
|
||||
|
||||
/** Ops: neuer Satz `name` mit den Varianten A und B (A = Hauptvariante). Gibt auch die neue Satz-Id zurück. */
|
||||
export function addDesignOptionSetOps(project: Project, name: string): { ops: CoreOp[]; id: string } {
|
||||
const sets = designOptionSets(project);
|
||||
const id = freeId(sets.map((s) => s.id), "satz-");
|
||||
const options: DesignOption[] = [
|
||||
{ id: "a", name: "A" },
|
||||
{ id: "b", name: "B" },
|
||||
];
|
||||
return { ops: [setField("designOptionSets", [...sets, { id, name: name.trim() || id, options, primary: "a" }])], id };
|
||||
}
|
||||
|
||||
/** Ops: weitere Variante im Satz (nächster Buchstabe). */
|
||||
export function addDesignOptionOps(project: Project, setId: string): CoreOp[] {
|
||||
const sets = designOptionSets(project);
|
||||
const s = sets.find((x) => x.id === setId);
|
||||
if (!s) return [];
|
||||
const name = nextOptionName(s);
|
||||
const id = freeId(s.options.map((o) => o.id), "v");
|
||||
return [setField("designOptionSets", sets.map((x) => (x.id === setId ? { ...x, options: [...x.options, { id, name }] } : x)))];
|
||||
}
|
||||
|
||||
/** Ops: Satz bzw. Variante umbenennen, Hauptvariante setzen. */
|
||||
export function renameDesignOptionSetOps(project: Project, setId: string, name: string): CoreOp[] {
|
||||
const sets = designOptionSets(project);
|
||||
if (!sets.some((s) => s.id === setId)) return [];
|
||||
return [setField("designOptionSets", sets.map((s) => (s.id === setId ? { ...s, name } : s)))];
|
||||
}
|
||||
|
||||
export function renameDesignOptionOps(project: Project, setId: string, optionId: string, name: string): CoreOp[] {
|
||||
const sets = designOptionSets(project);
|
||||
if (!sets.some((s) => s.id === setId && s.options.some((o) => o.id === optionId))) return [];
|
||||
return [setField("designOptionSets", sets.map((s) => (s.id === setId ? { ...s, options: s.options.map((o) => (o.id === optionId ? { ...o, name } : o)) } : s)))];
|
||||
}
|
||||
|
||||
export function setPrimaryOptionOps(project: Project, setId: string, optionId: string): CoreOp[] {
|
||||
const sets = designOptionSets(project);
|
||||
if (!sets.some((s) => s.id === setId && s.options.some((o) => o.id === optionId))) return [];
|
||||
return [setField("designOptionSets", sets.map((s) => (s.id === setId ? { ...s, primary: optionId } : s)))];
|
||||
}
|
||||
|
||||
/** Ops: Kombination der Ebene setzen (eine Variante je Satz; die Hauptvariante wird nicht gespeichert). */
|
||||
export function setLevelCombinationOps(project: Project, levelId: string, setId: string, optionId: string): CoreOp[] {
|
||||
const s = designOptionSets(project).find((x) => x.id === setId);
|
||||
if (!s || !s.options.some((o) => o.id === optionId)) return [];
|
||||
return patchItem(project, "drawingLevels", levelId, (l) => {
|
||||
const m: Combination = { ...(l.designOptions ?? {}) };
|
||||
if (primaryOption(s) === optionId) delete m[setId];
|
||||
else m[setId] = optionId;
|
||||
const next = { ...l, designOptions: m };
|
||||
if (!Object.keys(m).length) delete (next as { designOptions?: Combination }).designOptions;
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
// ── Vergleich ───────────────────────────────────────────────────────────────
|
||||
|
||||
/** Zeile der Vergleichstabelle (Kern `design_options::CompareRow`). */
|
||||
export interface DesignOptionCompareRow {
|
||||
choice: Combination;
|
||||
label: string;
|
||||
primary: boolean;
|
||||
gf: number;
|
||||
hnf: number;
|
||||
gv: number;
|
||||
footprint: number;
|
||||
az?: number | null;
|
||||
uez?: number | null;
|
||||
cost: number;
|
||||
}
|
||||
|
||||
/** Kennzahlen und Kosten je Kombination (Hauptkombination zuerst); `renovation`: Umbau-Zustand (Filter-Id). */
|
||||
export function compareDesignOptions(project: Project, renovation = ""): DesignOptionCompareRow[] {
|
||||
if (!designOptionSets(project).length) return [];
|
||||
return documentFor(project).query<DesignOptionCompareRow[]>("designOptionCompare", [], renovation ? JSON.stringify({ renovation }) : "");
|
||||
}
|
||||
|
||||
/** Vergleich als CSV (Semikolon) mit den Spaltenköpfen `head` (übersetzt). */
|
||||
export function compareDesignOptionsCsv(project: Project, head: readonly string[], renovation = ""): string {
|
||||
if (!designOptionSets(project).length) return "";
|
||||
return documentFor(project).query<string>("designOptionCompare", [], JSON.stringify(renovation ? { renovation, head } : { head }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Das Projekt so, dass die Kombination `c` überall gilt (CLI `--options`): die gewählten Varianten werden Hauptvarianten,
|
||||
* gespeicherte Wahlen dieser Sätze an Ebenen, Vorlagen, Ausschnitten und Viewports entfallen. Kein Op (Kopie für Exporte).
|
||||
*/
|
||||
export function projectWithCombination(project: Project, c: Combination): Project {
|
||||
const keys = Object.keys(c);
|
||||
if (!keys.length) return project;
|
||||
const strip = <T extends { designOptions?: Combination | null }>(x: T): T => {
|
||||
if (!x.designOptions || !keys.some((k) => k in x.designOptions!)) return x;
|
||||
const m = { ...x.designOptions };
|
||||
for (const k of keys) delete m[k];
|
||||
const next = { ...x, designOptions: m };
|
||||
if (!Object.keys(m).length) delete (next as { designOptions?: Combination | null }).designOptions;
|
||||
return next;
|
||||
};
|
||||
return {
|
||||
...project,
|
||||
designOptionSets: designOptionSets(project).map((s) => (c[s.id] && s.options.some((o) => o.id === c[s.id]) ? { ...s, primary: c[s.id] } : s)),
|
||||
drawingLevels: project.drawingLevels.map(strip),
|
||||
...(project.viewTemplates ? { viewTemplates: project.viewTemplates.map(strip) } : {}),
|
||||
...(project.viewSnapshots ? { viewSnapshots: project.viewSnapshots.map(strip) } : {}),
|
||||
...(project.layouts ? { layouts: project.layouts.map((l) => ({ ...l, viewports: l.viewports.map(strip) })) } : {}),
|
||||
};
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import type { Layout, LayoutOrientation, LayoutPaperFormat, MasterLayout, Projec
|
||||
import { core } from "../engine/coreWasm";
|
||||
import { t } from "../i18n/translate";
|
||||
import { findSnapshot, resolveTitleBlock, resolveViewportScale, sheetSizeMm } from "./layoutModel";
|
||||
import { combinationSuffix } from "./designOptions";
|
||||
|
||||
export interface PosterTemplate {
|
||||
/** Schlüssel in `MasterLayout.template`. */
|
||||
@@ -113,5 +114,22 @@ export function viewportScaleLabel(
|
||||
if (!snap) return null;
|
||||
const n = scaleOverride ?? resolveViewportScale(vp, snap);
|
||||
const { sizeMm, dyMm } = scaleLabelMetrics(sheet);
|
||||
return { text: `1:${n}`, x: vp.xMm, y: vp.yMm + vp.heightMm + dyMm, sizeMm };
|
||||
// [272] Titelzusatz: Varianten, die von der Hauptkombination abweichen (Ausschnitt bzw. Viewport).
|
||||
const suffix = viewportVariantSuffix(project, vp);
|
||||
return { text: suffix ? `1:${n} · ${suffix}` : `1:${n}`, x: vp.xMm, y: vp.yMm + vp.heightMm + dyMm, sizeMm };
|
||||
}
|
||||
|
||||
/** [272] Varianten eines Viewports, die von der Hauptkombination abweichen („Dachform B Satteldach“); leer sonst. */
|
||||
export function viewportVariantSuffix(project: Project, vp: Layout["viewports"][number]): string {
|
||||
if (!project.designOptionSets?.length) return "";
|
||||
const snap = findSnapshot(project, vp.snapshotId);
|
||||
return combinationSuffix(project, { ...(snap?.designOptions ?? {}), ...(vp.designOptions ?? {}) });
|
||||
}
|
||||
|
||||
/** [272] Titelzusatz unter einem Viewport ohne Massstabsangaben des Masters: nur die Varianten; `null` ohne Abweichung. */
|
||||
export function viewportVariantLabel(project: Project, vp: Layout["viewports"][number], sheet: { w: number; h: number }): { text: string; x: number; y: number; sizeMm: number } | null {
|
||||
const suffix = viewportVariantSuffix(project, vp);
|
||||
if (!suffix) return null;
|
||||
const { sizeMm, dyMm } = scaleLabelMetrics(sheet);
|
||||
return { text: suffix, x: vp.xMm, y: vp.yMm + vp.heightMm + dyMm, sizeMm };
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// [272] „Beispiel Varianten": das Demo-Haus (sampleProject) mit zwei Variantensätzen — Vorlage für Tests, die Kurzanleitung
|
||||
// (Abschnitt Varianten) und die Prüfbilder (`doc/review-272`).
|
||||
//
|
||||
// Satz „Dachform": A Flachdach (Hauptvariante, neues Dach RF2), B Satteldach (das Dach RF1 des Demo-Hauses).
|
||||
// Satz „Fassade": A Lochfenster (Nordfenster O2 des Demo-Hauses, Hauptvariante), B Bandfenster (O-band, 3.6 m breit).
|
||||
// Alles Übrige gehört zum Hauptmodell. Ein eigenes Beispiel, damit die bestehenden Goldens unverändert bleiben.
|
||||
|
||||
import type { DesignOptionSet, Opening, Project, Roof } from "./types";
|
||||
import { sampleProject } from "./sampleProject";
|
||||
|
||||
export const VARIANTEN_SETS: DesignOptionSet[] = [
|
||||
{ id: "dachform", name: "Dachform", options: [{ id: "a", name: "A Flachdach" }, { id: "b", name: "B Satteldach" }], primary: "a" },
|
||||
{ id: "fassade", name: "Fassade", options: [{ id: "a", name: "A Lochfenster" }, { id: "b", name: "B Bandfenster" }], primary: "a" },
|
||||
];
|
||||
|
||||
/** Das Varianten-Beispiel (frische Kopie bei jedem Aufruf). */
|
||||
export function buildVariantenSampleProject(): Project {
|
||||
const base = structuredClone(sampleProject);
|
||||
const rf1 = (base.roofs ?? [])[0];
|
||||
const roofs: Roof[] = [
|
||||
{ ...rf1, designOption: { set: "dachform", option: "b" } },
|
||||
{ ...rf1, id: "RF2", shape: "flach", pitchDeg: 0, overhang: 0.15, thickness: 0.3, designOption: { set: "dachform", option: "a" } },
|
||||
];
|
||||
const openings: Opening[] = (base.openings ?? []).map((o) => (o.id === "O2" ? { ...o, designOption: { set: "fassade", option: "a" } } : o));
|
||||
const o2 = (base.openings ?? []).find((o) => o.id === "O2")!;
|
||||
openings.push({ ...o2, id: "O-band", position: 0.7, width: 3.6, height: 1.0, sillHeight: 1.1, designOption: { set: "fassade", option: "b" } });
|
||||
return {
|
||||
...base,
|
||||
id: "beispiel-varianten",
|
||||
name: "Beispiel Varianten",
|
||||
roofs,
|
||||
openings,
|
||||
designOptionSets: structuredClone(VARIANTEN_SETS),
|
||||
};
|
||||
}
|
||||
@@ -224,6 +224,10 @@ export type Ceiling = {
|
||||
bottom?: VerticalAnchor;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -331,6 +335,10 @@ export type Column = {
|
||||
hatchSource?: AttributeSource;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -667,6 +675,29 @@ export type CustomPalette = {
|
||||
visible?: boolean;
|
||||
};
|
||||
|
||||
/** [272] Eine Variante eines Satzes (z. B. „A Flachdach“). */
|
||||
export type DesignOption = { id: string; name: string };
|
||||
|
||||
/** [272] Zugehörigkeit eines Elements zu einer Variante (Archicad „Design Options“). */
|
||||
export type DesignOptionRef = {
|
||||
/** Id des Variantensatzes (`DesignOptionSet.id`). */
|
||||
set: string;
|
||||
/** Id der Variante im Satz (`DesignOption.id`). */
|
||||
option: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* [272] Ein Variantensatz (z. B. „Dachform“) mit seinen Varianten; je Darstellung ist genau eine Variante des
|
||||
* Satzes sichtbar (Vorgabe: die Hauptvariante).
|
||||
*/
|
||||
export type DesignOptionSet = {
|
||||
id: string;
|
||||
name: string;
|
||||
options: Array<DesignOption>;
|
||||
/** Id der Hauptvariante. Fehlt/unbekannt ⇒ die erste Variante. */
|
||||
primary?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Detailgrad der Darstellung (≙ DOSSIER Einfach/Standard/Detail). Wirkt im
|
||||
* Grundriss auf Tür-/Fenstersymbole + Schraffuren/Linienfeinheit (siehe
|
||||
@@ -1010,6 +1041,10 @@ export type Drawing2D = {
|
||||
* Verhalten (ohne `hatchId` keine Schraffur).
|
||||
*/
|
||||
hatchSource?: AttributeSource;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/** Geometrie eines 2D-Zeichenelements (Tag `shape`). */
|
||||
@@ -1407,6 +1442,8 @@ export type DrawingLevel = {
|
||||
* noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
*/
|
||||
renovationPhase?: string;
|
||||
/** [272] Variantenkombination: Satz-Id → Varianten-Id (fehlende Sätze ⇒ Hauptvariante). */
|
||||
designOptions?: { [key in string]: string };
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1557,6 +1594,10 @@ export type ExtrudedSolid = {
|
||||
componentId?: string;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2161,6 +2202,10 @@ export type LayoutViewport = {
|
||||
* gleicher ±0.00 stehen und Kontext ausserhalb des Rahmens beschnitten wird.
|
||||
*/
|
||||
center?: Vec2;
|
||||
/**
|
||||
* [272] Variantenkombination des Viewports (über der des Ausschnitts): Satz-Id → Varianten-Id (fehlende Sätze ⇒ Hauptvariante).
|
||||
*/
|
||||
designOptions?: { [key in string]: string };
|
||||
};
|
||||
|
||||
/** Linienenden aller Striche im Plan/Schnitt/Ansicht und in den Exporten ([146]); fehlt = flach. */
|
||||
@@ -2799,6 +2844,10 @@ export type Opening = {
|
||||
* [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand wie die Wand (eine neue Öffnung in einer Bestandswand bricht die Wand dort ab, eine Öffnung „Abbruch“ wird zugemauert).
|
||||
*/
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -3255,6 +3304,11 @@ export type Project = {
|
||||
};
|
||||
/** [271] Umbau: Etappen, Farben je Status (SIA 400) und eigene Umbaufilter. */
|
||||
renovation?: RenovationSettings;
|
||||
/**
|
||||
* [272] Variantensätze (Archicad „Design Options“): Elemente mit `designOption` erscheinen nur in der
|
||||
* Kombination ihrer Variante.
|
||||
*/
|
||||
designOptionSets?: Array<DesignOptionSet>;
|
||||
};
|
||||
|
||||
/** Protokolleintrag einer Publikation ([79]): Datum, Blätter mit Revision, erzeugte Dateien. */
|
||||
@@ -3505,6 +3559,10 @@ export type Roof = {
|
||||
parapetComponentId?: string;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -3609,6 +3667,10 @@ export type Room = {
|
||||
* [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand (nur Sichtbarkeit und Flächen je Zustand, keine Umbau-Farbe: ein Raum ist kein Bauteil).
|
||||
*/
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -4019,6 +4081,10 @@ export type Stair = {
|
||||
postDepth?: number;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -4395,6 +4461,8 @@ export type ViewSnapshot = {
|
||||
* noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
*/
|
||||
renovationPhase?: string;
|
||||
/** [272] Variantenkombination: Satz-Id → Varianten-Id (fehlende Sätze ⇒ Hauptvariante). */
|
||||
designOptions?: { [key in string]: string };
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -4466,6 +4534,8 @@ export type ViewTemplate = {
|
||||
* noch, Abbruch späterer Etappen steht noch als Bestand. Fehlt ⇒ alle Etappen.
|
||||
*/
|
||||
renovationPhase?: string;
|
||||
/** [272] Variantenkombination: Satz-Id → Varianten-Id (fehlende Sätze ⇒ Hauptvariante). */
|
||||
designOptions?: { [key in string]: string };
|
||||
};
|
||||
|
||||
/** Ansichtstyp eines Geschosses (wie in App). */
|
||||
@@ -4624,6 +4694,10 @@ export type Wall = {
|
||||
surfacePatternOffset?: Vec2;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ export interface NativeAppMenuHandlers {
|
||||
onNewProjectFromComplexSample: () => void;
|
||||
onNewProjectFromWettbewerbSample: () => void;
|
||||
onNewProjectFromUmbauSample: () => void;
|
||||
onNewProjectFromVariantenSample: () => void;
|
||||
onNewProjectFromTemplate: () => void;
|
||||
onOpenProject: () => void;
|
||||
onSaveProject: () => void;
|
||||
@@ -194,6 +195,10 @@ export function useNativeAppMenu(
|
||||
text: t("menu.native.newFromUmbauSample"),
|
||||
action: () => handlersRef.current.onNewProjectFromUmbauSample(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.newFromVariantenSample"),
|
||||
action: () => handlersRef.current.onNewProjectFromVariantenSample(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.newFromTemplateFile"),
|
||||
action: () => handlersRef.current.onNewProjectFromTemplate(),
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// [272] Varianten-Vergleich im Flächenbilanz-Panel: Kennzahlen (GF, HNF, GV, Fussabdruck, AZ, ÜZ) und Kosten (Grobschätzung
|
||||
// inkl. MwSt.) je Kombination der Variantensätze nebeneinander, Hauptkombination zuerst (Kern `design_options::compare`);
|
||||
// mit CSV-Export. Nur mit Variantensätzen im Projekt; `renovation`: Umbau-Zustand wie die Kennzahlenleiste.
|
||||
|
||||
import { t } from "../i18n";
|
||||
import { compareDesignOptions, compareDesignOptionsCsv, designOptionSets, exportProjectName, formatChf } from "../core";
|
||||
import type { Project } from "../model/types";
|
||||
import { downloadCsv } from "./downloadFile";
|
||||
import { runWithAnonymityGate } from "../state/anonymityGate";
|
||||
|
||||
const fmt = (n: number, d = 1) => n.toLocaleString("de-CH", { minimumFractionDigits: d, maximumFractionDigits: d });
|
||||
|
||||
/** Spaltenköpfe (übersetzt) für Tabelle und CSV. */
|
||||
export function designOptionCompareHead(): string[] {
|
||||
return [t("designOption.compare.combination"), "GF m²", "HNF m²", "GV m³", t("designOption.compare.footprint"), "AZ", "ÜZ", t("designOption.compare.cost")];
|
||||
}
|
||||
|
||||
export function DesignOptionCompareSection({ project, renovation = "" }: { project: Project; renovation?: string }) {
|
||||
if (!designOptionSets(project).length) return null;
|
||||
const rows = compareDesignOptions(project, renovation);
|
||||
if (!rows.length) return null;
|
||||
const head = designOptionCompareHead();
|
||||
const stem = `${exportProjectName(project) || "projekt"}-varianten`;
|
||||
const exportCsv = () => runWithAnonymityGate(project, [`${stem}.csv`], () => downloadCsv(`${stem}.csv`, compareDesignOptionsCsv(project, head, renovation)));
|
||||
const base = rows[0];
|
||||
const delta = (v: number, b: number, d: number) => (v === b ? "" : ` (${v > b ? "+" : "−"}${fmt(Math.abs(v - b), d)})`);
|
||||
return (
|
||||
<div className="kz-variants" data-testid="design-option-compare">
|
||||
<div className="balance-section-label">{t("designOption.compare.title")}</div>
|
||||
<div className="kz-variants-scroll">
|
||||
<table className="kz-variants-table">
|
||||
<thead>
|
||||
<tr>
|
||||
{head.map((h) => (
|
||||
<th key={h}>{h}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((r) => (
|
||||
<tr key={r.label} className={r.primary ? "kz-variants-primary" : undefined} data-testid="design-option-compare-row">
|
||||
<td title={r.label}>{r.label}</td>
|
||||
<td className="num">{fmt(r.gf) + delta(r.gf, base.gf, 1)}</td>
|
||||
<td className="num">{fmt(r.hnf) + delta(r.hnf, base.hnf, 1)}</td>
|
||||
<td className="num">{fmt(r.gv, 0) + delta(r.gv, base.gv, 0)}</td>
|
||||
<td className="num">{fmt(r.footprint)}</td>
|
||||
<td className="num">{r.az == null ? "–" : fmt(r.az, 2)}</td>
|
||||
<td className="num">{r.uez == null ? "–" : fmt(r.uez, 2)}</td>
|
||||
<td className="num">{formatChf(r.cost)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<button type="button" className="balance-export" data-testid="design-option-compare-csv" onClick={exportCsv}>
|
||||
{t("designOption.compare.csv")}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// [272] Dock-Panel „Varianten“ (wie Archicads Design-Options-Verwaltung): Kombination der aktiven Ansicht (je Satz eine
|
||||
// Variante; ein Feld der Ebene wie der Umbaufilter, darum je Reiter eigen und mit Undo), „neue Elemente zeichnen in …“
|
||||
// (Zustand der Sitzung), Auswahl einer Variante zuweisen oder in eine Variante kopieren (ein Undo-Schritt), Sätze und
|
||||
// Varianten verwalten samt „Übernehmen“ (Ressourcen-Tab, dieselben Bausteine) und der Vergleich der Kennzahlen/Kosten.
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
import {
|
||||
acceptDesignOptionOps, addDesignOptionOps, addDesignOptionSetOps, assignDesignOptionOps, copyToDesignOptionOps, deleteDesignOptionOps, designOptionIds,
|
||||
designOptionSets, designOptionTargets, levelCombination, parseTarget, renameDesignOptionOps, renameDesignOptionSetOps, setLevelCombinationOps, setPrimaryOptionOps,
|
||||
} from "../core";
|
||||
import { DesignOptionsTab, type DesignOptionHandlers } from "../ui/resourceManager/DesignOptionsTab";
|
||||
import { DesignOptionCompareSection } from "./DesignOptionCompareSection";
|
||||
import { selectionDesignOptionIds } from "./objectInfo/DesignOptionField";
|
||||
|
||||
export function DesignOptionsPanel() {
|
||||
const project = useStore((s) => s.project);
|
||||
const activeLevelId = useStore((s) => s.activeLevelId);
|
||||
const selection = useStore((s) => s.selection);
|
||||
const draw = useStore((s) => s.drawDesignOption);
|
||||
const setDraw = useStore((s) => s.setDrawDesignOption);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const [target, setTarget] = useState("");
|
||||
const [showCompare, setShowCompare] = useState(false);
|
||||
const sets = designOptionSets(project);
|
||||
const level = project.drawingLevels.find((l) => l.id === activeLevelId);
|
||||
const combo = levelCombination(project, level);
|
||||
const levelEditable = !!level && (level.kind === "floor" || level.kind === "section" || level.kind === "elevation" || level.kind === "ceiling");
|
||||
const targets = designOptionTargets(project);
|
||||
const selIds = useMemo(() => designOptionIds(project, selectionDesignOptionIds(selection)), [project, selection]);
|
||||
const handlers: DesignOptionHandlers = {
|
||||
onAddDesignOptionSet: (name) => applyChange((p) => addDesignOptionSetOps(p, name).ops),
|
||||
onRenameDesignOptionSet: (setId, name) => applyChange((p) => renameDesignOptionSetOps(p, setId, name), `dopt-set-${setId}`),
|
||||
onAddDesignOption: (setId) => applyChange((p) => addDesignOptionOps(p, setId)),
|
||||
onRenameDesignOption: (setId, optionId, name) => applyChange((p) => renameDesignOptionOps(p, setId, optionId, name), `dopt-${setId}-${optionId}`),
|
||||
onSetPrimaryDesignOption: (setId, optionId) => applyChange((p) => setPrimaryOptionOps(p, setId, optionId)),
|
||||
onAcceptDesignOption: (setId, optionId) => applyChange((p) => acceptDesignOptionOps(p, setId, optionId)),
|
||||
onDeleteDesignOption: (setId, optionId) => applyChange((p) => deleteDesignOptionOps(p, setId, optionId)),
|
||||
};
|
||||
const drawKey = draw ? `${draw.set}/${draw.option}` : "";
|
||||
return (
|
||||
<div className="design-options-panel" data-testid="design-options-panel">
|
||||
{sets.length > 0 && (
|
||||
<>
|
||||
<div className="balance-section-label">{t("designOption.viewCombination")}</div>
|
||||
{sets.map((s) => (
|
||||
<label key={s.id} className="kz-parcel">
|
||||
<span>{s.name}</span>
|
||||
<select
|
||||
className="kz-input"
|
||||
value={combo[s.id] ?? ""}
|
||||
disabled={!levelEditable}
|
||||
aria-label={s.name}
|
||||
data-testid={`design-option-combo-${s.id}`}
|
||||
onChange={(e) => level && applyChange((p) => setLevelCombinationOps(p, level.id, s.id, e.target.value))}
|
||||
>
|
||||
{s.options.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
))}
|
||||
<label className="kz-parcel">
|
||||
<span>{t("designOption.drawIn")}</span>
|
||||
<select className="kz-input" value={drawKey} aria-label={t("designOption.drawIn")} data-testid="design-option-draw" onChange={(e) => setDraw(parseTarget(e.target.value))}>
|
||||
<option value="">{t("designOption.main")}</option>
|
||||
{targets.map((x) => (
|
||||
<option key={x.key} value={x.key}>
|
||||
{x.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<div className="balance-section-label">{t("designOption.selection", { n: selIds.length })}</div>
|
||||
<div className="kz-parcel">
|
||||
<select className="kz-input" value={target} aria-label={t("designOption.label")} data-testid="design-option-target" onChange={(e) => setTarget(e.target.value)}>
|
||||
<option value="">{t("designOption.main")}</option>
|
||||
{targets.map((x) => (
|
||||
<option key={x.key} value={x.key}>
|
||||
{x.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<button type="button" className="kz-add" disabled={!selIds.length} data-testid="design-option-assign" onClick={() => applyChange((p) => assignDesignOptionOps(p, selIds, parseTarget(target)))}>
|
||||
{t("designOption.assign")}
|
||||
</button>
|
||||
<button type="button" className="kz-add" disabled={!selIds.length} data-testid="design-option-copy" onClick={() => applyChange((p) => copyToDesignOptionOps(p, selIds, parseTarget(target)))}>
|
||||
{t("designOption.copy")}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<DesignOptionsTab project={project} handlers={handlers} />
|
||||
{sets.length > 0 && (
|
||||
<>
|
||||
<button type="button" className="balance-export" data-testid="design-option-compare-open" onClick={() => setShowCompare((v) => !v)}>
|
||||
{showCompare ? t("designOption.compare.hide") : t("designOption.compare.show")}
|
||||
</button>
|
||||
{showCompare && <DesignOptionCompareSection project={project} />}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import type { Project, RoomProgramRow } from "../model/types";
|
||||
import { setField, setFieldIfChanged } from "../core";
|
||||
import { RoomProgramImportButton } from "../ui/RoomProgramImportDialog";
|
||||
import { ProgramCompareSection } from "./ProgramCompareSection";
|
||||
import { DesignOptionCompareSection } from "./DesignOptionCompareSection";
|
||||
|
||||
type ProgramStatus = ReturnType<typeof checkRoomProgram>["rows"][number]["status"];
|
||||
|
||||
@@ -101,6 +102,9 @@ export function KennzahlenSection() {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* [272] Varianten: Kennzahlen und Kosten je Kombination nebeneinander (Leiste oben: Hauptvarianten). */}
|
||||
<DesignOptionCompareSection project={project} renovation={renState} />
|
||||
|
||||
<label className="kz-parcel">
|
||||
<span>{t("kennzahlen.parcelArea")}</span>
|
||||
<input
|
||||
|
||||
@@ -39,6 +39,7 @@ import { elementDimensions } from "./objectInfo/elementDims";
|
||||
import { InfoGroups, hasInfoGroups } from "./objectInfo/InfoGroups";
|
||||
import { infoGroupFrame, useInfoGroupState } from "./objectInfo/InfoGroup";
|
||||
import { RenovationField } from "./objectInfo/RenovationField";
|
||||
import { DesignOptionField } from "./objectInfo/DesignOptionField";
|
||||
|
||||
// ── Bezugspunkt-Raster ───────────────────────────────────────────────────────
|
||||
// Neun Anker als 3×3-Raster. Zeile 0 = oben (fy=0), Spalte 0 = links (fx=0).
|
||||
@@ -198,6 +199,8 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
|
||||
|
||||
{/* [271] Umbau: Status und Etappe der Auswahl (Mehrfachauswahl in einem Undo-Schritt). */}
|
||||
<RenovationField />
|
||||
{/* [272] Variante der Auswahl (Hauptmodell oder Satz: Variante; ein Undo-Schritt). */}
|
||||
<DesignOptionField />
|
||||
|
||||
{showPlacement && (
|
||||
<>
|
||||
|
||||
@@ -98,6 +98,19 @@ export function RoomBalanceTabIcon() {
|
||||
);
|
||||
}
|
||||
|
||||
/** [272] Varianten — Verzweigung in zwei Äste (A/B). */
|
||||
export function DesignOptionsTabIcon() {
|
||||
return (
|
||||
<svg {...common}>
|
||||
<path d="M8 14V8" />
|
||||
<path d="M8 8L3.5 3.5" />
|
||||
<path d="M8 8l4.5-4.5" />
|
||||
<circle cx="3.5" cy="3" r="1.2" />
|
||||
<circle cx="12.5" cy="3" r="1.2" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
/** Verlauf — Uhr mit Rückwärtspfeil. */
|
||||
export function HistoryTabIcon() {
|
||||
return (
|
||||
|
||||
@@ -30,6 +30,7 @@ import { BcfPanel } from "./BcfPanel";
|
||||
import { ClashPanel } from "./ClashPanel";
|
||||
import { HistoryPanel } from "./HistoryPanel";
|
||||
import { RenovationPanel, RenovationTabIcon } from "./RenovationPanel";
|
||||
import { DesignOptionsPanel } from "./DesignOptionsPanel";
|
||||
import { ObjectSettingsPanel } from "./objectSettings/ObjectSettingsPanel";
|
||||
import {
|
||||
ToolsTabIcon,
|
||||
@@ -41,6 +42,7 @@ import {
|
||||
RoomBalanceTabIcon,
|
||||
BcfTabIcon,
|
||||
HistoryTabIcon,
|
||||
DesignOptionsTabIcon,
|
||||
} from "./PanelIcons";
|
||||
|
||||
/** IDs der eingebauten Dock-Panels (auch für defaultLayout/Filter nutzbar). */
|
||||
@@ -58,6 +60,7 @@ export const BUILTIN_PANEL_IDS = {
|
||||
bcf: "bcf",
|
||||
clash: "clash",
|
||||
history: "history",
|
||||
designOptions: "design-options",
|
||||
objectSettings: "object-settings",
|
||||
objectLibrary: "object-library",
|
||||
renovation: "renovation",
|
||||
@@ -202,6 +205,16 @@ registerPanel({
|
||||
render: () => <HistoryPanel />,
|
||||
});
|
||||
|
||||
// [272] Varianten (Archicad „Design Options“): Sätze/Varianten, Kombination der Ansicht, Zeichen-Variante, Zuweisen,
|
||||
// Übernehmen, Vergleich. Nicht im Standard-Layout; über „Fenster > Panels“ bzw. den Chip „Variante: …“ der Statusleiste.
|
||||
registerPanel({
|
||||
id: BUILTIN_PANEL_IDS.designOptions,
|
||||
title: "designOption.title",
|
||||
icon: <DesignOptionsTabIcon />,
|
||||
hasDisplayMode: false,
|
||||
render: () => <DesignOptionsPanel />,
|
||||
});
|
||||
|
||||
// Objekteinstellungen ([195]) — Taste T: schwebendes Fenster, folgt der Auswahl; Bereiche „Objekt" (Objekt-Info)
|
||||
// und „Darstellung" (Attribute). Nicht im Standard-Layout; öffnet sich mit T bzw. „Bearbeiten > Objekteinstellungen…".
|
||||
registerPanel({
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// [272] Objekt-Info und Objekteinstellungen: „Variante“ — Hauptmodell oder eine Variante eines Satzes für die Auswahl.
|
||||
// Mehrfachauswahl: alle gewählten Elemente in einem Undo-Schritt; verschiedene Werte zeigen „gemischt“. Nur mit
|
||||
// Variantensätzen im Projekt.
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { t } from "../../i18n";
|
||||
import { assignDesignOptionOps, commonDesignOption, designOptionIds, designOptionSets, designOptionTargets, parseTarget } from "../../core";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import type { Selection } from "../../state/selection";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
import { selectionRenovationIds } from "../../state/renovationHook";
|
||||
|
||||
const MIXED = "__mixed";
|
||||
|
||||
/** Ids der Auswahl, die einer Variante angehören können (Bauteile, Räume, 2D-Zeichnungen). */
|
||||
export function selectionDesignOptionIds(sel: Selection): string[] {
|
||||
return [...selectionRenovationIds(sel), ...sel.drawings];
|
||||
}
|
||||
|
||||
export function DesignOptionField() {
|
||||
const project = useStore((s) => s.project);
|
||||
const selection = useStore((s) => s.selection);
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const ids = useMemo(() => designOptionIds(project, selectionDesignOptionIds(selection)), [project, selection]);
|
||||
const common = useMemo(() => commonDesignOption(project, ids), [project, ids]);
|
||||
if (ids.length === 0 || designOptionSets(project).length === 0) return null;
|
||||
const value = common === "mixed" || common === null ? MIXED : common;
|
||||
const options = [
|
||||
...(value === MIXED ? [{ value: MIXED, label: t("renovation.mixed") }] : []),
|
||||
{ value: "", label: t("designOption.main") },
|
||||
...designOptionTargets(project).map((x) => ({ value: x.key, label: x.label })),
|
||||
];
|
||||
return (
|
||||
<div className="objinfo-field" data-testid="objinfo-design-option">
|
||||
<span className="objinfo-flabel">{t("designOption.label")}</span>
|
||||
<Dropdown
|
||||
value={value}
|
||||
onChange={(v) => {
|
||||
if (v === MIXED) return;
|
||||
applyChange((p) => assignDesignOptionOps(p, ids, parseTarget(v)));
|
||||
}}
|
||||
options={options}
|
||||
title={t("designOption.label")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+6
-2
@@ -24,6 +24,8 @@ export interface AxoOptions extends Doc3d {
|
||||
/** [271] Umbaufilter (Id oder Name) und Etappe. */
|
||||
renovation?: string;
|
||||
renovationPhase?: string;
|
||||
/** [272] Variantenkombination (Satz-Id → Varianten-Id); fehlt = Hauptvarianten. */
|
||||
designOptions?: Record<string, string>;
|
||||
}
|
||||
|
||||
/** Kern-Abfrage `axoPlan`. */
|
||||
@@ -51,6 +53,8 @@ export function isDoc3dSnapshot(snap: Pick<ViewSnapshot, "viewType">): boolean {
|
||||
}
|
||||
|
||||
/** 3D-Dokument eines Ausschnitts (Kern: `sheet_viewports::doc3d_buf`): `doc3d`, sonst sein Blickwinkel `view3d`. */
|
||||
export function snapshotAxoPlan(project: Project, snap: ViewSnapshot, visibleCodes: Set<string>, scaleDenominator: number, mono = true): Plan | null {
|
||||
return generateAxoPlan(project, { view: snap.view3d, ...(snap.doc3d ?? {}), visibleCodes, scaleDenominator, mono });
|
||||
export function snapshotAxoPlan(project: Project, snap: ViewSnapshot, visibleCodes: Set<string>, scaleDenominator: number, mono = true, designOptions?: Record<string, string> | null): Plan | null {
|
||||
// [272] Variantenkombination des Ausschnitts bzw. Viewports.
|
||||
const opts = designOptions ?? snap.designOptions;
|
||||
return generateAxoPlan(project, { view: snap.view3d, ...(snap.doc3d ?? {}), visibleCodes, scaleDenominator, mono, ...(opts && Object.keys(opts).length ? { designOptions: opts } : {}) });
|
||||
}
|
||||
@@ -87,6 +87,8 @@ export function levelArg(level: DrawingLevel) {
|
||||
// [271] Umbaufilter und Etappe der Ebene (Kern `renovation.rs`).
|
||||
renovationFilter: level.renovationFilter,
|
||||
renovationPhase: level.renovationPhase,
|
||||
// [272] Variantenkombination der Ebene (Kern `design_options.rs`, Sichtbarkeit `renovation.rs`).
|
||||
designOptions: level.designOptions,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,8 @@ export function classFilterText(hide?: Hide3d, extra?: Record<string, unknown>):
|
||||
h.renovation = f.renovation;
|
||||
if (f.renovationPhase) h.renovationPhase = f.renovationPhase;
|
||||
}
|
||||
// [272] Variantenkombination der Ansicht (fehlt = Hauptvarianten; Kern `renovation.rs`).
|
||||
if (f.designOptions && Object.keys(f.designOptions).length) h.designOptions = f.designOptions;
|
||||
return Object.keys(h).length || extra ? JSON.stringify({ ...extra, ...h }) : "";
|
||||
}
|
||||
|
||||
@@ -125,6 +127,8 @@ export interface Filter3d {
|
||||
/** [271] Umbaufilter der Ansicht (Id) und Etappe: Ausgeblendetes fehlt, Bauteile in der Umbau-Farbe (ohne Teil-Cache). */
|
||||
renovation?: string;
|
||||
renovationPhase?: string;
|
||||
/** [272] Variantenkombination der Ansicht (Satz-Id → Varianten-Id); fehlt = Hauptvarianten. */
|
||||
designOptions?: Record<string, string>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,7 +339,8 @@ export function projectToModel3d(project: Project, opts: Model3dOptions = {}): R
|
||||
if (opts.renovationPhase) extra.renovationPhase = opts.renovationPhase;
|
||||
}
|
||||
const text = classFilterText(opts.hide, Object.keys(extra).length ? extra : undefined);
|
||||
const parts = opts.modelView || opts.renovation || filter3d(opts.hide).renovation || explode > 0 ? doc.query<Model3dParts>("model3dParts", args, text) : doc.model3dParts<Model3dParts>(args, text);
|
||||
// [272] Mit Variantensätzen ohne Änderungs-Antworten (die Teile hängen an der Kombination).
|
||||
const parts = opts.modelView || opts.renovation || filter3d(opts.hide).renovation || project.designOptionSets?.length || explode > 0 ? doc.query<Model3dParts>("model3dParts", args, text) : doc.model3dParts<Model3dParts>(args, text);
|
||||
// [115] Freie Körper als Kern-Netze (`model3d/solids.rs`) zwischen Kontext-Meshes und Stützen.
|
||||
const meshes: RMesh[] = [...parts.contextMeshes];
|
||||
for (const m of parts.solidMeshes) meshes.push(m);
|
||||
@@ -389,7 +394,8 @@ export function projectToModel3dParts(project: Project, opts: Model3dOptions = {
|
||||
const layered = opts.layeredWalls ?? true;
|
||||
const detail = opts.detail ?? "fein";
|
||||
// [271] Mit Umbaufilter ohne Teil-Cache: das ganze Modell (`projectToModel3d`).
|
||||
if (explodeGap(opts.explode) > 0 || opts.renovation || filter3d(opts.hide).renovation) return null;
|
||||
// [272] Mit Variantensätzen ebenso (die Teile hängen an der Kombination; der Kern rechnet dann ohne Cache).
|
||||
if (explodeGap(opts.explode) > 0 || opts.renovation || filter3d(opts.hide).renovation || project.designOptionSets?.length) return null;
|
||||
const voids = !!opts.voids;
|
||||
const args = [layered ? 1 : 0, DETAIL_CODE[detail] ?? 3, opts.forSection ? 1 : 0, voids ? 1 : 0, 0];
|
||||
const { parts, keyed } = documentFor(project).model3dPartsKeyed<Model3dParts>(args, classFilterText(opts.hide));
|
||||
|
||||
@@ -67,10 +67,14 @@ export async function viewportLevelPlan(
|
||||
/** [173] Modelldarstellung des Ausschnitts (`ViewSnapshot.modelViewOptionId`): geht der Ebene und der
|
||||
* Vorlage vor (Kern: `sheet_viewports::viewport_args`, Schnitt/Ansicht über `modelView`). */
|
||||
modelViewOptionId?: string | null,
|
||||
/** [272] Variantenkombination des Ausschnitts/Viewports (über der der Ebene; Kern: `sheet_viewports::snapshot_project`). */
|
||||
designOptions?: Record<string, string> | null,
|
||||
): Promise<Plan> {
|
||||
if (!template && !modelViewOptionId) return levelPlan(project, levelId, visibleCodes, detail, scaleDenominator, forPrint, mono, overrideRuleIds);
|
||||
const opts = designOptions && Object.keys(designOptions).length ? designOptions : null;
|
||||
if (!template && !modelViewOptionId && !opts) return levelPlan(project, levelId, visibleCodes, detail, scaleDenominator, forPrint, mono, overrideRuleIds);
|
||||
let tp = template ? projectWithTemplate(project, levelId, template) : project;
|
||||
if (modelViewOptionId) tp = projectWithModelView(tp, levelId, modelViewOptionId);
|
||||
if (opts) tp = projectWithDesignOptions(tp, levelId, opts);
|
||||
return withDocument(tp, () => levelPlan(tp, levelId, visibleCodes, template?.detail ?? detail, scaleDenominator, forPrint, mono, overrideRuleIds));
|
||||
}
|
||||
|
||||
@@ -78,8 +82,15 @@ export async function viewportLevelPlan(
|
||||
* Inhalt eines Ausschnitts auf dem Blatt bzw. im PDF: [266] 3D-Ausschnitte (Ansichtstyp „perspektive“) als 3D-Dokument aus dem
|
||||
* Kern (Vektor-Axonometrie/-Perspektive mit verdeckten Kanten, Kern: `sheet_viewports::doc3d_buf`), sonst {@link viewportLevelPlan}.
|
||||
*/
|
||||
export async function viewportSnapshotPlan(project: Project, snap: ViewSnapshot, visibleCodes: Set<string>, scaleDenominator: number, forPrint = false): Promise<Plan> {
|
||||
if (isDoc3dSnapshot(snap)) return snapshotAxoPlan(project, snap, visibleCodes, scaleDenominator, snapshotMono(project, snap)) ?? EMPTY;
|
||||
export async function viewportSnapshotPlan(project: Project, snap: ViewSnapshot, visibleCodes: Set<string>, scaleDenominator: number, forPrint = false, viewport?: { designOptions?: Record<string, string> | null } | null): Promise<Plan> {
|
||||
// [272] Variantenkombination: Ausschnitt, darüber die des Viewports (dieselbe Ansicht in anderer Kombination).
|
||||
const opts = viewportDesignOptions(snap, viewport);
|
||||
if (isDoc3dSnapshot(snap)) return snapshotAxoPlan(project, snap, visibleCodes, scaleDenominator, snapshotMono(project, snap), opts) ?? EMPTY;
|
||||
if (opts) {
|
||||
const dp = projectWithDesignOptions(project, snap.activeLevelId, opts);
|
||||
const fp = snap.renovationFilter ? projectWithRenovation(dp, snap.activeLevelId, snap.renovationFilter, snap.renovationPhase) : dp;
|
||||
return withDocument(fp, () => viewportLevelPlan(fp, snap.activeLevelId, visibleCodes, snap.detail, scaleDenominator, forPrint, snapshotMono(fp, snap), snapshotOverrideRuleIds(fp, snap), snapshotTemplate(fp, snap), snap.modelViewOptionId));
|
||||
}
|
||||
// [271] Umbaufilter des Ausschnitts: geht dem der Ebene vor (wie im Kern `sheet_viewports::viewport_args`).
|
||||
if (snap.renovationFilter) {
|
||||
const rp = projectWithRenovation(project, snap.activeLevelId, snap.renovationFilter, snap.renovationPhase);
|
||||
@@ -88,6 +99,17 @@ export async function viewportSnapshotPlan(project: Project, snap: ViewSnapshot,
|
||||
return viewportLevelPlan(project, snap.activeLevelId, visibleCodes, snap.detail, scaleDenominator, forPrint, snapshotMono(project, snap), snapshotOverrideRuleIds(project, snap), snapshotTemplate(project, snap), snap.modelViewOptionId);
|
||||
}
|
||||
|
||||
/** [272] Kombination eines Ausschnitts samt Viewport (Viewport geht vor); `null` ohne eigene Wahl. */
|
||||
export function viewportDesignOptions(snap: { designOptions?: Record<string, string> | null }, viewport?: { designOptions?: Record<string, string> | null } | null): Record<string, string> | null {
|
||||
const m = { ...(snap.designOptions ?? {}), ...(viewport?.designOptions ?? {}) };
|
||||
return Object.keys(m).length ? m : null;
|
||||
}
|
||||
|
||||
/** [272] Das Projekt mit der Variantenkombination `opts` an der Ebene `levelId` (über deren eigener Wahl). */
|
||||
export function projectWithDesignOptions(project: Project, levelId: string, opts: Record<string, string>): Project {
|
||||
return { ...project, drawingLevels: project.drawingLevels.map((l) => (l.id === levelId ? { ...l, designOptions: { ...(l.designOptions ?? {}), ...opts } } : l)) };
|
||||
}
|
||||
|
||||
/** [271] Das Projekt mit Umbaufilter `filter` (und Etappe) an der Ebene `levelId`. */
|
||||
export function projectWithRenovation(project: Project, levelId: string, filter: string, phase?: string): Project {
|
||||
return { ...project, drawingLevels: project.drawingLevels.map((l) => (l.id === levelId ? { ...l, renovationFilter: filter, ...(phase ? { renovationPhase: phase } : {}) } : l)) };
|
||||
|
||||
@@ -579,7 +579,11 @@ export function createProjectSlice(
|
||||
const applyCmd = (req0: object, coalesceKey?: string) => {
|
||||
// [271] Aktueller Zeichen-Status: der Kern gibt ihn neuen Bauteilen der Zeichenbefehle (`commands::stamp_renovation`).
|
||||
const dr = (get() as unknown as { drawRenovation?: { status: string; phase?: string } }).drawRenovation;
|
||||
const req = dr && (dr.status !== "existing" || dr.phase) ? { ...req0, renovation: dr } : req0;
|
||||
const req1 = dr && (dr.status !== "existing" || dr.phase) ? { ...req0, renovation: dr } : req0;
|
||||
// [272] Aktuelle Zeichen-Variante: neue Elemente der Zeichenbefehle gehören ihr (`design_options::stamp_ops`).
|
||||
const dopt = (get() as unknown as { drawDesignOption?: { set: string; option: string } | null }).drawDesignOption;
|
||||
const known = dopt && get().project.designOptionSets?.some((s) => s.id === dopt.set && s.options.some((o) => o.id === dopt.option));
|
||||
const req = known ? { ...req1, designOption: dopt } : req1;
|
||||
if (forwarded(() => storeDocument(get().project).cmdOps(req), coalesceKey)) return;
|
||||
let notice: string | undefined;
|
||||
set((s) => {
|
||||
|
||||
@@ -62,8 +62,12 @@ declare global {
|
||||
context: () => { id: string; type: string; first?: { x: number; y: number } }[];
|
||||
/** [271] Füllfarben der Element-Flächen im Grundriss der aktiven Ebene (Farbe → Anzahl, alle Klassen, 1:100). */
|
||||
planFillColors: () => Record<string, number>;
|
||||
/** [272] Öffnungs-Ids im Grundriss der aktiven Ebene (alle Klassen, 1:100). */
|
||||
planOpeningIds: () => string[];
|
||||
/** [271] Umbau: Filter und Etappe der aktiven Ebene, Zeichen-Status, Status je Wand. */
|
||||
renovation: () => { filter: string | null; phase: string | null; draw: string; walls: Record<string, string> };
|
||||
/** [272] Varianten: Kombination der aktiven Ebene, Zeichen-Variante, Variante je Element (`set/option`, leer = Hauptmodell), Sätze. */
|
||||
designOptions: () => { level: Record<string, string>; draw: string | null; elements: Record<string, string>; sets: string[] };
|
||||
/** [193] Gefüllte Flächen (Füllfarbe gesetzt) im Grundriss der aktiven Ebene (alle Kategorien, 1:100); bei 0 ist nichts Gefülltes mehr zu sehen. */
|
||||
planFills: () => number;
|
||||
/** [193] Höhe (z) des ersten Gelände-Netz-Punkts. */
|
||||
@@ -157,6 +161,23 @@ export function installTestHooks(): void {
|
||||
walk(s.project.layers);
|
||||
return generatePlan(s.project, s.activeLevelId, codes, undefined, s.detail, false, false, true, 50).primitives.filter((q) => q.kind === "line" && q.cls === cls).length;
|
||||
},
|
||||
planOpeningIds: () => {
|
||||
const s = getState();
|
||||
const codes = new Set<string>();
|
||||
const walk = (cs: { code: string; children?: unknown[] }[]): void => {
|
||||
for (const c of cs) {
|
||||
codes.add(c.code);
|
||||
walk((c.children ?? []) as { code: string; children?: unknown[] }[]);
|
||||
}
|
||||
};
|
||||
walk(s.project.layers);
|
||||
const ids = new Set<string>();
|
||||
for (const q of generatePlan(s.project, s.activeLevelId, codes, undefined, s.detail, false, false, true, 100).primitives) {
|
||||
const o = (q as { openingId?: string }).openingId;
|
||||
if (o) ids.add(o);
|
||||
}
|
||||
return [...ids].sort();
|
||||
},
|
||||
planFillColors: () => {
|
||||
const s = getState();
|
||||
const codes = new Set<string>();
|
||||
@@ -174,6 +195,15 @@ export function installTestHooks(): void {
|
||||
}
|
||||
return out;
|
||||
},
|
||||
designOptions: () => {
|
||||
const s = getState();
|
||||
const l = s.project.drawingLevels.find((x) => x.id === s.activeLevelId);
|
||||
const elements: Record<string, string> = {};
|
||||
for (const list of [s.project.walls, s.project.openings, s.project.roofs, s.project.ceilings, s.project.rooms]) {
|
||||
for (const e of (list ?? []) as { id: string; designOption?: { set: string; option: string } }[]) elements[e.id] = e.designOption ? `${e.designOption.set}/${e.designOption.option}` : "";
|
||||
}
|
||||
return { level: l?.designOptions ?? {}, draw: s.drawDesignOption ? `${s.drawDesignOption.set}/${s.drawDesignOption.option}` : null, elements, sets: (s.project.designOptionSets ?? []).map((x) => x.id) };
|
||||
},
|
||||
renovation: () => {
|
||||
const s = getState();
|
||||
const l = s.project.drawingLevels.find((x) => x.id === s.activeLevelId);
|
||||
|
||||
@@ -90,6 +90,7 @@ export function useNativeMenu(opts: {
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromVariantenSample,
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
@@ -121,6 +122,7 @@ export function useNativeMenu(opts: {
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromVariantenSample,
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
|
||||
@@ -51,6 +51,7 @@ import { withNewProjectNames } from "../model/newProjectNames";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { buildWettbewerbSampleProject } from "../model/sampleProjectWettbewerb";
|
||||
import { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
|
||||
import { buildVariantenSampleProject } from "../model/sampleProjectVarianten";
|
||||
import { withStandards } from "../model/standards";
|
||||
import type { Project } from "../model/types";
|
||||
import type { PlanViewHandle } from "../views/plan/PlanView";
|
||||
@@ -578,6 +579,13 @@ export function useProjectFileActions(
|
||||
getState().loadProject(next);
|
||||
lastSavedProjectRef.current = next;
|
||||
});
|
||||
// [272] „Neu aus Vorlage: Beispiel Varianten" — Demo-Haus mit den Sätzen Dachform (Flach-/Satteldach) und Fassade.
|
||||
const onNewProjectFromVariantenSample = () => guardDiscard(() => {
|
||||
releaseCurrentProjectLock();
|
||||
const next = buildVariantenSampleProject();
|
||||
getState().loadProject(next);
|
||||
lastSavedProjectRef.current = next;
|
||||
});
|
||||
// „Neu aus Vorlage: Datei wählen…" — native `.obpt`-Dialog unter Tauri, sonst
|
||||
// das versteckte `<input type=file>` (projectTemplateFileInputRef).
|
||||
const onNewProjectFromTemplate = () => {
|
||||
@@ -923,6 +931,7 @@ export function useProjectFileActions(
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromVariantenSample,
|
||||
onNewProjectFromTemplate,
|
||||
onProjectTemplateFileChosen,
|
||||
releaseCurrentProjectLock,
|
||||
|
||||
@@ -18,7 +18,7 @@ import type { useProjectActions } from "./useProjectActions";
|
||||
import type { useTopBarState } from "./useTopBarState";
|
||||
import { useViewTemplateHandlers } from "./useViewTemplateHandlers";
|
||||
import { modelViewHandlers } from "./useModelViewHandlers";
|
||||
import { setField, setPhasesOps } from "../core";
|
||||
import { setField, setPhasesOps, addDesignOptionSetOps, renameDesignOptionSetOps, addDesignOptionOps, renameDesignOptionOps, setPrimaryOptionOps, acceptDesignOptionOps, deleteDesignOptionOps } from "../core";
|
||||
|
||||
type TopBar = ReturnType<typeof useTopBarState>;
|
||||
type Dialogs = ReturnType<typeof useDialogState>;
|
||||
@@ -145,6 +145,14 @@ export function useResourceHandlers(opts: {
|
||||
else delete next.styles;
|
||||
return [setField("renovation", Object.keys(next).length ? next : undefined)];
|
||||
}),
|
||||
// [272] Varianten (Ressourcen-Tab „Varianten“): Sätze/Varianten, Hauptvariante, Übernehmen, Löschen (je ein Undo-Schritt).
|
||||
onAddDesignOptionSet: (name) => applyChange((p) => addDesignOptionSetOps(p, name).ops),
|
||||
onRenameDesignOptionSet: (setId, name) => applyChange((p) => renameDesignOptionSetOps(p, setId, name), `dopt-set-${setId}`),
|
||||
onAddDesignOption: (setId) => applyChange((p) => addDesignOptionOps(p, setId)),
|
||||
onRenameDesignOption: (setId, optionId, name) => applyChange((p) => renameDesignOptionOps(p, setId, optionId, name), `dopt-${setId}-${optionId}`),
|
||||
onSetPrimaryDesignOption: (setId, optionId) => applyChange((p) => setPrimaryOptionOps(p, setId, optionId)),
|
||||
onAcceptDesignOption: (setId, optionId) => applyChange((p) => acceptDesignOptionOps(p, setId, optionId)),
|
||||
onDeleteDesignOption: (setId, optionId) => applyChange((p) => deleteDesignOptionOps(p, setId, optionId)),
|
||||
onPatchComponent: patchComponent,
|
||||
onPatchWallType: patchWallType,
|
||||
onAddWallType: addWallType,
|
||||
|
||||
@@ -27,6 +27,12 @@ export interface ViewSlice {
|
||||
*/
|
||||
drawRenovation: { status: RenovationStatus; phase?: string };
|
||||
setDrawRenovation: (status: RenovationStatus, phase?: string) => void;
|
||||
/**
|
||||
* [272] Aktuelle Zeichen-Variante: neue Elemente der Zeichenbefehle gehören ihr (`null` = Hauptmodell). Zustand der
|
||||
* Sitzung, kein Undo-Schritt.
|
||||
*/
|
||||
drawDesignOption: { set: string; option: string } | null;
|
||||
setDrawDesignOption: (target: { set: string; option: string } | null) => void;
|
||||
// Ansichtstyp (Grundriss / Perspektive).
|
||||
viewType: ViewType;
|
||||
// Zuletzt gewählter Ansichtstyp je Zeichnungsebene — jeder Tab merkt sich
|
||||
@@ -100,6 +106,8 @@ export function createViewSlice(api: StoreApi<ViewSlice>): ViewSlice {
|
||||
activeLevelId: sampleProject.drawingLevels[0].id,
|
||||
drawRenovation: { status: "existing" },
|
||||
setDrawRenovation: (status, phase) => set({ drawRenovation: phase ? { status, phase } : { status } }),
|
||||
drawDesignOption: null,
|
||||
setDrawDesignOption: (target) => set({ drawDesignOption: target }),
|
||||
viewType: "grundriss",
|
||||
viewTypeByLevel: {},
|
||||
detail: "mittel",
|
||||
|
||||
+73
-1
@@ -9404,7 +9404,7 @@ body {
|
||||
}
|
||||
.rpi-table th,
|
||||
.rpi-table td {
|
||||
padding: 2px 6px;
|
||||
padding: 2px 4px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
@@ -9897,4 +9897,76 @@ body {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
/* [272] Varianten: Vergleichstabelle (Flächenbilanz) und Ressourcen-Tab. */
|
||||
.kz-variants-scroll {
|
||||
overflow-x: auto;
|
||||
}
|
||||
.kz-variants-table {
|
||||
border-collapse: collapse;
|
||||
font-size: 11px;
|
||||
width: 100%;
|
||||
}
|
||||
.kz-variants-table th,
|
||||
.kz-variants-table td {
|
||||
padding: 2px 4px;
|
||||
border-bottom: 1px solid rgba(127, 127, 127, 0.25);
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.kz-variants-table td:first-child {
|
||||
white-space: normal;
|
||||
min-width: 110px;
|
||||
}
|
||||
.kz-variants-table th {
|
||||
white-space: normal;
|
||||
}
|
||||
.kz-variants-table td.num {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.kz-variants-primary td {
|
||||
font-weight: 600;
|
||||
}
|
||||
.rm-design-option-set {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.rm-design-option {
|
||||
padding-left: 16px;
|
||||
}
|
||||
.rm-design-option-count {
|
||||
min-width: 2em;
|
||||
text-align: right;
|
||||
opacity: 0.7;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.rm-design-options .rm-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin: 2px 0;
|
||||
}
|
||||
.rm-design-options .rm-row input[type="text"] {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
.rm-design-options .rm-icon-btn {
|
||||
padding: 0 2px;
|
||||
line-height: 1;
|
||||
}
|
||||
.rm-design-options .rm-icon-btn .material-symbols-outlined {
|
||||
font-size: 16px;
|
||||
}
|
||||
.rm-design-options .rm-add-btn {
|
||||
white-space: nowrap;
|
||||
font-size: 11px;
|
||||
}
|
||||
.rm-design-options .rm-hint {
|
||||
font-size: 11px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.design-options-panel {
|
||||
padding: 4px 8px 8px;
|
||||
}
|
||||
.design-options-panel .kz-parcel select {
|
||||
max-width: 170px;
|
||||
}
|
||||
@@ -26,6 +26,7 @@ export interface AppMenuBarProps {
|
||||
onNewProjectFromComplexSample: () => void;
|
||||
onNewProjectFromWettbewerbSample: () => void;
|
||||
onNewProjectFromUmbauSample?: () => void;
|
||||
onNewProjectFromVariantenSample?: () => void;
|
||||
onNewProjectFromTemplate: () => void;
|
||||
onOpenProject: () => void;
|
||||
onSaveProject: () => void;
|
||||
@@ -68,6 +69,8 @@ export interface AppMenuBarProps {
|
||||
onOpenBcf?: () => void;
|
||||
/** Verlauf-Panel öffnen ([84]). */
|
||||
onOpenHistory?: () => void;
|
||||
/** [272] Panel „Varianten“ öffnen. */
|
||||
onOpenDesignOptions?: () => void;
|
||||
}
|
||||
|
||||
/** Menüleiste (Bearbeiten/Ansicht/Fenster) — sitzt in der TopBar neben der Wortmarke. */
|
||||
@@ -77,6 +80,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
onNewProjectFromComplexSample,
|
||||
onNewProjectFromWettbewerbSample,
|
||||
onNewProjectFromUmbauSample,
|
||||
onNewProjectFromVariantenSample,
|
||||
onNewProjectFromTemplate,
|
||||
onOpenProject,
|
||||
onSaveProject,
|
||||
@@ -107,6 +111,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
onOpenSettings,
|
||||
onOpenBcf,
|
||||
onOpenHistory,
|
||||
onOpenDesignOptions,
|
||||
}: AppMenuBarProps) {
|
||||
const fileItems: DropdownItem[] = [
|
||||
{ label: t("file.new"), onSelect: onNewProject },
|
||||
@@ -114,6 +119,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
{ label: t("file.newFromComplexSample"), onSelect: onNewProjectFromComplexSample },
|
||||
{ label: t("file.newFromWettbewerbSample"), onSelect: onNewProjectFromWettbewerbSample },
|
||||
...(onNewProjectFromUmbauSample ? [{ label: t("file.newFromUmbauSample"), onSelect: onNewProjectFromUmbauSample }] : []),
|
||||
...(onNewProjectFromVariantenSample ? [{ label: t("file.newFromVariantenSample"), onSelect: onNewProjectFromVariantenSample }] : []),
|
||||
{ label: t("file.newFromTemplateFile"), onSelect: onNewProjectFromTemplate },
|
||||
{ divider: true },
|
||||
{ label: t("file.open"), onSelect: onOpenProject },
|
||||
@@ -136,6 +142,7 @@ export const AppMenuBar = memo(function AppMenuBar({
|
||||
{ label: t("menu.edit.undo"), onSelect: onUndo, disabled: !canUndo },
|
||||
{ label: t("menu.edit.redo"), onSelect: onRedo, disabled: !canRedo },
|
||||
...(onOpenHistory ? [{ label: t("nav.history"), onSelect: onOpenHistory }] : []),
|
||||
...(onOpenDesignOptions ? [{ label: t("designOption.title"), onSelect: onOpenDesignOptions }] : []),
|
||||
{ divider: true },
|
||||
{
|
||||
label: t("menu.edit.delete"),
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// [272] Chip „Variante: …“ in der Statusleiste (neben „Umbau“): zeigt die Variantenkombination der aktiven Ansicht (nur die
|
||||
// Abweichungen von den Hauptvarianten) und öffnet per Klick das Panel „Varianten“, in dem man sie einstellt. Nur sichtbar,
|
||||
// wenn das Projekt Variantensätze hat; bei wenig Platz wandert es mit Pausfolie und „Umbau“ in „⋯“ ([263]).
|
||||
|
||||
import { t } from "../i18n";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { combinationSuffix, designOptionTargets } from "../core";
|
||||
|
||||
export function DesignOptionControl() {
|
||||
const project = useStore((s) => s.project);
|
||||
const activeLevelId = useStore((s) => s.activeLevelId);
|
||||
const draw = useStore((s) => s.drawDesignOption);
|
||||
if (!project.designOptionSets?.length) return null;
|
||||
const level = project.drawingLevels.find((l) => l.id === activeLevelId);
|
||||
const suffix = combinationSuffix(project, level?.designOptions);
|
||||
const drawKey = draw ? `${draw.set}/${draw.option}` : "";
|
||||
const drawLabel = designOptionTargets(project).find((x) => x.key === drawKey)?.label ?? t("designOption.main");
|
||||
const shown = suffix || t("designOption.primaryCombination");
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`sb-toggle${suffix || draw ? " sb-renovation-on" : ""}`}
|
||||
data-testid="design-option-toggle"
|
||||
title={t("designOption.hint", { combination: shown, draw: drawLabel })}
|
||||
onClick={() => window.dispatchEvent(new CustomEvent("dossier:reveal-panel", { detail: "design-options" }))}
|
||||
>
|
||||
{t("designOption.short", { combination: shown })}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
+31
-6
@@ -44,7 +44,7 @@ import {
|
||||
type GuideHit,
|
||||
} from "./sheetSnap";
|
||||
import { createLayoutImage, imageAspect, imageGeometry } from "../model/layoutImages";
|
||||
import { posterHeaderItems, viewportScaleLabel } from "../model/posterTemplates";
|
||||
import { posterHeaderItems, viewportScaleLabel, viewportVariantLabel } from "../model/posterTemplates";
|
||||
import { planToPrintSvg } from "../export/planToPrintSvg";
|
||||
import { legendPlan, legendPrintSvg } from "../export/legendSvg";
|
||||
import { legendBox, legendEntries, legendKeysOfViewports, type LegendKind } from "../analysis/legend";
|
||||
@@ -111,7 +111,8 @@ export function ViewportPlanSvg({
|
||||
// Massstab ZUERST: er geht in die Plan-Erzeugung ein (Bemassung in Papier-mm, s. model/dimension.ts).
|
||||
const scaleN = resolveViewportScale(viewport, snap);
|
||||
// Geschoss/Zeichnung wie bisher; Schnitt/Ansicht über die abgeleitete Projektion ([115], Schnitt asynchron).
|
||||
void viewportSnapshotPlan(project, snap, codes, scaleN)
|
||||
// [272] Eigene Variantenkombination des Viewports (dieselbe Ansicht in anderer Kombination).
|
||||
void viewportSnapshotPlan(project, snap, codes, scaleN, false, viewport)
|
||||
.then((plan) => {
|
||||
if (disposed) return;
|
||||
const print = planToPrintSvg(plan, {
|
||||
@@ -130,7 +131,7 @@ export function ViewportPlanSvg({
|
||||
return () => {
|
||||
disposed = true;
|
||||
};
|
||||
}, [project, viewport.snapshotId, viewport.widthMm, viewport.heightMm, viewport.scaleDenominator, viewport.center?.x, viewport.center?.y]);
|
||||
}, [project, viewport.snapshotId, viewport.widthMm, viewport.heightMm, viewport.scaleDenominator, viewport.center?.x, viewport.center?.y, viewport.designOptions]);
|
||||
// Lage/Grösse über die Attribute des inneren SVG (folgt auch dem Ghost beim Ziehen).
|
||||
useEffect(() => {
|
||||
if (ref.current) placeInner(ref.current, rect);
|
||||
@@ -803,9 +804,9 @@ export function LayoutSheetPane({
|
||||
);
|
||||
})}
|
||||
{/* Massstab unter jedem Viewport (Master „Massstabsangaben"). */}
|
||||
{master?.viewportScaleLabels &&
|
||||
layout.viewports.map((vp) => {
|
||||
const l = viewportScaleLabel(project, vp, sheet);
|
||||
{layout.viewports.map((vp) => {
|
||||
// [272] Ohne Massstabsangaben des Masters nur der Titelzusatz der Varianten (falls abweichend).
|
||||
const l = master?.viewportScaleLabels ? viewportScaleLabel(project, vp, sheet) : viewportVariantLabel(project, vp, sheet);
|
||||
return l ? (
|
||||
<text key={`sl-${vp.id}`} x={l.x} y={l.y} fontSize={l.sizeMm} fontFamily="Helvetica, Arial, sans-serif" fill="#111111" pointerEvents="none" data-scale-label>
|
||||
{l.text}
|
||||
@@ -1217,6 +1218,30 @@ export function LayoutSheetPane({
|
||||
/>
|
||||
</span>
|
||||
</label>
|
||||
{/* [272] Eigene Variantenkombination des Viewports: dieselbe Ansicht in anderer Kombination (Titelzusatz). */}
|
||||
{(project.designOptionSets ?? []).map((s) => (
|
||||
<label key={s.id} className="layout-sheet-hud-row">
|
||||
<span>{s.name}</span>
|
||||
<select
|
||||
className="res-input"
|
||||
data-testid={`vp-design-option-${s.id}`}
|
||||
value={selectedVp.designOptions?.[s.id] ?? ""}
|
||||
onChange={(e) => {
|
||||
const next = { ...(selectedVp.designOptions ?? {}) };
|
||||
if (e.target.value) next[s.id] = e.target.value;
|
||||
else delete next[s.id];
|
||||
handlers.onPatchViewport(selectedVp.id, { designOptions: Object.keys(next).length ? next : undefined });
|
||||
}}
|
||||
>
|
||||
<option value="">{t("designOption.fromSnapshot")}</option>
|
||||
{s.options.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
))}
|
||||
<div className="layout-sheet-hud-size">
|
||||
{Math.round(selectedVp.widthMm)} × {Math.round(selectedVp.heightMm)} mm
|
||||
</div>
|
||||
|
||||
@@ -48,6 +48,8 @@ import { ModelViewsTab } from "./resourceManager/ModelViewsTab";
|
||||
import type { ModelViewHandlers } from "./resourceManager/ModelViewsTab";
|
||||
import { RenovationTab } from "./resourceManager/RenovationTab";
|
||||
import type { RenovationHandlers } from "./resourceManager/RenovationTab";
|
||||
import { DesignOptionsTab } from "./resourceManager/DesignOptionsTab";
|
||||
import type { DesignOptionHandlers } from "./resourceManager/DesignOptionsTab";
|
||||
import { PenSetsTab } from "./resourceManager/PenSetsTab";
|
||||
import { PalettesTab } from "./resourceManager/PalettesTab";
|
||||
import { TextStylesTab } from "./resourceManager/TextStylesTab";
|
||||
@@ -72,6 +74,7 @@ export type TabId =
|
||||
| "viewTemplates"
|
||||
| "modelViews"
|
||||
| "renovation"
|
||||
| "designOptions"
|
||||
| "pens"
|
||||
| "palettes";
|
||||
|
||||
@@ -93,10 +96,11 @@ const TABS: { id: TabId; labelKey: string }[] = [
|
||||
{ id: "viewTemplates", labelKey: "resources.tab.viewTemplates" },
|
||||
{ id: "modelViews", labelKey: "resources.tab.modelViews" },
|
||||
{ id: "renovation", labelKey: "resources.tab.renovation" },
|
||||
{ id: "designOptions", labelKey: "resources.tab.designOptions" },
|
||||
];
|
||||
|
||||
/** Bündel der immutablen Mutationen (von App über setProject bereitgestellt). */
|
||||
export interface ResourceManagerHandlers extends ViewTemplateHandlers, ModelViewHandlers, RenovationHandlers {
|
||||
export interface ResourceManagerHandlers extends ViewTemplateHandlers, ModelViewHandlers, RenovationHandlers, DesignOptionHandlers {
|
||||
onPatchComponent: (id: string, patch: Partial<Component>) => void;
|
||||
onAddComponent: () => void;
|
||||
onDeleteComponent: (id: string) => void;
|
||||
@@ -496,6 +500,7 @@ export function ResourceManager({
|
||||
{tab === "viewTemplates" && <ViewTemplatesTab project={project} handlers={handlers} />}
|
||||
{tab === "modelViews" && <ModelViewsTab project={project} handlers={handlers} />}
|
||||
{tab === "renovation" && <RenovationTab project={project} handlers={handlers} />}
|
||||
{tab === "designOptions" && <DesignOptionsTab project={project} handlers={handlers} />}
|
||||
{tab === "overrides" && (
|
||||
<OverridesTab
|
||||
project={project}
|
||||
|
||||
+12
-1
@@ -16,6 +16,8 @@ import type { SnapSettings } from "../tools/types";
|
||||
import { t } from "../i18n";
|
||||
import { TraceControl } from "./TraceControl";
|
||||
import { RenovationControl } from "./RenovationControl";
|
||||
import { DesignOptionControl } from "./DesignOptionControl";
|
||||
import { useStore } from "../state/appStore";
|
||||
import { BUILD_INFO, formatBuildShort } from "../update/buildInfo";
|
||||
|
||||
export interface StatusBarProps {
|
||||
@@ -488,6 +490,9 @@ export const StatusBar = memo(function StatusBar({
|
||||
);
|
||||
const traceEl = <TraceControl enabled={!!traceEnabled} onRunCommand={onRunCommand} />;
|
||||
const renovationEl = <RenovationControl />;
|
||||
// [272] Varianten (nur mit Variantensätzen im Projekt; sonst leer).
|
||||
const hasDesignOptions = useStore((s) => !!s.project.designOptionSets?.length);
|
||||
const designOptionEl = <DesignOptionControl />;
|
||||
const snapEl = <SnapControl snap={snap} onSnapChange={onSnapChange} />;
|
||||
const refEl = (
|
||||
<button
|
||||
@@ -504,7 +509,7 @@ export const StatusBar = memo(function StatusBar({
|
||||
// Was in „⋯“ wandert (Reihenfolge = Wegfall-Priorität von oben nach unten).
|
||||
const inMore: React.ReactNode[] = [];
|
||||
if (level >= 3) inMore.push(<span key="lm">{lineModeEl}</span>);
|
||||
if (level >= 4) inMore.push(<span key="tr">{traceEl}</span>, <span key="ren">{renovationEl}</span>);
|
||||
if (level >= 4) inMore.push(<span key="tr">{traceEl}</span>, <span key="ren">{renovationEl}</span>, <span key="dopt">{designOptionEl}</span>);
|
||||
if (level >= 5) {
|
||||
inMore.push(<span key="sn">{snapEl}</span>, <span key="rf">{refEl}</span>);
|
||||
}
|
||||
@@ -535,6 +540,12 @@ export const StatusBar = memo(function StatusBar({
|
||||
<Sep />
|
||||
{renovationEl}
|
||||
<Sep />
|
||||
{hasDesignOptions && (
|
||||
<>
|
||||
{designOptionEl}
|
||||
<Sep />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{level < 5 && (
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// [272] Ressourcen-Tab „Varianten“: Variantensätze (z. B. „Dachform“) mit ihren Varianten anlegen, umbenennen, löschen;
|
||||
// Hauptvariante wählen; „Variante übernehmen“ (ihre Elemente ins Hauptmodell, die übrigen Varianten des Satzes werden
|
||||
// gelöscht — ein Undo-Schritt). Reine Darstellung über Handler mit Werten (auch im macOS-Nebenfenster).
|
||||
|
||||
import { useState } from "react";
|
||||
import { t } from "../../i18n";
|
||||
import type { Project } from "../../model/types";
|
||||
import { designOptionSets, primaryOption } from "../../core";
|
||||
|
||||
export interface DesignOptionHandlers {
|
||||
onAddDesignOptionSet?: (name: string) => void;
|
||||
onRenameDesignOptionSet?: (setId: string, name: string) => void;
|
||||
onAddDesignOption?: (setId: string) => void;
|
||||
onRenameDesignOption?: (setId: string, optionId: string, name: string) => void;
|
||||
onSetPrimaryDesignOption?: (setId: string, optionId: string) => void;
|
||||
/** Variante übernehmen: Elemente ins Hauptmodell, übrige Varianten des Satzes gelöscht, Satz weg. */
|
||||
onAcceptDesignOption?: (setId: string, optionId: string) => void;
|
||||
/** Satz (ohne `optionId`) bzw. Variante samt ihren Elementen löschen. */
|
||||
onDeleteDesignOption?: (setId: string, optionId?: string) => void;
|
||||
}
|
||||
|
||||
/** Zahl der Elemente je Variante (Satz-Id → Varianten-Id → Anzahl). */
|
||||
function counts(project: Project): Map<string, number> {
|
||||
const out = new Map<string, number>();
|
||||
const lists = [project.walls, project.openings, project.ceilings, project.roofs, project.stairs, project.columns, project.extrudedSolids, project.rooms, project.drawings2d];
|
||||
for (const list of lists) {
|
||||
for (const e of (list ?? []) as { designOption?: { set: string; option: string } }[]) {
|
||||
if (!e.designOption) continue;
|
||||
const k = `${e.designOption.set}/${e.designOption.option}`;
|
||||
out.set(k, (out.get(k) ?? 0) + 1);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export function DesignOptionsTab({ project, handlers }: { project: Project; handlers: DesignOptionHandlers }) {
|
||||
const sets = designOptionSets(project);
|
||||
const [newName, setNewName] = useState("");
|
||||
const n = counts(project);
|
||||
const add = () => {
|
||||
if (!handlers.onAddDesignOptionSet) return;
|
||||
handlers.onAddDesignOptionSet(newName.trim() || t("designOption.set.defaultName", { n: sets.length + 1 }));
|
||||
setNewName("");
|
||||
};
|
||||
return (
|
||||
<div className="rm-design-options" data-testid="rm-design-options">
|
||||
<h4 className="rm-subhead">{t("designOption.sets.title")}</h4>
|
||||
<p className="rm-hint">{t("designOption.sets.hint")}</p>
|
||||
{sets.length === 0 && <div className="rm-empty">{t("designOption.sets.empty")}</div>}
|
||||
{sets.map((s) => {
|
||||
const prim = primaryOption(s);
|
||||
return (
|
||||
<div key={s.id} className="rm-design-option-set" data-testid="rm-design-option-set">
|
||||
<div className="rm-row">
|
||||
<input
|
||||
type="text"
|
||||
value={s.name}
|
||||
aria-label={t("designOption.set")}
|
||||
disabled={!handlers.onRenameDesignOptionSet}
|
||||
onChange={(e) => handlers.onRenameDesignOptionSet?.(s.id, e.target.value)}
|
||||
/>
|
||||
<button type="button" className="rm-icon-btn" title={t("designOption.option.add")} aria-label={t("designOption.option.add")} disabled={!handlers.onAddDesignOption} onClick={() => handlers.onAddDesignOption?.(s.id)} data-testid="rm-design-option-add">
|
||||
<span className="material-symbols-outlined" aria-hidden="true">add</span>
|
||||
</button>
|
||||
<button type="button" className="rm-icon-btn" title={t("designOption.set.delete")} aria-label={t("designOption.set.delete")} disabled={!handlers.onDeleteDesignOption} onClick={() => handlers.onDeleteDesignOption?.(s.id)}>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">delete</span>
|
||||
</button>
|
||||
</div>
|
||||
{s.options.map((o) => (
|
||||
<div className="rm-row rm-design-option" key={o.id} data-testid="rm-design-option">
|
||||
<label className="rm-design-option-primary" title={t("designOption.primary")}>
|
||||
<input type="radio" name={`primary-${s.id}`} checked={prim === o.id} disabled={!handlers.onSetPrimaryDesignOption} onChange={() => handlers.onSetPrimaryDesignOption?.(s.id, o.id)} aria-label={t("designOption.primary")} />
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={o.name}
|
||||
aria-label={t("designOption.option")}
|
||||
disabled={!handlers.onRenameDesignOption}
|
||||
onChange={(e) => handlers.onRenameDesignOption?.(s.id, o.id, e.target.value)}
|
||||
/>
|
||||
<span className="rm-design-option-count" title={t("designOption.count")}>
|
||||
{n.get(`${s.id}/${o.id}`) ?? 0}
|
||||
</span>
|
||||
<button type="button" className="rm-add-btn" disabled={!handlers.onAcceptDesignOption} onClick={() => handlers.onAcceptDesignOption?.(s.id, o.id)} title={t("designOption.accept.hint")} data-testid="rm-design-option-accept">
|
||||
{t("designOption.accept")}
|
||||
</button>
|
||||
<button type="button" className="rm-icon-btn" title={t("designOption.option.delete")} aria-label={t("designOption.option.delete")} disabled={!handlers.onDeleteDesignOption} onClick={() => handlers.onDeleteDesignOption?.(s.id, o.id)}>
|
||||
<span className="material-symbols-outlined" aria-hidden="true">delete</span>
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<div className="rm-row">
|
||||
<input type="text" value={newName} placeholder={t("designOption.set.placeholder")} aria-label={t("designOption.set.new")} onChange={(e) => setNewName(e.target.value)} onKeyDown={(e) => e.key === "Enter" && add()} data-testid="rm-design-option-set-name" />
|
||||
<button type="button" className="rm-add-btn" disabled={!handlers.onAddDesignOptionSet} onClick={add} data-testid="rm-design-option-set-add">
|
||||
{t("designOption.set.add")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -31,6 +31,7 @@ export type TopBarEvents = Required<
|
||||
| "onNewProjectFromComplexSample"
|
||||
| "onNewProjectFromWettbewerbSample"
|
||||
| "onNewProjectFromUmbauSample"
|
||||
| "onNewProjectFromVariantenSample"
|
||||
| "onNewProjectFromTemplate"
|
||||
| "onOpenProject"
|
||||
| "onSaveProject"
|
||||
@@ -135,6 +136,7 @@ export function useTopBarElements(opts: {
|
||||
onNewProjectFromComplexSample={ev.onNewProjectFromComplexSample}
|
||||
onNewProjectFromWettbewerbSample={ev.onNewProjectFromWettbewerbSample}
|
||||
onNewProjectFromUmbauSample={ev.onNewProjectFromUmbauSample}
|
||||
onNewProjectFromVariantenSample={ev.onNewProjectFromVariantenSample}
|
||||
onNewProjectFromTemplate={ev.onNewProjectFromTemplate}
|
||||
onOpenProject={ev.onOpenProject}
|
||||
onSaveProject={ev.onSaveProject}
|
||||
|
||||
@@ -626,6 +626,11 @@ export function Wasm3DViewport({
|
||||
const l = s.project.drawingLevels.find((x) => x.id === s.activeLevelId);
|
||||
return l?.renovationFilter ? `${l.renovationFilter}\u0001${l.renovationPhase ?? ""}` : "";
|
||||
});
|
||||
// [272] Variantenkombination der aktiven Ebene (wie im Grundriss); ohne Wahl die Hauptvarianten (Kern).
|
||||
const optKey = useStore((s) => {
|
||||
const l = s.project.drawingLevels.find((x) => x.id === s.activeLevelId);
|
||||
return l?.designOptions ? JSON.stringify(l.designOptions) : "";
|
||||
});
|
||||
const hide = useMemo<Hide3d>(() => {
|
||||
const split = (k: string) => (k ? k.split("\u0001") : []);
|
||||
const codes = split(hiddenKey);
|
||||
@@ -633,10 +638,11 @@ export function Wasm3DViewport({
|
||||
const dim = { grey: split(greyKey), lock: split(lockKey), greyFloors: split(greyFloorsKey) };
|
||||
const [renovation, renovationPhase] = split(renKey);
|
||||
const ren = renovation ? { renovation, ...(renovationPhase ? { renovationPhase } : {}) } : {};
|
||||
return onlyIds || hiddenIds.length || floors.length || dim.grey.length || dim.lock.length || dim.greyFloors.length || renovation
|
||||
? { ...toFilter3d({ only: onlyIds, hidden: hiddenIds }, codes, floors, dim), ...ren }
|
||||
const opts = optKey ? { designOptions: JSON.parse(optKey) as Record<string, string> } : {};
|
||||
return onlyIds || hiddenIds.length || floors.length || dim.grey.length || dim.lock.length || dim.greyFloors.length || renovation || optKey
|
||||
? { ...toFilter3d({ only: onlyIds, hidden: hiddenIds }, codes, floors, dim), ...ren, ...opts }
|
||||
: codes;
|
||||
}, [hiddenKey, floorsKey, greyKey, greyFloorsKey, lockKey, onlyIds, hiddenIds, renKey]);
|
||||
}, [hiddenKey, floorsKey, greyKey, greyFloorsKey, lockKey, onlyIds, hiddenIds, renKey, optKey]);
|
||||
const hideRef = useRef(hide);
|
||||
hideRef.current = hide;
|
||||
// Versatz je Geschoss ([65]) für Griffe und gezogene Höhen (Modell bleibt unversetzt).
|
||||
|
||||
Reference in new issue
Block a user