|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="annotation-box"
|
|
|
- :class="{draggable: type}"
|
|
|
+ :class="{draggable: type, selected: selected}"
|
|
|
:style="style"
|
|
|
@mousedown.stop.prevent="moveSelf" @touchstart.stop.prevent="moveSelf">
|
|
|
<div class="nw" @mousedown.stop.prevent="resizeSelf('nw')" @touchstart.stop.prevent="resizeSelf('nw')"></div>
|
|
@@ -53,26 +53,30 @@
|
|
|
<script>
|
|
|
export default {
|
|
|
name: "annotation-box",
|
|
|
- props: ['type', 'image', 'position', 'socket', 'boxUrl', 'labels', 'supports'],
|
|
|
+ props: ['type', 'image', 'position', 'socket', 'boxUrl', 'labels', 'supports', 'selected'],
|
|
|
data: function () {
|
|
|
return {
|
|
|
showLabelSelection: false
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ selected: {
|
|
|
+ immediate: true,
|
|
|
+ handler: function (newVal) {
|
|
|
+ if (newVal)
|
|
|
+ window.addEventListener('keypress', this.keypressEvent);
|
|
|
+ else
|
|
|
+ window.removeEventListener('keypress', this.keypressEvent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ destroyed: function () {
|
|
|
+ window.removeEventListener('keypress', this.keypressEvent);
|
|
|
+ },
|
|
|
computed: {
|
|
|
immutable: function () {
|
|
|
return !this.type;
|
|
|
},
|
|
|
- backgroundColor: function () {
|
|
|
- switch (this.type) {
|
|
|
- case 'user':
|
|
|
- return 'rgba(255, 0, 0, 0.3)';
|
|
|
- case 'pipeline':
|
|
|
- return 'rgba(0, 0, 255, 0.3)';
|
|
|
- default:
|
|
|
- return 'rgba(255, 255, 255, 0.3)';
|
|
|
- }
|
|
|
- },
|
|
|
confirmationButton: function () {
|
|
|
return this.type === 'pipeline';
|
|
|
},
|
|
@@ -88,6 +92,26 @@ export default {
|
|
|
else
|
|
|
return false;
|
|
|
},
|
|
|
+ backgroundColor: function () {
|
|
|
+ switch (this.type) {
|
|
|
+ case 'user':
|
|
|
+ return 'rgba(255, 0, 0, 0.3)';
|
|
|
+ case 'pipeline':
|
|
|
+ return 'rgba(0, 0, 255, 0.3)';
|
|
|
+ default:
|
|
|
+ return 'rgba(255, 255, 255, 0.3)';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ borderColor: function () {
|
|
|
+ switch (this.type) {
|
|
|
+ case 'user':
|
|
|
+ return 'rgba(255, 0, 0, 0.6)';
|
|
|
+ case 'pipeline':
|
|
|
+ return 'rgba(0, 0, 255, 0.6)';
|
|
|
+ default:
|
|
|
+ return 'rgba(255, 255, 255, 0.6)';
|
|
|
+ }
|
|
|
+ },
|
|
|
style: function () {
|
|
|
const left = this.image.left;
|
|
|
const top = this.image.top;
|
|
@@ -99,11 +123,18 @@ export default {
|
|
|
top: (top + this.position.y * height) + 'px',
|
|
|
width: (this.position.w * width) + 'px',
|
|
|
height: (this.position.h * height) + 'px',
|
|
|
- backgroundColor: this.backgroundColor
|
|
|
+ backgroundColor: this.backgroundColor,
|
|
|
+ borderColor: this.borderColor
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ keypressEvent: function (event) {
|
|
|
+ if (event.key === 'q')
|
|
|
+ this.confirmSelf();
|
|
|
+ else if (event.key === 'e')
|
|
|
+ this.deleteSelf();
|
|
|
+ },
|
|
|
confirmSelf: function () {
|
|
|
this.updateSelf(this.position);
|
|
|
},
|
|
@@ -152,6 +183,10 @@ export default {
|
|
|
grid-template-columns: 10px auto 10px;
|
|
|
}
|
|
|
|
|
|
+.annotation-box.selected {
|
|
|
+ border: 2px solid;
|
|
|
+}
|
|
|
+
|
|
|
.buttons {
|
|
|
display: flex;
|
|
|
justify-content: center;
|