www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit 8f844021a630e390c533c37a53f53b4834ceebdf
parent 3bbbe8dd81f2390fe6efaf3d051a65b0a2d4a99f
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Thu, 31 Oct 2024 21:02:39 -0700

Add furniture labels

This displays the furniture name on top of the furniture in the SVG
itself. In the future I'll apply some processing to ensure it's
always within the furniture by altering font sizing, adding rotation,
truncating, etc.

Diffstat:
Mfiles/floorplans/floorplan/editor.js | 32++++++++++++++++++++++++++++++++
Mfiles/floorplans/floorplan/main.js | 5+++++
2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/files/floorplans/floorplan/editor.js b/files/floorplans/floorplan/editor.js @@ -338,6 +338,7 @@ export class FloorplanEditor { this.layout = "1" this.ui.top = this.draw.group().attr({ id: "top" }) + this.ui.labels = this.draw.group().attr({ id: "labels" }) // Resize grid when appropriate this.draw.on("zoom", function(event) { @@ -475,6 +476,19 @@ export class FloorplanEditor { } } + furnitureLabels(show) { + console.debug("Editor.furnitureLabels", show) + const l = this.ui.labels + if (show === undefined) { + return l.hasClass("hidden") + } + if (show) { + l.addClass("hidden") + } else { + l.removeClass("hidden") + } + } + updateGrid(box) { let grid = this.draw.findExactlyOne("#grid") if (!box) { @@ -785,6 +799,24 @@ export class FloorplanEditor { }) } fm.cx(value.x).cy(value.y) + + let tid = id + "_text" + let text = editor.draw.findOne(byId(tid)) + if (!f.name) { + if (text) { + text.remove() + } + } else { + if (!text) { + text = editor.ui.labels.text(f.name) + .attr({ id: tid }) + .font('size', '8in') + } else { + text.plain(f.name) + } + text.cx(value.x).cy(value.y) + } + fm.transform({ rotate: value.angle }) diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js @@ -213,6 +213,11 @@ function run(editor) { editor.fitToView() }} }))) + tg.append(item(ui.button("Furniture labels", "Toggle furniture label visability", null, { + handlers: { click: function() { + editor.furnitureLabels(!editor.furnitureLabels()) + }} + }))) tg.append(item( selector(editor.modes, function(mode) { if (mode === "View") {