diff --git a/src/pages/detect.vue b/src/pages/detect.vue index a1a8f7f..0de0000 100644 --- a/src/pages/detect.vue +++ b/src/pages/detect.vue @@ -577,19 +577,31 @@ this.detectorLevel = value }, structureClick(e) { - const boxCoords = this.box2cvs(this.showResults) + let self = this + function loopIndex(i) { + if (self.selectedChip == -1) return i + let li = i + self.selectedChip + if (li >= numBoxes) li -= numBoxes + return li + } + let boxCoords = this.box2cvs(this.showResults) + const numBoxes = boxCoords.length let clickX = (e.offsetX - this.canvasOffset.x) / this.canvasZoom let clickY = (e.offsetY - this.canvasOffset.y) / this.canvasZoom - var findBox = boxCoords.findIndex( (r, i) => { return r.cvsLeft <= clickX && + let boxEnd = boxCoords.splice(0, this.selectedChip) + boxCoords = boxCoords.concat(boxEnd) + var findBox = boxCoords.findIndex( (r, i) => { + let di = loopIndex(i) + if (di == this.selectedChip ) return false + return r.cvsLeft <= clickX && r.cvsRight >= clickX && r.cvsTop <= clickY && r.cvsBottom >= clickY && - this.resultData.detections[i].resultIndex > this.selectedChip && - this.resultData.detections[i].aboveThreshold && - this.resultData.detections[i].isSearched && - !this.resultData.detections[i].isDeleted + this.resultData.detections[di].aboveThreshold && + this.resultData.detections[di].isSearched && + !this.resultData.detections[di].isDeleted }) - this.selectChip(findBox >= 0 ? this.resultData.detections[findBox].resultIndex : this.selectedChip) + this.selectChip(findBox >= 0 ? this.resultData.detections[loopIndex(findBox)].resultIndex : this.selectedChip) }, box2cvs(boxInput) { if (!boxInput || boxInput.length == 0) return []