Skip to content

Commit c8218a8

Browse files
committed
【杨琨】【二三维统一绘制工具】
【杨琨】【解决阵地点控制点不足的BUG】
1 parent 678aa17 commit c8218a8

File tree

6 files changed

+16
-86
lines changed

6 files changed

+16
-86
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ import Point from "../../PlotUtilBase/Geometry/Point";
1010
import {PlotObjectFactory} from "../Shapes/PlotObjectFactory";
1111

1212
export default class DrawPoint2D extends DrawObject {
13-
constructor(fabricCanvas, symbol) {
13+
constructor(fabricCanvas, symbol, options) {
1414
super();
1515
this.m_fabricCanvas = fabricCanvas;
1616
this.m_symbol = symbol;
1717
this.m_coordSys = this.m_fabricCanvas.getCoordSys();
1818
this.onMouseUp = this.innerOnMouseUp.bind(this);
19+
//绘制完成回调函数
20+
const {addedPlot} = options;
21+
this._addedPlot = addedPlot;
1922
}
2023

2124
addHooks() {
@@ -44,6 +47,9 @@ export default class DrawPoint2D extends DrawObject {
4447
this.m_fabricCanvas.add(object);
4548
this.m_fabricCanvas.requestRenderAll();
4649
this.fireFinishEvent({ plotObj2D: object });
50+
if(this._addedPlot){
51+
this._addedPlot(object);
52+
}
4753
this.disable();
4854
})
4955

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { PlotObjectFactory } from '../Shapes/PlotObjectFactory';
1111

1212
const _ = require('lodash');
1313
export default class DrawPolyline2D extends DrawObject {
14-
constructor(fabricCanvas, symbol) {
14+
constructor(fabricCanvas, symbol, options) {
1515
super();
1616
this.m_fabricCanvas = fabricCanvas;
1717
this.m_symbol = symbol;
@@ -20,6 +20,9 @@ export default class DrawPolyline2D extends DrawObject {
2020
this.m_coords = [[0, 0]];
2121
this.onMouseUp = this.innerOnMouseUp.bind(this);
2222
this.onMouseMove = _.throttle(this.innerOnMouseMove.bind(this), 30);
23+
//绘制完成回调函数
24+
const {addedPlot} = options;
25+
this._addedPlot = addedPlot;
2326
}
2427

2528
addHooks() {
@@ -54,6 +57,9 @@ export default class DrawPolyline2D extends DrawObject {
5457
if (lastPnt && Math.abs(pnt[0] - lastPnt.x) < 1e-4 && Math.abs(pnt[1] - lastPnt.y) < 1e-4) {
5558
this.fireFinishEvent({ plotObj2D: this.m_object });
5659
this.m_startDrawing = false;
60+
if(this._addedPlot){
61+
this._addedPlot(this.m_object);
62+
}
5763
this.disable();
5864
} else {
5965
this.m_coords.push(new Point(pnt[0], pnt[1]));

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

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/service/2DPlot/PlotCanvas.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,6 @@ export default class PlotCanvas {
144144
return this.m_CoordSys;
145145
}
146146

147-
/**
148-
* @function: Module:PlotCanvas.prototype.DrawSymbol
149-
* @description: 绘制工具
150-
* @param {*} symbol 符号节点
151-
* @return {*}
152-
*/
153-
DrawSymbol(symbol) {
154-
if (this.drawTool) {
155-
this.drawTool.disable();
156-
}
157-
this.drawTool = DrawPlotObjectFactory2D.createInstance(symbol.type, this, symbol);
158-
if (this.drawTool) {
159-
this.drawTool.enable();
160-
}
161-
return this.drawTool;
162-
}
163147
/**
164148
* @function: Module:PlotCanvas.prototype.addPlotObjectBy3DPlotObj
165149
* @description: 根据三维对象添加二维对象

src/service/PlotBase/Draw/DrawTool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class DrawTool {
9090
*/
9191
_drawPlot2D(symbol){
9292
if (!this._drawTool) {
93-
this._drawTool = DrawPlotObjectFactory2D.createInstance(symbol.type, this._plotLayer, symbol);
93+
this._drawTool = DrawPlotObjectFactory2D.createInstance(symbol.type, this._plotLayer, symbol, this._options);
9494
}
9595

9696
//开始绘制

src/service/PlotBase/SvgLoader/element/BasePlotElement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class BasePlotElement extends SvgElement {
369369
_setNodeAttr(child, key, value) {
370370
const {baseSVGAttributes, extendElementAttributes} =
371371
child.getSaveBaseAttributes();
372-
const baseSVGStyleAttributes = child.styleObject.getStyleNameArr();
372+
const baseSVGStyleAttributes = this.getStyleObject().getStyleNameArr();
373373

374374
if (baseSVGStyleAttributes.indexOf(key) > -1) {
375375
child.getStyleObject().setStyle(key, value);

0 commit comments

Comments
 (0)