Browse Source

improve the plot #39

tags/2.3.1
Caven Chen 4 years ago
parent
commit
a737f999fa
2 changed files with 18 additions and 12 deletions
  1. 4
    4
      modules/tools/DrawTool.js
  2. 14
    8
      modules/tools/EditTool.js

+ 4
- 4
modules/tools/DrawTool.js View File

this._viewer.on(MouseEventType.CLICK, this._onClick, this) this._viewer.on(MouseEventType.CLICK, this._onClick, this)
this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this) this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
this.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
this._plotEvent.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this._plotEvent.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
} }


/** /**
this._viewer.off(MouseEventType.CLICK, this._onClick, this) this._viewer.off(MouseEventType.CLICK, this._onClick, this)
this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
this.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
this._plotEvent.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this._plotEvent.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
} }


/** /**

+ 14
- 8
modules/tools/EditTool.js View File

_onRightClick(e) { _onRightClick(e) {
let position = let position =
this._options.clampToModel && e.position ? e.position : e.surfacePosition this._options.clampToModel && e.position ? e.position : e.surfacePosition
this._plotEvent.fire(PlotEventType.DRAW_STOP, {
this._plotEvent.fire(PlotEventType.EDIT_STOP, {
pickedAnchor: this._pickedAnchor, pickedAnchor: this._pickedAnchor,
position: position position: position
}) })
this._anchors.push(anchor) this._anchors.push(anchor)
} }


/**
*
* @param index
* @param position
* @private
*/
_onUpdateAnchor({ index, position }) { _onUpdateAnchor({ index, position }) {
this._anchors[index] && this._anchors[index].position.setValue(position) this._anchors[index] && this._anchors[index].position.setValue(position)
} }
this._viewer.on(MouseEventType.CLICK, this._onClick, this) this._viewer.on(MouseEventType.CLICK, this._onClick, this)
this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this) this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
this.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.on(PlotEventType.UPDATE_ANCHOR, this._onUpdateAnchor, this)
this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
this._plotEvent.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this._plotEvent.on(PlotEventType.UPDATE_ANCHOR, this._onUpdateAnchor, this)
this._plotEvent.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
} }


/** /**
this._viewer.off(MouseEventType.CLICK, this._onClick, this) this._viewer.off(MouseEventType.CLICK, this._onClick, this)
this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
this.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.off(PlotEventType.UPDATE_ANCHOR, this._onUpdateAnchor, this)
this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
this._plotEvent.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this._plotEvent.off(PlotEventType.UPDATE_ANCHOR, this._onUpdateAnchor, this)
this._plotEvent.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
} }


/** /**
this._options = { ...DEF_OPTS, ...options } this._options = { ...DEF_OPTS, ...options }
this._unbindEvent() this._unbindEvent()
this._bindEvent() this._bindEvent()
this.fire(PlotEventType.DRAW_START, this._options)
this.fire(PlotEventType.EDIT_START, this._options)
return this return this
} }



Loading…
Cancel
Save