Prechádzať zdrojové kódy

Update 'src/app/components/circumference-component/drawers/circumference-drawer.js'

IMPORTANTE: Revision to remove bug that was generating error when reading Circumference in GEO file.
leo 2 mesiacov pred
rodič
commit
d0ddb05c7a

+ 17 - 40
src/app/components/circumference-component/drawers/circumference-drawer.js

@@ -37,19 +37,17 @@ export class CircumferenceDrawer extends SelectableDrawer {
 
   // @calledby app/core/models/components/component.js: draw(e): this.drawer.draw(e);
   draw (e) {
-    var auxE = ""; //D
-    console.log("circumference-drawer.js!draw(e)"); //D
-    try { // allow working in presence of error, besides to help debug process
+    var auxE = "";
+    console.log("circumference-drawer.js!draw(e): inicio"); //D
+    try {
       if (e != undefined) {
         if (e.target != undefined && e.target.attrs.class != undefined &&
             (e.target.attrs.class == ELEMENTS_CLASS.POINT || e.target.attrs.class == ELEMENTS_CLASS.INTERSECTION_POINT) ) {
-          console.log("circumference-drawer.js!draw(e): (1) e.target.attrs.class=" + (e.target.attrs.class != undefined ? e.target.attrs.class : "<>")); //D
           this.drawByStates(e.target);
           return;
           }
         else
         if (e.attrs != undefined && e.attrs.genericObject != undefined) {
-          console.log("circumference-drawer.js!draw(e): (2) e.target.attrs.genericObject=" + (e.target.attrs.genericObject != undefined ? e.target.attrs.genericObject : "<>")); //D
           this.resolveAggregators([e.attrs.genericObject.center, e.attrs.genericObject.radius], undefined, false);
           this.createByCircumference(e.attrs.genericObject);
           return;
@@ -58,19 +56,20 @@ export class CircumferenceDrawer extends SelectableDrawer {
       auxE += "1, "; //D
       const points = Selector.getSelectedPoints();
       auxE += "2 (#points=" + (points!=undefined && points.length!=undefined ? points.length : "0") + "), "; //D
-      console.log("circumference-drawer.js!draw(e): (3) antes de this.drawByStates()");
       if (points == undefined || points.length == 0) {
         auxE += "3, "; //D
         this.drawByStates();
         auxE += "4, "; //D
-        } 
+        }
       else {
         auxE += "5, "; //D
         this.drawByPoints(points, undefined, e);
         auxE += "6, "; //D
         }
     } catch (error) {
-      console.log("circumference-drawer.js!draw(e): Error '" + error + "', with " + auxE);
+      console.log("circumference-drawer.js!draw(e): Error '" + error + "'; e=" + e + ": path: " + auxE);
+      // var err = new Error(); console.log(err.stack);
+      console.trace(); //D present the execution stack - whowever do not apper the lines/names from this Konvas source code...
       }
     }
 
@@ -88,40 +87,28 @@ export class CircumferenceDrawer extends SelectableDrawer {
   drawByStates (konvaObject) {
     var auxE = ""; //D
     let aggregator = undefined;
-    auxE += "1, "; //D
     try {
     if (konvaObject != undefined) {
-      auxE += "2, "; //D
       aggregator = Objects.getByKonvaObject(konvaObject)[0];
-      auxE += "3, "; //D
       }
     if (this.state == undefined) {
-      auxE += "4, "; //D
       this.state = this.states[0];
-      this.setStatus("Select the first point A, will be the center of the circumference");
-      auxE += "5, "; //D
+      this.setStatus("Select the first point A, to be the center of the circumference"); //TODO Internacionalizar: Selecione o centro da Circunferência"
       }
     else
     if (this.state == this.states[0]) { // first point A from Circunference(A,B)
-      auxE += "6, "; //D
       this.centerAggregator = aggregator != undefined ? aggregator : this.pointDrawer.drawPoint();
       this.center = this.centerAggregator.genericObject;
       this.state = this.states[1];
-      this.setStatus("Select the second point B such that ||A-B|| define the circumference radius");
-      auxE += "7, "; //D
+      this.setStatus("Select the second point B such that ||A-B|| define the circumference radius"); //TODO Internacionalizar: Selecione o centro da Circunferencia"
       }
     else
     if (this.state == this.states[1]) { // second point B from Circunference(A,B)
-      auxE += "8, "; //D
       this.radiusAggregator = aggregator != undefined ? aggregator : this.pointDrawer.drawPoint();
-      auxE += "9, "; //D
       this.radius = this.radiusAggregator.genericObject;
-      auxE += "10, "; //D
       this.createAndDraw(this.center, this.radius);
-      auxE += "11, "; //D
       this.reset();
       this.state = this.states[0];
-      auxE += "12, "; //D
       }
     auxE += "13, "; //D
     } catch (error) {
@@ -130,43 +117,33 @@ export class CircumferenceDrawer extends SelectableDrawer {
     }
 
   createAndDraw (center, radius) {
-    var auxE = "";
+    var auxE = ""; // To debug...
     try {
     this.center = center;
-    this.radius = radius; //D auxE += "1, "; //D
-    this.circumference = new CircumferenceModel(this.center, this.radius); //D auxE += "2, "; //D
-    const label = Label.draw(true); //D auxE += "3, "; //D
+    this.radius = radius;
+    this.circumference = new CircumferenceModel(this.center, this.radius);
+    const label = Label.draw(true);
     this.circumference.setLabel(label);
     auxE += "4 (this.circumference.id=" + (this.circumference!=undefined ? this.circumference.id : "<>") + "), "; //D
     this.createByCircumference(this.circumference);
-    auxE += "5, "; //D
     } catch (error) {
       console.log("circumference-drawer.js!createAndDraw(center, radius): Error '" + error + "', with " + auxE);
-      }
+      }		
     }
 
   createByCircumference (circumference) {
-    var auxE = "";
+    var auxE = ""; // To debug...
     var aggregator = "";
     try {
     this.circumference = circumference;
-    auxE += "1, "; //D
     this.konvaObject = this.drawCircumference(this.circumference);
-    auxE += "2, "; //D
     aggregator = new DrawerAggregator(this, this.circumference, this.konvaObject, ELEMENTS_CLASS.CIRCUMFERENCE);
-    auxE += "3, "; //D
-    super.addAggregator(aggregator); // SelectableDrawer extends Drawer: app/core/drawers/drawer.js: addAggregator(aggregator)
-    auxE += "4, "; //D
+    super.addAggregator(aggregator);
     this.centerAggregator.addAggregator(aggregator);
-    auxE += "5, "; //D
     this.radiusAggregator.addAggregator(aggregator);
-    auxE += "6, "; //D
     SelectableDrawer.drawObject(this.konvaObject);
-    auxE += "7, "; //D
     this.konvaObject.zIndex(0);
-    auxE += "8, "; //D
     super.batchDraw();
-    auxE += "9, "; //D
     } catch (error) {
       console.log("circumference-drawer.js!createByCircumference(circumference): Error '" + error + "', with " + auxE);
       }
@@ -222,4 +199,4 @@ export class CircumferenceDrawer extends SelectableDrawer {
     super.batchDraw();
     }
 
-  }
+  } // export class CircumferenceDrawer extends SelectableDrawer