diff options
author | mehekj <mehek.jethani@gmail.com> | 2022-05-04 23:10:48 -0400 |
---|---|---|
committer | mehekj <mehek.jethani@gmail.com> | 2022-05-04 23:10:48 -0400 |
commit | 4f237303dbc5398cc0f7de8e15901e1b87d57adb (patch) | |
tree | c4053b8a68421849a36a2a65465a347e7e77ec9d /src | |
parent | 33fc3811e758441e7344706004feba1599d8d833 (diff) |
use ink screen space pts for transcription
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/InkTranscription.tsx | 25 | ||||
-rw-r--r-- | src/client/views/InkingStroke.tsx | 1 |
2 files changed, 11 insertions, 15 deletions
diff --git a/src/client/views/InkTranscription.tsx b/src/client/views/InkTranscription.tsx index ef4510f38..5e0667bed 100644 --- a/src/client/views/InkTranscription.tsx +++ b/src/client/views/InkTranscription.tsx @@ -9,6 +9,7 @@ import './InkTranscription.scss'; import { aggregateBounds } from '../../Utils'; import { CollectionFreeFormView } from './collections/collectionFreeForm'; import { DocumentManager } from "../util/DocumentManager"; +import { InkingStroke } from './InkingStroke'; export class InkTranscription extends React.Component { @@ -109,12 +110,14 @@ export class InkTranscription extends React.Component { const strokes: InkData[] = []; const times: number[] = []; - console.log(validInks); + // console.log(validInks); validInks.filter(i => Cast(i.data, InkField)).forEach(i => { const d = Cast(i.data, InkField, null); - const left = Math.min(...d?.inkData.map(pd => pd.X) ?? [0]); - const top = Math.min(...d?.inkData.map(pd => pd.Y) ?? [0]); - strokes.push(d.inkData.map(pd => ({ X: pd.X + NumCast(i.x) - left, Y: pd.Y + NumCast(i.y) - top }))); + // const left = Math.min(...d?.inkData.map(pd => pd.X) ?? [0]); + // const top = Math.min(...d?.inkData.map(pd => pd.Y) ?? [0]); + // strokes.push(d.inkData.map(pd => ({ X: pd.X + NumCast(i.x) - left, Y: pd.Y + NumCast(i.y) - top }))); + const inkStroke = DocumentManager.Instance.getDocumentView(i)?.ComponentView as InkingStroke; + strokes.push(d.inkData.map(pd => (inkStroke.ptToScreen({ X: pd.X, Y: pd.Y })))); times.push(DateCast(i.creationDate).getDate().getTime()); }); @@ -135,10 +138,6 @@ export class InkTranscription extends React.Component { } inkJSON = (stroke: InkData, time: number) => { - const scale = NumCast(this.containingLayout?._viewScale, 1); - const panX = NumCast(this.containingLayout?._panX); - const panY = NumCast(this.containingLayout?._panY); - return { "pointerType": "PEN", "pointerId": 1, @@ -226,14 +225,14 @@ export class InkTranscription extends React.Component { newCollection.title = word; } // nda - bug: when deleting a stroke before leaving writing mode, delete the stroke from unprocessed ink docs - console.log(newCollection); + // console.log(newCollection); newCollection && docView.props.addDocument?.(newCollection); }); } exportInk = (e: any, ref: any) => { const exports = e.detail.exports; - console.log(e); + // console.log(e); if (exports) { if (exports['application/x-latex']) { const latex = exports['application/x-latex']; @@ -285,12 +284,8 @@ export class InkTranscription extends React.Component { const text = exports['text/plain']; // console.log(text); - if (exports['application/vnd.myscript.jiix']) { - console.log(JSON.parse(exports['application/vnd.myscript.jiix'])); - } - if (this.currGroup) { - console.log("curr grouping"); + // console.log("curr grouping"); this.currGroup.transcription = text; this.currGroup.title = text.split("\n")[0]; } diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx index 40fe6aa68..6c95f0f77 100644 --- a/src/client/views/InkingStroke.tsx +++ b/src/client/views/InkingStroke.tsx @@ -253,6 +253,7 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps>() { (point.X - inkLeft - inkStrokeWidth / 2) * inkScaleX + inkStrokeWidth / 2, (point.Y - inkTop - inkStrokeWidth / 2) * inkScaleY + inkStrokeWidth / 2)).map(p => ({ X: p[0], Y: p[1] })); const screenHdlPts = screenPts; + console.log(screenPts); const startMarker = StrCast(this.layoutDoc.strokeStartMarker); const endMarker = StrCast(this.layoutDoc.strokeEndMarker); |