diff options
| author | bobzel <zzzman@gmail.com> | 2020-08-05 13:06:14 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-05 13:06:14 -0400 |
| commit | a9fbb81375d3e97b808d2cb90e68c9716ee916b7 (patch) | |
| tree | 23a8545c9660ed57f0e3af7f6537cf4c2e5edc7f /src/client/views/InkingStroke.tsx | |
| parent | 1c54fb50438698bbc7a533ff98102e2a41458017 (diff) | |
| parent | d3c49ce7b1921dec4c27f425b2af788e3d6385e9 (diff) | |
Merge pull request #489 from browngraphicslab/ink_edits
fixed bugs after testing
Diffstat (limited to 'src/client/views/InkingStroke.tsx')
| -rw-r--r-- | src/client/views/InkingStroke.tsx | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx index 8e3f72cee..6c5eda256 100644 --- a/src/client/views/InkingStroke.tsx +++ b/src/client/views/InkingStroke.tsx @@ -18,6 +18,8 @@ import { Doc } from "../../fields/Doc"; import FormatShapePane from "./collections/collectionFreeForm/FormatShapePane"; import { action } from "mobx"; import { setupMoveUpEvents } from "../../Utils"; +import { undoBatch, UndoManager } from "../util/UndoManager"; + library.add(faPaintBrush); @@ -26,8 +28,12 @@ const InkDocument = makeInterface(documentSchema); @observer export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocument>(InkDocument) { + private _controlUndo?: UndoManager.Batch; + public static LayoutString(fieldStr: string) { return FieldView.LayoutString(InkingStroke, fieldStr); } + + private analyzeStrokes = () => { const data: InkData = Cast(this.dataDoc[this.fieldKey], InkField)?.inkData ?? []; CognitiveServices.Inking.Appliers.ConcatenateHandwriting(this.dataDoc, ["inkAnalysis", "handwriting"], [data]); @@ -52,6 +58,7 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume @action onControlDown = (e: React.PointerEvent, i: number): void => { setupMoveUpEvents(this, e, this.onControlMove, this.onControlup, (e) => { }); + this._controlUndo = UndoManager.StartBatch("DocDecs set radius"); this._prevX = e.clientX; this._prevY = e.clientY; this._controlNum = i; @@ -76,6 +83,8 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume this._prevX = 0; this._prevY = 0; this._controlNum = 0; + this._controlUndo?.end(); + this._controlUndo = undefined; } public static MaskDim = 50000; @@ -90,10 +99,10 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume const top = Math.min(...ys) - strokeWidth / 2; const right = Math.max(...xs) + strokeWidth / 2; const bottom = Math.max(...ys) + strokeWidth / 2; - const width = right - left; - const height = bottom - top; - const scaleX = (this.props.PanelWidth() - strokeWidth) / (width - strokeWidth); - const scaleY = (this.props.PanelHeight() - strokeWidth) / (height - strokeWidth); + const width = Math.max(right - left); + const height = Math.max(1, bottom - top); + const scaleX = width === strokeWidth ? 1 : (this.props.PanelWidth() - strokeWidth) / (width - strokeWidth); + const scaleY = height === strokeWidth ? 1 : (this.props.PanelHeight() - strokeWidth) / (height - strokeWidth); const strokeColor = StrCast(this.layoutDoc.color, ""); const points = InteractionUtils.CreatePolyline(data, left, top, strokeColor, strokeWidth, strokeWidth, @@ -125,18 +134,17 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume } handleLine.push({ X1: data[data.length - 2].X, Y1: data[data.length - 2].Y, X2: data[data.length - 1].X, Y2: data[data.length - 1].Y, X3: data[data.length - 1].X, Y3: data[data.length - 1].Y, dot1: data.length - 1, dot2: data.length - 1 }); - - } - if (data.length <= 4) { - handlePoints = []; - handleLine = []; - controlPoints = []; - for (var i = 0; i < data.length; i++) { - controlPoints.push({ X: data[i].X, Y: data[i].Y, I: i }); - } - } - const dotsize = String(Math.min(width * scaleX, height * scaleY) / 40); + // if (data.length <= 4) { + // handlePoints = []; + // handleLine = []; + // controlPoints = []; + // for (var i = 0; i < data.length; i++) { + // controlPoints.push({ X: data[i].X, Y: data[i].Y, I: i }); + // } + + // } + const dotsize = String(Math.max(width * scaleX, height * scaleY) / 40); const controls = controlPoints.map((pts, i) => |
