Skip to content

Commit 237fc09

Browse files
committed
fix(voxel-annotations): do not display the brush cursor in the 3d view
1 parent bb53de2 commit 237fc09

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

src/layer/vox/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ export function UserLayerWithVoxelEditingMixin<
300300
value = BigInt(x);
301301
}
302302

303-
const info = DATA_TYPE_BIT_INFO[dataType as keyof typeof DATA_TYPE_BIT_INFO];
303+
const info =
304+
DATA_TYPE_BIT_INFO[dataType as keyof typeof DATA_TYPE_BIT_INFO];
304305
if (!info) {
305306
this.paintValue.value = value;
306307
return value;
@@ -313,15 +314,14 @@ export function UserLayerWithVoxelEditingMixin<
313314
if (signed) {
314315
const signBit = 1n << BigInt(bits - 1);
315316
if ((truncated & signBit) !== 0n) {
316-
truncated -= (1n << BigInt(bits));
317+
truncated -= 1n << BigInt(bits);
317318
}
318319
}
319320

320321
this.paintValue.value = truncated;
321322
return truncated;
322323
}
323324

324-
325325
abstract _createVoxelRenderLayer(
326326
source: MultiscaleVolumeChunkSource,
327327
transform: WatchableValueInterface<RenderLayerTransformOrError>,

src/rendered_data_panel.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -816,16 +816,16 @@ export abstract class RenderedDataPanel extends RenderedPanel {
816816
},
817817
);
818818

819-
this.overlay_canvas = document.createElement('canvas');
820-
this.overlay_canvas.style.position = 'absolute';
821-
this.overlay_canvas.style.top = '0';
822-
this.overlay_canvas.style.left = '0';
823-
this.overlay_canvas.style.width = '100%';
824-
this.overlay_canvas.style.height = '100%';
825-
this.overlay_canvas.style.pointerEvents = 'none';
826-
this.overlay_canvas.style.zIndex = '10';
819+
this.overlay_canvas = document.createElement("canvas");
820+
this.overlay_canvas.style.position = "absolute";
821+
this.overlay_canvas.style.top = "0";
822+
this.overlay_canvas.style.left = "0";
823+
this.overlay_canvas.style.width = "100%";
824+
this.overlay_canvas.style.height = "100%";
825+
this.overlay_canvas.style.pointerEvents = "none";
826+
this.overlay_canvas.style.zIndex = "10";
827827
this.element.appendChild(this.overlay_canvas);
828-
this.overlay_context = this.overlay_canvas.getContext('2d')!;
828+
this.overlay_context = this.overlay_canvas.getContext("2d")!;
829829

830830
this.boundsUpdated.add(() => {
831831
this.overlay_canvas.width = this.renderViewport.logicalWidth;
@@ -842,19 +842,24 @@ export abstract class RenderedDataPanel extends RenderedPanel {
842842
if (radius > 0) {
843843
ctx.beginPath();
844844
ctx.arc(x, y, radius, 0, 2 * Math.PI);
845-
ctx.fillStyle = 'rgba(255, 255, 255, 0.2)';
845+
ctx.fillStyle = "rgba(255, 255, 255, 0.2)";
846846
ctx.fill();
847-
ctx.strokeStyle = 'rgba(255, 255, 255, 1)';
847+
ctx.strokeStyle = "rgba(255, 255, 255, 1)";
848848
ctx.lineWidth = 3;
849849
ctx.stroke();
850-
ctx.strokeStyle = 'rgba(0, 0, 0, 1)';
850+
ctx.strokeStyle = "rgba(0, 0, 0, 1)";
851851
ctx.lineWidth = 1.5;
852852
ctx.stroke();
853853
}
854854
}
855855

856856
clearOverlay() {
857-
this.overlay_context.clearRect(0, 0, this.overlay_canvas.width, this.overlay_canvas.height);
857+
this.overlay_context.clearRect(
858+
0,
859+
0,
860+
this.overlay_canvas.width,
861+
this.overlay_canvas.height,
862+
);
858863
}
859864

860865
abstract translateDataPointByViewportPixels(

src/ui/voxel_annotations.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type {
2020
VoxelEditingContext,
2121
} from "#src/layer/vox/index.js";
2222
import { RenderedDataPanel } from "#src/rendered_data_panel.js";
23+
import { SliceViewPanel } from "#src/sliceview/panel.js";
2324
import { StatusMessage } from "#src/status.js";
2425
import { LayerTool, registerTool, type ToolActivation } from "#src/ui/tool.js";
2526
import { vec3 } from "#src/util/geom.js";
@@ -146,15 +147,15 @@ export class VoxelBrushTool extends BaseVoxelTool {
146147
activation.registerDisposer(
147148
this.mouseState.changed.add(() => {
148149
this.updateBrushOutline();
149-
})
150+
}),
150151
);
151152
}
152153

153154
private getActivePanel(): RenderedDataPanel | undefined {
154155
let activePanel: RenderedDataPanel | undefined;
155156
for (const panel of this.layer.manager.root.display.panels) {
156157
if (panel instanceof RenderedDataPanel) {
157-
if (panel.mouseX !== -1) {
158+
if (panel.mouseX !== -1 && panel instanceof SliceViewPanel) {
158159
activePanel = panel;
159160
} else {
160161
panel.clearOverlay();

0 commit comments

Comments
 (0)