Bläddra i källkod

Update 'src/app/core/drawers/drawer-aggregator.js'

Added explaining comments (about list of dependents) and removed some "console.log"
leo 2 månader sedan
förälder
incheckning
05ac42bfa5
1 ändrade filer med 12 tillägg och 5 borttagningar
  1. 12 5
      src/app/core/drawers/drawer-aggregator.js

+ 12 - 5
src/app/core/drawers/drawer-aggregator.js

@@ -48,6 +48,8 @@ export class DrawerAggregator {
     this.elementClass = elementClass;
     }
 
+  // Add in OG.dependents[] any object that directly depend of OG
+  // Examples: A:=Point(1,2); B:=Point(3,4); C:=MidPoint(A,B) => A.dependentsOnThis[] <- C; B.dependentsOnThis[] <- C
   addAggregator (aggregator) {
     if (this.aggregators==undefined) {
       console.log("drawer-aggregator.js!addAggregator(aggregator): Error, 'this.aggregators==undefined'");
@@ -55,25 +57,30 @@ export class DrawerAggregator {
       }
     var auxE = "1, ";
     try {
+      // Add the Geometric Object "aggregator.genericObject" in list of dependents of this Geometric Object "this.genericObject"
+      console.log("drawer-aggregator.js!addAggregator(aggregator): adiciona OG.id=" + aggregator.genericObject.id + " como dependente de " + this.genericObject.id);
       if (!this.aggregators.includes(aggregator)) {
         auxE += "2, "; //D
         this.aggregators.push(aggregator);
         auxE += "3, "; //D
-        this.genericObject.dependentsOnThis.push(aggregator.genericObject);
+        this.genericObject.dependentsOnThis.push(aggregator.genericObject); // app/core/models/objects/generic-object.js: this.dependentsOnThis = []
         }
     } catch (error) {
       console.log("drawer-aggregator.js!addAggregator(aggregator): Error '" + error + "', with " + auxE);
       }
     }
 
+  // Update all objects that dependend of this
   update (e) {
+    // REVER "this.aggregators[]": NAO pode ser um vetor como lista de dependentes! Seria lista de todos os objetos?
     var tam = this.aggregators?this.aggregators.length:0; //D xxx
-    var aux = JSON.stringify(this.geometricObject) + ", #this.aggregators=" + tam + " : "; //D xxx
-    for (var ii=0; ii<tam; ii++) aux += this.aggregators[ii].id + ","; //D xxx
-    console.log("drawer-aggregator.js!update(e): this.id=" + this.id + ": this.geometricObject=" + aux); //D xxx
+    var aux = JSON.stringify(this.geometricObject) + ", #this.aggregators=" + tam + " : list of dependents = ["; //D xxx
+    //D List the dependents of
+    //D for (var ii=0; ii<tam; ii++) aux += this.aggregators[ii].id + ","; aux += "]"; //D xxx
+    //D console.log("drawer-aggregator.js!update(e): this.id=" + this.id + ": this.geometricObject=" + aux); //D xxx
     this.drawer.update(this, e);
     this.updateAggregators(this.aggregators, e);
-      }
+    }
 
   updateAggregators (aggregators, e) {
     console.log("drawer-aggregator.js!updateAggregators(aggregators,e)"); //D