|
@@ -6,6 +6,18 @@ import { selector as Selector } from "../../../core/application/selector";
|
|
|
import { LineSegmentModel } from "../models/line-segment-model";
|
|
|
import { PointDrawer } from "../../point-component/drawers/point-drawer";
|
|
|
import { objects as Objects } from "../../../core/application/objects";
|
|
|
+import { app as App } from "../../../app";
|
|
|
+import { stageManager as StageManager } from "../../../core/application/stage-manager";
|
|
|
+const HOVER_STYLE = {
|
|
|
+ fill: "#33BCFF",
|
|
|
+ strokeWidth: 4,
|
|
|
+ stroke: "#33BCFF"
|
|
|
+};
|
|
|
+const STYLE = {
|
|
|
+ fill: "grey",
|
|
|
+ strokeWidth: 2,
|
|
|
+ stroke: "grey"
|
|
|
+};
|
|
|
export class LineSegmentDrawer extends Drawer {
|
|
|
static FIRST_POINT_STATE() {
|
|
|
return "FIRST_POINT";
|
|
@@ -26,6 +38,7 @@ export class LineSegmentDrawer extends Drawer {
|
|
|
];
|
|
|
this.lineSegment;
|
|
|
this.pointDrawer = new PointDrawer();
|
|
|
+ super.setElementClass(ELEMENTS_CLASS.LINE_SEGMENT);
|
|
|
}
|
|
|
setPointA(point) {
|
|
|
this.pointA = point;
|
|
@@ -44,8 +57,7 @@ export class LineSegmentDrawer extends Drawer {
|
|
|
|
|
|
draw() {
|
|
|
const points = Selector.getSelectedPoints();
|
|
|
-
|
|
|
- if (points == undefined || points.length < 1) {
|
|
|
+ if (points == undefined || points.length == 0) {
|
|
|
this.drawByState();
|
|
|
}
|
|
|
this.drawByPoints(points);
|
|
@@ -65,8 +77,6 @@ export class LineSegmentDrawer extends Drawer {
|
|
|
[this.aggregatorA, this.aggregatorB]
|
|
|
);
|
|
|
super.setState(undefined);
|
|
|
- } else {
|
|
|
- super.setState(undefined);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -155,9 +165,24 @@ export class LineSegmentDrawer extends Drawer {
|
|
|
return line;
|
|
|
}
|
|
|
static configureLineEvents(line) {
|
|
|
- line.on("click tap", function(e) {
|
|
|
- this.pointDrawer.drawPoint();
|
|
|
+ line.on("mouseover", function() {
|
|
|
+ const selectedTool = App.getSelectedTool();
|
|
|
+ if (
|
|
|
+ selectedTool != undefined &&
|
|
|
+ selectedTool.drawer != undefined &&
|
|
|
+ selectedTool.drawer.elementClass == ELEMENTS_CLASS.INTERSECTION_POINT
|
|
|
+ ) {
|
|
|
+ this.strokeWidth(HOVER_STYLE.strokeWidth);
|
|
|
+ this.stroke(HOVER_STYLE.stroke);
|
|
|
+ StageManager.getCurrentKonvaStage().draw();
|
|
|
+ }
|
|
|
});
|
|
|
+ line.on("mouseout", function() {
|
|
|
+ this.strokeWidth(STYLE.strokeWidth);
|
|
|
+ this.stroke(STYLE.stroke);
|
|
|
+ StageManager.getCurrentKonvaStage().draw();
|
|
|
+ });
|
|
|
+
|
|
|
return line;
|
|
|
}
|
|
|
|