Files
vpn-dns-gateway/demo/tikzrefinery/code/README.md
vsun1 27b82c169e
vpn-dns-gateway/pipeline/head This commit looks good
vpn-dns-gateway/pipeline/pr-main This commit looks good
Add frozen TikZRefinery demo baseline and build pipeline
2026-11-25 22:46:33 -05:00

288 lines
17 KiB
Markdown

# TikZRefinery application
This directory contains the C++/Qt Alpha implementation of the desktop
graphical TikZ editor. Vincent selected C++ with Qt on October 1, 2026.
- `src/` contains application source code.
- `tests/` contains automated tests.
- `examples/` contains sample TikZ documents and demonstrations.
- `resources/` contains application-owned icons, fixtures, and other resources.
## Class organization
| Class | Location | Responsibility |
|---|---|---|
| `tkrTikzDocument` | `src/model/` | Preserve source bytes, parsed records, revisions and minimal edits |
| `tkrTikzParserExplicit` | `src/parsing/` | Interpret explicit cm rectangles/segments, byte ranges and fixed extent |
| `tkrEditService` | `src/editing/` | Prepare constrained move/resize geometry and coordinate replacements |
| `tkrCoordinateMapper` | `src/geometry/` | Convert centimeter coordinates and scene positions |
| `tkrEditorController` | `src/controller/` | Coordinate model/scene, parsing, file I/O and saving |
| `tkrDiagramScene` | `src/ui/` | Display/select elements, report body/corner gestures and preview geometry |
| `tkrDiagramView` | `src/ui/` | Fit the canvas to the pane and paint the fixed editing extent |
| `tkrMainWindow` | `src/ui/` | Own the document/controller/scene and provide application controls |
| `tkrWorkspaceSidebar` | `src/ui/` | Own tab strip/pages; retain collapsed, selected-page and width state |
| `tkrShapePalette` | `src/ui/` | Show copied rectangle-provider status; creation disabled |
| `tkrFolderBrowser` | `src/ui/` | Show folder placeholder and request the existing guarded Open flow |
| `tkrShapePluginStore` | `src/plugins/` | Validate, load and pin the rectangle module |
| `tkrShapeProvider` | `plugin-api/` | Shared value-only provider Strategy interface |
| `tkrRectangleShapeProvider` | `plugins/rectangle/` | Supply rectangle presentation and constrained operations in a separate DLL |
Each concrete class has a header and implementation; the pure provider interface is header-only. `src/model/EditorTypes.h` holds
shared data records. See [CODING_GUIDE.md](CODING_GUIDE.md) for naming, ownership,
source ranges and editing contracts.
On October 15, the six project classes and their matching files were renamed
to use `tkr<MainClassName><Specification>`. The optional suffix describes a
specialization, as in `tkrTikzParserExplicit`; it does not introduce a base
class. The allowed maximum is three project-defined inheritance levels, but
the concrete classes remain `final`. The rectangle implementation realizes the
provider interface; that project-defined chain has two levels.
The source-module rule now appears under Developer Requirements with its
existing REQ-A-005 ID. Four new DEV requirements and proposed checks record
class naming, other identifiers, depth, and ownership documentation.
The report's Software Architecture chapter includes an MVC allocation and a
class responsibility overview with linked detail diagrams, including the edit service. Supporting
activities remain in its Design Documents appendix.
Their editable TikZ sources are under
[`documents/assets/design-diagrams/`](../documents/assets/design-diagrams/).
The diagrams distinguish whole-element editing from remaining endpoint work.
## Current behavior and limits
The source defines a window with Open/Save controls, a read-only source viewer,
and a graphics scene. The controller reads original bytes and provides
safe-save plumbing; the model validates source replacements. The mapper handles
origin, scale and the inverted y axis. The explicit-coordinate parser preserves numeric
byte ranges and displays outlines; the bounding path sets the fixed comparison
extent and creates no item. Elements can be selected and dragged as a whole. Opening
a file preserves its bytes and clean state, so Save remains disabled.
Drag a box (including its interior), line or arrow body to translate it. The
scene previews movement while source stays unchanged. Release validates and
commits one coordinate batch, updates the source pane and enables Save.
Escape or focus loss cancels the preview. Save, opening another file or closing
also cancels an active preview. Ctrl+S saves committed edits; the existing close
guard handles unsaved changes. Click-only selection does not dirty the file.
The hit allowance is about five viewport pixels. Displacement is rounded to
0.000001 cm on release, with exact decimal translation of the original numbers;
unchanged-axis spellings and all unrelated bytes are preserved. Move and resize
preview and release stop at the furthest valid position inside a fixed extent,
including stroke. Reaching that limit is an accepted edit, not a rejection.
Select a rectangle, then drag one of its four blue corner handles to resize.
The opposite corner stays fixed; crossing it flips the rectangle. Width and
height each stop at 0.01 cm (0.1 mm), independently, so thin fillers are allowed.
Handles retain their screen size under view transforms. Escape, focus loss
and Save cancel an active resize preview. A changed release applies one batch.
Aspect-ratio locking and edge-only handles remain unimplemented. Session
undo/redo now covers completed coordinate edits in 0.1.4-alpha.
See `tests/evidence/resize-2026-11-12/README.md` for bounded automated evidence.
The whole-element increment passed all four CTest entries. Qt viewport mouse
events exercise contact, line/arrow movement, cancellation, source changes and
save/reopen; all three actual saved results match independently compiled output
within the prototype one-pixel allowance. See
[`tests/evidence/whole-element-drag-2026-10-21.md`](tests/evidence/whole-element-drag-2026-10-21.md).
The interactive demo is `code/build/demo/boxes-drag-demo.tex`; keep its edits
for review and avoid saving over the corpus fixtures when experimenting.
The first October 21 increment passed both then-registered tests and a fixed-extent
TinyTeX raster comparison for the initial and touching-reference boxes. The
automated window Open check also reaches the source, scene and status widgets.
See [`tests/evidence/rectangle-display-2026-10-21.md`](tests/evidence/rectangle-display-2026-10-21.md)
for observations, the one-pixel prototype comparison threshold, retained
images/metrics, reproduction commands, and limits. Loading the touching
reference does not establish a working drag/contact workflow.
The subsequent line/arrow increment passed all three registered tests and
fixed-extent comparisons for all eight corpus files. The reference files were
valid TikZ; the editor previously rejected their unsupported segment syntax.
It now displays single straight `--` segments and the default `->`, `<-`, `<->`
arrowheads. See [`tests/evidence/segment-display-2026-10-21.md`](tests/evidence/segment-display-2026-10-21.md).
Accepted input is a bare supported-command fragment, a single unconfigured
`tikzpicture`, or the exact `article`/`tikz`/empty-page wrapper in the corpus.
Absolute signed decimal/integer `cm` pairs and reversed corners are supported.
Options may contain `black`, `solid`, and one positive literal `line width` in
`pt`, in any order; a segment may also have one arrow-direction option. The
default width is 0.4pt. Comments, UTF-8 comment bytes, CRLF,
and an initial UTF-8 BOM retain their original offsets. One optional bounding
path must precede drawings and enclose their outlines. Unsupported syntax,
wrappers, custom arrow tips/styles, curves, polylines, transforms, loops and
macros yield a diagnostic and an empty canvas. Zero-length segments and arrows
whose tip insets consume their shaft are refused. This remains a bounded prototype.
The first native build passed on October 20, 2026 using Qt 6.12.0, matching
MinGW/GCC 13.1.0, CMake 3.30.5, and Ninja 1.12.1 on Windows. CTest passed the
one registered `core_foundations` test. Vincent opened `boxes-initial.tex` in
the running application and confirmed the source display. This does not verify
parsing, dragging, filesystem saves, timing, or canvas/PDF agreement. See
[`tests/evidence/first-run-2026-10-20.md`](tests/evidence/first-run-2026-10-20.md).
## Build and run
### Recommended first Windows setup
Use the [Qt Online Installer](https://www.qt.io/development/download-open-source)
and its open-source installation route. The recommended starting kit is desktop
Qt 6 with the matching MinGW-w64 64-bit compiler, installed together. MSVC is
also supported; it needs a separate Visual Studio C++ installation and the
matching MSVC Qt package.
1. Create/sign in to a Qt account and choose a folder such as `C:\Qt`.
2. Choose Custom Installation to inspect the components. Select one stable
released Qt 6 desktop version and its **MinGW 64-bit** package. Qt 6.2 is
the project's minimum, not a request to install that old release. Avoid
beta, preview, or release-candidate builds.
3. Include **Qt Creator**, the **MinGW compiler matching that Qt kit**,
**CMake** (3.21 or later), and **Ninja**. Use the supplied matching compiler;
its version depends on the selected Qt release. Core and Widgets are required.
4. Open this directory's `CMakeLists.txt` in Qt Creator and select the desktop
Qt 6 MinGW 64-bit kit. Check Preferences > Kits: Qt, compiler, debugger and
CMake must resolve without errors. Keep the build directory under `code/build/`.
5. Configure, build, and run. Open `boxes-initial.tex` to see two outlined boxes
and the read-only source view; move/resize are available for the supported subset. Run the
core tests separately before treating their checks as passed.
Qt Creator is the IDE, Qt supplies libraries, and MinGW supplies the compiler.
Installing the IDE alone is insufficient. Confirm the installed versions and
paths before running the command-line build below.
References: [Qt installation](https://doc.qt.io/qt-6/qt-online-installation.html),
[Windows configurations](https://doc.qt.io/qt-6/windows.html),
[opening CMake projects](https://doc.qt.io/qtcreator/creator-project-opening.html).
### Verified local Windows commands (October 20, 2026)
From the repository root in PowerShell, using the installed paths:
```powershell
$env:Path = 'C:\Qt\6.12.0\mingw_64\bin;C:\Qt\Tools\mingw1310_64\bin;C:\Qt\Tools\Ninja;' + $env:Path
& C:\Qt\Tools\CMake_64\bin\cmake.exe -S code -B code/build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=C:/Qt/6.12.0/mingw_64 -DCMAKE_CXX_COMPILER=C:/Qt/Tools/mingw1310_64/bin/g++.exe -DCMAKE_MAKE_PROGRAM=C:/Qt/Tools/Ninja/ninja.exe
& C:\Qt\Tools\CMake_64\bin\cmake.exe --build code/build --parallel 4
& C:\Qt\Tools\CMake_64\bin\ctest.exe --test-dir code/build --output-on-failure
& .\code\build\TikZRefinery.exe
```
An optional source-file argument opens that file on startup, for example:
```powershell
& .\code\build\TikZRefinery.exe .\code\examples\explicit-coordinates\arrow-initial.tex
```
Stop after any failed command and inspect its output. Close the running app
before rebuilding it. The PATH change applies only to this PowerShell session;
it lets Windows find Qt and MinGW DLLs without copying them into the repository.
The executable in `code/build/` is a development build, not a deployed package.
### Refresh the Windows prototype package
Use the Demo 3 Release package at
[`code/packages/0.1.4-alpha/`](packages/0.1.4-alpha/)
for interactive review. Open `TikZRefinery.exe` from that folder in Explorer.
It carries the Qt and MinGW runtime files and can be reopened without the
development shell. Keep the executable with the package contents.
Current policy uses `0.feature.revision-alpha`. A build retains the document
baseline it implements even as the report advances. Completed document/code
revisions advance the final number; completed feature releases advance the middle
number and reset revision. Normal titles and versioned package folders omit Git
hashes; About exposes short/full identity, source state and the loaded provider.
**Preserve `packages/TikZRefinery-windows-x64/`, the frozen Alpha 0.10.3 package,
and its edited examples.** Its matching reports remain separate. The extracted
rectangle module is delivered in `0.1.2-alpha/`; `0.2.0-alpha` is the later
shape-discovery/creation milestone. See [the SDK](plugin-api/README.md) and
[extraction evidence](tests/evidence/plugin-extraction-2026-11-20/README.md).
Both Debug and Release pass six CTest suites, including actual DLL loading,
negative compatibility cases and host validation. This is bounded evidence,
not completed product acceptance.
The November 23 follow-up implements the bounded 0.1.3-alpha sidebar shell:
Shapes/Files icons, collapse/reopen, retained session page/width, provider status
and the existing guarded Open action. Creation remains disabled; no folder tree,
catalogue API or service-ownership refactor is claimed. The scene still owns the
plugin store. All seven suites pass in Debug and Release; native review checks
the visible shell and unsaved-work guard. About truthfully records checkpoint
`7a2965a4f14e` with modified working tree. See [shell evidence](tests/evidence/sidebar-shell-2026-11-23/README.md).
The preceding [identity-only demo evidence](tests/evidence/demo3-package-2026-11-23/README.md)
is historical and does not describe the replacement executable. Older packages
and existing edited examples remain preserved.
For a visual increment, close the packaged app normally, then configure a
Release build with the same Qt kit and run CTest. Use the commands in the
previous section with a separate task-local build path under `work/` and
`-DCMAKE_BUILD_TYPE=Release`. Check deployment with that kit's
`windeployqt --release --compiler-runtime --no-translations --no-opengl-sw --no-system-d3d-compiler`.
Add `--dry-run --list relative --dir <package-folder> <built-exe>` to see the
required files before copying. Reuse the installed files if the kit is
unchanged and the list is complete; redeploy the runtime and plugins if the kit
or dependencies change.
For an authorized application increment, update only its designated development
package and manifest; do not replace the frozen demo executable.
Preserve any edited examples. Verify close and reopen with a Windows-only
PATH before leaving the packaged app open for review, then remove the task's
reproducible build scratch. See the
[latest package check](tests/evidence/package-2026-11-05.md) and the
[original Week 8 package evidence](tests/evidence/package-2026-10-23.md).
### Command-line build
Requires CMake 3.21+, a C++17 compiler, and a compatible Qt 6 development kit
(Core and Widgets; project minimum 6.2). Choose a Qt kit matching the compiler
and architecture. Python/PySide6 alone is not the C++ development kit.
In a shell configured for that kit, from the repository root:
```powershell
cmake -S code -B code/build -DCMAKE_PREFIX_PATH="<Qt kit directory>"
cmake --build code/build --config Debug
ctest --test-dir code/build -C Debug --output-on-failure
```
The executable is typically `code/build/Debug/TikZRefinery.exe` for a
multi-configuration generator, or `code/build/TikZRefinery.exe` for a
single-configuration generator. Run from the Qt kit's environment so Qt DLLs
and platform plugins are available. Use the package above for interactive
review outside that environment.
The `core_foundations` checks cover independent mapping expectations (TC-028),
untouched UTF-8/CRLF bytes, variable-length replacements, stale revisions,
overlapping ranges and atomic rejection of invalid batches. They do not cover
GUI interaction, filesystem saves or canvas/PDF fidelity. The separate
`rectangle_display` test covers parser/model/controller/scene geometry and an
offscreen window Open action. `segment_display` covers all six line/arrow
fixtures, direction flags, endpoints/ranges, mixed geometry, refused syntax,
and startup-file windows. `whole_element_drag` covers viewport pointer gestures,
exact minimal byte edits, cancellation, save/reopen, external-change refusal,
precision and a 2x scaled/panned view. `tests/CompareRectangles.py` performs the external raster comparison
separately, using the bundled Python/Pillow runtime and installed TinyTeX/Poppler.
The **Canvas** pane now uses a bordered white drawing surface so black TikZ
geometry stays visible in either theme. The adjacent **TikZ source** pane
still follows the window palette. The canvas fits the pane by default; for
documents with a fixed editing extent, white paper matches that extent and
the grey surround is outside it. See the
[fit and boundary checks](tests/evidence/canvas-fit-2026-11-05/README.md) and
[earlier palette checks](tests/evidence/canvas-contrast-2026-11-05/README.md).
## Next increment
1. Review the separately packaged rectangle plugin and actual UI screenshot.
2. Review shape discovery, creation gestures and source insertion before the
later 0.2.0-alpha milestone.
3. Keep the planned transaction and history boundaries; generic transactions,
endpoint editing, zoom/pan and integrated compilation remain pending.
The 0.1.4-alpha package implements session undo/redo for completed coordinate
edits. Edit > Undo (Ctrl+Z) and Redo (Ctrl+Y) restore exact source bytes. Save
retains history; successful Open/Reload clears it. A changed edit after Undo
discards the redo branch. Snapshots have no automatic eviction; memory use grows
with the session. Allocation failure before publication rejects the edit.
See [history evidence](tests/evidence/undo-redo-2026-11-24/README.md).
The LaTeX report records the selected class and language decisions in the
Development Plan and architectural requirements context. Product verification
remains pending.