|
@@ -4,6 +4,7 @@ import { DrawerAggregator } from "../../../core/drawers/drawer-aggregator";
|
|
import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
|
|
import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
|
|
import { selector as Selector } from "../../../core/application/selector";
|
|
import { selector as Selector } from "../../../core/application/selector";
|
|
import { SelectableDrawer } from "../../../core/drawers/selectable-drawer";
|
|
import { SelectableDrawer } from "../../../core/drawers/selectable-drawer";
|
|
|
|
+import { objects as Objects } from "../../../core/application/objects";
|
|
|
|
|
|
export class CircumferenceDrawer extends SelectableDrawer {
|
|
export class CircumferenceDrawer extends SelectableDrawer {
|
|
constructor() {
|
|
constructor() {
|
|
@@ -19,9 +20,19 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
}
|
|
}
|
|
|
|
|
|
draw(e) {
|
|
draw(e) {
|
|
|
|
+ if (
|
|
|
|
+ e != undefined &&
|
|
|
|
+ e.target != undefined &&
|
|
|
|
+ e.target.attrs.class != undefined &&
|
|
|
|
+ (e.target.attrs.class == ELEMENTS_CLASS.POINT ||
|
|
|
|
+ e.target.attrs.class == ELEMENTS_CLASS.INTERSECTION_POINT)
|
|
|
|
+ ) {
|
|
|
|
+ this.drawByStates(e.target);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
const points = Selector.getSelectedPoints();
|
|
const points = Selector.getSelectedPoints();
|
|
if (points == undefined || points.length == 0) {
|
|
if (points == undefined || points.length == 0) {
|
|
- this.drawByStates(e);
|
|
|
|
|
|
+ this.drawByStates();
|
|
} else this.drawByPoints(points, undefined, e);
|
|
} else this.drawByPoints(points, undefined, e);
|
|
}
|
|
}
|
|
drawByPoints(points, aggregators, e) {
|
|
drawByPoints(points, aggregators, e) {
|
|
@@ -41,17 +52,23 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
this.reset();
|
|
this.reset();
|
|
this.setStatus("");
|
|
this.setStatus("");
|
|
}
|
|
}
|
|
- drawByStates(e) {
|
|
|
|
|
|
+ drawByStates(konvaObject) {
|
|
|
|
+ let aggregator = undefined;
|
|
|
|
+ if (konvaObject != undefined) {
|
|
|
|
+ aggregator = Objects.getByKonvaObject(konvaObject)[0];
|
|
|
|
+ }
|
|
if (this.state == undefined) {
|
|
if (this.state == undefined) {
|
|
this.state = this.states[0];
|
|
this.state = this.states[0];
|
|
this.setStatus("Selecione o centro da Circunferência");
|
|
this.setStatus("Selecione o centro da Circunferência");
|
|
} else if (this.state == this.states[0]) {
|
|
} else if (this.state == this.states[0]) {
|
|
- this.centerAggregator = this.pointDrawer.drawPoint();
|
|
|
|
|
|
+ this.centerAggregator =
|
|
|
|
+ aggregator != undefined ? aggregator : this.pointDrawer.drawPoint();
|
|
this.center = this.centerAggregator.genericObject;
|
|
this.center = this.centerAggregator.genericObject;
|
|
this.state = this.states[1];
|
|
this.state = this.states[1];
|
|
this.setStatus("Selecione o raio da Circunferência");
|
|
this.setStatus("Selecione o raio da Circunferência");
|
|
} else if (this.state == this.states[1]) {
|
|
} else if (this.state == this.states[1]) {
|
|
- this.radiusAggregator = this.pointDrawer.drawPoint();
|
|
|
|
|
|
+ this.radiusAggregator =
|
|
|
|
+ aggregator != undefined ? aggregator : this.pointDrawer.drawPoint();
|
|
this.radius = this.radiusAggregator.genericObject;
|
|
this.radius = this.radiusAggregator.genericObject;
|
|
this.createAndDraw(this.center, this.radius);
|
|
this.createAndDraw(this.center, this.radius);
|
|
this.reset();
|
|
this.reset();
|
|
@@ -78,25 +95,6 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
return aggregator;
|
|
return aggregator;
|
|
}
|
|
}
|
|
drawcircumference(circumference) {
|
|
drawcircumference(circumference) {
|
|
- // const circle = new Konva.Circle({
|
|
|
|
- // x: circumference.center.posX,
|
|
|
|
- // y: circumference.center.posY,
|
|
|
|
- // radius: circumference.getRadius(),
|
|
|
|
- // fill: "transparent",
|
|
|
|
- // stroke: "grey",
|
|
|
|
- // strokeWidth: 2,
|
|
|
|
- // strokeScaleEnabled: false,
|
|
|
|
- // transformEnabled: false,
|
|
|
|
- // draggable: false,
|
|
|
|
- // selectable: false,
|
|
|
|
- // index: 0,
|
|
|
|
- // class: ELEMENTS_CLASS.CIRCUMFERENCE,
|
|
|
|
- // style: { stroke: "grey", fill: "grey" },
|
|
|
|
- // fillEnable: false,
|
|
|
|
- // strokeHitEnabled: true,
|
|
|
|
- // hitStrokeWidth: true,
|
|
|
|
- // strokeEnabled: true
|
|
|
|
- // });
|
|
|
|
const circle = new Konva.Arc({
|
|
const circle = new Konva.Arc({
|
|
x: circumference.center.posX,
|
|
x: circumference.center.posX,
|
|
y: circumference.center.posY,
|
|
y: circumference.center.posY,
|