Skip to content

Commit

Permalink
fix(VtkView): Better annotations and LPS naming
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Jun 25, 2018
1 parent 3fb97d5 commit 215b6de
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/components/core/GlobalSettings/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
import { Events } from 'paraview-glance/src/constants';

const ORIENTATION_PRESETS = [
{ text: 'Axial/Coronal/Saggital', value: 'lps' },
{ text: 'XYZ', value: 'default' },
{ text: 'LPS', value: 'lps' },
];

const AXIS_TYPES = [
Expand Down Expand Up @@ -83,7 +83,7 @@ export default {
backgroundColor: DEFAULT_BACKGROUND,
orientationAxis: true,
annotationOpacity: 1,
orientationPreset: view ? view.getPresetToOrientationAxes() : 'lps',
orientationPreset: view ? view.getPresetToOrientationAxes() : 'default',
orientationPresets: ORIENTATION_PRESETS,
axisTypes: AXIS_TYPES,
axisType: view ? view.getOrientationAxesType() : 'arrow',
Expand Down
1 change: 0 additions & 1 deletion src/components/core/GlobalSettings/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
dense
flat
hide-details
:disabled="!orientationAxis || axisType != 'cube'"

v-model="orientationPreset"
:items="orientationPresets"
Expand Down
7 changes: 7 additions & 0 deletions src/components/core/VtkView/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export const VIEW_TYPES = [
{ text: 'Orientation Z', value: 'View2D_Z:z' },
];

export const VIEW_TYPES_LPS = [
{ text: 'View 3D', value: 'View3D:default' },
{ text: 'Saggital', value: 'View2D_Y:y' },
{ text: 'Coronal', value: 'View2D_X:x' },
{ text: 'Axial', value: 'View2D_Z:z' },
];

export const VIEW_ORIENTATIONS = {
default: {
axis: 1,
Expand Down
28 changes: 28 additions & 0 deletions src/components/core/VtkView/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ function getView(proxyManager, viewType, container) {

// set background to transparent
view.setBackground(0, 0, 0, 0);

// FIXME: Use storage to choose defaults
view.setPresetToOrientationAxes('default');
}

if (container) {
Expand All @@ -78,6 +81,30 @@ function getView(proxyManager, viewType, container) {

// ----------------------------------------------------------------------------

function updateViewsAnnotation(proxyManager) {
const hasImageData = proxyManager
.getSources()
.find((s) => s.getDataset().isA && s.getDataset().isA('vtkImageData'));
const views = proxyManager.getViews();

for (let i = 0; i < views.length; i++) {
const view = views[i];
view.setCornerAnnotation('se', '');
if (view.getProxyName().indexOf('2D') !== -1 && hasImageData) {
/* eslint-disable */
view.setCornerAnnotation(
'nw',
'CW ${colorWindow} - CL ${colorLevel}<br>Slice ${slice}'
);
/* eslint-enable */
} else {
view.setCornerAnnotation('nw', '');
}
}
}

// ----------------------------------------------------------------------------

function bindView(proxyManager, viewType, container) {
return getView(proxyManager, viewType, container);
}
Expand All @@ -90,4 +117,5 @@ export default {
getView,
getViewActions,
getNumberOfVisibleViews,
updateViewsAnnotation,
};
26 changes: 24 additions & 2 deletions src/components/core/VtkView/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Events, Widgets } from 'paraview-glance/src/constants';
import {
DEFAULT_VIEW_TYPE,
VIEW_TYPES,
VIEW_TYPES_LPS,
VIEW_ORIENTATIONS,
} from 'paraview-glance/src/components/core/VtkView/constants';

Expand Down Expand Up @@ -137,7 +138,7 @@ function toggleCrop() {
this.isCropping = true;

// Add subscription to monitor crop change
if (this.subscriptions.length === 2 && volumeRep.getCropFilter) {
if (this.subscriptions.length === 3 && volumeRep.getCropFilter) {
this.subscriptions.push(
volumeRep
.getCropFilter()
Expand Down Expand Up @@ -231,6 +232,22 @@ function singleView() {
});
}

// ----------------------------------------------------------------------------

function orientationLabels() {
return this.view.getPresetToOrientationAxes() === 'lps'
? ['L', 'P', 'S']
: ['X', 'Y', 'Z'];
}

// ----------------------------------------------------------------------------

function viewTypes() {
return this.view.getPresetToOrientationAxes() === 'lps'
? VIEW_TYPES_LPS
: VIEW_TYPES;
}

// ----------------------------------------------------------------------------
// Vue LifeCycle
// ----------------------------------------------------------------------------
Expand All @@ -255,6 +272,10 @@ function onMounted() {
() => window.removeEventListener('resize', this.resizeCurrentView),
this.proxyManager.onProxyRegistrationChange(() => {
// When proxy change, just re-render widget
viewHelper.updateViewsAnnotation(this.proxyManager);
this.$forceUpdate();
}).unsubscribe,
this.view.onModified(() => {
this.$forceUpdate();
}).unsubscribe,
];
Expand Down Expand Up @@ -312,7 +333,6 @@ export default {
data() {
return {
palette: BACKGROUND,
viewTypes: VIEW_TYPES,
backgroundSheet: false,
isCropping: false,
inAnimation: false,
Expand All @@ -329,6 +349,7 @@ export default {
getAvailableActions,
onBeforeDestroy,
onMounted,
orientationLabels,
quadView,
resetCamera,
resetCrop,
Expand All @@ -339,6 +360,7 @@ export default {
splitView,
toggleCrop,
updateOrientation,
viewTypes,
},
mounted() {
this.$nextTick(this.onMounted);
Expand Down
18 changes: 9 additions & 9 deletions src/components/core/VtkView/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</v-tooltip>
</div>
<v-tooltip left>
<span :class="$style.noSelect">Rotate left 90°</span>
<span :class="$style.noSelect">Rotate camera left 90°</span>
<v-btn
slot="activator"
icon
Expand All @@ -54,7 +54,7 @@
</v-btn>
</v-tooltip>
<v-tooltip left>
<span :class="$style.noSelect">Rotate right 90°</span>
<span :class="$style.noSelect">Rotate camera right 90°</span>
<v-btn
slot="activator"
icon
Expand All @@ -66,39 +66,39 @@
</v-btn>
</v-tooltip>
<v-tooltip left v-if="view.getProxyName() === 'View3D'">
<span :class="$style.noSelect">Reset Camera to Orientation X</span>
<span :class="$style.noSelect">Reset Camera to Orientation {{orientationLabels()[0]}}</span>
<v-btn
slot="activator"
icon
dark
small
v-on:click="updateOrientation('x')"
>
X
{{orientationLabels()[0]}}
</v-btn>
</v-tooltip>
<v-tooltip left v-if="view.getProxyName() === 'View3D'">
<span :class="$style.noSelect">Reset Camera to Orientation Y</span>
<span :class="$style.noSelect">Reset Camera to Orientation {{orientationLabels()[1]}}</span>
<v-btn
slot="activator"
icon
dark
small
v-on:click="updateOrientation('y')"
>
Y
{{orientationLabels()[1]}}
</v-btn>
</v-tooltip>
<v-tooltip left v-if="view.getProxyName() === 'View3D'">
<span :class="$style.noSelect">Reset Camera to Orientation Z</span>
<span :class="$style.noSelect">Reset Camera to Orientation {{orientationLabels()[2]}}</span>
<v-btn
slot="activator"
icon
dark
small
v-on:click="updateOrientation('z')"
>
Z
{{orientationLabels()[2]}}
</v-btn>
</v-tooltip>
</v-layout>
Expand Down Expand Up @@ -131,7 +131,7 @@
flat
dark
:class="$style.viewTypeSelector"
:items="viewTypes"
:items="viewTypes()"
:value="viewType"
@change="changeViewType"
/>
Expand Down

0 comments on commit 215b6de

Please sign in to comment.