Skip to content

Commit 0ee12de

Browse files
author
zhaokai
committed
【修改】【drawtool工具未定义情况处理】
1 parent db6b123 commit 0ee12de

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

src/service/PlotBase/Draw/DrawTool.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import {DrawPlotObjectFactory3D} from "../../3DPlot/Draw";
2-
import {PlotLayer3D} from "../../3DPlot";
3-
import {PlotLayer2D} from "../../2DPlot";
4-
import {DrawPlotObjectFactory2D} from "../../2DPlot/Draw/DrawPlotObjectFactory2D";
1+
import { DrawPlotObjectFactory3D } from '../../3DPlot/Draw';
2+
import { PlotLayer3D } from '../../3DPlot';
3+
import { PlotLayer2D } from '../../2DPlot';
4+
import { DrawPlotObjectFactory2D } from '../../2DPlot/Draw/DrawPlotObjectFactory2D';
5+
import LogTool from '../../PlotUtilBase/Log/LogTool';
56

67
/**
78
* @class module:3DPlot.DrawTool
@@ -40,9 +41,9 @@ class DrawTool {
4041
* @param symbol - {Object} 必选项,标绘图元的符号对象
4142
*/
4243
drawPlot(symbol) {
43-
if(this._plotLayer instanceof PlotLayer3D){
44+
if (this._plotLayer instanceof PlotLayer3D) {
4445
this._drawPlot3D(symbol);
45-
}else if(this._plotLayer instanceof PlotLayer2D){
46+
} else if (this._plotLayer instanceof PlotLayer2D) {
4647
this._drawPlot2D(symbol);
4748
}
4849
}
@@ -57,29 +58,22 @@ class DrawTool {
5758
//一直是原有符号
5859
if (!this._drawTool) {
5960
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-
);
61+
this._drawTool = DrawPlotObjectFactory3D.createInstance(symbol.type, this._plotLayer._viewer, symbol, this._plotLayer, this._options);
6762
}
6863

6964
//换新符号
7065
if (symbol.should !== this._symbolUrl) {
7166
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-
);
67+
68+
this._drawTool = DrawPlotObjectFactory3D.createInstance(symbol.type, this._plotLayer._viewer, symbol, this._plotLayer, this._options);
7969
}
8070

81-
//开始绘制
82-
this._drawTool.enable();
71+
if (this._drawTool) {
72+
//开始绘制
73+
this._drawTool.enable();
74+
}else{
75+
LogTool.warn("drawTool未定义!")
76+
}
8377
}
8478

8579
/**
@@ -88,13 +82,17 @@ class DrawTool {
8882
*
8983
* @param symbol - {Object} 必选项,标绘图元的符号对象
9084
*/
91-
_drawPlot2D(symbol){
85+
_drawPlot2D(symbol) {
9286
if (!this._drawTool) {
9387
this._drawTool = DrawPlotObjectFactory2D.createInstance(symbol.type, this._plotLayer, symbol, this._options);
9488
}
9589

96-
//开始绘制
97-
this._drawTool.enable();
90+
if (this._drawTool) {
91+
//开始绘制
92+
this._drawTool.enable();
93+
}else{
94+
LogTool.warn("drawTool未定义!")
95+
}
9896
}
9997

10098
/**
@@ -111,4 +109,4 @@ class DrawTool {
111109
}
112110
}
113111

114-
export default DrawTool;
112+
export default DrawTool;

src/service/PlotUtilBase/SimpleFactory.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
* @Author: zk
55
* @Date: 2022-06-22 16:04:04
66
* @LastEditors: zk
7-
* @LastEditTime: 2022-06-23 11:47:01
7+
* @LastEditTime: 2022-06-23 14:05:46
88
*/
99
import { defined } from './Check';
1010
import { warn } from './Log';
11+
import LogTool from './Log/LogTool';
1112

1213
/**
1314
* 简单工厂方法
@@ -44,7 +45,7 @@ export default class SimpleFactory {
4445
}
4546

4647
if (!defined(Proto)) {
47-
warn('未找到', type, '对应的原型', this._type2Protos);
48+
LogTool.warn(`未找到${type}对应的原型`)
4849
return undefined;
4950
}
5051

0 commit comments

Comments
 (0)