feat: 完成关系箭头标注,右键删除
This commit is contained in:
parent
06d4378c73
commit
585cd1e65f
|
@ -110,7 +110,7 @@
|
||||||
</div>
|
</div>
|
||||||
<CVPoint v-if="projectType === '图片点标注'" :fileContent="nowText" :annoDetails="ners" :nowType="nowType" :types="types" :save="save"></CVPoint>
|
<CVPoint v-if="projectType === '图片点标注'" :fileContent="nowText" :annoDetails="ners" :nowType="nowType" :types="types" :save="save"></CVPoint>
|
||||||
<RLHF v-if="projectType === '人类反馈强化学习'" :fileContent="nowText" :annoDetails="ners" :nowType="nowType" :types="types" :save="save"></RLHF>
|
<RLHF v-if="projectType === '人类反馈强化学习'" :fileContent="nowText" :annoDetails="ners" :nowType="nowType" :types="types" :save="save"></RLHF>
|
||||||
<Rel v-if="projectType === '关系标注'" :relDetails="relDetails" :nowType="nowType" :save="save"></Rel>
|
<Rel v-if="projectType === '关系标注'" :relDetails="relDetails" :nowType="nowType" :types="types" :save="save"></Rel>
|
||||||
</div>
|
</div>
|
||||||
<div class="page-btn-box">
|
<div class="page-btn-box">
|
||||||
<button class="page-btn" @click="changeIdx(-1, $event)" @mouseover="setFocus('page-up')" @mouseleave="setFocus('')">上一个 {{ fastTypeKey['page-up'] ? `【${fastTypeKey['page-up']}】` : '' }}</button>
|
<button class="page-btn" @click="changeIdx(-1, $event)" @mouseover="setFocus('page-up')" @mouseleave="setFocus('')">上一个 {{ fastTypeKey['page-up'] ? `【${fastTypeKey['page-up']}】` : '' }}</button>
|
||||||
|
@ -568,6 +568,7 @@ export default {
|
||||||
startSelect: function (idx, event) {
|
startSelect: function (idx, event) {
|
||||||
if (this.nerProjectType.indexOf(this.projectType) === -1) return
|
if (this.nerProjectType.indexOf(this.projectType) === -1) return
|
||||||
if (this.nowType.indexOf('关系-') > -1) {
|
if (this.nowType.indexOf('关系-') > -1) {
|
||||||
|
if (event.which === 3) return
|
||||||
if (typeof this.relStartIdx === 'number') {
|
if (typeof this.relStartIdx === 'number') {
|
||||||
console.log(this.relStartIdx, idx)
|
console.log(this.relStartIdx, idx)
|
||||||
this.relDetails.push({
|
this.relDetails.push({
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="rel-box">
|
<div class="rel-box">
|
||||||
<div v-for="(relDetail, idx) in relDetails" :key="idx" class="rel" @click="clickLine(idx)">
|
<svg v-for="(relLine, idx) in relLines" :key="idx" class="rel"
|
||||||
<div>{{relDetail}}</div>
|
xmlns="http://www.w3.org/2000/svg" version="1.1" >
|
||||||
</div>
|
<marker id="arrow" markerUnits="strokeWidth" markerWidth="10" markerHeight="10" viewBox="0 0 12 12" refX="6" refY="6" orient="auto">
|
||||||
|
<path d="M2,2 L10,6 L2,10 L6,6 L2,2" :style="`fill:${types[relDetails[idx]['type']]['color']}`"/>
|
||||||
|
</marker>
|
||||||
|
<path :d="relLine"
|
||||||
|
:title="relDetails[idx]['type']"
|
||||||
|
:style="`stroke:${types[relDetails[idx]['type']]['color']};stroke-width:2;fill:#0000;marker-end:url(#arrow)`"
|
||||||
|
@contextmenu="delRel($event, idx)"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -18,53 +26,59 @@ export default ({
|
||||||
},
|
},
|
||||||
relDetails: {
|
relDetails: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: undefined,
|
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
save: {
|
save: {
|
||||||
type: Function,
|
type: Function,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
types: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
points: [],
|
points: [],
|
||||||
width: 0,
|
width: 0,
|
||||||
height: 0
|
height: 0,
|
||||||
|
relLines: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
log (...args) {
|
log (...args) {
|
||||||
console.log(args)
|
console.log(args)
|
||||||
|
},
|
||||||
|
delRel (e, idx) {
|
||||||
|
e.preventDefault()
|
||||||
|
this.relDetails.splice(idx, 1)
|
||||||
|
this.save()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
relDetails: {
|
relDetails: {
|
||||||
handler (val) {
|
handler (val) {
|
||||||
console.log(val)
|
console.log(this.types)
|
||||||
|
let _relLines = []
|
||||||
|
for (let i = 0; i < val.length; i++) {
|
||||||
|
const item = val[i]
|
||||||
|
let startCharDom = document.getElementById(item.start)
|
||||||
|
let endCharDom = document.getElementById(item.end)
|
||||||
|
let sx = startCharDom.offsetLeft + startCharDom.offsetWidth / 2
|
||||||
|
let sy = startCharDom.offsetTop + 9
|
||||||
|
let ex = endCharDom.offsetLeft + endCharDom.offsetWidth / 2
|
||||||
|
let ey = endCharDom.offsetTop + 9
|
||||||
|
let cx = (sx + ex) / 2
|
||||||
|
let cy = (sy + ey) / 2 - 20
|
||||||
|
_relLines.push(`M${sx} ${sy} Q${cx} ${cy} ${ex} ${ey}`)
|
||||||
|
}
|
||||||
|
console.log(_relLines)
|
||||||
|
this.relLines = _relLines
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
},
|
},
|
||||||
delRel: {
|
|
||||||
handler (val) {
|
|
||||||
if (!val) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.relDetails.splice(this.relDetails.indexOf(val), 1)
|
|
||||||
this.save()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
nowType: {
|
nowType: {
|
||||||
handler (val) {
|
handler (val) {
|
||||||
if (!val) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (this.annoDetails.indexOf(val) === -1) {
|
|
||||||
this.annoDetails.push(val)
|
|
||||||
} else {
|
|
||||||
this.annoDetails.splice(this.annoDetails.indexOf(val), 1)
|
|
||||||
}
|
|
||||||
this.save()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,4 +86,19 @@ export default ({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.rel-box,
|
||||||
|
.rel {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 100;
|
||||||
|
/* background: rgba(0, 0, 0, 0.5); */
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.rel path {
|
||||||
|
pointer-events: all;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue