|
@@ -4,6 +4,7 @@ import { DrawerAggregator } from "../../../core/drawers/drawer-aggregator";
|
|
|
import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
|
|
|
import { selector as Selector } from "../../../core/application/selector";
|
|
|
import { SelectableDrawer } from "../../../core/drawers/selectable-drawer";
|
|
|
+import { objects as Objects } from "../../../core/application/objects";
|
|
|
|
|
|
export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
constructor() {
|
|
@@ -19,9 +20,19 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
if (points == undefined || points.length == 0) {
|
|
|
- this.drawByStates(e);
|
|
|
+ this.drawByStates();
|
|
|
} else this.drawByPoints(points, undefined, e);
|
|
|
}
|
|
|
drawByPoints(points, aggregators, e) {
|
|
@@ -41,17 +52,23 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
this.reset();
|
|
|
this.setStatus("");
|
|
|
}
|
|
|
- drawByStates(e) {
|
|
|
+ drawByStates(konvaObject) {
|
|
|
+ let aggregator = undefined;
|
|
|
+ if (konvaObject != undefined) {
|
|
|
+ aggregator = Objects.getByKonvaObject(konvaObject)[0];
|
|
|
+ }
|
|
|
if (this.state == undefined) {
|
|
|
this.state = this.states[0];
|
|
|
this.setStatus("Selecione o centro da Circunferência");
|
|
|
} 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.state = this.states[1];
|
|
|
this.setStatus("Selecione o raio da Circunferência");
|
|
|
} 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.createAndDraw(this.center, this.radius);
|
|
|
this.reset();
|
|
@@ -78,25 +95,6 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
return aggregator;
|
|
|
}
|
|
|
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({
|
|
|
x: circumference.center.posX,
|
|
|
y: circumference.center.posY,
|