From 4f237303dbc5398cc0f7de8e15901e1b87d57adb Mon Sep 17 00:00:00 2001
From: mehekj <mehek.jethani@gmail.com>
Date: Wed, 4 May 2022 23:10:48 -0400
Subject: use ink screen space pts for transcription

---
 src/client/views/InkTranscription.tsx | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

(limited to 'src/client/views/InkTranscription.tsx')

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];
                 }
-- 
cgit v1.2.3-70-g09d2

