Skip to content

Help panel, Units settings, file format = IFCX, hlookup/take fixes, code folding#2

Merged
DutchSailor merged 7 commits into
mainfrom
feat/file-open-browse
May 20, 2026
Merged

Help panel, Units settings, file format = IFCX, hlookup/take fixes, code folding#2
DutchSailor merged 7 commits into
mainfrom
feat/file-open-browse

Conversation

@DutchSailor

Copy link
Copy Markdown
Collaborator

Summary

Grote batch UX + correctness work. Alles loopt live via Vite HMR.

Bestandsformaat (round-trippable)

.ifc-calculation is nu een IFCX JSON-LD document met de CalcPAD-bron embedded onder source.content. Een IFC-viewer leest het als een geldige IFCX-file; deze app leest dezelfde file terug als calc-bron. IfcViewerPanel toont 1:1 wat Save naar schijf schrijft. Backward-compat: legacy raw .cpd files worden nog steeds geaccepteerd.

HelpPanel (taal-referentie)

Lege editor → Preview wordt vervangen door HelpPanel.tsx met CalcPAD-stijl referentie:

  • Klikbare snippets voor variabelen, functies, conditionals, loops, macros, tekeningen, tekst
  • Sections met + collapsible
  • Klik fragment → wordt aan het einde van de editor toegevoegd
  • File → Nieuw wist de editor zodat HelpPanel verschijnt

Settings → Eenheden

Nieuwe tab met CalcPAD-knoppen:

  • Hoek-eenheid: deg / rad / gra — live doorgevoerd naar setAngleMode zodat sin(45) werkelijk afhankelijk is van de mode
  • Return-angle-with-unit toggle (placeholder)
  • Default display units: lengte (mm/cm/m), kracht (N/kN/MN), spanning (Pa/kPa/MPa/GPa/N·mm⁻²)
  • Persistent via Tauri store; bij app-boot restored

Editor verbeteringen

  • Ctrl+Scroll zoom in zowel editor als preview (independente zoom per pane)
  • Code folding voor @svg, @select, #if, #repeat, #for, #def name(...), #hide (gutter minus-knop)
  • \"…\" strings krijgen string-token in syntax highlight

Math correctness — 2259-Intertek

  • Wind 1 NaN cascade gefixed: hlookup/hlookup_ge/hlookup_le/vlookup herschreven als unit-aware 2D lookup met expliciete lookupCol/returnCol. take(1; scalar) returnt de scalar i.p.v. NaN. q_p resolved → 0,751 kN/m², alle P_rep + F_Wind nu numeriek.
  • #val en #noc als no-op directives (display-hints, niet zichtbaar in output)
  • renderVarDisplay fix: l = 12.34m ml = 12.34 m

Images

  • Picture0–5.png van het Intertek-rapport in templates/calcpad-samples/Images/ gebundeld
  • Nieuwe ParseOptions.imageUrls map rewrites <img src=\"./Images/X.png\"> basenames naar Vite-bundled URLs
  • calcpadImageUrls registreert deze map; doorgegeven aan parse() in Preview, IfcViewerPanel, CalcTab

File Open (Office-style)

  • File → Open landt op een Browse-paneel: prominente Bladeren… kaart + recente-bestanden lijst
  • Ribbon "Bladeren…" knop voegt automatisch toe aan recents
  • Recente bestanden klikbaar → laadt via Tauri readTextFile en unwrap-t IFCX

Cleanup

  • IFC-ribbontab leegmaakt (geen knoppen — file-ops in Calc-tab)
  • Start-ribbon: Kop / Formule / Keuzelijst / PDF voorvertonen weg
  • File → Import weg uit Backstage (niets te importeren)

Test plan

  • Open File → Nieuw → HelpPanel zichtbaar rechts; klik snippet → editor vult zich; HelpPanel verdwijnt
  • Editor: collaps @svg-block met − in de gutter, expand met +
  • Ctrl+wheel in editor → font groter/kleiner; Ctrl+wheel in preview → tekst groter/kleiner
  • Open cpd-2259-intertek: Picture0 rendert in hoofdstuk 2, Wind 1 toont geldige waarden, 5.1 toont l = 12.34 m zonder dubbel m
  • Settings → Eenheden → Graden, Save → sin(90) in editor geeft 1
  • File → Save As → bestand opent in viewer als geldige IFCX JSON
  • File → Open op die file → editor toont weer de CalcPAD source

🤖 Generated with Claude Code

DutchSailor and others added 7 commits May 20, 2026 07:51
Reflects the rename + the substantial feature set added in this branch:
real CalcPAD compatibility (including the 2259-Intertek regression
sample), parametric SVG macros, @img(*.svg) inlining, live IFCX/STEP
generation, the IFC viewer panel, Tauri desktop shell, and the load-
case tabs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The File-menu Open item used to do nothing (recents list with no
loader wired up). Now it shows a prominent Browse… card on top that
opens the OS file picker, with the recent-files list below — clicking
a recent loads it via Tauri readTextFile.

- App.tsx: handleBrowse + handleOpenRecent wired to documentStore +
  useRecentFiles, passed through to Backstage as onBrowse / onOpenFile
- Backstage.tsx: OpenPanel renders a Browse… card; props extended
  with onBrowse; click outside closes
- Backstage.css: .bs-browse-card styled in --theme-accent-soft with
  hover/active states
- CalcTab.tsx: ribbon "Openen" → "Browse…", same handler now adds to
  recents via useRecentFiles
- i18n: openPanel.browse / browseDesc / title / clearAll / etc keys
  in nl + en; ribbon.calc.browse in nl + en

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…directives, imageUrls

- hlookup / hlookup_ge / hlookup_le / vlookup rewritten as a single
  unit-aware 2D lookup helper. Honours the lookupCol / returnCol args
  CalcPAD passes, extracts numeric value from mathjs Units, and falls
  back to flat-vector lookup when the matrix is 1D. Fixes 5.2.1 Wind 1
  NaN cascade — the 2259-Intertek wind reference pressure now solves.
- `take(idx, scalar)` returns the scalar instead of NaN, so chains like
  `take(1; hlookup_ge(M; h; 1; 1))` work when hlookup_ge returns a cell.
- Trig wrappers (sin/cos/tan + a/.../) honour a global angle mode set
  via the new `setAngleMode(mode)` export — Settings → Eenheden picks
  rad / deg / gra and the change applies instantly.
- `#val` and `#noc` registered as no-op directives (display hints that
  don't affect math), so they don't surface in the rendered output.
- Parser: new `ParseOptions.imageUrls` map rewrites `<img src="...">`
  basenames to Vite-bundled asset URLs (Picture0.png et al.).
- Renderer: `renderVarDisplay` now splits result via `splitResult` so
  `l = 12.34m` no longer renders the unit twice as `12.34m m`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…pable)

The on-disk format is now a JSON-LD IFCX document with the CalcPAD
source embedded under `source.content`. An IFC viewer can read it as
a normal IFCX file; this app reads it back as the calc source.

- wrapAsIfcCalculation / unwrapFromIfcCalculation helpers in fileOps
- saveCalculationFile takes (source, ifcx, defaultName) and writes the
  wrapped JSON; default extension is .ifc-calculation
- openCalculationFile + handleOpenRecent unwrap on load (also accepts
  legacy raw .cpd / .ifc-calculation text)
- IfcViewerPanel's IFCX viewer shows the *exact* JSON that Save would
  write (calls wrapAsIfcCalculation under the hood)
- IFC ribbon tab cleared — file ops live in the Calc tab now
- handleNew in CalcTab loads an empty document so the HelpPanel shows

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- HelpPanel.tsx + .css — CalcPAD-style language reference shown in the
  preview pane when the editor is empty. Click sections to expand, click
  snippets to insert into the editor. Mirrors the CalcPAD "How it works"
  card.
- useZoom hook: Ctrl+wheel zoom for both panes. Editor sets the CSS var
  --cm-font-size on its wrapper (CodeMirror picks it up via Editor.css);
  Preview adjusts root font-size %.
- ifcCalcLanguage.ts adds a foldService — `@svg`, `@select`, `#if`,
  `#repeat`, `#for`, `#def name(...)`, and `#hide` ranges all collapse
  via the gutter minus button. Nested blocks of the same kind nest
  correctly.
- Preview switches to HelpPanel when source.trim() is empty.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
New Settings tab with the four knobs CalcPAD users expect:
  • Hoek-eenheid (deg / rad / gra) — live, applied to sin/cos/tan
  • Return-angle-with-unit toggle
  • Default display units: lengte, kracht, spanning

The angle-mode choice routes through setAngleMode() on save and on app
boot (App.tsx subscribes to `units-changed` events + restores from the
Tauri store on mount). Defaults match CalcPAD: rad, mm, kN, MPa.

i18n keys in nl + en.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…g scripts

- Backstage: removed File → Import entry and ImportPanel (nothing to
  import; opening files happens via File → Open / Browse)
- calcpad-includes: register Picture0–5.png as Vite ?url assets so the
  parser's imageUrls rewrite resolves `<img src="./Images/Picture0.png">`
  in 2259-Intertek-units to the bundled asset
- .gitignore: scripts/debug-*.mjs + last-render.html (scratch artefacts)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@DutchSailor DutchSailor merged commit c81133a into main May 20, 2026
0 of 3 checks passed
@DutchSailor DutchSailor deleted the feat/file-open-browse branch May 20, 2026 13:39
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.

1 participant