Skip to content

Commit 678aa17

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

File tree

7 files changed

+135
-27
lines changed

7 files changed

+135
-27
lines changed
Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import {DrawPlotObjectFactory3D} from "./DrawPlotObjectFactory3D";
1+
import {DrawPlotObjectFactory2D} from "./DrawPlotObjectFactory2D";
22

33
/**
4-
* @class module:3DPlot.DrawTool
5-
* @description 行业标绘绘制工具
4+
* @class module:2DPlot.DrawTool2D
5+
* @description 行业标绘(二维)绘制工具
66
* @author 基础平台-杨琨
77
* @param {PlotLayer3D} layer 标绘图层
88
* @param {Object} options 绘制参数
99
*/
10-
class DrawTool {
10+
class DrawTool2D {
1111
constructor(layer, options) {
1212
//标绘图层
1313
this._plotLayer = layer;
@@ -37,25 +37,13 @@ class DrawTool {
3737
//一直是原有符号
3838
if (!this._drawTool) {
3939
this._symbolUrl = symbol.src;
40-
this._drawTool = DrawPlotObjectFactory3D.createInstance(
41-
symbol.type,
42-
this._plotLayer._viewer,
43-
symbol,
44-
this._plotLayer,
45-
this._options
46-
);
40+
this._drawTool = DrawPlotObjectFactory2D.createInstance(symbol.type, this, symbol);
4741
}
4842

4943
//换新符号
5044
if (symbol.should !== this._symbolUrl) {
5145
this._symbolUrl = symbol.src;
52-
this._drawTool = DrawPlotObjectFactory3D.createInstance(
53-
symbol.type,
54-
this._plotLayer._viewer,
55-
symbol,
56-
this._plotLayer,
57-
this._options
58-
);
46+
this._drawTool = DrawPlotObjectFactory2D.createInstance(symbol.type, this, symbol);
5947
}
6048

6149
//开始绘制
@@ -75,4 +63,4 @@ class DrawTool {
7563
}
7664
}
7765

78-
export default DrawTool;
66+
export default DrawTool2D;

src/service/2DPlot/Shapes/PlotPolylineObject.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ const PlotPolylineObject = fabric.util.createClass(PlotObject, {
2626
baseSize: 2000000,
2727
originBaseX: 0,
2828
originBaseY: 0,
29-
29+
setPnts(latlngs) {
30+
this.callSuper('setPnts', latlngs);
31+
this.innerInitControls();
32+
this.set('dirty', true);
33+
},
3034
setBounds: function setBounds(ctx) {
3135
this._setBounds(this._calcBounds(ctx));
3236
},

src/service/3DPlot/Draw/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
* @FilePath: \MapGISPlotBase\src\3DPlot\Draw\index.js
88
*/
99
import { DrawPlotObjectFactory3D } from "./DrawPlotObjectFactory3D";
10-
import DrawTool from "./DrawTool";
1110

12-
export { DrawPlotObjectFactory3D,DrawTool };
11+
export { DrawPlotObjectFactory3D };
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import {DrawPlotObjectFactory3D} from "../../3DPlot/Draw";
2+
import {PlotLayer3D} from "../../3DPlot";
3+
import {PlotCanvas} from "../../2DPlot";
4+
import {DrawPlotObjectFactory2D} from "../../2DPlot/Draw/DrawPlotObjectFactory2D";
5+
6+
/**
7+
* @class module:3DPlot.DrawTool
8+
* @description 行业标绘绘制工具
9+
* @author 基础平台-杨琨
10+
* @param {PlotLayer3D} layer 标绘图层
11+
* @param {Object} options 绘制参数
12+
*/
13+
class DrawTool {
14+
constructor(layer, options) {
15+
//标绘图层
16+
this._plotLayer = layer;
17+
//绘制工具
18+
this._drawTool = undefined;
19+
//SVG的url
20+
this._symbolUrl = undefined;
21+
//绘制参数
22+
this._options = options;
23+
}
24+
25+
/**
26+
* @function module:3DPlot.DrawTool.setLayer
27+
* @description 设置要作用的标绘图层
28+
* @public
29+
*
30+
* @param layer - {PlotLayer3D} 必选项,标绘图层
31+
*/
32+
setLayer(layer) {
33+
this._plotLayer = layer;
34+
}
35+
36+
/**
37+
* @description 绘制标绘图元工具
38+
* @public
39+
*
40+
* @param symbol - {Object} 必选项,标绘图元的符号对象
41+
*/
42+
drawPlot(symbol) {
43+
if(this._plotLayer instanceof PlotLayer3D){
44+
this._drawPlot3D(symbol);
45+
}else if(this._plotLayer instanceof PlotCanvas){
46+
this._drawPlot2D(symbol);
47+
}
48+
}
49+
50+
/**
51+
* @description 绘制标绘图元(三维)
52+
* @private
53+
*
54+
* @param symbol - {Object} 必选项,标绘图元的符号对象
55+
*/
56+
_drawPlot3D(symbol) {
57+
//一直是原有符号
58+
if (!this._drawTool) {
59+
this._symbolUrl = symbol.src;
60+
this._drawTool = DrawPlotObjectFactory3D.createInstance(
61+
symbol.type,
62+
this._plotLayer._viewer,
63+
symbol,
64+
this._plotLayer,
65+
this._options
66+
);
67+
}
68+
69+
//换新符号
70+
if (symbol.should !== this._symbolUrl) {
71+
this._symbolUrl = symbol.src;
72+
this._drawTool = DrawPlotObjectFactory3D.createInstance(
73+
symbol.type,
74+
this._plotLayer._viewer,
75+
symbol,
76+
this._plotLayer,
77+
this._options
78+
);
79+
}
80+
81+
//开始绘制
82+
this._drawTool.enable();
83+
}
84+
85+
/**
86+
* @description 绘制标绘图元(二维)
87+
* @private
88+
*
89+
* @param symbol - {Object} 必选项,标绘图元的符号对象
90+
*/
91+
_drawPlot2D(symbol){
92+
if (!this._drawTool) {
93+
this._drawTool = DrawPlotObjectFactory2D.createInstance(symbol.type, this._plotLayer, symbol);
94+
}
95+
96+
//开始绘制
97+
this._drawTool.enable();
98+
}
99+
100+
/**
101+
* @function module:3DPlot.DrawTool.stopDraw
102+
* @public
103+
* @description 停止绘制
104+
*/
105+
stopDraw() {
106+
if (this._drawTool) {
107+
this._drawTool.disable();
108+
}
109+
110+
this._drawTool = undefined;
111+
}
112+
}
113+
114+
export default DrawTool;

src/service/PlotBase/Draw/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
import DrawObject from "./DrawObject";
1111
import { DrawPlotObjectFactory } from "./DrawObjectFactory";
12+
import DrawTool from "./DrawTool";
1213

1314
export default{
1415
DrawObject,
15-
DrawPlotObjectFactory
16+
DrawPlotObjectFactory,
17+
DrawTool
1618
}

src/service/PlotBase/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
*/
88
import SymbolManager from './SymbolManager/SymbolManager';
99
import TimeLine from './Animation/TimeLine/TimeLine'
10-
11-
export {SymbolManager,TimeLine} ;
10+
import DrawTool from './Draw/DrawTool'
11+
12+
export {SymbolManager,TimeLine,DrawTool} ;

src/service/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ import ArcGis from './ArcGis';
3737
import {SymbolManager} from "./PlotBase/index"
3838
import { PlotCanvas } from './2DPlot/index';
3939
import { PlotCanvasGroup } from './2DPlot/PlotCanvasGroup'
40-
import {PlotLayer3D,PlotLayerMap,DrawTool} from "./3DPlot/index"
41-
import { TimeLine } from './PlotBase/index';
40+
import {PlotLayer3D,PlotLayerMap} from "./3DPlot/index"
41+
import { TimeLine, DrawTool } from './PlotBase/index';
4242

4343

4444
export {

0 commit comments

Comments
 (0)