12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { Drawer } from "../../../core/drawers/drawer";
- import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
- import { label as Label } from "../../../component-registry/label";
- import { app as App } from "../../../app";
- import { DrawerAggragator } from "../../../core/drawers/drawer-aggregator";
- import { selector as Selector } from "../../../core/application/selector";
- export class LineSegmentDrawer extends Drawer {
- static FIRST_POINT() {
- return "FIRST_POINT";
- }
- static SECOND_POINT() {
- return "SECOND_POINT";
- }
- constructor() {
- super();
- this.pointA;
- this.pointB;
- this.states = [
- LineSegmentDrawer.FIRST_POINT,
- LineSegmentDrawer.SECOND_POINT
- ];
- }
- setPointA(point) {
- this.pointA = point;
- }
- setPointB(point) {
- this.pointB = point;
- }
- draw() {
- // if (this._state == null) {
- // this._state = LineSegment.STATE_PRIMEIRO_PONTO;
- // this._points.clear();
- // App.setStatus("Selecione o primeiro ponto no canvas");
- // } else if (this._state === LineSegment.STATE_PRIMEIRO_PONTO) {
- // const pos = App.pos();
- // this._points.add({ x: pos.x, y: pos.y });
- // this._state = LineSegment.STATE_SEGUNDO_PONTO;
- // } else if (this._state === LineSegment.STATE_SEGUNDO_PONTO) {
- // const pos = App.pos();
- // this._points.add({ x: pos.x, y: pos.y });
- // this.drawPoint(this._points);
- // this._points.clear();
- // this._state = LineSegment.STATE_PRIMEIRO_PONTO;
- // }
- const points = Selector.getPoints();
- console.info("points", points);
- if (points == undefined || points.length < 1) return;
- console.info("pointA", points[0]);
- console.info("pointB", points[1]);
- }
- update() {}
- static getKonvaLine(pointA, pointB) {
- const points = [pointA.posX, pointA.posY, pointB.posX, pointB.posY];
- return new Konva.Line({
- points: points,
- stroke: "grey",
- strokeWidth: 2,
- lineJoin: "round",
- draggable: false,
- strokeScaleEnabled: false,
- class: ELEMENTS_CLASS.LINE_SEGMENT,
- connections: []
- });
- }
- static drawKonvaLine(pointA, pointB) {
- const line = LineSegmentDrawer.getKonvaLine(pointA, pointB);
- }
- }
|