Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VtkTwoView): layer opacity has uniform 1 opacity transfer function #449

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 4 additions & 25 deletions src/components/VtkTwoView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ import BoundingRectangle from '@/src/components/tools/BoundingRectangle.vue';
import { useToolSelectionStore } from '@/src/store/tools/toolSelection';
import { useAnnotationToolStore } from '@/src/store/tools';
import { doesToolFrameMatchViewAxis } from '@/src/composables/annotationTool';
import { TypedArray } from '@kitware/vtk.js/types';
import type { TypedArray } from '@kitware/vtk.js/types';
import { useResizeObserver } from '../composables/useResizeObserver';
import { useOrientationLabels } from '../composables/useOrientationLabels';
import { getLPSAxisFromDir } from '../utils/lps';
Expand Down Expand Up @@ -241,7 +241,6 @@ import {
WL_HIST_BINS,
} from '../constants';
import { useProxyManager } from '../composables/proxyManager';
import { getShiftedOpacityFromPreset } from '../utils/vtk-helpers';
import { useLayersStore } from '../store/datasets-layers';
import { useViewCameraStore } from '../store/view-configs/camera';
import useLayerColoringStore from '../store/view-configs/layers';
Expand Down Expand Up @@ -805,34 +804,14 @@ export default defineComponent({
lut.setDataRange(...ctFunc.mappingRange);

const pwf = proxyManager.getPiecewiseFunction(arrayName);
pwf.setMode(opFunc.mode);
pwf.setMode(vtkPiecewiseFunctionProxy.Mode.Points);
pwf.setDataRange(...opFunc.mappingRange);

switch (opFunc.mode) {
case vtkPiecewiseFunctionProxy.Mode.Gaussians:
pwf.setGaussians(opFunc.gaussians);
break;
case vtkPiecewiseFunctionProxy.Mode.Points: {
const opacityPoints = getShiftedOpacityFromPreset(
opFunc.preset,
opFunc.mappingRange,
opFunc.shift
);
if (opacityPoints) {
pwf.setPoints(opacityPoints);
}
break;
}
case vtkPiecewiseFunctionProxy.Mode.Nodes:
pwf.setNodes(opFunc.nodes);
break;
default:
}
pwf.setPoints([[0, 1]]); // only slice mesh controls opacity
rep.setOpacity(blendConfig.opacity);

// control color range manually
rep.setRescaleOnColorBy(false);
rep.setColorBy(arrayName, location);
rep.setOpacity(blendConfig.opacity);

// Need to trigger a render for when we are restoring from a state file
viewProxy.value.renderLater();
Expand Down
1 change: 1 addition & 0 deletions src/store/view-configs/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const defaultLayersConfig = (): LayersConfig => ({
preset: '',
mappingRange: [0, 1],
},
// opacity function not used in VtkTwoView
opacityFunction: {
mode: vtkPiecewiseFunctionProxy.Mode.Gaussians,
gaussians: [],
Expand Down
Loading