From ed658f2e5340c85e4466068be6ea63dd3143cc50 Mon Sep 17 00:00:00 2001 From: Zachary Zhang Date: Wed, 25 Sep 2024 23:14:46 -0400 Subject: add some comments --- src/client/views/GestureOverlay.tsx | 77 ++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx index 26cffb18b..1cd6de55c 100644 --- a/src/client/views/GestureOverlay.tsx +++ b/src/client/views/GestureOverlay.tsx @@ -138,6 +138,10 @@ export class GestureOverlay extends ObservableReactComponent doc.type === 'ink').map(doc => DocumentView.getDocumentView(doc, DocumentView.getDocumentView(doc))); if ((ffView?.ComponentView as CollectionFreeFormView).childDocs) { - //how many cusps the scribble hsa for (const doc of childDocs) { const otherInk = DocumentView.getDocumentView(doc)?.ComponentView as InkingStroke; - if (otherInk instanceof InkingStroke) { - const { inkData: otherInkData } = otherInk?.inkScaledData() ?? { inkData: [] }; - const otherScreenPts = otherInkData.map(point => otherInk.ptToScreen(point)); - if (this.isRectangleOverlap(this.getExtremeCoordinates(otherScreenPts), this.getExtremeCoordinates(inkData))) { - const intersects = this.doInksIntersect(inkData, otherScreenPts); - intersects.forEach(intersect => { - let percentage = ''; - if (intersect.includes('/')) { - const leftOfSlash = intersect.split('/')[0]; - percentage = leftOfSlash; - } else { - percentage = intersect; - } - intersectArray[Math.floor((percentage as unknown as number) * cuspArray.length)] = true; - const docsInBoundingBox = this.docsInBoundingBox(doc, childDocs); - childDocs = childDocs.filter(doc => !docsInBoundingBox.includes(doc)); - docsToDelete.push(...docsInBoundingBox); - docsToDelete.push(doc); - }); - } + const { inkData: otherInkData } = otherInk?.inkScaledData() ?? { inkData: [] }; + const otherScreenPts = otherInkData.map(point => otherInk.ptToScreen(point)); + if (this.isRectangleOverlap(this.getExtremeCoordinates(otherScreenPts), this.getExtremeCoordinates(inkData))) { + const intersects = this.doInksIntersect(inkData, otherScreenPts); + intersects.forEach(intersect => { + let percentage = ''; + if (intersect.includes('/')) { + const leftOfSlash = intersect.split('/')[0]; + percentage = leftOfSlash; + } else { + percentage = intersect; + } + intersectArray[Math.floor((percentage as unknown as number) * cuspArray.length)] = true; + const docsInBoundingBox = this.docsInBoundingBox(doc, childDocs); + childDocs = childDocs.filter(doc => !docsInBoundingBox.includes(doc)); + docsToDelete.push(...docsInBoundingBox); + docsToDelete.push(doc); + }); } } console.log(intersectArray); @@ -192,6 +193,12 @@ export class GestureOverlay extends ObservableReactComponent @@ -211,8 +218,8 @@ export class GestureOverlay extends ObservableReactComponent ({ + const scribbleCurve: Bezier = InkField.Segment(scribble, i); + const strokeCurve: Bezier = InkField.Segment(inkStroke, j); + const points = strokeCurve.points.map(point => ({ X: point.x, Y: point.y, })); if (ffView && ffView.ComponentView instanceof CollectionFreeFormView && this.isRectangleOverlap(extremeScribble, this.getExtremeCoordinates(points))) { - const result = (ffView.ComponentView as CollectionFreeFormView).bintersects(intersectCurve, eraserCurve)[0]; + const result = (ffView.ComponentView as CollectionFreeFormView).bintersects(scribbleCurve, strokeCurve)[0]; if (result !== undefined) { intersectArray.push(result.toString()); } @@ -318,11 +329,6 @@ export class GestureOverlay extends ObservableReactComponent { - const ffView = DocumentView.allViews().find(view => view.ComponentView instanceof CollectionFreeFormView); - const scribbleInk = (ffView?.ComponentView as CollectionFreeFormView).childDocs[(ffView?.ComponentView as CollectionFreeFormView).childDocs.length - 1]; - //this.isScribble((DocumentView.getDocumentView(scribbleInk)?.ComponentView as InkingStroke).inkScaledData().inkData); - }, 1); return this.dispatchGesture(name); case Gestures.RightAngle: return this.convertToText().length > 0; @@ -342,7 +348,6 @@ export class GestureOverlay extends ObservableReactComponent