Skip to content

Commit a7c0efa

Browse files
committed
fix(tools): prevent tool selection while placing annotation tools
Skip selecting tools when ruler, rectangle, or polygon tool is active. This prevents bugs when clicking on existing tools while placing new ones.
1 parent a47d9bb commit a7c0efa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/components/tools/SelectTool.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import { onVTKEvent } from '@/src/composables/onVTKEvent';
33
import { WIDGET_PRIORITY } from '@kitware/vtk.js/Widgets/Core/AbstractWidget/Constants';
44
import { useToolSelectionStore } from '@/src/store/tools/toolSelection';
5+
import { useToolStore } from '@/src/store/tools';
6+
import { Tools } from '@/src/store/tools/types';
57
import { vtkAnnotationToolWidget } from '@/src/vtk/ToolWidgetUtils/types';
68
import { inject } from 'vue';
79
import { VtkViewContext } from '@/src/components/vtk/context';
@@ -10,11 +12,19 @@ const view = inject(VtkViewContext);
1012
if (!view) throw new Error('No VtkView');
1113
1214
const selectionStore = useToolSelectionStore();
15+
const toolStore = useToolStore();
16+
17+
const PLACING_TOOLS = [Tools.Ruler, Tools.Rectangle, Tools.Polygon];
1318
1419
onVTKEvent(
1520
view.interactor,
1621
'onLeftButtonPress',
1722
(event: any) => {
23+
if (PLACING_TOOLS.includes(toolStore.currentTool)) {
24+
// avoid bugs when starting a placing tool on an existing tool and right clicking and deleting existing tools
25+
return;
26+
}
27+
1828
const withModifiers = !!(event.shiftKey || event.controlKey);
1929
const selectedData = view.widgetManager.getSelectedData();
2030
if ('widget' in selectedData) {

0 commit comments

Comments
 (0)