Skip to content

Commit

Permalink
Bugfix/region highlight bugs (#196)
Browse files Browse the repository at this point in the history
* Set interpolation type based on background or not

* Put guard for valid region in onSelect for visibility

* Move valid region check to widgets
  • Loading branch information
davidborland authored Nov 11, 2022
1 parent daa1f92 commit 9db036f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/src/modules/view/components/slice-view/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export function Widgets(painter) {
handles.visibility.onEndInteractionEvent(() => {
const info = getWidgetInfo(widgets.visibility);

onSelect(info.region, 'visibility');
if (info.region) onSelect(info.region, 'visibility');
});

handles.claim.onEndInteractionEvent(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Surface } from './surface';

export function RegionSurface() {
const surface = Surface();
surface.setSliceHighlight(true);
surface.getMapper().setScalarVisibility(false);

return {
setRegion: region => surface.setRegions([region]),
getRegion: () => surface.getRegions()[0],
setInputData: data => surface.setInputData(data),
getInputData: () => surface.getInputData(),
setSliceHighlight: () => surface.setSliceHighlight(true),
getActor: () => surface.getActor(),
getHighlight: () => surface.getHighlight(),
setVisibility: visible => surface.getActor().setVisibility(visible),
Expand Down
5 changes: 5 additions & 0 deletions client/src/modules/view/components/surface/surface.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function Surface() {

const actor = vtkActor.newInstance();
actor.setMapper(mapper);
actor.getProperty().setInterpolationToFlat();

const highlight = Highlight();
highlight.setVisibility(false);
Expand Down Expand Up @@ -55,11 +56,15 @@ export function Surface() {
VertexShaderCode: SliceHighlightVP,
FragmentShaderCode: SliceHighlightFP
};

actor.getProperty().setInterpolationToFlat();
}
else {
mapper.setInputConnection(flyingEdges.getOutputPort());

if (sliceCalculator) sliceCalculator.delete();

actor.getProperty().setInterpolationToPhong();
}
},
setSlice: (slice, colors) => {
Expand Down
8 changes: 6 additions & 2 deletions client/src/modules/view/components/volume-view/volume-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export function VolumeView(painter) {
// Clean up any old surfaces
[...surfaces, ...backgroundSurfaces].forEach(surface => {
renderWindow.getRenderer().removeActor(surface.getActor());
renderWindow.getRenderer().removeActor(surface.getHighlight().getActor());
surface.cleanUp();
});

Expand All @@ -202,17 +203,18 @@ export function VolumeView(painter) {
// Create surfaces for each region
surfaces = regions.map(region => {
const surface = RegionSurface();
surface.setColor(region.colors.surface);
surface.setRegion(region);
surface.setColor(region.colors.surface);
surface.setSliceHighlight(true);

return surface;
});

// Create surfaces for each background region
backgroundSurfaces = backgroundRegions.map(region => {
const surface = RegionSurface();
surface.setColor(backgroundColors.surface2);
surface.setRegion(region);
surface.setColor(backgroundColors.surface2);
surface.setVisibility(false);

return surface;
Expand All @@ -226,6 +228,7 @@ export function VolumeView(painter) {
surfaces.forEach(surface => {
surface.setInputData(data);
renderer.addActor(surface.getActor());
renderer.addActor(surface.getHighlight().getActor());

if (slice >= 0) {
const region = getRegion(regions, surface);
Expand All @@ -237,6 +240,7 @@ export function VolumeView(painter) {
backgroundSurfaces.forEach(surface => {
surface.setInputData(data);
renderer.addActor(surface.getActor());
renderer.addActor(surface.getHighlight().getActor());
});
}
},
Expand Down

0 comments on commit 9db036f

Please sign in to comment.