simple-circuit-engine 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +10 -7
- package/CLAUDE.md +4 -6
- package/README.md +5 -2
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.js +74 -2114
- package/dist/core/setup.d.ts +17 -0
- package/dist/core/simulation/CircuitRunner.d.ts +176 -0
- package/dist/core/simulation/DirtyTracker.d.ts +87 -0
- package/dist/core/simulation/EventQueue.d.ts +68 -0
- package/dist/core/simulation/StateManager.d.ts +100 -0
- package/dist/core/simulation/behaviors/BehaviorRegistry.d.ts +70 -0
- package/dist/core/simulation/behaviors/ComponentBehavior.d.ts +53 -0
- package/dist/core/simulation/behaviors/basic/BatteryBehavior.d.ts +14 -0
- package/dist/core/simulation/behaviors/basic/ClockBehavior.d.ts +24 -0
- package/dist/core/simulation/behaviors/basic/DoubleThrowSwitchBehavior.d.ts +33 -0
- package/dist/core/simulation/behaviors/basic/LightbulbBehavior.d.ts +23 -0
- package/dist/core/simulation/behaviors/basic/RectangleLEDBehavior.d.ts +24 -0
- package/dist/core/simulation/behaviors/basic/RelayBehavior.d.ts +33 -0
- package/dist/core/simulation/behaviors/basic/SmallLEDBehavior.d.ts +24 -0
- package/dist/core/simulation/behaviors/basic/SwitchBehavior.d.ts +33 -0
- package/dist/core/simulation/behaviors/basic/index.d.ts +20 -0
- package/dist/core/simulation/behaviors/gates/InverterBehavior.d.ts +29 -0
- package/dist/core/simulation/behaviors/gates/Nand4GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/Nand8GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/NandGateBehavior.d.ts +28 -0
- package/dist/core/simulation/behaviors/gates/Nor4GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/Nor8GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/NorGateBehavior.d.ts +22 -0
- package/dist/core/simulation/behaviors/gates/Xor4GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/Xor8GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/XorGateBehavior.d.ts +22 -0
- package/dist/core/simulation/behaviors/gates/index.d.ts +34 -0
- package/dist/core/simulation/behaviors/index.d.ts +24 -0
- package/dist/core/simulation/behaviors/types.d.ts +101 -0
- package/dist/core/simulation/index.d.ts +18 -0
- package/dist/core/simulation/states/ComponentState.d.ts +57 -0
- package/dist/core/simulation/states/SimulationState.d.ts +46 -0
- package/dist/core/simulation/states/basic/BatteryState.d.ts +16 -0
- package/dist/core/simulation/states/basic/ClockState.d.ts +16 -0
- package/dist/core/simulation/states/basic/DoubleThrowSwitchState.d.ts +21 -0
- package/dist/core/simulation/states/basic/LightbulbState.d.ts +21 -0
- package/dist/core/simulation/states/basic/RectangleLEDState.d.ts +9 -0
- package/dist/core/simulation/states/basic/RelayState.d.ts +25 -0
- package/dist/core/simulation/states/basic/SmallLEDState.d.ts +21 -0
- package/dist/core/simulation/states/basic/SwitchState.d.ts +25 -0
- package/dist/core/simulation/states/gates/InverterState.d.ts +17 -0
- package/dist/core/simulation/states/gates/Nand4GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Nand8GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/NandGateState.d.ts +16 -0
- package/dist/core/simulation/states/gates/Nor4GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Nor8GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/NorGateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Xor4GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Xor8GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/XorGateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/index.d.ts +25 -0
- package/dist/core/simulation/states/index.d.ts +26 -0
- package/dist/core/simulation/states/types.d.ts +32 -0
- package/dist/core/simulation/types.d.ts +155 -0
- package/dist/core/topology/Circuit.d.ts +420 -0
- package/dist/core/topology/CircuitMetadata.d.ts +24 -0
- package/dist/core/topology/CircuitOptions.d.ts +14 -0
- package/dist/core/topology/Component.d.ts +152 -0
- package/dist/core/topology/ENode.d.ts +200 -0
- package/dist/core/topology/Wire.d.ts +130 -0
- package/dist/core/topology/delays.d.ts +52 -0
- package/dist/core/topology/index.d.ts +14 -0
- package/dist/core/topology/types.d.ts +175 -0
- package/dist/core/utils/CameraOptions.d.ts +83 -0
- package/dist/core/utils/MemoizeDecorator.d.ts +9 -0
- package/dist/core/utils/Position.d.ts +166 -0
- package/dist/core/utils/Position3D.d.ts +77 -0
- package/dist/core/utils/Rotation.d.ts +82 -0
- package/dist/core/utils/index.d.ts +24 -0
- package/dist/core/utils/types.d.ts +35 -0
- package/dist/core-Bjta9Y7_.js +2707 -0
- package/dist/core-Bjta9Y7_.js.map +1 -0
- package/dist/index.d.ts +13 -6306
- package/dist/index.js +117 -110
- package/dist/scene/CircuitEngine.d.ts +270 -0
- package/dist/scene/index.d.ts +0 -1
- package/dist/scene/index.js +43 -39
- package/dist/scene/setup.d.ts +18 -0
- package/dist/scene/shared/AbstractCircuitController.d.ts +211 -0
- package/dist/scene/shared/BranchingPointVisualFactory.d.ts +70 -0
- package/dist/scene/shared/EventEmitter.d.ts +92 -0
- package/dist/scene/shared/HoverManager.d.ts +151 -0
- package/dist/scene/shared/SelectionManager.d.ts +159 -0
- package/dist/scene/shared/WireVisualManager.d.ts +242 -0
- package/dist/scene/shared/components/ComponentVisualFactory.d.ts +438 -0
- package/dist/scene/shared/components/DefaultVisualFactory.d.ts +51 -0
- package/dist/scene/shared/components/FactoryRegistry.d.ts +84 -0
- package/dist/scene/shared/components/GroupedFactoryRegistry.d.ts +153 -0
- package/dist/scene/shared/components/basic/BatteryVisualFactory.d.ts +13 -0
- package/dist/scene/shared/components/basic/ClockVisualFactory.d.ts +79 -0
- package/dist/scene/shared/components/basic/DoubleThrowSwitchVisualFactory.d.ts +87 -0
- package/dist/scene/shared/components/basic/LabelVisualFactory.d.ts +148 -0
- package/dist/scene/shared/components/basic/LightbulbVisualFactory.d.ts +72 -0
- package/dist/scene/shared/components/basic/RectangleLEDVisualFactory.d.ts +86 -0
- package/dist/scene/shared/components/basic/RelayVisualFactory.d.ts +92 -0
- package/dist/scene/shared/components/basic/SmallLEDVisualFactory.d.ts +86 -0
- package/dist/scene/shared/components/basic/SwitchVisualFactory.d.ts +85 -0
- package/dist/scene/shared/components/gates/InverterVisualFactory.d.ts +104 -0
- package/dist/scene/shared/components/gates/Nand4GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/Nand8GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/NandGateVisualFactory.d.ts +101 -0
- package/dist/scene/shared/components/gates/Nor4GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/Nor8GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/NorGateVisualFactory.d.ts +101 -0
- package/dist/scene/shared/components/gates/Xor4GateVisualFactory.d.ts +29 -0
- package/dist/scene/shared/components/gates/Xor8GateVisualFactory.d.ts +29 -0
- package/dist/scene/shared/components/gates/XorGateVisualFactory.d.ts +103 -0
- package/dist/scene/shared/components/index.d.ts +29 -0
- package/dist/scene/shared/components/types.d.ts +43 -0
- package/dist/scene/shared/types.d.ts +476 -0
- package/dist/scene/shared/utils/CameraUtils.d.ts +23 -0
- package/dist/scene/shared/utils/ColorUtils.d.ts +26 -0
- package/dist/scene/shared/utils/ControlsUtils.d.ts +8 -0
- package/dist/scene/shared/utils/GeometryUtils.d.ts +261 -0
- package/dist/scene/shared/utils/LayerConstants.d.ts +40 -0
- package/dist/scene/shared/utils/LightingUtils.d.ts +31 -0
- package/dist/scene/shared/utils/MaterialUtils.d.ts +73 -0
- package/dist/scene/shared/utils/Options.d.ts +16 -0
- package/dist/scene/simulation/CircuitRunnerController.d.ts +227 -0
- package/dist/scene/static/CircuitController.d.ts +227 -0
- package/dist/scene/static/CircuitWriter.d.ts +146 -0
- package/dist/scene/static/PinTooltipWidget.d.ts +26 -0
- package/dist/scene/static/tools/BuildTool.d.ts +286 -0
- package/dist/scene/static/tools/ComponentPickerWidget.d.ts +82 -0
- package/dist/scene/static/tools/ConfigPanelWidget.d.ts +93 -0
- package/dist/scene/static/tools/MultiSelectTool.d.ts +265 -0
- package/dist/scene-CVsDdySt.js +7357 -0
- package/dist/scene-CVsDdySt.js.map +1 -0
- package/package.json +24 -25
- package/dist/CircuitRunner-BQQlhwjD.js +0 -1981
- package/dist/CircuitRunner-BQQlhwjD.js.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/scene/index.js.map +0 -1
- package/dist/setup-CIq_kgaw.js +0 -10230
- package/dist/setup-CIq_kgaw.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ComponentType } from '../../../core/index.ts';
|
|
2
|
+
import { IGroupedFactoryRegistry } from '../../shared/components/GroupedFactoryRegistry';
|
|
3
|
+
/**
|
|
4
|
+
* Sentinel value representing the "Branching Point" pseudo-component entry.
|
|
5
|
+
* When selected, BuildTool creates a branching point instead of a component.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BRANCHING_POINT_SENTINEL: "__branching_point__";
|
|
8
|
+
/**
|
|
9
|
+
* Union of actual component types and the branching point sentinel.
|
|
10
|
+
*/
|
|
11
|
+
export type PickerSelection = ComponentType | typeof BRANCHING_POINT_SENTINEL;
|
|
12
|
+
/**
|
|
13
|
+
* Persisted widget state (survives open/close cycles within a session).
|
|
14
|
+
*/
|
|
15
|
+
export interface ComponentPickerState {
|
|
16
|
+
selectedGroupId: string;
|
|
17
|
+
selectedItem: PickerSelection | null;
|
|
18
|
+
widgetWidth: number;
|
|
19
|
+
widgetHeight: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* DOM overlay widget for selecting components from grouped registry.
|
|
23
|
+
*
|
|
24
|
+
* Features:
|
|
25
|
+
* - Group dropdown for filtering component types
|
|
26
|
+
* - Scrollable item list with selection highlight
|
|
27
|
+
* - Draggable header bar
|
|
28
|
+
* - Resizable via CSS resize
|
|
29
|
+
* - State persistence across open/close (group, selection, size)
|
|
30
|
+
*/
|
|
31
|
+
export declare class ComponentPickerWidget {
|
|
32
|
+
private readonly registry;
|
|
33
|
+
private container;
|
|
34
|
+
private groupDropdown;
|
|
35
|
+
private itemList;
|
|
36
|
+
private state;
|
|
37
|
+
private readonly onSelectionChange;
|
|
38
|
+
private readonly onClose;
|
|
39
|
+
private escapeHandler;
|
|
40
|
+
private dragOffset;
|
|
41
|
+
private dragMoveHandler;
|
|
42
|
+
private dragEndHandler;
|
|
43
|
+
/**
|
|
44
|
+
* @param registry - Grouped factory registry providing groups and component types
|
|
45
|
+
* @param onSelectionChange - Called when user selects or deselects an item
|
|
46
|
+
* @param onClose - Called when user closes the widget (close button or Escape)
|
|
47
|
+
*/
|
|
48
|
+
constructor(registry: IGroupedFactoryRegistry, onSelectionChange: (selection: PickerSelection | null) => void, onClose: () => void);
|
|
49
|
+
/** Whether the widget is currently open and visible */
|
|
50
|
+
get isOpen(): boolean;
|
|
51
|
+
/** The currently selected item (persists across open/close) */
|
|
52
|
+
get currentSelection(): PickerSelection | null;
|
|
53
|
+
/**
|
|
54
|
+
* Open the widget at the given screen position.
|
|
55
|
+
* If already open, repositions to the new location.
|
|
56
|
+
*
|
|
57
|
+
* @param screenPosition - Screen coordinates (typically from mouse event)
|
|
58
|
+
*/
|
|
59
|
+
open(screenPosition: {
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
}): void;
|
|
63
|
+
/**
|
|
64
|
+
* Close the widget and remove DOM.
|
|
65
|
+
* Preserves state (group, selection, size) for next open.
|
|
66
|
+
*/
|
|
67
|
+
close(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Full cleanup including state reset.
|
|
70
|
+
*/
|
|
71
|
+
dispose(): void;
|
|
72
|
+
private createDOM;
|
|
73
|
+
private renderItemList;
|
|
74
|
+
private createItemElement;
|
|
75
|
+
private selectItem;
|
|
76
|
+
private positionContainer;
|
|
77
|
+
private startDrag;
|
|
78
|
+
private onDragMove;
|
|
79
|
+
private endDrag;
|
|
80
|
+
private registerEventListeners;
|
|
81
|
+
private removeEventListeners;
|
|
82
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { UUID, Component } from '../../../core/index.ts';
|
|
2
|
+
import { IFactoryRegistry } from '../../shared/components/ComponentVisualFactory';
|
|
3
|
+
/**
|
|
4
|
+
* Manages lil-gui configuration panel for component config editing
|
|
5
|
+
*
|
|
6
|
+
* Responsibilities:
|
|
7
|
+
* - Panel lifecycle (open, close, dispose)
|
|
8
|
+
* - DOM container creation and positioning
|
|
9
|
+
* - lil-gui initialization and form building
|
|
10
|
+
* - Click-outside and Escape key handling
|
|
11
|
+
* - onChange event wiring to update component config
|
|
12
|
+
* - Event emission for config changes
|
|
13
|
+
*/
|
|
14
|
+
export declare class ConfigPanelWidget {
|
|
15
|
+
private factoryRegistry;
|
|
16
|
+
private readonly editComponentConfig;
|
|
17
|
+
private _isOpen;
|
|
18
|
+
private _currentComponentId;
|
|
19
|
+
private gui;
|
|
20
|
+
private container;
|
|
21
|
+
private formDataObject;
|
|
22
|
+
private clickOutsideHandler;
|
|
23
|
+
private escapeHandler;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new ConfigPanelManager
|
|
26
|
+
*
|
|
27
|
+
* @param factoryRegistry - Factory registry for getting component factories
|
|
28
|
+
* @param editComponentConfig - Function to edit component config
|
|
29
|
+
* @param _camera - Three.js camera (reserved for future use)
|
|
30
|
+
* @param _domElement - Container DOM element (reserved for future use)
|
|
31
|
+
*/
|
|
32
|
+
constructor(factoryRegistry: IFactoryRegistry, editComponentConfig: (componentId: UUID, newConfig: Map<string, string>) => void, _camera: unknown, _domElement: unknown);
|
|
33
|
+
/**
|
|
34
|
+
* Check if panel is currently open
|
|
35
|
+
*/
|
|
36
|
+
get isOpen(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get the ID of the component currently being edited
|
|
39
|
+
*/
|
|
40
|
+
get currentComponentId(): UUID | null;
|
|
41
|
+
/**
|
|
42
|
+
* Open the config panel for a component
|
|
43
|
+
*
|
|
44
|
+
* @param component - component to edit
|
|
45
|
+
* @param screenPosition - Screen coordinates for panel positioning
|
|
46
|
+
* @returns true if panel opened, false if component has no config
|
|
47
|
+
*/
|
|
48
|
+
open(component: Component, screenPosition: {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
}): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Close the config panel if open
|
|
54
|
+
*/
|
|
55
|
+
close(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Dispose of all resources
|
|
58
|
+
*/
|
|
59
|
+
dispose(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Position the container adjacent to component (right side preferred)
|
|
62
|
+
*/
|
|
63
|
+
private positionContainer;
|
|
64
|
+
/**
|
|
65
|
+
* Build lil-gui from form definition
|
|
66
|
+
*/
|
|
67
|
+
private buildGui;
|
|
68
|
+
/**
|
|
69
|
+
* Handle value change in the config form
|
|
70
|
+
* Maps form data back to core config and updates the component.
|
|
71
|
+
* When defaultLogicFamily or activationLogic changes, rebuilds the GUI to reflect
|
|
72
|
+
* updated disabled states and computed transitionSpan values.
|
|
73
|
+
*
|
|
74
|
+
* @param changedKey - The key of the field that changed
|
|
75
|
+
* @param _value - The new value
|
|
76
|
+
* @param component - Component being edited
|
|
77
|
+
* @param factory - Visual factory for the component
|
|
78
|
+
*/
|
|
79
|
+
private onValueChange;
|
|
80
|
+
/**
|
|
81
|
+
* Rebuild the GUI in place, re-reading the updated component config.
|
|
82
|
+
* Used after interdependent field changes (defaultLogicFamily, activationLogic).
|
|
83
|
+
*/
|
|
84
|
+
private rebuildGui;
|
|
85
|
+
/**
|
|
86
|
+
* Setup event listeners for dismissing the panel
|
|
87
|
+
*/
|
|
88
|
+
private setupEventListeners;
|
|
89
|
+
/**
|
|
90
|
+
* Remove event listeners
|
|
91
|
+
*/
|
|
92
|
+
private removeEventListeners;
|
|
93
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { UUID, ENodeSourceType } from '../../../core/index.ts';
|
|
2
|
+
import { IEditingTool, CursorType } from '../../shared/types';
|
|
3
|
+
import { CircuitController } from '../CircuitController';
|
|
4
|
+
/**
|
|
5
|
+
* MultiSelectTool - Enables multi-element selection and bulk operations
|
|
6
|
+
* @module scene/static/tools/MultiSelectTool
|
|
7
|
+
*/
|
|
8
|
+
import * as THREE from 'three';
|
|
9
|
+
/**
|
|
10
|
+
* Operating modes for the MultiSelectTool
|
|
11
|
+
*/
|
|
12
|
+
export type MultiSelectToolMode = 'idle' | 'selecting' | 'dragging';
|
|
13
|
+
/**
|
|
14
|
+
* State during rectangle selection operation (T010)
|
|
15
|
+
*/
|
|
16
|
+
export interface SelectionRectState {
|
|
17
|
+
/** Starting mouse position in screen coordinates */
|
|
18
|
+
startScreen: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
/** Current mouse position in screen coordinates */
|
|
23
|
+
currentScreen: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
};
|
|
27
|
+
/** DOM element for visual rectangle overlay */
|
|
28
|
+
overlayElement: HTMLDivElement;
|
|
29
|
+
/** Whether Shift key is held (additive selection mode) */
|
|
30
|
+
shiftHeld: boolean;
|
|
31
|
+
/** Elements currently previewed as "will be selected" */
|
|
32
|
+
previewedElements: Set<UUID>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* State during bulk move operation (T023)
|
|
36
|
+
*/
|
|
37
|
+
export interface BulkDragState {
|
|
38
|
+
/** Starting cursor position in world coordinates */
|
|
39
|
+
dragStartWorld: THREE.Vector3;
|
|
40
|
+
/** Snapshot of initial positions for all selected elements */
|
|
41
|
+
initialPositions: Map<UUID, THREE.Vector3>;
|
|
42
|
+
/** Wire IDs that need geometry updates during drag */
|
|
43
|
+
affectedWireIds: Set<UUID>;
|
|
44
|
+
/** Initial intermediate positions for selected wires (wireId -> array of positions) */
|
|
45
|
+
initialWireIntermediatePositions: Map<UUID, THREE.Vector3[]>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Complete clipboard data structure for copy/paste
|
|
49
|
+
* TODO : copy and paste edited enodes sourceType and components config
|
|
50
|
+
*/
|
|
51
|
+
export interface ClipboardData {
|
|
52
|
+
/** Center of selection bounding box in grid coordinates */
|
|
53
|
+
anchor: {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
};
|
|
57
|
+
/** Copied component definitions */
|
|
58
|
+
components: ClipboardComponent[];
|
|
59
|
+
/** Copied branching point definitions */
|
|
60
|
+
branchingPoints: ClipboardBranchingPoint[];
|
|
61
|
+
/** Copied wire definitions (only wires with both endpoints in selection) */
|
|
62
|
+
wires: ClipboardWire[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Component data within clipboard
|
|
66
|
+
*/
|
|
67
|
+
export interface ClipboardComponent {
|
|
68
|
+
/** Component type identifier */
|
|
69
|
+
type: string;
|
|
70
|
+
/** Position relative to clipboard anchor */
|
|
71
|
+
relativePosition: {
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
};
|
|
75
|
+
/** Rotation angle in degrees */
|
|
76
|
+
rotation: number;
|
|
77
|
+
/** Original element ID for wire remapping during paste */
|
|
78
|
+
originalId: UUID;
|
|
79
|
+
/** Original configuration data for the component */
|
|
80
|
+
config: Map<string, string>;
|
|
81
|
+
/** Original pins sourceTypes */
|
|
82
|
+
pinSources: Array<ENodeSourceType | undefined | null>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Branching point data within clipboard
|
|
86
|
+
*/
|
|
87
|
+
export interface ClipboardBranchingPoint {
|
|
88
|
+
/** Position relative to clipboard anchor */
|
|
89
|
+
relativePosition: {
|
|
90
|
+
x: number;
|
|
91
|
+
y: number;
|
|
92
|
+
};
|
|
93
|
+
/** Original element ID for wire remapping during paste */
|
|
94
|
+
originalId: UUID;
|
|
95
|
+
/** Source type of the branching point */
|
|
96
|
+
source?: ENodeSourceType | undefined;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Wire data within clipboard
|
|
100
|
+
*/
|
|
101
|
+
export interface ClipboardWire {
|
|
102
|
+
/** Original ID of first endpoint (component pin or branching point) */
|
|
103
|
+
node1OriginalId: UUID;
|
|
104
|
+
/** Original ID of second endpoint */
|
|
105
|
+
node2OriginalId: UUID;
|
|
106
|
+
/** Intermediate positions relative to clipboard anchor */
|
|
107
|
+
relativeIntermediatePositions: Array<{
|
|
108
|
+
x: number;
|
|
109
|
+
y: number;
|
|
110
|
+
}>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* MultiSelectTool implementation
|
|
114
|
+
*
|
|
115
|
+
* Provides functionality for:
|
|
116
|
+
* - Rectangle selection of multiple elements
|
|
117
|
+
* - Bulk move operations
|
|
118
|
+
* - Bulk delete operations
|
|
119
|
+
* - Copy/paste and cut/paste operations
|
|
120
|
+
*/
|
|
121
|
+
export declare class MultiSelectTool implements IEditingTool {
|
|
122
|
+
readonly type: "multiSelect";
|
|
123
|
+
private mode;
|
|
124
|
+
private readonly controller;
|
|
125
|
+
private selectionRectState;
|
|
126
|
+
private bulkDragState;
|
|
127
|
+
private clipboardData;
|
|
128
|
+
private clipboardPinToComponent;
|
|
129
|
+
private clipboardPinIndices;
|
|
130
|
+
private handlePointerDown;
|
|
131
|
+
private handlePointerMove;
|
|
132
|
+
private handlePointerUp;
|
|
133
|
+
private handleKeyDown;
|
|
134
|
+
private handleGridPositionMove;
|
|
135
|
+
constructor(controller: CircuitController);
|
|
136
|
+
/**
|
|
137
|
+
* Get the current operating mode
|
|
138
|
+
*/
|
|
139
|
+
getMode(): MultiSelectToolMode;
|
|
140
|
+
/**
|
|
141
|
+
* Called when tool becomes active
|
|
142
|
+
*/
|
|
143
|
+
onActivate(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Called when tool is deactivated
|
|
146
|
+
*/
|
|
147
|
+
onDeactivate(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Cancel any in-progress operation
|
|
150
|
+
*/
|
|
151
|
+
cancelOperation(): void;
|
|
152
|
+
/**
|
|
153
|
+
* Get the current cursor type for this tool (T031)
|
|
154
|
+
*/
|
|
155
|
+
getCursorType(): CursorType;
|
|
156
|
+
/**
|
|
157
|
+
* Get preview objects to render in the scene
|
|
158
|
+
*/
|
|
159
|
+
getPreviewObjects(): THREE.Object3D[];
|
|
160
|
+
/**
|
|
161
|
+
* Handle pointer down event (T011, T019, T020, T021, T024)
|
|
162
|
+
* - Empty space: start rectangle selection
|
|
163
|
+
* - Element click: select that element (clear others unless Shift held)
|
|
164
|
+
* - Selected element: prepare for bulk drag (Phase 4)
|
|
165
|
+
*/
|
|
166
|
+
private _handlePointerDown;
|
|
167
|
+
/**
|
|
168
|
+
* Handle pointer move event (T013)
|
|
169
|
+
* Updates rectangle dimensions during selection
|
|
170
|
+
*/
|
|
171
|
+
private _handlePointerMove;
|
|
172
|
+
/**
|
|
173
|
+
* Handle pointer up event (T016, T021, T029)
|
|
174
|
+
* Commits selection or bulk drag, or clears if it was just a click
|
|
175
|
+
*/
|
|
176
|
+
private _handlePointerUp;
|
|
177
|
+
/**
|
|
178
|
+
* Handle grid position move event (T027)
|
|
179
|
+
* Updates element positions during bulk drag
|
|
180
|
+
*/
|
|
181
|
+
private _handleGridPositionMove;
|
|
182
|
+
/**
|
|
183
|
+
* Handle keyboard events (T017, T030, T034, T043, T048, T053)
|
|
184
|
+
* - Escape: cancel current operation
|
|
185
|
+
* - Delete/Backspace: delete selection
|
|
186
|
+
* - Ctrl+C/Cmd+C: copy selection
|
|
187
|
+
* - Ctrl+V/Cmd+V: paste clipboard
|
|
188
|
+
* - Ctrl+X/Cmd+X: cut selection
|
|
189
|
+
*/
|
|
190
|
+
private _handleKeyDown;
|
|
191
|
+
/**
|
|
192
|
+
* Start rectangle selection (T012)
|
|
193
|
+
*/
|
|
194
|
+
private _startSelectionRect;
|
|
195
|
+
/**
|
|
196
|
+
* Update CSS overlay dimensions and position (T013)
|
|
197
|
+
*/
|
|
198
|
+
private _updateSelectionRectOverlay;
|
|
199
|
+
/**
|
|
200
|
+
* Update preview highlighting for elements inside rectangle (T015)
|
|
201
|
+
*/
|
|
202
|
+
private _updatePreviewHighlighting;
|
|
203
|
+
/**
|
|
204
|
+
* Get elements inside the current selection rectangle (T014)
|
|
205
|
+
* Components/BPs: selected if center is inside rectangle
|
|
206
|
+
* Wires: selected only if BOTH endpoints are selected
|
|
207
|
+
*/
|
|
208
|
+
private _getElementsInSelectionRect;
|
|
209
|
+
/**
|
|
210
|
+
* Commit the rectangle selection (T016, T018, T022)
|
|
211
|
+
*/
|
|
212
|
+
private _commitSelectionRect;
|
|
213
|
+
/**
|
|
214
|
+
* Cancel rectangle selection (T017)
|
|
215
|
+
*/
|
|
216
|
+
private _cancelSelectionRect;
|
|
217
|
+
/**
|
|
218
|
+
* Clean up selection rectangle overlay
|
|
219
|
+
*/
|
|
220
|
+
private _cleanupSelectionRect;
|
|
221
|
+
/**
|
|
222
|
+
* Start bulk drag operation (T024, T025, T026, T032)
|
|
223
|
+
*/
|
|
224
|
+
private _startBulkDrag;
|
|
225
|
+
/**
|
|
226
|
+
* Update bulk drag - apply delta to all selected elements (T027, T028)
|
|
227
|
+
*/
|
|
228
|
+
private _updateBulkDrag;
|
|
229
|
+
/**
|
|
230
|
+
* Commit bulk drag operation (T029, T032)
|
|
231
|
+
*/
|
|
232
|
+
private _commitBulkDrag;
|
|
233
|
+
/**
|
|
234
|
+
* Cancel bulk drag operation - revert all elements to initial positions (T030)
|
|
235
|
+
*/
|
|
236
|
+
private _cancelBulkDrag;
|
|
237
|
+
/**
|
|
238
|
+
* Check if clipboard has content (T050)
|
|
239
|
+
*/
|
|
240
|
+
hasClipboardContent(): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Copy current selection to clipboard (T039, T040, T041, T042, T051)
|
|
243
|
+
* @returns true if copy succeeded (non-empty selection)
|
|
244
|
+
*/
|
|
245
|
+
copySelection(): boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Paste clipboard content at cursor position (T044, T045, T046, T047, T049, T051)
|
|
248
|
+
* @returns true if paste succeeded (non-empty clipboard)
|
|
249
|
+
*/
|
|
250
|
+
pasteAtCursor(): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Cut current selection (copy + delete) (T052)
|
|
253
|
+
* @returns true if cut succeeded
|
|
254
|
+
*/
|
|
255
|
+
cutSelection(): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Delete all selected elements (T033, T034, T035, T036, T037)
|
|
258
|
+
*
|
|
259
|
+
* Deletion order per research.md:
|
|
260
|
+
* 1. Selected wires
|
|
261
|
+
* 2. Selected components (cascades to connected wires)
|
|
262
|
+
* 3. Selected branching points
|
|
263
|
+
*/
|
|
264
|
+
deleteSelection(): boolean;
|
|
265
|
+
}
|