|
@@ -37,19 +37,17 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
|
|
|
|
|
|
draw (e) {
|
|
|
- var auxE = "";
|
|
|
- console.log("circumference-drawer.js!draw(e)");
|
|
|
- try {
|
|
|
+ var auxE = "";
|
|
|
+ console.log("circumference-drawer.js!draw(e): inicio");
|
|
|
+ try {
|
|
|
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) ) {
|
|
|
- console.log("circumference-drawer.js!draw(e): (1) e.target.attrs.class=" + (e.target.attrs.class != undefined ? e.target.attrs.class : "<>"));
|
|
|
this.drawByStates(e.target);
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
if (e.attrs != undefined && e.attrs.genericObject != undefined) {
|
|
|
- console.log("circumference-drawer.js!draw(e): (2) e.target.attrs.genericObject=" + (e.target.attrs.genericObject != undefined ? e.target.attrs.genericObject : "<>"));
|
|
|
this.resolveAggregators([e.attrs.genericObject.center, e.attrs.genericObject.radius], undefined, false);
|
|
|
this.createByCircumference(e.attrs.genericObject);
|
|
|
return;
|
|
@@ -58,19 +56,20 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
auxE += "1, ";
|
|
|
const points = Selector.getSelectedPoints();
|
|
|
auxE += "2 (#points=" + (points!=undefined && points.length!=undefined ? points.length : "0") + "), ";
|
|
|
- console.log("circumference-drawer.js!draw(e): (3) antes de this.drawByStates()");
|
|
|
if (points == undefined || points.length == 0) {
|
|
|
auxE += "3, ";
|
|
|
this.drawByStates();
|
|
|
auxE += "4, ";
|
|
|
- }
|
|
|
+ }
|
|
|
else {
|
|
|
auxE += "5, ";
|
|
|
this.drawByPoints(points, undefined, e);
|
|
|
auxE += "6, ";
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.log("circumference-drawer.js!draw(e): Error '" + error + "', with " + auxE);
|
|
|
+ console.log("circumference-drawer.js!draw(e): Error '" + error + "'; e=" + e + ": path: " + auxE);
|
|
|
+
|
|
|
+ console.trace();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -88,40 +87,28 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
drawByStates (konvaObject) {
|
|
|
var auxE = "";
|
|
|
let aggregator = undefined;
|
|
|
- auxE += "1, ";
|
|
|
try {
|
|
|
if (konvaObject != undefined) {
|
|
|
- auxE += "2, ";
|
|
|
aggregator = Objects.getByKonvaObject(konvaObject)[0];
|
|
|
- auxE += "3, ";
|
|
|
}
|
|
|
if (this.state == undefined) {
|
|
|
- auxE += "4, ";
|
|
|
this.state = this.states[0];
|
|
|
- this.setStatus("Select the first point A, will be the center of the circumference");
|
|
|
- auxE += "5, ";
|
|
|
+ this.setStatus("Select the first point A, to be the center of the circumference");
|
|
|
}
|
|
|
else
|
|
|
if (this.state == this.states[0]) {
|
|
|
- auxE += "6, ";
|
|
|
this.centerAggregator = aggregator != undefined ? aggregator : this.pointDrawer.drawPoint();
|
|
|
this.center = this.centerAggregator.genericObject;
|
|
|
this.state = this.states[1];
|
|
|
- this.setStatus("Select the second point B such that ||A-B|| define the circumference radius");
|
|
|
- auxE += "7, ";
|
|
|
+ this.setStatus("Select the second point B such that ||A-B|| define the circumference radius");
|
|
|
}
|
|
|
else
|
|
|
if (this.state == this.states[1]) {
|
|
|
- auxE += "8, ";
|
|
|
this.radiusAggregator = aggregator != undefined ? aggregator : this.pointDrawer.drawPoint();
|
|
|
- auxE += "9, ";
|
|
|
this.radius = this.radiusAggregator.genericObject;
|
|
|
- auxE += "10, ";
|
|
|
this.createAndDraw(this.center, this.radius);
|
|
|
- auxE += "11, ";
|
|
|
this.reset();
|
|
|
this.state = this.states[0];
|
|
|
- auxE += "12, ";
|
|
|
}
|
|
|
auxE += "13, ";
|
|
|
} catch (error) {
|
|
@@ -130,43 +117,33 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
}
|
|
|
|
|
|
createAndDraw (center, radius) {
|
|
|
- var auxE = "";
|
|
|
+ var auxE = "";
|
|
|
try {
|
|
|
this.center = center;
|
|
|
- this.radius = radius;
|
|
|
- this.circumference = new CircumferenceModel(this.center, this.radius);
|
|
|
- const label = Label.draw(true);
|
|
|
+ this.radius = radius;
|
|
|
+ this.circumference = new CircumferenceModel(this.center, this.radius);
|
|
|
+ const label = Label.draw(true);
|
|
|
this.circumference.setLabel(label);
|
|
|
auxE += "4 (this.circumference.id=" + (this.circumference!=undefined ? this.circumference.id : "<>") + "), ";
|
|
|
this.createByCircumference(this.circumference);
|
|
|
- auxE += "5, ";
|
|
|
} catch (error) {
|
|
|
console.log("circumference-drawer.js!createAndDraw(center, radius): Error '" + error + "', with " + auxE);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
createByCircumference (circumference) {
|
|
|
- var auxE = "";
|
|
|
+ var auxE = "";
|
|
|
var aggregator = "";
|
|
|
try {
|
|
|
this.circumference = circumference;
|
|
|
- auxE += "1, ";
|
|
|
this.konvaObject = this.drawCircumference(this.circumference);
|
|
|
- auxE += "2, ";
|
|
|
aggregator = new DrawerAggregator(this, this.circumference, this.konvaObject, ELEMENTS_CLASS.CIRCUMFERENCE);
|
|
|
- auxE += "3, ";
|
|
|
- super.addAggregator(aggregator);
|
|
|
- auxE += "4, ";
|
|
|
+ super.addAggregator(aggregator);
|
|
|
this.centerAggregator.addAggregator(aggregator);
|
|
|
- auxE += "5, ";
|
|
|
this.radiusAggregator.addAggregator(aggregator);
|
|
|
- auxE += "6, ";
|
|
|
SelectableDrawer.drawObject(this.konvaObject);
|
|
|
- auxE += "7, ";
|
|
|
this.konvaObject.zIndex(0);
|
|
|
- auxE += "8, ";
|
|
|
super.batchDraw();
|
|
|
- auxE += "9, ";
|
|
|
} catch (error) {
|
|
|
console.log("circumference-drawer.js!createByCircumference(circumference): Error '" + error + "', with " + auxE);
|
|
|
}
|
|
@@ -222,4 +199,4 @@ export class CircumferenceDrawer extends SelectableDrawer {
|
|
|
super.batchDraw();
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ }
|