fix(tag): bug
This commit is contained in:
@@ -4,6 +4,7 @@ import { useLabelStore } from "./store"
|
||||
import { useBottomToolsStore } from "./useBottomToolsStore"
|
||||
import { usePaperStore } from "./usePaperStore"
|
||||
import { useTopToolsStore } from "./useTopToolsStore"
|
||||
import { getObjectTagVisibility } from "./utils/objectVisibility"
|
||||
|
||||
const TAG_FONT_SIZE = 12
|
||||
const TAG_VERTICAL_GAP = 8
|
||||
@@ -159,13 +160,12 @@ const useRenderTag = () => {
|
||||
const activeImage = useBottomToolsStore.getState().activeImage
|
||||
const group = usePaperStore.getState().group
|
||||
if (!group) return
|
||||
const visible = useTopToolsStore.getState().showTags
|
||||
const configs = useTopToolsStore.getState().showTagsConfigs
|
||||
const groupScale =
|
||||
Number.isFinite(group.scaling?.x) && group.scaling.x !== 0
|
||||
? group.scaling.x
|
||||
: 1
|
||||
const applyPointTagCompensation = (
|
||||
const applyScreenSpaceTagCompensation = (
|
||||
item: paper.Item,
|
||||
anchor: [number, number]
|
||||
) => {
|
||||
@@ -235,7 +235,7 @@ const useRenderTag = () => {
|
||||
tag_anchor: tagAnchor,
|
||||
},
|
||||
parent: group,
|
||||
visible,
|
||||
visible: getObjectTagVisibility(activeImage, id, "text"),
|
||||
})
|
||||
text.translate(
|
||||
new paper.Point(
|
||||
@@ -259,8 +259,10 @@ const useRenderTag = () => {
|
||||
tag_anchor: tagAnchor,
|
||||
},
|
||||
parent: group,
|
||||
visible,
|
||||
visible: getObjectTagVisibility(activeImage, id, "text_mask"),
|
||||
})
|
||||
applyScreenSpaceTagCompensation(text, tagAnchor)
|
||||
applyScreenSpaceTagCompensation(textMask, tagAnchor)
|
||||
text.bringToFront()
|
||||
}
|
||||
|
||||
@@ -276,7 +278,7 @@ const useRenderTag = () => {
|
||||
tag_category: "mask",
|
||||
},
|
||||
parent: group,
|
||||
visible: visible && configs.includes("外框"),
|
||||
visible: getObjectTagVisibility(activeImage, id, "mask"),
|
||||
})
|
||||
// 标注对象点id
|
||||
if (path instanceof paper.CompoundPath) {
|
||||
@@ -301,9 +303,9 @@ const useRenderTag = () => {
|
||||
tag_anchor: pointTextPosition,
|
||||
},
|
||||
parent: group,
|
||||
visible: visible && configs.includes("点ID"),
|
||||
visible: getObjectTagVisibility(activeImage, id, "point_text"),
|
||||
})
|
||||
applyPointTagCompensation(pointText, pointTextPosition)
|
||||
applyScreenSpaceTagCompensation(pointText, pointTextPosition)
|
||||
index++
|
||||
})
|
||||
})
|
||||
@@ -327,9 +329,9 @@ const useRenderTag = () => {
|
||||
tag_anchor: pointTextPosition,
|
||||
},
|
||||
parent: group,
|
||||
visible: visible && configs.includes("点ID"),
|
||||
visible: getObjectTagVisibility(activeImage, id, "point_text"),
|
||||
})
|
||||
applyPointTagCompensation(pointText, pointTextPosition)
|
||||
applyScreenSpaceTagCompensation(pointText, pointTextPosition)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user