Browse Source

Update 'src/app/core/models/application/actions/action-manager.js'

To read GEO with intersection point
Several indentation changes
Inserted new comments and "try/catch" to help in debug process
leo 2 năm trước cách đây
mục cha
commit
0e265f4bf4

+ 48 - 21
src/app/core/models/application/actions/action-manager.js

@@ -1,44 +1,71 @@
+/*
+ * iGeom by LInE
+ * Free software to student private data
+ *
+ * http://www.matematica.br/igeom
+ * http://www.usp.br/line
+ *
+ * Prepare string to build GEO file in iGeomJS
+ * 
+ * ./app/core/models/application/actions/action-manager.js
+ * @version 2023/07/14: Fixed reading GEO file with midpoint
+ */
+
 import { xor } from "lodash";
 import { xor } from "lodash";
 import { browser } from "../../../application/browser";
 import { browser } from "../../../application/browser";
 
 
 export class ActionManager {
 export class ActionManager {
-  constructor() {
+
+  constructor () {
     this.actions = [];
     this.actions = [];
-  }
-  push(action) {
+    }
+
+  push (action) {
     this.actions.push(action);
     this.actions.push(action);
-  }
-  remove(genericObject) {
+    }
 
 
+  remove (genericObject) {
     const action = this.actions.find(action => action.genericObject == genericObject);
     const action = this.actions.find(action => action.genericObject == genericObject);
     const index = this.actions.indexOf(action);
     const index = this.actions.indexOf(action);
     this.actions.splice(index, 1);
     this.actions.splice(index, 1);
-  }
-  pop() {
+    }
+
+  pop () {
     throw "Not implemented";
     throw "Not implemented";
-  }
-  clear() {
+    }
+
+  clear () {
     this.actions = [];
     this.actions = [];
-  }
-  load(actions) {
+    }
+
+  load (actions) {
     this.actions = actions;
     this.actions = actions;
-  }
-  save() {
+    }
+
+  // Generate GEO file
+  save () {
+    var strLine = "";
     const LINES = [
     const LINES = [
       `# igeom: http://www.matematica.br!
       `# igeom: http://www.matematica.br!
 [ .: iGeom : Geometria Interativa na Internet :. ]!
 [ .: iGeom : Geometria Interativa na Internet :. ]!
 [ versao: 1.0.0 ]!
 [ versao: 1.0.0 ]!
-[ PC = ${browser.appName}; DD = 0 ]!
-[[${new Date()}; ${browser.osName}]]!
+[ PC = ${browser.appName  }; DD = 0 ]!
+[[${new Date()  }; ${browser.osName  }]]!
 [0:1.1, 1:3,  - iGeom versao 1.0.0]!\n`
 [0:1.1, 1:3,  - iGeom versao 1.0.0]!\n`
     ];
     ];
+    console.log("action-manager.js!save(): initial");
     this.actions.forEach(action => {
     this.actions.forEach(action => {
-      action.rehydrate();
-      LINES.push(action.toString());
-    });
+      try {
+        action.rehydrate(); // in app/core/models/application/actions/action.js
+        strLine = action.toString();
+        LINES.push(strLine);
+      } catch (error) { console.log("action-manager.js!save(): error " + error + "\n* " + strLine); }
+      });
     let file = new Blob([...LINES], {
     let file = new Blob([...LINES], {
       type: "text/plain;charset=utf-8"
       type: "text/plain;charset=utf-8"
-    });
+      });
+    console.log("action-manager.js!save(): final");
     return file;
     return file;
-  }
-}
+    }
+
+  } // export class ActionManager