2.5.4. Alignment editor

Calculate ▸ Alignment Editor… opens a modal dialog that lets you edit every part of an alignment in one place. It is the main interactive tool for building or modifying a design from PIs.

2.5.4.1. Tabs

The editor is a TPageControl with the following tabs:

  • Horizontal — PI table (point of intersection). Each row is one PI with X, Y, optional radius, optional in-spiral length, optional out-spiral length. Add / Delete / Reverse buttons + the Solve button which calls BuildAlignmentFromPIs(FPIs, FSolvedGeom).

  • Vertical — PVI table (point of vertical intersection): one row per PVI with station, elevation and curve length (0 = no curve at that PVI, just a grade break).

  • Station Equations — Back / Ahead chainage pairs (see StationEquations).

  • Cross-section tabs — generated dynamically for each cross-section collection that the alignment uses (Superelevation L/R, Widening L/R, Horizontal Offset, Vertical Offset, Transitional Super L/R, Cant). Each tab has its own start-sta/end-sta/value grid with Add / Delete buttons.

2.5.4.2. PI solver

The Horizontal tab’s grid lets you enter the PI coordinates and their radius / spiral lengths. Solve runs BuildAlignmentFromPIs which infers the connecting line / arc / clothoid elements; the bottom status bar reports Solved: 23 elements, station 64800.000 - 195000.000.

The Solve step is now optional — pressing Apply auto-solves when at least two PIs are present (see below).

2.5.4.3. Apply — one-stop save

Apply is the single “commit everything to the session” button. Its previous version refused to commit anything if the horizontal hadn’t been solved; the new behaviour is:

  1. Sync the PI grid into FPIs.

  2. If two or more PIs exist → auto-solve them via BuildAlignmentFromPIs, rebuild HGeometry from the solve; solver errors abort the Apply.

  3. If 0–1 PIs are present → skip the horizontal rebuild and leave the existing HGeometry untouched (loaded from file).

  4. Always commit the rest, regardless of PI count:

    • Vertical profile — rebuild from the VGrid PVIs;

    • Cross-section data — Superelevation, Widening, Horizontal / Vertical Offset, Cant, Transitional Offsets (via CommitCrossSectionUI);

    • Station equations — sort by Back, derive rawStation per row, ClearStationEquations + re-add via GridToStationEq.

  5. Engine.RebuildSpatialIndex and Session.Modified := True.

  6. Success message — distinct text when no PIs were present ("Applied to alignment (no horizontal PIs to solve; existing horizontal geometry preserved).").

This means you can open an alignment that only has resolved elements (no PIs in the source — e.g., imported from a foreign ALM that stored elements but not PI lists), edit just the cross-section or station equations, and Apply saves those edits without ever touching the horizontal centreline.

2.5.4.4. Station-equation entry — chainage-based

The Station Equations tab has just two editable columns: Station Back and Station Ahead — both chainages. On Apply the engine sorts entries by Back and derives the internal raw distance via StationToRaw(back) for each, accounting for any lower-chainage equations already added.

This is the conscious replacement for the earlier raw-distance field, which was a usability trap (users typed chainage values into it; chainages past the alignment end never triggered the equation). The current entry UI works purely in chainage and the raw-distance value is computed for you.

2.5.4.5. Other commands

Buttons elsewhere in the editor:

  • Reverse — flip the PI list end-to-end; useful when the source data was digitised in the wrong direction.

  • Insert PI — add a new PI between two selected rows; new PI takes the midpoint of its neighbours by default.

  • Close — closes the dialog without saving (the warning “Solve first” no longer appears since Apply now handles all paths).

After Close the main form’s ActiveFrame.RefreshData is called so the tree counts and the visible grid refresh automatically.