Skip to content

feat(tool-chest): save and reuse measurement presets in tool sets (#311) - #779

Open
oscar981-op wants to merge 1 commit into
OpenAEC-Foundation:mainfrom
oscar981-op:feat/tool-chest-311
Open

oscar981-op wants to merge 1 commit into
OpenAEC-Foundation:mainfrom
oscar981-op:feat/tool-chest-311

Conversation

@oscar981-op

Copy link
Copy Markdown
Contributor

Fixes #311.

Approach

Builds on the existing tool-default preferences instead of adding a second style system. The body of setAsDefaultStyle moved to js/core/style-prefs.js and is shared by both.

  • Save: right-click → "Save to Tool Chest" captures every property except geometry, measured results, identity and links to other annotations.
    • The layer is stored by name and colour, so it carries over to other documents.
    • Line width and font size are stored without viewport scaling.
    • Supported: distance, area, perimeter, angle, line, arrow, polyline, polygon, rectangle, ellipse, cloud, filled area, wall.
  • Panel (left sidebar): tool sets and items. Create, rename (F2 or double-click), delete (confirmation when not empty), move (drag or "Move to…"), export a set to .opdstools and import one.
  • Use an item: clicking it starts its tool with the item's style laid over the preferences temporarily, so the preview and the tool use it.
    • The rest of the properties are applied to the next annotation through a recordAdd hook, so undo stays complete.
    • The unit is converted keeping the real length, and a missing layer is created.
    • The overlay is never saved, and it ends on a tool change or Esc.
  • Import: checks format, version, item shape and size. Geometry, ids and prototype keys are stripped; unknown types are skipped. A name clash offers rename, overwrite or keep both.
  • Persistence: its own app-data catalog file on desktop (opds-tool-chest), browser storage on web. It survives a preferences reset.
  • Depth (requested in the issue, did not exist): measureDepth for distance, perimeter and area, with a computed surface or volume. Saved as OPS_Depth and loaded back.
  • Real translations in all 40 locales.

Tests

  • New: tool-chest.test.mjs, tool-chest-wiring.test.mjs, measure-depth.test.mjs, toolChestStore.test.mjs. They cover capture without geometry, applying a preset, tool set CRUD and rename, export/import round-trip and rejecting malformed files, and persistence.
  • A depth round-trip was added in plattegrond-meta.test.mjs.
  • Full suite: 0 failures. vite build and tsc are clean.

Not yet checked in the running app

  • The panel, context menu and import dialog. HTML5 drag-and-drop in Tauri may be blocked; "Move to…" is the fallback.
  • The live preview style for tools that don't read the preferences (angle, wall). They get the style only once the annotation is placed.
  • The real file dialogs and .opdstools read/write.
  • Esc ending the session (covered by a source test only).
  • Depth through a full save and reopen (only the key round-trip is tested).

🤖 Generated with Claude Code

…enAEC-Foundation#311)

Right-click a measurement (or line, arrow, polyline, polygon, rectangle,
ellipse, cloud, filled area, wall) and choose "Save to Tool Chest": every
property except the drawn geometry, the measured result and the per-
annotation identity is stored as an item - layer (by name), colours, line
width, label/name, unit, precision, depth, hatch, line ends, dimension type.

- New "Tool Chest" tab in the left sidebar: tool sets with items; create,
  rename (F2/double-click), delete, move items (drag or "Move to..."),
  export a tool set to a .opdstools file and import one. Importing a name
  that already exists asks: rename, overwrite or keep both.
- Clicking an item deselects (never changes) the current selection, starts
  the item's tool and overlays the item's style on the tool preferences for
  preview and drawing; the next annotation gets the remaining properties via
  a recordAdd hook (unit converted with the same real length, missing layer
  created). The overlay is never persisted and ends on any tool change.
- Deleting an item leaves placed annotations untouched (values are copied).
- Chest persisted in the app data (own file on desktop, browser storage on
  the web), so it survives restarts and a preferences reset.
- Exchange file is validated: format/version, item shape, size limits;
  geometry, ids and prototype keys are stripped, unknown types skipped.
- Measurements get a depth field (surface/volume shown in the properties
  panel), saved in the PDF as OPS_Depth.
- setAsDefaultStyle's preference writer moved to core/style-prefs.js and
  shared with the Tool Chest overlay.
- Translations for all 40 locales; unit tests for capture, apply, session
  overlay, tool set CRUD, export/import round trip, malformed files and
  persistence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Tool Chest ("Werkkist") for saving and reusing preconfigured measurements

1 participant