Browse Source

improve the plot #39

tags/2.3.1
Caven Chen 4 years ago
parent
commit
e86268ab19
3 changed files with 10 additions and 9 deletions
  1. 2
    1
      modules/event/EventType.js
  2. 5
    5
      modules/tools/DrawTool.js
  3. 3
    3
      modules/tools/EditTool.js

+ 2
- 1
modules/event/EventType.js View File



const PlotEventType = { const PlotEventType = {
DRAW_START: 'drawStart', DRAW_START: 'drawStart',
DRAW_ANCHOR: 'drawAnchor',
DRAW_MOVING: 'drawMoving', DRAW_MOVING: 'drawMoving',
DRAW_STOP: 'drawStop', DRAW_STOP: 'drawStop',
EDIT_START: 'editStart', EDIT_START: 'editStart',
EDIT_STOP: 'editEnd', EDIT_STOP: 'editEnd',
ADD_ANCHOR: 'addAnchor',
CREATE_ANCHOR: 'createAnchor',
ANCHOR_MOVING: 'anchorMoving', ANCHOR_MOVING: 'anchorMoving',
EDIT_ANCHOR_STOP: 'editAnchorStop', EDIT_ANCHOR_STOP: 'editAnchorStop',
CLEAR_ANCHOR: 'clearAnchor' CLEAR_ANCHOR: 'clearAnchor'

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

return false return false
} }
if (!this._floatingAnchor) { if (!this._floatingAnchor) {
this._floatingAnchor = this._onAddAnchor({ position })
this._floatingAnchor = this._onCreateAnchor({ position })
} }
this._plotEvent.fire(PlotEventType.ADD_ANCHOR, position)
this._plotEvent.fire(PlotEventType.DRAW_ANCHOR, position)
} }


/** /**
* @returns {*} * @returns {*}
* @private * @private
*/ */
_onAddAnchor({ position, isCenter = false }) {
_onCreateAnchor({ position, isCenter = false }) {
this._anchorLayer.entities.add({ this._anchorLayer.entities.add({
position: position, position: position,
billboard: { billboard: {
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.ADD_ANCHOR, this._onAddAnchor, this)
this.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) this.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.ADD_ANCHOR, this._onAddAnchor, this)
this.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
} }



+ 3
- 3
modules/tools/EditTool.js View File

* @param isMid * @param isMid
* @private * @private
*/ */
_onAddAnchor({ position, index, isCenter = false, isMid = false }) {
_onCreateAnchor({ position, index, isCenter = false, isMid = false }) {
let image = isMid let image = isMid
? this._options.icon_midAnchor ? this._options.icon_midAnchor
: isCenter : isCenter
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.ADD_ANCHOR, this._onAddAnchor, this)
this.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) this.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.ADD_ANCHOR, this._onAddAnchor, this)
this.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
} }



Loading…
Cancel
Save