-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathTrackItem.vue
More file actions
388 lines (360 loc) · 9.79 KB
/
TrackItem.vue
File metadata and controls
388 lines (360 loc) · 9.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<script lang="ts">
import {
defineComponent, computed, PropType, ref,
} from 'vue';
import context from 'dive-common/store/context';
import TooltipBtn from './TooltipButton.vue';
import TypePicker from './TypePicker.vue';
import {
useHandler, useTime, useReadOnlyMode, useTrackFilters, useCameraStore, useTrackStyleManager,
} from '../provides';
import Track from '../track';
import useVuetify from '../use/useVuetify';
export default defineComponent({
name: 'TrackItem',
components: { TooltipBtn, TypePicker },
props: {
solo: {
type: Boolean,
default: false,
},
trackType: {
type: String,
required: true,
},
track: {
type: Object as PropType<Track>,
required: true,
},
inputValue: {
type: Boolean,
required: true,
},
selected: {
type: Boolean,
required: true,
},
secondarySelected: {
type: Boolean,
required: true,
},
editing: {
type: Boolean,
required: true,
},
merging: {
type: Boolean,
default: false,
},
color: {
type: String,
required: true,
},
lockTypes: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
},
setup(props, { emit }) {
const vuetify = useVuetify();
const { frame: frameRef } = useTime();
const handler = useHandler();
const trackFilters = useTrackFilters();
const allTypesRef = trackFilters.allTypes;
const readOnlyMode = useReadOnlyMode();
const cameraStore = useCameraStore();
const { typeStyling } = useTrackStyleManager();
const multiCam = ref(cameraStore.camMap.value.size > 1);
/**
* Use of revision is safe because it will only create a
* dependency when track is selected. DO NOT use this computed
* value except inside if (props.selected === true) blocks!
*/
const feature = computed(() => {
if (props.track.revision.value) {
const { features, interpolate } = props.track.canInterpolate(frameRef.value);
const [real, lower, upper] = features;
return {
real,
lower,
upper,
shouldInterpolate: interpolate,
targetKeyframe: real?.keyframe ? real : (lower || upper),
isKeyframe: real?.keyframe,
};
}
return {
real: null,
lower: null,
upper: null,
targetKeyframe: null,
shouldInterpolate: false,
isKeyframe: false,
};
});
/* isTrack distinguishes between track and detection */
const isTrack = computed(() => props.track.length > 1 || feature.value.shouldInterpolate);
/* Sets styling for the selected track */
const style = computed(() => {
if (props.selected) {
return {
'background-color': `${vuetify.theme.themes.dark.accentBackground}`,
};
}
if (props.secondarySelected) {
return {
'background-color': '#3a3a3a',
};
}
return {};
});
const keyframeDisabled = computed(() => (
!feature.value.real && !feature.value.shouldInterpolate)
|| (props.track.length === 1 && frameRef.value === props.track.begin));
function toggleKeyframe() {
if (!keyframeDisabled.value) {
props.track.toggleKeyframe(frameRef.value);
}
}
function toggleInterpolation() {
props.track.toggleInterpolation(frameRef.value);
}
function toggleAllInterpolation() {
props.track.toggleInterpolationForAllGaps(frameRef.value);
}
function clickToggleInterpolation(event: MouseEvent) {
if (event.ctrlKey) {
toggleAllInterpolation();
} else {
toggleInterpolation();
}
}
function gotoNext() {
const nextFrame = props.track.getNextKeyframe(frameRef.value + 1);
if (nextFrame !== undefined) {
emit('seek', nextFrame);
}
}
function gotoPrevious() {
const previousFrame = props.track.getPreviousKeyframe(frameRef.value - 1);
if (previousFrame !== undefined) {
emit('seek', previousFrame);
}
}
function setTrackType(type: string) {
cameraStore.setTrackType(props.track.id, type);
}
function openMultiCamTools() {
if (context.state.active !== 'MultiCamTools') {
context.toggle('MultiCamTools');
}
}
function handleClicked(event: PointerEvent) {
const modifiers = event.ctrlKey ? { ctrl: true } : undefined;
handler.trackSeek(props.track.trackId, modifiers);
}
return {
/* data */
feature,
isTrack,
style,
frame: frameRef,
allTypes: allTypesRef,
keyframeDisabled,
trackFilters,
readOnlyMode,
multiCam,
/* methods */
gotoNext,
gotoPrevious,
handler,
openMultiCamTools,
toggleInterpolation,
clickToggleInterpolation,
toggleAllInterpolation,
toggleKeyframe,
setTrackType,
typeStyling,
handleClicked,
};
},
});
</script>
<template>
<div
class="track-item d-flex flex-column align-start hover-show-parent px-1"
:style="style"
>
<v-row
class="pt-2 justify-center item-row"
no-gutters
align="center"
>
<div
v-if="solo"
class="type-color-box"
:style="{
backgroundColor: color,
}"
/>
<v-checkbox
v-else
class="my-0 ml-1 pt-0"
dense
hide-details
:disabled="disabled"
:input-value="inputValue"
:color="color"
@change="trackFilters.updateCheckedId(track.trackId, $event)"
/>
<v-tooltip
open-delay="200"
bottom
max-width="200"
:disabled="track.trackId.toString().length < 8"
>
<template #activator="{ on }">
<div
class="trackNumber pl-0 pr-2"
v-on="on"
@click.self="handleClicked"
>
{{ track.trackId }}
</div>
</template>
<span> {{ track.trackId }} </span>
</v-tooltip>
<v-chip
v-if="track.set"
outlined
x-small
:color="typeStyling.annotationSetColor(track.set)"
>
{{ track.set }}
</v-chip>
<v-spacer />
<TypePicker
:value="trackType"
v-bind="{
lockTypes, readOnlyMode, allTypes, selected,
}"
@input="setTrackType($event)"
/>
</v-row>
<v-row
class="my-1 justify-center item-row flex-nowrap"
no-gutters
>
<v-spacer v-if="!isTrack" />
<template v-if="selected">
<span
v-show="false"
v-mousetrap="[
{ bind: 'k', handler: toggleKeyframe },
{ bind: 'i', handler: toggleInterpolation },
{ bind: 'ctrl+i', handler: toggleAllInterpolation },
{ bind: 'home', handler: () => $emit('seek', track.begin) },
{ bind: 'end', handler: () => $emit('seek', track.end) },
]"
/>
<tooltip-btn
color="error"
icon="mdi-delete"
:disabled="merging || readOnlyMode"
:tooltip-text="`Delete ${isTrack ? 'Track' : 'Detection'}`"
@click="handler.removeTrack([track.trackId])"
/>
<span v-if="!multiCam">
<tooltip-btn
v-if="isTrack"
:disabled="!track.canSplit(frame) || merging || readOnlyMode"
icon="mdi-call-split"
tooltip-text="Split Track"
@click="handler.trackSplit(track.trackId, frame)"
/>
<tooltip-btn
v-if="isTrack && !readOnlyMode"
:icon="(feature.isKeyframe)
? 'mdi-star'
: 'mdi-star-outline'"
:disabled="keyframeDisabled"
tooltip-text="Toggle keyframe"
@click="toggleKeyframe"
/>
<tooltip-btn
v-if="isTrack && !readOnlyMode"
:icon="(feature.shouldInterpolate)
? 'mdi-vector-selection'
: 'mdi-selection-off'"
tooltip-text="Toggle interpolation, ctrl+click to toggle all interpolation"
@click="clickToggleInterpolation($event)"
/>
</span>
<span v-else>
<tooltip-btn
icon="mdi-camera"
tooltip-text="Open MultiCamera Tools"
@click="openMultiCamTools"
/>
</span>
</template>
<v-spacer v-if="isTrack" />
<template v-if="isTrack">
<tooltip-btn
icon="mdi-chevron-double-left"
tooltip-text="Seek to track beginning"
@click="$emit('seek', track.begin)"
/>
<tooltip-btn
icon="mdi-chevron-left"
tooltip-text="Seek to previous keyframe"
@click="gotoPrevious"
/>
<tooltip-btn
icon="mdi-chevron-right"
tooltip-text="Seek to next keyframe"
@click="gotoNext"
/>
<tooltip-btn
icon="mdi-chevron-double-right"
tooltip-text="Seek to track end"
@click="$emit('seek', track.end)"
/>
</template>
<tooltip-btn
v-else
icon="mdi-map-marker"
tooltip-text="Seek to detection"
@click="$emit('seek', track.begin)"
/>
<tooltip-btn
v-if="!merging"
:icon="(editing) ? 'mdi-pencil-box' : 'mdi-pencil-box-outline'"
tooltip-text="Toggle edit mode"
:disabled="!inputValue || readOnlyMode"
@click="handler.trackEdit(track.trackId)"
/>
</v-row>
</div>
</template>
<style lang="scss" scoped>
@import 'src/components/styles/common.scss';
.track-item {
border-radius: inherit;
.item-row {
width: 100%;
}
.type-color-box {
margin: 7px;
margin-top: 4px;
min-width: 15px;
max-width: 15px;
min-height: 15px;
max-height: 15px;
}
}
</style>