From b6ae411cfa04f6736d91749e6c99beb8179b3a30 Mon Sep 17 00:00:00 2001
From: eleanor-park <eleanor_park@brown.edu>
Date: Fri, 14 Jun 2024 14:23:56 -0400
Subject: looking for weird error

---
 .../collectionFreeForm/CollectionFreeFormView.tsx  | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index e66dbd796..a27ac2a0c 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1,12 +1,13 @@
 /* eslint-disable react/jsx-props-no-spreading */
 /* eslint-disable jsx-a11y/click-events-have-key-events */
 /* eslint-disable jsx-a11y/no-static-element-interactions */
-import { Bezier } from 'bezier-js';
+import { Bezier, Point } from 'bezier-js';
 import { Colors } from 'browndash-components';
 import { action, computed, IReactionDisposer, makeObservable, observable, reaction, runInAction } from 'mobx';
 import { observer } from 'mobx-react';
 import { computedFn } from 'mobx-utils';
 import * as React from 'react';
+import { TbAlpha } from 'react-icons/tb';
 import { ClientUtils, DashColor, lightOrDark, OmitKeys, returnFalse, returnZero, setupMoveUpEvents, UpdateIcon } from '../../../../ClientUtils';
 import { DateField } from '../../../../fields/DateField';
 import { ActiveEraserWidth, ActiveInkWidth, Doc, DocListCast, Field, FieldType, Opt, SetActiveInkColor, SetActiveInkWidth } from '../../../../fields/Doc';
@@ -26,6 +27,7 @@ import { aggregateBounds, clamp, emptyFunction, intersectRect, Utils } from '../
 import { Docs } from '../../../documents/Documents';
 import { CollectionViewType, DocumentType } from '../../../documents/DocumentTypes';
 import { DocUtils } from '../../../documents/DocUtils';
+import { FitCurve, GenerateControlPoints } from '../../../util/bezierFit';
 import { DragManager } from '../../../util/DragManager';
 import { dropActionType } from '../../../util/DropActionTypes';
 import { CompileScript } from '../../../util/Scripting';
@@ -55,7 +57,6 @@ import { CollectionFreeFormRemoteCursors } from './CollectionFreeFormRemoteCurso
 import './CollectionFreeFormView.scss';
 import { MarqueeView } from './MarqueeView';
 import { SmartDrawHandler } from './SmartDrawHandler';
-import { ImageLabelHandler } from './ImageLabelHandler';
 
 @observer
 class CollectionFreeFormOverlayView extends React.Component<{ elements: () => ViewDefResult[] }> {
@@ -144,10 +145,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
             : this._props.childPointerEvents?.() ??
                   (this._props.viewDefDivClick || //
                   (this.layoutEngine === computePassLayout.name && !this._props.isSelected()) ||
-                  this.isContentActive() === false ||
-                  Doc.ActiveTool === InkTool.RadiusEraser ||
-                  Doc.ActiveTool === InkTool.SegmentEraser ||
-                  Doc.ActiveTool === InkTool.StrokeEraser
+                  this.isContentActive() === false
                       ? 'none'
                       : this._props.pointerEvents?.());
     }
@@ -685,6 +683,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
     @action
     onEraserClick = (e: PointerEvent, doubleTap?: boolean) => {
         this.erase(e, [0, 0]);
+        e.stopPropagation();
         return false;
     };
 
@@ -1265,19 +1264,20 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
 
     @action
     createDrawing = (e: PointerEvent, doubleTap?: boolean) => {
-        SmartDrawHandler.Instance.displaySmartDrawHandler(e.pageX, e.pageY, this.createInkStroke);
+        SmartDrawHandler.Instance.displaySmartDrawHandler(e.pageX, e.pageY, this.createInkStrokes);
     };
 
     @action
-    createInkStroke = (strokeList: InkData[]) => {
-        strokeList.forEach(coords => {
-            // const stroke = new InkField(coords);
-            // const points = coords.map(p => intersect.inkView.ComponentView?.ptToScreen?.({ X: p.X, Y: p.Y }) ?? { X: 0, Y: 0 }), [] as PointData[]);
-            const bounds = InkField.getBounds(coords);
+    createInkStrokes = (strokeList: InkData[], alpha?: number) => {
+        console.log(strokeList.length);
+        strokeList.forEach(inkData => {
+            // const points: InkData = FitCurve(inkData, 20) as InkData;
+            const allPts = GenerateControlPoints(inkData, alpha);
+            const bounds = InkField.getBounds(allPts);
             const B = this.screenToFreeformContentsXf.transformBounds(bounds.left, bounds.top, bounds.width, bounds.height);
             const inkWidth = ActiveInkWidth() * this.ScreenToLocalBoxXf().Scale;
             const inkDoc = Docs.Create.InkDocument(
-                coords,
+                allPts,
                 { title: 'stroke',
                     x: B.x - inkWidth / 2,
                     y: B.y - inkWidth / 2,
-- 
cgit v1.2.3-70-g09d2

