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 ;
0 commit comments