|
@@ -17,18 +17,26 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
this.radius;
|
|
|
this.centerAggregator;
|
|
|
this.konvaObject;
|
|
|
+ this.setElementClass(ELEMENTS_CLASS.CIRCUMFERENCE);
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
+ if (e != undefined) {
|
|
|
+
|
|
|
+ if (
|
|
|
+ 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;
|
|
|
+ } else if (e.attrs != undefined && e.attrs.genericObject != undefined) {
|
|
|
+
|
|
|
+ this.resolveAggregators([e.attrs.genericObject.center, e.attrs.genericObject.radius], undefined, false);
|
|
|
+ this.createByCircumference(e.attrs.genericObject);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
const points = Selector.getSelectedPoints();
|
|
|
if (points == undefined || points.length == 0) {
|
|
@@ -36,14 +44,7 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
} else this.drawByPoints(points, undefined, e);
|
|
|
}
|
|
|
drawByPoints(points, aggregators, e) {
|
|
|
- if (aggregators == undefined)
|
|
|
- aggregators = Selector.getSelectedPointsAggregators();
|
|
|
- else {
|
|
|
- aggregators = [
|
|
|
- Objects.getByGenericObject(this.pointA)[0],
|
|
|
- Objects.getByGenericObject(this.pointB)[0]
|
|
|
- ];
|
|
|
- }
|
|
|
+ aggregators = this.resolveAggregators(points, aggregators, true);
|
|
|
this.centerAggregator = aggregators[0];
|
|
|
this.radiusAggregator = aggregators[1];
|
|
|
this.center = points[0];
|
|
@@ -79,7 +80,11 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
this.center = center;
|
|
|
this.radius = radius;
|
|
|
this.circumference = new CircumferenceModel(this.center, this.radius);
|
|
|
- this.konvaObject = this.drawcircumference(this.circumference);
|
|
|
+ this.createByCircumference(this.circumference);
|
|
|
+ }
|
|
|
+ createByCircumference(circumference) {
|
|
|
+ this.circumference = circumference;
|
|
|
+ this.konvaObject = this.drawCircumference(this.circumference);
|
|
|
const aggregator = new DrawerAggregator(
|
|
|
this,
|
|
|
this.circumference,
|
|
@@ -94,7 +99,7 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
super.batchDraw();
|
|
|
return aggregator;
|
|
|
}
|
|
|
- drawcircumference(circumference) {
|
|
|
+ drawCircumference(circumference) {
|
|
|
const circle = new Konva.Arc({
|
|
|
x: circumference.center.posX,
|
|
|
y: circumference.center.posY,
|
|
@@ -115,6 +120,25 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
SelectableDrawer.setSelectableIfToolChanged(circle);
|
|
|
return circle;
|
|
|
}
|
|
|
+ resolveAggregators(points, aggregators, selected) {
|
|
|
+ if (this.center == undefined) {
|
|
|
+ this.center = points[0];
|
|
|
+ }
|
|
|
+ if (this.radius == undefined) {
|
|
|
+ this.radius = points[1];
|
|
|
+ }
|
|
|
+ if (aggregators == undefined && selected == true)
|
|
|
+ aggregators = Selector.getSelectedPointsAggregators();
|
|
|
+ else {
|
|
|
+ aggregators = [
|
|
|
+ Objects.getByGenericObject(points[0])[0],
|
|
|
+ Objects.getByGenericObject(points[1])[0]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ this.centerAggregator = aggregators[0];
|
|
|
+ this.radiusAggregator = aggregators[1];
|
|
|
+ return aggregators;
|
|
|
+ }
|
|
|
|
|
|
update(aggregator, e) {
|
|
|
if (!aggregator.visible) return;
|