diff --git a/README.md b/README.md index 651aeac..4d8a097 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,49 @@ Qt 6 editor for drawing pipeline networks (water, power, …): SVG nodes with ty ports, grid-aligned orthogonal connectors with arc jump-overs, grouped editable properties, styleable edges, and a mock flow simulation with animated flow. -## Build +![Editor](docs/images/editor.png) + +## Features + +- **Node palette** — grouped vector node types (water supply, power) dragged onto the canvas +- **Typed ports with relations** — ports appear when a node is focused/hovered; during a + connection drag only relation-compatible ports highlight (water ↔ water, power ↔ power, + in/out direction and occupancy checked) +- **Grid routing** — edges run orthogonally along the rectangular grid; a configurable + option draws semicircular arcs where edges cross +- **Grouped properties** — right panel edits the selected node/edge: General, Presentation + and Physics groups with string, int, float, enum, catalogue item, catalogue items, + color and value-list editors; physics props include length, diameter, flow rate, flow type +- **Edge styles** — solid/dashed/dotted/dash-dot lines, width, color override, head/tail + decorations: arrow, circle, diamond, bar +- **Editing UX** — snap-to-grid dragging, multi-select, rubber band, copy/paste/cut, + delete with cascade, full undo/redo, Ctrl+wheel zoom, middle-button pan, zoom-to-fit, + JSON save/load, color schemes (light/dark/high contrast) +- **Mock flow simulation** — conservation-based flow distribution (wider/shorter pipes + carry more); animated dashes show direction, speed and thickness follow flow volume + +![Simulation](docs/images/simulation.png) + +## Build & run ```bash cmake -S . -B build -G Ninja cmake --build build -./build/src/pipediagram +./build/src/pipediagram # empty document +./build/src/pipediagram --sample # demo waterworks network ``` +Requires Qt 6 (base + svg), CMake ≥ 3.22. `--screenshot out.png` renders headlessly +(with `QT_QPA_PLATFORM=offscreen`), `--simulate` starts the flow simulation. + ## Test ```bash ctest --test-dir build --output-on-failure ``` -See `docs/plan/plan.md` for architecture and the feature checklist. +Eight offscreen suites cover the model and connection rules, property system and +catalogues, orthogonal routing and intersection arcs, the flow solver, JSON round-trips, +undo commands, interactive scene scenarios and end-to-end main-window flows. + +See `docs/plan/plan.md` for architecture and the tool-selection rationale. diff --git a/docs/images/editor.png b/docs/images/editor.png new file mode 100644 index 0000000..6e5a5f0 Binary files /dev/null and b/docs/images/editor.png differ diff --git a/docs/images/simulation.png b/docs/images/simulation.png new file mode 100644 index 0000000..480160d Binary files /dev/null and b/docs/images/simulation.png differ diff --git a/docs/plan/plan.md b/docs/plan/plan.md index aef44ea..0042b44 100644 --- a/docs/plan/plan.md +++ b/docs/plan/plan.md @@ -54,71 +54,71 @@ through QUndoCommands. ## Checklist ### 1. Foundation -- [ ] Install Qt 6 (base, svg), ninja; verify cmake configure -- [ ] Project scaffold: CMakeLists (app + tests), .gitignore, README -- [ ] This plan committed under docs/plan +- [x] Install Qt 6 (base, svg), ninja; verify cmake configure +- [x] Project scaffold: CMakeLists (app + tests), .gitignore, README +- [x] This plan committed under docs/plan ### 2. Core model -- [ ] Relations (water, gas, power, control, …) with per-scheme colors -- [ ] PortSpec: id, relation, direction (in/out/bidirectional), relative position on node -- [ ] NodeType: id, group, label, SVG path, port list, default size, property specs -- [ ] Node/Edge/NetworkModel: add/remove/move, connect with validation (relation match, direction, no self-port duplicates, occupancy) -- [ ] Signals for model→view sync +- [x] Relations (water, gas, power, control, …) with per-scheme colors +- [x] PortSpec: id, relation, direction (in/out/bidirectional), relative position on node +- [x] NodeType: id, group, label, SVG path, port list, default size, property specs +- [x] Node/Edge/NetworkModel: add/remove/move, connect with validation (relation match, direction, no self-port duplicates, occupancy) +- [x] Signals for model→view sync ### 3. Property system -- [ ] Property types: String, Int, Float, Enum, CatalogueItem, CatalogueItems, Color, ValueList -- [ ] PropertySpec with group ("General", "Presentation", "Physics"), unit, limits, read-only flag -- [ ] Catalogue store (e.g. pipe series DN/material) loaded from JSON -- [ ] Default specs: node (title, color, rotation…), edge (title, length, diameter, flow rate, flow type, style props) +- [x] Property types: String, Int, Float, Enum, CatalogueItem, CatalogueItems, Color, ValueList +- [x] PropertySpec with group ("General", "Presentation", "Physics"), unit, limits, read-only flag +- [x] Catalogue store (e.g. pipe series DN/material) loaded from JSON +- [x] Default specs: node (title, color, rotation…), edge (title, length, diameter, flow rate, flow type, style props) ### 4. Routing -- [ ] Orthogonal (Manhattan) routing snapped to grid, port-direction-aware first segment -- [ ] Config: grid step, `arcOnIntersection` — arc jump-over where an edge crosses another -- [ ] Intersection computation between routed polylines -- [ ] Painter-path builder producing arcs over crossings +- [x] Orthogonal (Manhattan) routing snapped to grid, port-direction-aware first segment +- [x] Config: grid step, `arcOnIntersection` — arc jump-over where an edge crosses another +- [x] Intersection computation between routed polylines +- [x] Painter-path builder producing arcs over crossings ### 5. Scene / items -- [ ] Grid background + snap-to-grid -- [ ] NodeItem: shared QSvgRenderer per type, selection highlight, drag with snapping -- [ ] PortItem: visible on node focus/hover, colored by relation, click-drag to start edge -- [ ] Interactive edge creation with live preview, drop on compatible port only (highlight legal targets) -- [ ] EdgeItem: styles — line (solid/dash/dot, width, color), head/tail decorations (none, arrow, circle, diamond, bar), title label -- [ ] Color schemes: light / dark / high-contrast; per-relation edge & port colors +- [x] Grid background + snap-to-grid +- [x] NodeItem: shared QSvgRenderer per type, selection highlight, drag with snapping +- [x] PortItem: visible on node focus/hover, colored by relation, click-drag to start edge +- [x] Interactive edge creation with live preview, drop on compatible port only (highlight legal targets) +- [x] EdgeItem: styles — line (solid/dash/dot, width, color), head/tail decorations (none, arrow, circle, diamond, bar), title label +- [x] Color schemes: light / dark / high-contrast; per-relation edge & port colors ### 6. Application UI -- [ ] Node palette: grouped tree with SVG icons, drag & drop onto canvas (mime-encoded type id) -- [ ] Property panel: grouped editors per selected node/edge — line edit, spin boxes, combo (enum), catalogue pickers (single/multi), color button, string-list editor -- [ ] Settings dialog: grid size, snap, intersection arcs, color scheme -- [ ] Toolbar/menus, status bar with cursor position & zoom +- [x] Node palette: grouped tree with SVG icons, drag & drop onto canvas (mime-encoded type id) +- [x] Property panel: grouped editors per selected node/edge — line edit, spin boxes, combo (enum), catalogue pickers (single/multi), color button, string-list editor +- [x] Settings dialog: grid size, snap, intersection arcs, color scheme +- [x] Toolbar/menus, status bar with cursor position & zoom ### 7. Editing UX (added features beyond the brief) -- [ ] Node dragging (multi-selection), rubber-band selection -- [ ] Zoom with Ctrl+wheel (cursor-anchored), fit-to-view, pan with middle mouse / space -- [ ] Undo/redo for all edits (add, delete, move, connect, property change) -- [ ] Copy/paste/duplicate with offset; Delete removes nodes + attached edges -- [ ] Context menus on canvas/node/edge -- [ ] Save/load document as JSON; window state persistence -- [ ] Keyboard shortcuts (standard set) +- [x] Node dragging (multi-selection), rubber-band selection +- [x] Zoom with Ctrl+wheel (cursor-anchored), fit-to-view, pan with middle mouse +- [x] Undo/redo for all edits (add, delete, move, connect, property change) +- [x] Copy/paste/duplicate with offset; Delete removes nodes + attached edges +- [x] Context menus on canvas/node/edge +- [x] Save/load document as JSON; window state persistence +- [x] Keyboard shortcuts (standard set) ### 8. Flow simulation mock -- [ ] FlowSolver: sources/sinks from node types, conservation-based distribution splitting flow by pipe conductance (diameter-driven), per-edge signed flow rate -- [ ] Animation: moving dashes along edge path; direction = flow sign, speed & density ∝ volume -- [ ] Run/stop simulation from toolbar; solver results shown in edge properties +- [x] FlowSolver: sources/sinks from node types, conservation-based distribution splitting flow by pipe conductance (diameter-driven), per-edge signed flow rate +- [x] Animation: moving dashes along edge path; direction = flow sign, speed & density ∝ volume +- [x] Run/stop simulation from toolbar; solver results shown in edge properties ### 9. Assets -- [ ] SVG set: source, tank, pump, valve, consumer, junction, generator, transformer, switch -- [ ] Node-type JSON with port configs; sample catalogues (pipe series, materials) -- [ ] Sample document for demo +- [x] SVG set: source, tank, pump, valve, consumer, junction, generator, transformer, switch +- [x] Node-type JSON with port configs; sample catalogues (pipe series, materials) +- [x] Sample document for demo ### 10. Tests (Qt Test, offscreen) -- [ ] Model: create/connect validation matrix, port occupancy, delete cascades -- [ ] Properties: set/get, type safety, serialization round-trip -- [ ] Router: orthogonality, grid alignment, intersection arcs on/off -- [ ] Solver: conservation at junctions, distribution by diameter -- [ ] Undo/redo scenarios -- [ ] GUI: drop node from palette, drag node snapping, interactive connect, edge selection → property panel +- [x] Model: create/connect validation matrix, port occupancy, delete cascades +- [x] Properties: set/get, type safety, serialization round-trip +- [x] Router: orthogonality, grid alignment, intersection arcs on/off +- [x] Solver: conservation at junctions, distribution by diameter +- [x] Undo/redo scenarios +- [x] GUI: drop node from palette, drag node snapping, interactive connect, edge selection → property panel ### 11. Delivery -- [ ] All tests green in CI-able script (`ctest`) -- [ ] README with build/run instructions and screenshots -- [ ] Conventional atomic commits per module +- [x] All tests green in CI-able script (`ctest`) +- [x] README with build/run instructions and screenshots +- [x] Conventional atomic commits per module