Skip to content

Commit

Permalink
Merge pull request #336 from Kitware/fix-slicing-step
Browse files Browse the repository at this point in the history
Fix slicing step
  • Loading branch information
floryst committed May 12, 2020
2 parents 6312a28 + d87f2d9 commit 0a878b2
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 50 deletions.
171 changes: 133 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -47,7 +47,7 @@
"pug": "^2.0.4",
"pug-plain-loader": "^1.0.0",
"typeface-roboto": "0.0.54",
"vtk.js": "13.13.1",
"vtk.js": "14.0.1",
"vue": "2.6.10",
"vue-cli-plugin-vuetify": "^2.0.3",
"vuetify": "2.2.0",
Expand Down
24 changes: 13 additions & 11 deletions src/store/index.js
Expand Up @@ -46,16 +46,18 @@ function merge(dst, src) {
}
/* eslint-enable no-param-reassign */

function changeActiveSliceDelta(proxyManager, delta) {
function stepActiveSlice(proxyManager, inc) {
const view = proxyManager.getActiveView();
if (view.isA('vtkView2DProxy')) {
const sliceReps = view
.getRepresentations()
.filter((r) => r.isA('vtkSliceRepresentationProxy'));
if (sliceReps.length) {
const rep = sliceReps[0];
rep.setSlice(rep.getSlice() + delta);
}
const source = proxyManager.getActiveSource();
const r = proxyManager.getRepresentation(source, view);
const domain = r.getPropertyDomainByName('slice');
if (r.isA('vtkSliceRepresentationProxy') && domain) {
const step = inc ? domain.step : -domain.step;
const slice = Math.min(
domain.max,
Math.max(domain.min, r.getSlice() + step)
);
r.setSlice(slice);
}
}

Expand Down Expand Up @@ -354,12 +356,12 @@ function createStore(pxm = null) {
},
increaseSlice({ state }) {
if (state.route === 'app') {
changeActiveSliceDelta(proxyManager, 1);
stepActiveSlice(proxyManager, true);
}
},
decreaseSlice({ state }) {
if (state.route === 'app') {
changeActiveSliceDelta(proxyManager, -1);
stepActiveSlice(proxyManager, false);
}
},
takeScreenshot({ commit, state }, viewToUse = null) {
Expand Down

0 comments on commit 0a878b2

Please sign in to comment.