Skip to content

Commit ebdab79

Browse files
committed
【杨琨】【添加二三维联动-绘制功能】
1 parent 1ddb68d commit ebdab79

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/service/2DPlot/Draw/DrawPoint2D.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class DrawPoint2D extends DrawObject {
3030

3131
removeHooks() {
3232
this._plotLayer.interactive = false;
33+
this._plotLayer._isDrawing = false;
3334
this._plotLayer.off("mouse:up", this.onMouseUp);
3435
super.removeHooks();
3536
}
@@ -44,7 +45,7 @@ export default class DrawPoint2D extends DrawObject {
4445
});
4546

4647
object.setPnts([new Point(pnt[0],pnt[1])]);
47-
48+
this._plotLayer._isDrawing = true;
4849
this._plotLayer.addPlot(object);
4950
this._plotLayer.requestRenderAll();
5051
this.fireFinishEvent({ plotObj2D: object });

src/service/2DPlot/Draw/DrawPolyline2D.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default class DrawPolyline2D extends DrawObject {
3838
this.m_fabricCanvas.interactive = true;
3939
this.m_fabricCanvas.off('mouse:move', this.onMouseMove);
4040
this.m_fabricCanvas.off('mouse:up', this.onMouseUp);
41+
this.m_fabricCanvas._isDrawing = false;
4142
super.removeHooks();
4243
}
4344

@@ -73,6 +74,7 @@ export default class DrawPolyline2D extends DrawObject {
7374
canvas: this.m_fabricCanvas
7475
});
7576
this.m_fabricCanvas.addPlot(this.m_object);
77+
this.m_fabricCanvas._isDrawing = true;
7678
addExtendLayersPlot(this.m_fabricCanvas._linkTool, this.m_object);
7779
});
7880
}

src/service/2DPlot/PlotLayer2D.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import SymbolManager from '../PlotBase/SymbolManager/SymbolManager';
1414
import FabricLineUtil from './EditTool/FabricLineUtil';
1515
import {addExtendLayersPlot, removeExtendLayersPlot} from "../3DPlot/Utils/PlotUtil";
1616

17-
export default class PlotLayer2D {
17+
class PlotLayer2D {
1818
constructor() {
1919
// 标绘对象
2020
this.m_plotObjects = [];
@@ -30,6 +30,10 @@ export default class PlotLayer2D {
3030

3131
//二三维联动工具
3232
this._linkTool = undefined;
33+
//点击回调事件
34+
this._pickPlot = undefined;
35+
//是否在绘制图元,绘制途中不触发pick事件
36+
this._isDrawing = false;
3337
}
3438

3539
/**
@@ -428,3 +432,24 @@ export default class PlotLayer2D {
428432
this._fabricCanvas.requestRenderAll();
429433
}
430434
}
435+
436+
Object.defineProperties(PlotLayer2D.prototype, {
437+
pickPlot: {
438+
get() {
439+
return this._pickPlot;
440+
},
441+
set(v) {
442+
let that = this;
443+
this._pickPlot = v;
444+
this.off("mouse:down");
445+
this.on("mouse:down", function (result) {
446+
result = result || {};
447+
if(result.target && !that._isDrawing){
448+
that._pickPlot(result.target);
449+
}
450+
});
451+
}
452+
}
453+
});
454+
455+
export default PlotLayer2D;

0 commit comments

Comments
 (0)