|
59 | 59 | │ │ ├── core/ # Constants, types, utilities |
60 | 60 | │ │ ├── processing/ # Data processing, render queue |
61 | 61 | │ │ └── renderers/ # Plotly and SVG renderers |
| 62 | +│ ├── routing/ # Orthogonal wire routing (A* pathfinding) |
62 | 63 | │ ├── pyodide/ # Python runtime (backend, bridge) |
63 | 64 | │ │ └── backend/ # Modular backend system (registry, state, types) |
64 | 65 | │ │ └── pyodide/ # Pyodide Web Worker implementation |
@@ -120,6 +121,19 @@ Worker (10 Hz) Main Thread UI (10 Hz) |
120 | 121 | - **Non-blocking**: Simulation never waits for plot rendering |
121 | 122 | - **extendTraces**: Scope plots append data incrementally instead of full re-render |
122 | 123 |
|
| 124 | +### Wire Routing |
| 125 | + |
| 126 | +PathView uses Simulink-style orthogonal wire routing with A* pathfinding: |
| 127 | + |
| 128 | +- **Automatic routing**: Wires route around nodes with 90° bends only |
| 129 | +- **User waypoints**: Press `\` on selected edge to add manual waypoints |
| 130 | +- **Draggable waypoints**: Drag waypoint markers to reposition, double-click to delete |
| 131 | +- **Segment dragging**: Drag segment midpoints to create new waypoints |
| 132 | +- **Incremental updates**: Spatial indexing (O(1) node updates) for smooth dragging |
| 133 | +- **Hybrid routing**: Routes through user waypoints: Source → A* → W1 → A* → Target |
| 134 | + |
| 135 | +Key files: `src/lib/routing/` (pathfinder, grid builder, route calculator) |
| 136 | + |
123 | 137 | ### Key Abstractions |
124 | 138 |
|
125 | 139 | | Layer | Purpose | Key Files | |
@@ -203,6 +217,27 @@ This generates TypeScript files in `src/lib/*/generated/` with: |
203 | 217 |
|
204 | 218 | Start the dev server and check that your block appears in the Block Library panel. |
205 | 219 |
|
| 220 | +### Port Synchronization |
| 221 | + |
| 222 | +Some blocks process inputs as parallel paths where each input has a corresponding output (e.g., Integrator, Amplifier, Sin). For these blocks, the UI only shows input port controls and outputs auto-sync. |
| 223 | + |
| 224 | +Configure in `src/lib/nodes/uiConfig.ts`: |
| 225 | + |
| 226 | +```typescript |
| 227 | +export const syncPortBlocks = new Set([ |
| 228 | + 'Integrator', |
| 229 | + 'Differentiator', |
| 230 | + 'Delay', |
| 231 | + 'PID', |
| 232 | + 'PID_Antiwindup', |
| 233 | + 'Amplifier', |
| 234 | + 'Sin', 'Cos', 'Tan', 'Tanh', |
| 235 | + 'Abs', 'Sqrt', 'Exp', 'Log', 'Log10', |
| 236 | + 'Mod', 'Clip', 'Pow', |
| 237 | + 'SampleHold' |
| 238 | +]); |
| 239 | +``` |
| 240 | + |
206 | 241 | --- |
207 | 242 |
|
208 | 243 | ## Adding New Toolboxes |
@@ -448,6 +483,7 @@ Press `?` to see all shortcuts in the app. Key shortcuts: |
448 | 483 | | **Transform** | `R` | Rotate 90° | |
449 | 484 | | | `X` / `Y` | Flip H/V | |
450 | 485 | | | `Arrows` | Nudge selection | |
| 486 | +| **Wires** | `\` | Add waypoint to selected edge | |
451 | 487 | | **View** | `F` | Fit view | |
452 | 488 | | | `H` | Go to root | |
453 | 489 | | | `T` | Toggle theme | |
|
0 commit comments