feat: add branch overviews scoped outdoor plans and complete room moves
This commit is contained in:
1 parent
382d6e04f2
commit
16eddacebf
35 files changed
+2598
-2116
No files matched your search
@@ -7,6 +7,7 @@ import { bounds, centroid, isFixed, polygonArea, roomsReachingUp, type Floor, ty
|
||||
import type { Wall } from "../../../geometry/walls.ts";
|
||||
import { edgePlus, pointsAttribute, type CanvasContext } from "./context.ts";
|
||||
import { formatArea, formatLength } from "../../../units.ts";
|
||||
import { isOutdoorFloor } from "../../../topology.ts";
|
||||
|
||||
type Layer = TemplateResult | typeof nothing;
|
||||
|
||||
@@ -41,7 +42,7 @@ export function gridLayer(ctx: CanvasContext, size: { w: number; h: number }): L
|
||||
/** The rooms of the floor below, faintly, as orientation; rooms below that rise through this floor are hatched – it stays open there. */
|
||||
export function floorBelowLayer(ctx: CanvasContext): Layer {
|
||||
const current=ctx.host.doc.floors.find((f)=>f.id===ctx.floorId);
|
||||
const floors = ctx.host.doc.topology?ctx.host.doc.floors.filter((f)=>current?.outdoor_location_id?f.outdoor_location_id===current.outdoor_location_id:!f.outdoor_location_id&&f.building_id===current?.building_id):ctx.host.doc.floors;
|
||||
const floors = ctx.host.doc.topology?ctx.host.doc.floors.filter((f)=>isOutdoorFloor(current)?f.id===current?.id:!isOutdoorFloor(f)&&f.building_id===current?.building_id):ctx.host.doc.floors;
|
||||
const at = floors.findIndex((f) => f.id === ctx.floorId);
|
||||
const below = at > 0 ? floors[at - 1] : undefined;
|
||||
if (!below) return nothing;
|
||||
@@ -51,6 +52,18 @@ export function floorBelowLayer(ctx: CanvasContext): Layer {
|
||||
)}</g>`;
|
||||
}
|
||||
|
||||
/** Read-only overview; clicking an outline first opens its actual floor for editing. */
|
||||
export function scopeOverviewLayer(ctx: CanvasContext, floors: readonly Floor[]): Layer {
|
||||
return svg`<g class="nf-scope-overview">${floors.map((f)=>{
|
||||
const points=[...f.rooms.flatMap((r)=>r.points),...f.outdoor.flatMap((a)=>a.points)];
|
||||
const c=points.length?centroid(points):null;
|
||||
return svg`<g data-overview-floor=${f.id} tabindex="0" role="button" aria-label=${f.name}>
|
||||
<title>${f.name}</title>${[...f.rooms.map((r)=>r.points),...f.outdoor.map((a)=>a.points)].map((p)=>svg`<polygon points=${pointsAttribute(ctx,p)} />`)}
|
||||
${c?svg`<text x=${ctx.toScreen(c)[0]} y=${ctx.toScreen(c)[1]}>${f.name}</text>`:nothing}
|
||||
</g>`;
|
||||
})}</g>`;
|
||||
}
|
||||
|
||||
/** The wall pieces; outer ones are drawn stronger, and walls lower than the floor lighter. */
|
||||
export function wallsLayer(ctx: CanvasContext, walls: readonly Wall[]): Layer {
|
||||
const full = ctx.host.floor?.height ?? 2.5;
|
||||
|
||||
Reference in new issue
Block a user