| if (this._currentWorker) { | if (this._currentWorker) { | ||||
| this._currentWorker.stop() | this._currentWorker.stop() | ||||
| } | } | ||||
| let maxAnchorSize = style?.maxAnchorSize || 999 | |||||
| style && delete style['maxAnchorSize'] | |||||
| this._currentWorker = this._createDrawWorker(type, style)?.start(this, { | this._currentWorker = this._createDrawWorker(type, style)?.start(this, { | ||||
| ...this._options, | ...this._options, | ||||
| maxAnchorSize: maxAnchorSize, | |||||
| onDrawStop: callback, | onDrawStop: callback, | ||||
| clampToModel: clampToModel ?? this._options.clampToModel | clampToModel: clampToModel ?? this._options.clampToModel | ||||
| }) | }) |
| * @private | * @private | ||||
| */ | */ | ||||
| _onDrawAnchor(position) { | _onDrawAnchor(position) { | ||||
| let len = this._positions.length | |||||
| this._positions.push(position) | this._positions.push(position) | ||||
| this.drawTool.fire(PlotEventType.CREATE_ANCHOR, { position }) | this.drawTool.fire(PlotEventType.CREATE_ANCHOR, { position }) | ||||
| if (len >= this._options.maxAnchorSize) { | |||||
| this._positions.pop() | |||||
| this.drawTool.fire(PlotEventType.DRAW_STOP) | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| icon_center: IMG_CIRCLE_YELLOW, | icon_center: IMG_CIRCLE_YELLOW, | ||||
| icon_anchor: IMG_CIRCLE_RED, | icon_anchor: IMG_CIRCLE_RED, | ||||
| icon_size: [12, 12], | icon_size: [12, 12], | ||||
| clampToModel: false | |||||
| clampToModel: false, | |||||
| maxAnchorSize: 999 | |||||
| } | } | ||||
| class DrawTool { | class DrawTool { |