Browse Source

add maxAnchorSize for drawing ployline

tags/2.13.0
Caven Chen 3 years ago
parent
commit
2c3a746ecc
3 changed files with 10 additions and 1 deletions
  1. 3
    0
      modules/plot/Plot.js
  2. 5
    0
      modules/plot/draw/DrawPolyline.js
  3. 2
    1
      modules/tools/DrawTool.js

+ 3
- 0
modules/plot/Plot.js View File

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
}) })

+ 5
- 0
modules/plot/draw/DrawPolyline.js View File

* @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)
}
} }
} }



+ 2
- 1
modules/tools/DrawTool.js View File

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 {

Loading…
Cancel
Save