| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import VectorType from '../enum/VectorType.js'
- import Geometry from './Geometry.js'
- import SelectState from '../enum/SelectState.js'
- import { mathUtil } from '../MathUtil.js'
- import Constant from '../Constant.js'
- export default class Arrow extends Geometry {
- constructor(startPoint, endPoint, vectorId, floor) {
- super()
- this.startPoint = startPoint
- this.endPoint = endPoint
- this.floor = floor?floor:0
- this.color = 'rgba( 0,0,0,1)';
- this.geoType = VectorType.Arrow
- this.setId(vectorId)
- }
- isContain(position){
- const dis1 = mathUtil.getDistance(position, this.startPoint)
- const dis2 = mathUtil.getDistance(position, this.endPoint)
- if(dis1 < Constant.minAdsorb){
- return SelectState.Start
- }
- if(dis2 < Constant.minAdsorb){
- return SelectState.End
- }
- let flag = mathUtil.isContainForSegment(position, this.startPoint, this.endPoint)
- if(flag){
- return SelectState.All
- }
- return null;
- }
- updatePoint(newPosition,dir){
- if(dir == SelectState.Start && mathUtil.getDistance(newPosition, this.endPoint)>Constant.minAdsorb){
- mathUtil.clonePoint(this.startPoint,newPosition)
- }
- else if(dir == SelectState.End && mathUtil.getDistance(newPosition, this.startPoint)>Constant.minAdsorb){
- mathUtil.clonePoint(this.endPoint,newPosition)
- }
- }
- setColor(color) {
- this.color = color
- }
- }
|