Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 18x 18x 18x 18x 3x 1x 488x 7x 4x 3x 18x | import { ref, watch } from 'vue';
import { storeToRefs } from 'pinia';
import { useMcadStore } from '@/stores/mcad.store';
import { InteractionType } from '@3cr/types-ts';
import { DataOverlayMcad } from '@3cr/viewer-types-ts';
export function useMcadSelectTool() {
const { mcadEvent } = storeToRefs(useMcadStore());
const isActive = ref<boolean>(false);
const selected = ref<DataOverlayMcad | null>(null);
watch(mcadEvent, (event) => {
if (isActive.value && event?.Interaction === InteractionType.POINTER_UP) {
selected.value = event.Mcad;
}
});
function isSelected(mcad: DataOverlayMcad): boolean {
return selected.value?.Id === mcad.Id;
}
function toggle(mcad: DataOverlayMcad): void {
if (!isSelected(mcad)) {
selected.value = mcad;
} else {
selected.value = null;
}
}
return { isActive, selected, isSelected, toggle };
}
|