|
@@ -1,125 +1,81 @@
|
|
|
<template>
|
|
|
- <div v-if="visible" class="cropped-image">
|
|
|
- <div id="close_btn" class="btn"
|
|
|
- @mousedown.prevent="close"
|
|
|
- @touchstart.prevent="close">
|
|
|
- <img alt="close button" src="@/assets/icons/cross.svg">
|
|
|
- </div>
|
|
|
- <div class="image-container" :style="style">
|
|
|
- <div v-if="box">
|
|
|
- <h3>{{labelName}}</h3>
|
|
|
- <img :src="src" ref="crop" alt="crop" />
|
|
|
- </div>
|
|
|
- <div v-else>Select a crop to show</div>
|
|
|
- </div>
|
|
|
+ <div class="cropped-image">
|
|
|
+ <div class="close-button"
|
|
|
+ @mousedown.prevent="$emit('close', true)"
|
|
|
+ @touchstart.prevent="$emit('close', true)">
|
|
|
+ <img alt="close button" src="@/assets/icons/cross.svg">
|
|
|
</div>
|
|
|
|
|
|
+ <div v-if="src" class="image-container">
|
|
|
+ <h3>{{ label }}</h3>
|
|
|
|
|
|
+ <img alt="crop" :src="src"/>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ click a bounding box
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- export default {
|
|
|
- name: "cropped-image",
|
|
|
- props: ["width", "margin", "labels"],
|
|
|
-
|
|
|
-
|
|
|
- // mounted: function() {}
|
|
|
- // destroyed: function() {}
|
|
|
-
|
|
|
- data: function() {
|
|
|
- return {
|
|
|
- visible: false,
|
|
|
- box: null,
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- computed: {
|
|
|
- src: function () {
|
|
|
- if (!this.box)
|
|
|
- return ''
|
|
|
- var width = this.width - 2 * this.margin /*padding*/;
|
|
|
- return this.$root.socket.url(`/results/${this.box.identifier}/crop/${width}x${width}`)
|
|
|
- },
|
|
|
-
|
|
|
- style: function() {
|
|
|
-
|
|
|
- return {
|
|
|
- minWidth: `${this.width}px`,
|
|
|
- margin: `${this.margin}px`,
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
- labelName: function() {
|
|
|
- if (!this.box)
|
|
|
- return ''
|
|
|
-
|
|
|
- if (this.box.label == null)
|
|
|
- return 'Unknown'
|
|
|
-
|
|
|
- let name = 'Not Found';
|
|
|
- for (let label of this.labels){
|
|
|
- if (label.identifier != this.box.label)
|
|
|
- continue;
|
|
|
-
|
|
|
- name = label.name;
|
|
|
- break;
|
|
|
- }
|
|
|
- return name
|
|
|
- },
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- methods: {
|
|
|
- toggle: function () {
|
|
|
- this.set_visible(!this.visible);
|
|
|
- },
|
|
|
-
|
|
|
- set_visible: function (visible) {
|
|
|
- this.visible = visible;
|
|
|
-
|
|
|
- if (!visible)
|
|
|
- this.box = null;
|
|
|
-
|
|
|
- this.$emit("visibility-change", visible);
|
|
|
- },
|
|
|
-
|
|
|
- show: function (box_element) {
|
|
|
- this.box = box_element.box;
|
|
|
- },
|
|
|
-
|
|
|
- close: function() {
|
|
|
- this.set_visible(false);
|
|
|
- this.$emit("closed");
|
|
|
- }
|
|
|
- },
|
|
|
+export default {
|
|
|
+ name: "cropped-image",
|
|
|
+ props: ['labels', 'file', 'box'],
|
|
|
+ computed: {
|
|
|
+ src: function () {
|
|
|
+ if (!this.box)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ const file = this.file.identifier;
|
|
|
+ const uuid = this.file.uuid;
|
|
|
+ const x = this.box.data.x;
|
|
|
+ const y = this.box.data.y;
|
|
|
+ const w = this.box.data.w;
|
|
|
+ const h = this.box.data.h;
|
|
|
+
|
|
|
+ return this.$root.socket.url(`/data/${file}/1024/${x}x${y}x${w}x${h}?uuid=${uuid}`)
|
|
|
+ },
|
|
|
+ label: function () {
|
|
|
+ if (!this.box)
|
|
|
+ return false;
|
|
|
+ if (this.box.label == null)
|
|
|
+ return 'Unknown'
|
|
|
+
|
|
|
+ for (let label of this.labels)
|
|
|
+ if (label.identifier === this.box.label)
|
|
|
+ return label.name;
|
|
|
+
|
|
|
+ return 'Not found';
|
|
|
}
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-
|
|
|
.cropped-image {
|
|
|
+ width: 40%;
|
|
|
height: 100%;
|
|
|
-
|
|
|
- background-color: rgba(133, 133, 133, 0.7);
|
|
|
-}
|
|
|
-
|
|
|
-.image-container {
|
|
|
- /*align-items: center;*/
|
|
|
- justify-content: center;
|
|
|
+ background-color: #858585;
|
|
|
+ position: relative;
|
|
|
+ padding: 2rem 1rem;
|
|
|
text-align: center;
|
|
|
- display: flex;
|
|
|
}
|
|
|
|
|
|
-.image-container img {
|
|
|
- border-width: 2px;
|
|
|
- border-style: solid;
|
|
|
+.close-button {
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ right: 0;
|
|
|
+ padding: 0.5rem 0.67rem;
|
|
|
+ cursor: pointer;
|
|
|
+ filter: invert(1);
|
|
|
}
|
|
|
|
|
|
-#close_btn {
|
|
|
- justify-content: right;
|
|
|
- text-align: right;
|
|
|
-
|
|
|
- margin: 5px;
|
|
|
+.close-button img {
|
|
|
+ width: 1.5rem;
|
|
|
}
|
|
|
|
|
|
+.image-container img {
|
|
|
+ border: 2px solid;
|
|
|
+ max-width: 100%;
|
|
|
+}
|
|
|
</style>
|