Browse Source

new features of point

Victor Luiz Domingues 5 years ago
parent
commit
3b505fec7b

+ 1 - 0
src/app/app.js

@@ -35,6 +35,7 @@ export const app = (function() {
     });
     _stage.on("click tap", function(e) {
       const tool = _getSelectedTool();
+      console.info("state", State.getCurrentState());
       if (tool != undefined) {
         const fun = tool.draw.bind(tool);
         fun();

+ 6 - 3
src/app/components/point-component/drawers/point-drawer.js

@@ -3,6 +3,8 @@ import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
 import { label as Label } from "../../../component-registry/label";
 import { app as App } from "../../../app";
 import { PointModel } from "../models/point-model";
+import { DrawerAggragator } from "../../../core/drawers/drawer-aggregator";
+
 const HOVER_STYLE = {
   fill: "#9bc364",
   strokeWidth: 2,
@@ -36,16 +38,16 @@ export class PointDrawer extends Drawer {
   }
   draw() {
     if (this.state == undefined) {
-      this.state = this.states[0];
+      super.setState(this.states[0]);
       App.setStatus("Selecione o centro do Ponto");
       return;
     } else if (this.state == this.states[0]) {
       let pos = App.pos();
       this.point = new PointModel(pos.x, pos.y);
       this.setPoint(this.point, true);
-      //   super.addAggregator(new DrawerAggregator(this, this.point));
+      super.addAggregator(new DrawerAggragator(this, this.point));
       super.draw(this.group);
-      this.clear();
+      super.setState(this.states[0]);
       return this.group;
     }
   }
@@ -101,4 +103,5 @@ export class PointDrawer extends Drawer {
       App.stage.draw();
     });
   }
+  update() {}
 }

+ 2 - 0
src/app/core/application/selector.js

@@ -3,6 +3,7 @@ import { stages as Stages } from "../application/stages";
 import { state as State } from "../application/state";
 import { objects as Objects } from "../application/objects";
 import { ELEMENTS_CLASS } from "../enums/elements-class-enum";
+import { app as App } from "../../app";
 export class Selector {
   constructor() {
     this._objects = [];
@@ -67,6 +68,7 @@ export class Selector {
 
   updateDragSelector(posIn) {
     if (State.getCurrentState() != APP_STATE.NONE) return;
+    App.clearSelectedTool();
     let currentObjects = Objects.get();
     let posRect = this.reverse(this._selectorPosStart, this._selectorPosNow);
     this._selectorPosNow = { x: posIn.x, y: posIn.y };

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

@@ -1,12 +1,15 @@
 export class DrawerAggragator {
   constructor(drawer, geometricObject) {
     this.drawer = drawer;
-    this.geometricObject = geometricObject;
+    this.genericObject = geometricObject;
   }
-  setGeometricObject(geometricObject) {
-    this.geometricObject = geometricObject;
+  setGeometricObject(genericObject) {
+    this.genericObject = genericObject;
   }
-  setDrawer(konvaObject) {
-    this.konvaObject = konvaObject;
+  setDrawer(drawer) {
+    this.drawer = drawer;
+  }
+  update() {
+    this.drawer.update();
   }
 }

+ 1 - 0
src/app/core/drawers/drawer-manager.js

@@ -16,5 +16,6 @@ class DrawerManager {
   draw(object) {
     this.currentStage.draw(object);
   }
+  addAggregator(aggregator) {}
 }
 export const drawerManager = new DrawerManager();

+ 6 - 0
src/app/core/drawers/drawer.js

@@ -9,6 +9,9 @@ export class Drawer {
     this.state = undefined;
   }
   onDragMove() {}
+  setState(state) {
+    this.state = state;
+  }
   clearState() {
     this.state = undefined;
   }
@@ -26,4 +29,7 @@ export class Drawer {
   draw(object) {
     this.drawerManager.draw(object);
   }
+  update() {
+    throw "Not implemented exception";
+  }
 }

+ 1 - 1
src/app/core/models/objects/dynamic-object.js

@@ -12,6 +12,6 @@ export class DynamicObject extends GenericObject {
     }
   }
   addDependency(dynamicObject) {
-    this.dependencies = dynamicObject;
+    this.dependencies.push(dynamicObject);
   }
 }