import { IConvertObjType, IDrawingEvents, IContrastEvents, IDrawOpts } from "./core/types"; import { CanvasState } from "./CanvasState"; import { RenderingUtils } from "./RenderingUtils"; import { EventRouter } from "./eventRouter"; import { SphereTool } from "./tools/SphereTool"; import { CrosshairTool } from "./tools/CrosshairTool"; import { ContrastTool } from "./tools/ContrastTool"; import { ZoomTool } from "./tools/ZoomTool"; import { EraserTool } from "./tools/EraserTool"; import { PanTool } from "./tools/PanTool"; import { DrawingTool } from "./tools/DrawingTool"; import { ImageStoreHelper } from "./tools/ImageStoreHelper"; import { SphereBrushTool } from "./tools/SphereBrushTool"; import { AiAssistTool } from "./tools/AiAssistTool"; import { UndoManager } from "./core"; /** * DrawToolCore — Tool orchestration and event routing. * * Previously extended CommToolsData; now uses composition: * - `state: CanvasState` — pure state container * - `renderer: RenderingUtils` — rendering / slice-buffer helpers * * Created by NrrdTools which passes in a shared CanvasState. */ export declare class DrawToolCore { container: HTMLElement; mainAreaContainer: HTMLDivElement; /** Shared state container (created by NrrdTools, passed in). */ readonly state: CanvasState; /** Rendering utilities (created here, uses shared state). */ readonly renderer: RenderingUtils; drawingPrameters: IDrawingEvents; contrastEventPrameters: IContrastEvents; pencilUrls: string[]; undoManager: UndoManager; eventRouter: EventRouter; sphereTool: SphereTool; crosshairTool: CrosshairTool; protected contrastTool: ContrastTool; protected zoomTool: ZoomTool; protected eraserTool: EraserTool; protected panTool: PanTool; protected drawingTool: DrawingTool; protected imageStoreHelper: ImageStoreHelper; protected sphereBrushTool: SphereBrushTool; /** AI-assist interactive prompt tool (experimental). Public so NrrdTools/app can drive it. */ aiAssistTool: AiAssistTool; /** Slice index recorded when paintOnCanvas() starts, guards stale-click */ private paintSliceIndex; /** Wheel event dispatch mode — replaces manual wheel add/remove (Phase 2) */ private activeWheelMode; /** * While a slice-drag is in progress we temporarily reinterpret the wheel * as Scroll:Slice so that wheel + drag both move slices instead of drag * switching slices while wheel zooms. The original setting captured here * is restored on pointerup. `null` means no swap is currently active. * Only set to 'Scroll:Zoom' — Scroll:Slice never needs a swap. */ private wheelModeBeforeDrag; start: () => void; constructor(container: HTMLElement, state: CanvasState); private initTools; private initDrawToolCore; /** * Shift + mouse-wheel resize for the brush and eraser tools. * * Mirrors the sphereBrush/sphereEraser "scroll to change radius" UX so the * user no longer has to reach for the B&E Size slider mid-annotation. Active * whenever the EventRouter is in `draw` mode (i.e. Shift is held — with or * without the left button down) and the current tool is brush or eraser. * * Pencil is deliberately excluded: it also draws with Shift, but its stroke * width is fixed and unrelated to `brushAndEraserSize`. Sphere-family tools * keep their own wheel-radius handler (`activeWheelMode === 'sphereBrush'`). * * `gui_states.mode` is the source of truth for the active tool here, not * `eventRouter.getGuiTool()` — the latter is only updated for sphere tools. * * @returns true if the event was handled (and should not fall through to * the zoom/slice/sphere wheel handlers). */ private tryBrushEraserResizeWheel; setPencilIconUrls(urls: string[]): void; private setCurrentLayer; draw(opts?: IDrawOpts): void; private zoomActionAfterDrawSphere; private paintOnCanvas; /** * Extracted from paintOnCanvas() pointerleave handler. */ private handlePointerLeave; /** Extracted from paintOnCanvas() — handles sphere placement on left-click */ private handleSphereClick; private initAllCanvas; private useEraser; configMouseZoomWheel(): (e: WheelEvent) => void; configMouseSliceWheel(): void; private enableCrosshair; drawImageOnEmptyImage(canvas: HTMLCanvasElement): void; /****************************Sphere functions (delegated to SphereTool)****************************************************/ drawCalculatorSphereOnEachViews(axis: "x" | "y" | "z"): void; private configMouseSphereWheel; drawCalculatorSphere(radius: number): void; drawSphere(mouseX: number, mouseY: number, radius: number): void; /** * Refresh sphere canvas from sphereMaskVolume for the current slice/axis. */ refreshSphereOverlay(): void; /** * Convert cursor point between axis views. * Delegated to CrosshairTool. */ convertCursorPoint(from: "x" | "y" | "z", to: "x" | "y" | "z", cursorNumX: number, cursorNumY: number, currentSliceIndex: number): IConvertObjType | undefined; private setUpSphereOrigins; /****************************layer div controls****************************************************/ getRestLayer(): string[]; /**************************** Undo/Redo functions (Phase 6 — Delta-based) ****************************/ /** * Clear the mask on the current slice canvas for the active layer ONLY. */ clearActiveSlice(): void; /** * Undo the last drawing operation on the active layer. */ undoLastPainting(): void; /** * Redo the last undone operation on the active layer. */ redoLastPainting(): void; /** * Re-render a layer canvas from MaskVolume and composite to master. */ private applyUndoRedoToCanvas; /****************************Store images (delegated to ImageStoreHelper)****************************************************/ syncLayerSliceData(index: number, layer: string): void; /******************************** Utils gui related functions (delegated to ContrastTool) ***************************************/ setupConrastEvents(callback: (step: number, towards: "horizental" | "vertical") => void): void; configContrastDragMode: () => void; removeContrastDragMode: () => void; updateSlicesContrast: (value: number, flag: string) => void; repraintCurrentContrastSlice: () => void; /** Override in NrrdTools */ setIsDrawFalse(target: number): void; /** Override in NrrdTools */ setSyncsliceNum(): void; /** Override in NrrdTools */ resetPaintAreaUIPosition(l?: number, t?: number): void; /** Override in NrrdTools */ resizePaintArea(factor: number): void; /** Override in NrrdTools */ setEmptyCanvasSize(axis?: "x" | "y" | "z"): void; /** Override in NrrdTools */ flipDisplayImageByAxis(): void; /** Override in NrrdTools */ updateOriginAndChangedWH(): void; /** Override in NrrdTools */ resetLayerCanvas(): void; /** Override in NrrdTools */ redrawDisplayCanvas(): void; /** Override in NrrdTools */ enterSphereMode(): void; /** Override in NrrdTools */ exitSphereMode(): void; /** Override in NrrdTools */ reloadMasksFromVolume(): void; /** Override in NrrdTools */ updateMouseWheelEvent(): void; }