|
14 | 14 | import { importFile } from '$lib/schema/fileOps'; |
15 | 15 | import { ALL_COMPONENT_EXTENSIONS } from '$lib/types/component'; |
16 | 16 | import { GRID_SIZE } from '$lib/constants/grid'; |
| 17 | + import { pinnedPreviewsStore } from '$lib/stores/pinnedPreviews'; |
| 18 | + import { plotDataStore } from '$lib/plotting/processing/plotDataStore'; |
| 19 | + import { previewSideForRotation, extendBoundsForPreview } from '$lib/utils/previewBounds'; |
| 20 | + import type { NodeInstance } from '$lib/types/nodes'; |
17 | 21 |
|
18 | 22 | interface Props { |
19 | 23 | pendingUpdates: string[]; |
|
33 | 37 | return; |
34 | 38 | } |
35 | 39 |
|
| 40 | + const previewsPinned = get(pinnedPreviewsStore); |
| 41 | + const plotState = get(plotDataStore); |
| 42 | +
|
36 | 43 | // Calculate bounding box of all nodes, accounting for origin |
37 | 44 | let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity; |
38 | 45 | for (const node of nodes) { |
|
42 | 49 | const origin = (node.origin as [number, number]) ?? [0.5, 0.5]; |
43 | 50 | const left = node.position.x - width * origin[0]; |
44 | 51 | const top = node.position.y - height * origin[1]; |
45 | | - minX = Math.min(minX, left); |
46 | | - minY = Math.min(minY, top); |
47 | | - maxX = Math.max(maxX, left + width); |
48 | | - maxY = Math.max(maxY, top + height); |
| 52 | + let bounds = { left, top, right: left + width, bottom: top + height }; |
| 53 | +
|
| 54 | + // Extend bounds for pinned plot previews on recording blocks (Scope/Spectrum) |
| 55 | + if (previewsPinned && node.type === 'pathview' && plotState.plots.has(node.id)) { |
| 56 | + const data = node.data as NodeInstance; |
| 57 | + const rotation = (data.params?.['_rotation'] as number) || 0; |
| 58 | + bounds = extendBoundsForPreview(bounds, previewSideForRotation(rotation)); |
| 59 | + } |
| 60 | +
|
| 61 | + minX = Math.min(minX, bounds.left); |
| 62 | + minY = Math.min(minY, bounds.top); |
| 63 | + maxX = Math.max(maxX, bounds.right); |
| 64 | + maxY = Math.max(maxY, bounds.bottom); |
49 | 65 | } |
50 | 66 |
|
51 | 67 | // Add some padding around the nodes themselves |
|
0 commit comments