Skip to content

Commit d09d2d2

Browse files
committed
refactor: rename imageConfig -> imageParams
1 parent 7aa9365 commit d09d2d2

7 files changed

Lines changed: 43 additions & 43 deletions

File tree

src/components/VtkThreeView.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
4343
const {
4444
sceneSources,
45-
imageConfig,
45+
imageParams,
4646
colorBy,
4747
extentWithSpacing,
4848
baseImageColorPreset,
@@ -56,7 +56,7 @@ export default {
5656
.filter((id) => id in pipelines)
5757
.map((id) => pipelines[id].last);
5858
},
59-
imageConfig: (state) => state.visualization.imageConfig,
59+
imageParams: (state) => state.visualization.imageParams,
6060
colorBy: (state, getters) =>
6161
getters.sceneObjectIDs.map((id) => state.visualization.colorBy[id]),
6262
extentWithSpacing: (_, getters) =>
@@ -75,7 +75,7 @@ export default {
7575
windowing: (state) => state.visualization.windowing,
7676
});
7777
78-
const spacing = computed(() => imageConfig.value.spacing);
78+
const spacing = computed(() => imageParams.value.spacing);
7979
8080
const viewRef = useVtkView({
8181
containerRef: vtkContainer,

src/components/VtkTwoView.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ function resize2DCameraToFit(view, lookAxis, viewUpAxis, bounds) {
109109
* This differs from view.resetCamera() in that we reset the view
110110
* to the specified bounds.
111111
*/
112-
function resetCamera(viewRef, lookAxis, viewUpAxis, imageConfig, resizeToFit) {
112+
function resetCamera(viewRef, lookAxis, viewUpAxis, imageParams, resizeToFit) {
113113
const view = unref(viewRef);
114114
if (view) {
115115
const renderer = view.getRenderer();
116116
renderer.computeVisiblePropBounds();
117-
renderer.resetCamera(imageConfig.value.bounds);
117+
renderer.resetCamera(imageParams.value.bounds);
118118
119119
if (unref(resizeToFit)) {
120-
const { extent, spacing } = imageConfig.value;
120+
const { extent, spacing } = imageParams.value;
121121
const extentWithSpacing = extent.map(
122122
(e, i) => e * spacing[Math.floor(i / 2)]
123123
);
@@ -158,7 +158,7 @@ export default {
158158
// currentSlice is expected to be in image coords.
159159
const {
160160
sceneSources,
161-
imageConfig,
161+
imageParams,
162162
colorBy,
163163
extentWithSpacing,
164164
baseImage,
@@ -172,7 +172,7 @@ export default {
172172
.filter((id) => id in pipelines)
173173
.map((id) => pipelines[id].last);
174174
},
175-
imageConfig: (state) => state.visualization.imageConfig,
175+
imageParams: (state) => state.visualization.imageParams,
176176
colorBy: (state, getters) =>
177177
getters.sceneObjectIDs.map((id) => state.visualization.colorBy[id]),
178178
extentWithSpacing: (_, getters) =>
@@ -213,7 +213,7 @@ export default {
213213
// configure camera orientation
214214
apply2DCameraPlacement(
215215
viewRef,
216-
imageConfig,
216+
imageParams,
217217
viewUp,
218218
orientation,
219219
axis,
@@ -233,12 +233,12 @@ export default {
233233
// reset camera conditions
234234
watch(
235235
[baseImage, extentWithSpacing],
236-
() => resetCamera(viewRef, axis, viewUpAxis, imageConfig, resizeToFit),
236+
() => resetCamera(viewRef, axis, viewUpAxis, imageParams, resizeToFit),
237237
{ immediate: true }
238238
);
239239
useSubscription(viewRef, (view) =>
240240
view.onResize(() =>
241-
resetCamera(viewRef, axis, viewUpAxis, imageConfig, resizeToFit)
241+
resetCamera(viewRef, axis, viewUpAxis, imageParams, resizeToFit)
242242
)
243243
);
244244
@@ -265,7 +265,7 @@ export default {
265265
default: windowing.value.level,
266266
}));
267267
const sliceRange = computed(() => {
268-
const { extent } = unref(imageConfig);
268+
const { extent } = unref(imageParams);
269269
return {
270270
min: extent[axis.value * 2],
271271
max: extent[axis.value * 2 + 1],

src/composables/view/view2D.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ const ViewTypeAxis = {
344344

345345
export function useIJKAxisCamera(viewType) {
346346
const { direction } = useComputedState({
347-
direction: (state) => state.visualization.imageConfig.direction,
347+
direction: (state) => state.visualization.imageParams.direction,
348348
});
349349

350350
return multiComputed(() => {
@@ -388,23 +388,23 @@ export function useIJKAxisCamera(viewType) {
388388
/**
389389
* Sets the camera based on camera configuration parameters.
390390
* @param {Ref<vtkViewProxy>} view
391-
* @param {Ref<ImageConfig>} imageConfig
391+
* @param {Ref<ImageParams>} imageParams
392392
* @param {Ref<number[3]>} viewUp
393393
* @param {Ref<-1|1>} orientation
394394
* @param {Ref<0|1|2>} axis
395395
* @param {'image'|'world'} frame
396396
*/
397397
export function apply2DCameraPlacement(
398398
view,
399-
imageConfig,
399+
imageParams,
400400
viewUp,
401401
orientation,
402402
axis,
403403
frame
404404
) {
405405
function updateCamera() {
406406
// get world bounds center
407-
const { bounds } = imageConfig.value;
407+
const { bounds } = imageParams.value;
408408
const center = [
409409
(bounds[0] + bounds[1]) / 2,
410410
(bounds[2] + bounds[3]) / 2,
@@ -420,7 +420,7 @@ export function apply2DCameraPlacement(
420420
const vup = [...viewUp.value];
421421

422422
if (unref(frame) === 'image') {
423-
const { direction } = imageConfig.value;
423+
const { direction } = imageParams.value;
424424
vec3.transformMat3(dop, dop, direction);
425425
vec3.transformMat3(vup, vup, direction);
426426
}
@@ -435,7 +435,7 @@ export function apply2DCameraPlacement(
435435
view.value.set({ axis: axis.value }, true); // set the corresponding axis
436436
}
437437

438-
watch([imageConfig, viewUp, orientation, axis], updateCamera, {
438+
watch([imageParams, viewUp, orientation, axis], updateCamera, {
439439
immediate: true,
440440
});
441441
}

src/store/visualization.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function asInteger(value, defaultValue) {
2020
return defaultValue;
2121
}
2222

23-
export const defaultImageConfig = () => ({
23+
export const defaultImageParams = () => ({
2424
bounds: [0, 1, 0, 1, 0, 1],
2525
extent: [0, 1, 0, 1, 0, 1],
2626
dimensions: [1, 1, 1],
@@ -86,7 +86,7 @@ export default (dependencies) => ({
8686
pipelines: {},
8787
slices: defaultSlicing(),
8888
resizeToFit: true,
89-
imageConfig: defaultImageConfig(),
89+
imageParams: defaultImageParams(),
9090
windowing: defaultWindowing(),
9191
colorBy: {}, // id -> { array, location }
9292
arrayLutPresets: {}, // arrayName -> LUT preset
@@ -101,11 +101,11 @@ export default (dependencies) => ({
101101
};
102102
},
103103

104-
setImageConfig(
104+
setImageParams(
105105
state,
106106
{ bounds, extent, spacing, direction, worldToIndex, indexToWorld }
107107
) {
108-
state.imageConfig = {
108+
state.imageParams = {
109109
bounds: [...bounds],
110110
extent: [...extent],
111111
dimensions: [
@@ -183,7 +183,7 @@ export default (dependencies) => ({
183183

184184
getters: {
185185
extentWithSpacing(state) {
186-
const { spacing, extent } = state.imageConfig;
186+
const { spacing, extent } = state.imageParams;
187187
return extent.map((b, i) => b * spacing[Math.floor(i / 2)]);
188188
},
189189
baseImagePipeline(state, getters, rootState) {
@@ -203,7 +203,7 @@ export default (dependencies) => ({
203203
actions: {
204204
async updateScene({ dispatch }, { reset = false }) {
205205
if (reset) {
206-
await dispatch('updateImageConfig');
206+
await dispatch('updateImageParams');
207207
await dispatch('resetWindowing');
208208
await dispatch('resetSlicing');
209209
await dispatch('updateColorBy');
@@ -219,7 +219,7 @@ export default (dependencies) => ({
219219
},
220220

221221
/**
222-
* Should run after updateImageConfig
222+
* Should run after updateImageParams
223223
*/
224224
createPipelinesForScene({ commit, state, rootGetters, rootState }) {
225225
const { proxyManager } = dependencies;
@@ -237,11 +237,11 @@ export default (dependencies) => ({
237237
}
238238
},
239239

240-
async updateImageConfig({ commit, rootState }) {
240+
async updateImageParams({ commit, rootState }) {
241241
const { selectedBaseImage, data } = rootState;
242242
if (selectedBaseImage !== NO_SELECTION) {
243243
const image = data.vtkCache[selectedBaseImage];
244-
commit('setImageConfig', {
244+
commit('setImageParams', {
245245
bounds: image.getBounds(),
246246
extent: image.getExtent(),
247247
spacing: image.getSpacing(),
@@ -259,8 +259,8 @@ export default (dependencies) => ({
259259
}
260260
bbox.inflate(5); // some extra padding
261261
// Without a base image, we assume a spacing of 1.
262-
commit('setImageConfig', {
263-
...defaultImageConfig(),
262+
commit('setImageParams', {
263+
...defaultImageParams(),
264264
bounds: bbox.getBounds(),
265265
extent: bbox.getBounds(),
266266
});
@@ -285,19 +285,19 @@ export default (dependencies) => ({
285285
},
286286

287287
/**
288-
* updateImageConfig should be invoked prior to this action.
288+
* updateImageParams should be invoked prior to this action.
289289
*/
290290
async resetSlicing({ commit, state, rootState }) {
291291
if (rootState.selectedBaseImage !== NO_SELECTION) {
292-
const { extent } = state.imageConfig;
292+
const { extent } = state.imageParams;
293293
await commit('setSlices', {
294294
x: extent[0],
295295
y: extent[2],
296296
z: extent[4],
297297
});
298298
} else {
299299
// pick middle of extent
300-
const { extent } = state.imageConfig;
300+
const { extent } = state.imageParams;
301301
const center = [
302302
(extent[0] + extent[1]) / 2,
303303
(extent[2] + extent[3]) / 2,

src/widgets/paint.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export default class PaintWidget extends Widget {
4545
updateManipulator(view) {
4646
if (view) {
4747
const axis = view.getAxis();
48-
const { slices, imageConfig } = this.store.state.visualization;
49-
const { spacing } = imageConfig;
48+
const { slices, imageParams } = this.store.state.visualization;
49+
const { spacing } = imageParams;
5050
const normal = [0, 0, 0];
5151
normal[axis] = 1;
5252
const origin = [0, 0, 0];
@@ -85,13 +85,13 @@ export default class PaintWidget extends Widget {
8585

8686
if (id !== NO_SELECTION) {
8787
const { vtkCache } = this.store.state.data;
88-
const { imageConfig } = this.store.state.visualization;
88+
const { imageParams } = this.store.state.visualization;
8989
const { radius, currentLabelFor } = this.store.state.annotations;
9090

9191
this.filter = vtkPaintFilter.newInstance();
9292
this.filter.setBackgroundImage(vtkCache[selectedBaseImage]);
9393
this.filter.setLabelMap(vtkCache[id]);
94-
this.filter.setMaskWorldToIndex(imageConfig.worldToIndex);
94+
this.filter.setMaskWorldToIndex(imageParams.worldToIndex);
9595
this.filter.setLabel(currentLabelFor[id]);
9696
this.onRadiusChange(radius);
9797
} else {
@@ -116,7 +116,7 @@ export default class PaintWidget extends Widget {
116116
const {
117117
spacing,
118118
worldToIndex,
119-
} = this.store.state.visualization.imageConfig;
119+
} = this.store.state.visualization.imageParams;
120120
const inv = mat4.create();
121121
const pt = vec3.create();
122122
mat4.invert(inv, worldToIndex);

src/widgets/ruler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export default class RulerWidget extends Widget {
7777
updateManipulator(view) {
7878
if (view && this.lockedSlice === null) {
7979
const axis = view.getAxis();
80-
const { slices, imageConfig } = this.store.state.visualization;
81-
const { spacing } = imageConfig;
80+
const { slices, imageParams } = this.store.state.visualization;
81+
const { spacing } = imageParams;
8282
const normal = [0, 0, 0];
8383
normal[axis] = 1;
8484
const origin = [0, 0, 0];

src/widgets/slicingCrosshairs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class RulerWidget extends Widget {
1414
this.factory = vtkCrosshairsWidget.newInstance();
1515
this.state = this.factory.getWidgetState();
1616

17-
const { extent, spacing } = this.store.state.visualization.imageConfig;
17+
const { extent, spacing } = this.store.state.visualization.imageParams;
1818
this.state
1919
.getHandle()
2020
.setBounds(...extent.map((b, i) => b * spacing[Math.floor(i / 2)]));
@@ -31,7 +31,7 @@ export default class RulerWidget extends Widget {
3131
}
3232

3333
const origin = this.state.getHandle().getOrigin();
34-
const { spacing } = this.store.state.visualization.imageConfig;
34+
const { spacing } = this.store.state.visualization.imageParams;
3535
this.store.dispatch('visualization/setSlices', {
3636
x: origin[0] / spacing[0],
3737
y: origin[1] / spacing[1],
@@ -54,8 +54,8 @@ export default class RulerWidget extends Widget {
5454
updateManipulator(view) {
5555
if (view) {
5656
const axis = view.getAxis();
57-
const { slices, imageConfig } = this.store.state.visualization;
58-
const { spacing } = imageConfig;
57+
const { slices, imageParams } = this.store.state.visualization;
58+
const { spacing } = imageParams;
5959
const normal = [0, 0, 0];
6060
normal[axis] = 1;
6161
const origin = [0, 0, 0];

0 commit comments

Comments
 (0)