All files / src/components/navigation/mcad McadInvert.vue

100% Statements 16/16
100% Branches 0/0
100% Functions 7/7
100% Lines 13/13

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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98                                                                                                                        15x   15x 15x   15x 15x 15x     1x 1x       1x 1x       1x 1x       3x                        
<template>
  <div>
    <span
      class="text-caption"
      style="font-size: 12px !important; font-weight: 600"
    >
      {{ t('labels.mcadInvert') }}
    </span>
    <v-row
      align-content="space-around"
      no-gutters
    >
      <v-col class="pt-2">
        <v-checkbox
          color="primary"
          :model-value="x"
          density="compact"
          hide-details
          label="X-axis"
          style="font-weight: 500"
          @update:model-value="invertX"
        />
      </v-col>
      <v-col class="pt-2">
        <v-checkbox
          :model-value="y"
          density="compact"
          hide-details
          label="Y-axis"
          color="primary"
          style="font-weight: 500"
          @update:model-value="invertY"
        />
      </v-col>
      <v-col class="pt-2">
        <v-checkbox
          color="primary"
          :model-value="z"
          density="compact"
          hide-details
          label="Z-axis"
          style="font-weight: 500"
          @update:model-value="invertZ"
        />
      </v-col>
    </v-row>
  </div>
</template>
 
<script setup lang="ts">
import { useViewer3cr } from '@/composables/useViewer3cr';
import { computed } from 'vue';
import { ObjectInvert } from '@3cr/types-ts';
import { useI18n } from 'vue-i18n';
import { DataOverlayMcad } from '@3cr/viewer-types-ts';
 
interface Props {
  mcad: DataOverlayMcad;
}
 
const props = defineProps<Props>();
 
const { t } = useI18n();
const viewer3cr = useViewer3cr();
 
const x = computed(() => props.mcad.Inverted.InvertedSagittal);
const y = computed(() => props.mcad.Inverted.InvertedCoronal);
const z = computed(() => props.mcad.Inverted.InvertedTransverse);
 
async function invertX(): Promise<void> {
  const message = makeObjectInvert(!x.value, y.value, z.value);
  await viewer3cr.invertMcadObject({ message });
}
 
async function invertY(): Promise<void> {
  const message = makeObjectInvert(x.value, !y.value, z.value);
  await viewer3cr.invertMcadObject({ message });
}
 
async function invertZ(): Promise<void> {
  const message = makeObjectInvert(x.value, y.value, !z.value);
  await viewer3cr.invertMcadObject({ message });
}
 
function makeObjectInvert(x: boolean, y: boolean, z: boolean): ObjectInvert {
  return {
    Version: '0.0.0',
    Id: props.mcad.Id,
    Inverted: {
      Version: '0.0.0',
      InvertedSagittal: x,
      InvertedCoronal: y,
      InvertedTransverse: z,
    },
  };
}
</script>