Skip to content

Commit 35c22be

Browse files
authored
Fix Screenshot captures (#335)
1 parent c9aba67 commit 35c22be

File tree

7 files changed

+19
-69
lines changed

7 files changed

+19
-69
lines changed

client/src/components/EmailDialog.vue

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ export default defineComponent({
1616
type: Boolean,
1717
required: true,
1818
},
19-
notes: {
20-
type: Array,
21-
default: () => [],
22-
},
2319
},
2420
setup() {
2521
const screenshots = computed(() => store.state.screenshots);
22+
const currentViewData = computed(() => store.getters.currentViewData);
2623
const currentFrame = computed(() => store.getters.currentFrame);
2724
const currentScan = computed(() => store.getters.currentScan);
2825
const { removeScreenshot } = store.commit;
@@ -31,6 +28,7 @@ export default defineComponent({
3128
3229
return {
3330
screenshots,
31+
currentViewData,
3432
currentFrame,
3533
currentScan,
3634
removeScreenshot,
@@ -69,11 +67,6 @@ export default defineComponent({
6967
this.initialize();
7068
}
7169
},
72-
notes(value) {
73-
if (value) {
74-
this.initialize();
75-
}
76-
},
7770
},
7871
methods: {
7972
initialize() {
@@ -95,19 +88,13 @@ export default defineComponent({
9588
}
9689
this.showCC = !!this.cc.length;
9790
this.showBCC = !!this.bcc.length;
98-
const experiment = `Regarding ${this.currentScan.experiment}, ${this.currentScan.name}`;
99-
this.subject = experiment;
100-
this.body = `Experiment: ${this.currentScan.experiment}
101-
Scan: ${this.currentScan.name}`;
102-
if (this.notes) {
103-
this.body = `${this.body}
104-
Notes:
105-
`;
106-
this.body = this.notes
107-
.map(
108-
(note) => `${note.creator.first_name} ${note.creator.last_name}: ${note.created}\n${note.note}`,
109-
)
110-
.join('\n');
91+
this.subject = `Regarding ${this.currentViewData.experimentName}, ${this.currentScan.name}`;
92+
this.body = `Experiment: ${this.currentViewData.experimentName}\nScan: ${this.currentScan.name}\n`;
93+
if (this.currentViewData.scanDecisions.length > 0) {
94+
this.body += `Decisions:\n ${this.currentViewData.scanDecisions.map(
95+
(decision) => ` ${decision.creator.email} (${decision.created}): `
96+
+ `${decision.decision.toUpperCase()} ${decision.note.length > 0 ? `, ${decision.note}` : ''}`,
97+
)}`;
11198
}
11299
this.initialized = true;
113100
},

client/src/components/ScreenshotDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default {
136136
color="primary"
137137
text
138138
>
139-
Save
139+
Attach to email draft
140140
</v-btn>
141141
</v-card-actions>
142142
</v-card>

client/src/components/VtkViewer.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import { vec3 } from 'gl-matrix';
44
import Vue from 'vue';
55
import { mapState, mapGetters, mapMutations } from 'vuex';
66
7-
import { cleanFrameName } from '@/utils/helper';
87
import CrosshairSet from '../utils/crosshairs';
98
import fill2DView from '../utils/fill2DView';
10-
import { getView } from '../vtk/viewManager';
119
import { VIEW_ORIENTATIONS } from '../vtk/constants';
1210
1311
export default {
@@ -40,7 +38,7 @@ export default {
4038
'jIndexSlice',
4139
'kIndexSlice',
4240
]),
43-
...mapGetters(['currentFrame', 'currentScan']),
41+
...mapGetters(['currentFrame', 'currentScan', 'currentViewData']),
4442
representation() {
4543
return (
4644
// force add dependency on currentFrame
@@ -236,14 +234,11 @@ export default {
236234
return trueAxis;
237235
},
238236
async takeScreenshot() {
239-
const view = getView(this.proxyManager, `ScreenshotView2D_${this.name}:${this.name}`, this.screenshotContainer);
240-
view.getOpenglRenderWindow().setSize(512, 512);
241-
fill2DView(view, 512, 512);
242-
const dataURL = await view.captureImage();
237+
const dataURL = await this.view.captureImage();
243238
this.setCurrentScreenshot({
244-
name: `${this.currentScan.experiment}/${
245-
this.currentScan.name
246-
}/${cleanFrameName(this.currentFrame.name)}/${this.displayName}`,
239+
name: `${this.currentViewData.experimentName}/${
240+
this.currentViewData.scanName
241+
}/${this.currentFrame.frame_number}/${this.displayName}`,
247242
dataURL,
248243
});
249244
},

client/src/store/index.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ function prepareProxyManager(proxyManager) {
5757
}
5858
}
5959

60-
function prepareScreenshotViews(proxyManager) {
61-
['ScreenshotView2D_x:x', 'ScreenshotView2D_y:y', 'ScreenshotView2D_z:z'].forEach((type) => {
62-
getView(proxyManager, type, null);
63-
});
64-
}
65-
6660
function getArrayName(filename) {
6761
const idx = filename.lastIndexOf('.');
6862
const name = idx > -1 ? filename.substring(0, idx) : filename;
@@ -384,8 +378,7 @@ const {
384378
};
385379
},
386380
currentFrame(state) {
387-
const { frames, currentFrameId } = state;
388-
return currentFrameId ? frames[currentFrameId] : null;
381+
return state.currentFrameId ? state.frames[state.currentFrameId] : null;
389382
},
390383
previousFrame(state, getters) {
391384
return getters.currentFrame
@@ -813,9 +806,6 @@ const {
813806
if (needPrep || !state.proxyManager.getViews().length) {
814807
prepareProxyManager(state.proxyManager);
815808
state.vtkViews = state.proxyManager.getViews();
816-
// initializing the screenshot view resets the render settings, so do it now instead of
817-
// when a screenshot is taken
818-
prepareScreenshotViews(state.proxyManager);
819809
}
820810
if (!state.vtkViews.length) {
821811
state.vtkViews = state.proxyManager.getViews();

client/src/utils/helper.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
export function cleanFrameName(name) {
2-
const cleanName = name.replace(/^image/, '').replace(/.nii.gz$/, '');
3-
if (cleanName === '') {
4-
return '1';
5-
}
6-
return cleanName;
7-
}
8-
9-
export function formatSize(size, { base = 1024, unit = 'B' } = {}) {
1+
export default function formatSize(size, { base = 1024, unit = 'B' } = {}) {
102
if (size < base) {
113
return `${size} ${unit}`;
124
}

client/src/views/Frame.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Navbar from '@/components/Navbar.vue';
88
import ControlPanel from '@/components/ControlPanel.vue';
99
import ExperimentsView from '@/components/ExperimentsView.vue';
1010
import VtkViewer from '@/components/VtkViewer.vue';
11-
import { cleanFrameName, formatSize } from '@/utils/helper';
11+
import formatSize from '@/utils/helper';
1212
1313
export default {
1414
name: 'Frame',
@@ -96,7 +96,6 @@ export default {
9696
'swapToFrame',
9797
'getFrame',
9898
]),
99-
cleanFrameName,
10099
async logoutUser() {
101100
await this.logout();
102101
this.$router.go('/'); // trigger re-render into oauth flow

client/src/vtk/viewManager.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function getViewType(view) {
3636

3737
// ----------------------------------------------------------------------------
3838

39-
function getView(proxyManager, viewType, container) {
39+
function getView(proxyManager, viewType) {
4040
const [type, name] = viewType.split(':');
4141
let view = null;
4242
const views = proxyManager.getViews();
@@ -71,11 +71,6 @@ function getView(proxyManager, viewType, container) {
7171
view.setPresetToOrientationAxes('default');
7272
}
7373

74-
if (container) {
75-
view.setContainer(container);
76-
view.resize();
77-
}
78-
7974
return view;
8075
}
8176

@@ -98,16 +93,9 @@ function updateViewsAnnotation(proxyManager) {
9893
}
9994
}
10095

101-
// ----------------------------------------------------------------------------
102-
103-
function bindView(proxyManager, viewType, container) {
104-
return getView(proxyManager, viewType, container);
105-
}
106-
10796
// ----------------------------------------------------------------------------
10897
export default {
10998
getViewType,
110-
bindView,
11199
getView,
112100
getViewActions,
113101
getNumberOfVisibleViews,
@@ -116,7 +104,6 @@ export default {
116104

117105
export {
118106
getViewType,
119-
bindView,
120107
getView,
121108
getViewActions,
122109
getNumberOfVisibleViews,

0 commit comments

Comments
 (0)