Skip to content

Commit e664a17

Browse files
authored
Merge pull request #449 from PaulHax/layer-opacity
fix(VtkTwoView): layer opacity has uniform 1 opacity transfer function
2 parents 53c8f46 + 3257595 commit e664a17

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

src/components/VtkTwoView.vue

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ import BoundingRectangle from '@/src/components/tools/BoundingRectangle.vue';
203203
import { useToolSelectionStore } from '@/src/store/tools/toolSelection';
204204
import { useAnnotationToolStore } from '@/src/store/tools';
205205
import { doesToolFrameMatchViewAxis } from '@/src/composables/annotationTool';
206-
import { TypedArray } from '@kitware/vtk.js/types';
206+
import type { TypedArray } from '@kitware/vtk.js/types';
207207
import { useResizeObserver } from '../composables/useResizeObserver';
208208
import { useOrientationLabels } from '../composables/useOrientationLabels';
209209
import { getLPSAxisFromDir } from '../utils/lps';
@@ -241,7 +241,6 @@ import {
241241
WL_HIST_BINS,
242242
} from '../constants';
243243
import { useProxyManager } from '../composables/proxyManager';
244-
import { getShiftedOpacityFromPreset } from '../utils/vtk-helpers';
245244
import { useLayersStore } from '../store/datasets-layers';
246245
import { useViewCameraStore } from '../store/view-configs/camera';
247246
import useLayerColoringStore from '../store/view-configs/layers';
@@ -805,34 +804,14 @@ export default defineComponent({
805804
lut.setDataRange(...ctFunc.mappingRange);
806805
807806
const pwf = proxyManager.getPiecewiseFunction(arrayName);
808-
pwf.setMode(opFunc.mode);
807+
pwf.setMode(vtkPiecewiseFunctionProxy.Mode.Points);
809808
pwf.setDataRange(...opFunc.mappingRange);
810-
811-
switch (opFunc.mode) {
812-
case vtkPiecewiseFunctionProxy.Mode.Gaussians:
813-
pwf.setGaussians(opFunc.gaussians);
814-
break;
815-
case vtkPiecewiseFunctionProxy.Mode.Points: {
816-
const opacityPoints = getShiftedOpacityFromPreset(
817-
opFunc.preset,
818-
opFunc.mappingRange,
819-
opFunc.shift
820-
);
821-
if (opacityPoints) {
822-
pwf.setPoints(opacityPoints);
823-
}
824-
break;
825-
}
826-
case vtkPiecewiseFunctionProxy.Mode.Nodes:
827-
pwf.setNodes(opFunc.nodes);
828-
break;
829-
default:
830-
}
809+
pwf.setPoints([[0, 1]]); // only slice mesh controls opacity
810+
rep.setOpacity(blendConfig.opacity);
831811
832812
// control color range manually
833813
rep.setRescaleOnColorBy(false);
834814
rep.setColorBy(arrayName, location);
835-
rep.setOpacity(blendConfig.opacity);
836815
837816
// Need to trigger a render for when we are restoring from a state file
838817
viewProxy.value.renderLater();

src/store/view-configs/layers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const defaultLayersConfig = (): LayersConfig => ({
4949
preset: '',
5050
mappingRange: [0, 1],
5151
},
52+
// opacity function not used in VtkTwoView
5253
opacityFunction: {
5354
mode: vtkPiecewiseFunctionProxy.Mode.Gaussians,
5455
gaussians: [],

0 commit comments

Comments
 (0)