合并
This commit is contained in:
@ -56,13 +56,9 @@ class StandText extends Base {
|
||||
this.options.show = (options.show || options.show === false) ? options.show : true
|
||||
this.nodePoints = []
|
||||
this.entity
|
||||
this.options.instruct = options.instruct || ""
|
||||
this.options.operatingPoint = options.operatingPoint || ""
|
||||
this.options.attribute = options.attribute || {}
|
||||
this.options.attribute.link = this.options.attribute.link || {}
|
||||
this.options.attribute.link.content = this.options.attribute.link.content || []
|
||||
this.options.attribute.camera = this.options.attribute.camera || []
|
||||
this.options.attributeType = options.attributeType || 'richText'
|
||||
|
||||
delete this.options.name
|
||||
|
||||
this.extrudedHeight
|
||||
this._EventBinding = new EventBinding()
|
||||
this.Dialog = _Dialog
|
||||
@ -71,6 +67,9 @@ class StandText extends Base {
|
||||
StandText.create(this)
|
||||
}
|
||||
|
||||
get name() {
|
||||
return
|
||||
}
|
||||
get text() {
|
||||
return this.options.text
|
||||
}
|
||||
@ -297,14 +296,6 @@ class StandText extends Base {
|
||||
|
||||
// }
|
||||
|
||||
get attributeCamera() {
|
||||
return this.options.attribute.camera
|
||||
}
|
||||
|
||||
set attributeCamera(v) {
|
||||
this.options.attribute.camera = v
|
||||
}
|
||||
|
||||
//创建
|
||||
static async create(that) {
|
||||
|
||||
@ -397,15 +388,13 @@ class StandText extends Base {
|
||||
this.Dialog.showCallBack && this.Dialog.showCallBack()
|
||||
},
|
||||
secondaryEditCallBack: () => {
|
||||
StandText.nodeEdit(this)
|
||||
this.nodeEdit()
|
||||
}
|
||||
})
|
||||
this._DialogObject._element.body.className = this._DialogObject._element.body.className + ' stand-text'
|
||||
let contentElm = document.createElement('div');
|
||||
contentElm.innerHTML = html(this)
|
||||
this._DialogObject.contentAppChild(contentElm)
|
||||
this.attributeType = this.options.attributeType
|
||||
this.attributeCamera = this.options.attribute.camera
|
||||
// setTimeout(() => {
|
||||
// this.attributeLink = this.options.attribute.link.content
|
||||
// this.cameraSelect()
|
||||
@ -538,23 +527,24 @@ class StandText extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
static nodeEdit(that, cb = () => { }) {
|
||||
nodeEdit(cb = () => { }) {
|
||||
if (YJ.Measure.GetMeasureStatus()) {
|
||||
cb('上一次测量未结束')
|
||||
} else {
|
||||
YJ.Measure.SetMeasureStatus(true)
|
||||
that.tip = new MouseTip('请选择一个顶点,右键取消', that.sdk)
|
||||
that.event = new MouseEvent(that.sdk)
|
||||
that.nodePoints = []
|
||||
this._nodeEditCallback = cb
|
||||
this.tip = new MouseTip('请选择一个顶点,右键取消', this.sdk)
|
||||
this.event = new MouseEvent(this.sdk)
|
||||
this.nodePoints = []
|
||||
let selectPoint
|
||||
let originalPosition
|
||||
|
||||
let positions = that.options.positions
|
||||
let positions = this.options.positions
|
||||
let fromDegreesArray = []
|
||||
let minimumHeights = []
|
||||
let maximumHeights = []
|
||||
let width = that.computeDistance2(positions)
|
||||
let extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
||||
let width = this.computeDistance2(positions)
|
||||
let extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||
minimumHeights.push(positions[i].alt)
|
||||
@ -565,55 +555,55 @@ class StandText extends Base {
|
||||
let leftEvent = (movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
isAdd = true
|
||||
let pos3 = that.sdk.viewer.scene.clampToHeight(cartesian, [that.entity])
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(pos3, that.sdk.viewer)
|
||||
originalPosition = that.options.positions[selectPoint.index]
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
let pos3 = this.sdk.viewer.scene.clampToHeight(cartesian, [this.entity])
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(pos3, this.sdk.viewer)
|
||||
originalPosition = this.options.positions[selectPoint.index]
|
||||
let entity = this.sdk.viewer.entities.add({
|
||||
name: 'node-secondary-edit-point',
|
||||
position: Cesium.Cartesian3.fromDegrees(that.options.positions[selectPoint.index].lng, that.options.positions[selectPoint.index].lat, that.options.positions[selectPoint.index].alt),
|
||||
position: Cesium.Cartesian3.fromDegrees(this.options.positions[selectPoint.index].lng, this.options.positions[selectPoint.index].lat, this.options.positions[selectPoint.index].alt),
|
||||
billboard: {
|
||||
image: that.getSourceRootPath() + '/img/point.png',
|
||||
image: this.getSourceRootPath() + '/img/point.png',
|
||||
width: 15,
|
||||
height: 15,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
||||
},
|
||||
})
|
||||
that.nodePoints.splice(selectPoint.index, 0, entity)
|
||||
that.options.positions.splice(selectPoint.index, 0, that.options.positions[selectPoint.index])
|
||||
this.nodePoints.splice(selectPoint.index, 0, entity)
|
||||
this.options.positions.splice(selectPoint.index, 0, this.options.positions[selectPoint.index])
|
||||
|
||||
let positions = that.options.positions
|
||||
let positions = this.options.positions
|
||||
fromDegreesArray = []
|
||||
minimumHeights = []
|
||||
maximumHeights = []
|
||||
width = that.computeDistance2(positions)
|
||||
extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
||||
width = this.computeDistance2(positions)
|
||||
extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||
minimumHeights.push(positions[i].alt)
|
||||
maximumHeights.push(positions[i].alt + extrudedHeight)
|
||||
}
|
||||
that.tip.setPosition(
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.position.x,
|
||||
movement.position.y
|
||||
)
|
||||
}
|
||||
else {
|
||||
var pick = that.sdk.viewer.scene.pick(movement.position);
|
||||
var pick = this.sdk.viewer.scene.pick(movement.position);
|
||||
if (pick && pick.id && pick.id.name && pick.id.name === 'node-secondary-edit-point') {
|
||||
selectPoint = pick.id
|
||||
that.nodePoints.splice(pick.id.index, 1)
|
||||
that.sdk.viewer.entities.remove(pick.id)
|
||||
that.tip.set_text('左键开始,右键结束,CTRL+右键撤销')
|
||||
originalPosition = that.cartesian3Towgs84(cartesian, that.sdk.viewer)
|
||||
that.entity.wall.positions = new Cesium.CallbackProperty(function () {
|
||||
this.nodePoints.splice(pick.id.index, 1)
|
||||
this.sdk.viewer.entities.remove(pick.id)
|
||||
this.tip.set_text('左键开始,右键结束,CTRL+右键撤销')
|
||||
originalPosition = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||
this.entity.wall.positions = new Cesium.CallbackProperty(function () {
|
||||
return Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||
}, false)
|
||||
that.entity.wall.maximumHeights = new Cesium.CallbackProperty(function () {
|
||||
this.entity.wall.maximumHeights = new Cesium.CallbackProperty(function () {
|
||||
return maximumHeights
|
||||
}, false)
|
||||
that.entity.wall.minimumHeights = new Cesium.CallbackProperty(function () {
|
||||
this.entity.wall.minimumHeights = new Cesium.CallbackProperty(function () {
|
||||
return minimumHeights
|
||||
}, false)
|
||||
}
|
||||
@ -621,69 +611,69 @@ class StandText extends Base {
|
||||
}
|
||||
let rightEvent = (movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
that.options.positions[selectPoint.index] = originalPosition
|
||||
this.options.positions[selectPoint.index] = originalPosition
|
||||
if(isAdd) {
|
||||
that.options.positions.splice(selectPoint.index, 1)
|
||||
this.options.positions.splice(selectPoint.index, 1)
|
||||
}
|
||||
cb(null, that.options.positions)
|
||||
cb(null, this.options.positions)
|
||||
}
|
||||
let positions = that.options.positions
|
||||
let positions = this.options.positions
|
||||
fromDegreesArray = []
|
||||
minimumHeights = []
|
||||
maximumHeights = []
|
||||
width = that.computeDistance2(positions)
|
||||
extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
||||
width = this.computeDistance2(positions)
|
||||
extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||
minimumHeights.push(positions[i].alt)
|
||||
maximumHeights.push(positions[i].alt + extrudedHeight)
|
||||
}
|
||||
that.entity.wall.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||
this.entity.wall.positions = Cesium.Cartesian3.fromDegreesArray(fromDegreesArray)
|
||||
|
||||
for (let i = 0; i < that.nodePoints.length; i++) {
|
||||
that.sdk.viewer.entities.remove(that.nodePoints[i])
|
||||
for (let i = 0; i < this.nodePoints.length; i++) {
|
||||
this.sdk.viewer.entities.remove(this.nodePoints[i])
|
||||
}
|
||||
that.nodePoints = []
|
||||
this.nodePoints = []
|
||||
YJ.Measure.SetMeasureStatus(false)
|
||||
that.event.destroy()
|
||||
that.tip.destroy()
|
||||
this.event.destroy()
|
||||
this.tip.destroy()
|
||||
}
|
||||
|
||||
that.event.mouse_left(leftEvent)
|
||||
this.event.mouse_left(leftEvent)
|
||||
|
||||
that.event.mouse_right(rightEvent)
|
||||
this.event.mouse_right(rightEvent)
|
||||
|
||||
that.event.mouse_move((movement, cartesian) => {
|
||||
this.event.mouse_move((movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
let pos3 = that.sdk.viewer.scene.clampToHeight(cartesian, [that.entity])
|
||||
that.options.positions[selectPoint.index] = that.cartesian3Towgs84(pos3, that.sdk.viewer)
|
||||
let positions = that.options.positions
|
||||
let pos3 = this.sdk.viewer.scene.clampToHeight(cartesian, [this.entity])
|
||||
this.options.positions[selectPoint.index] = this.cartesian3Towgs84(pos3, this.sdk.viewer)
|
||||
let positions = this.options.positions
|
||||
fromDegreesArray = []
|
||||
minimumHeights = []
|
||||
maximumHeights = []
|
||||
width = that.computeDistance2(positions)
|
||||
extrudedHeight = that.aspectRatio ? (width / that.aspectRatio) : 0
|
||||
width = this.computeDistance2(positions)
|
||||
extrudedHeight = this.aspectRatio ? (width / this.aspectRatio) : 0
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||
minimumHeights.push(positions[i].alt)
|
||||
maximumHeights.push(positions[i].alt + extrudedHeight)
|
||||
}
|
||||
}
|
||||
that.tip.setPosition(
|
||||
this.tip.setPosition(
|
||||
cartesian,
|
||||
movement.endPosition.x,
|
||||
movement.endPosition.y
|
||||
)
|
||||
})
|
||||
|
||||
that.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
||||
this.event.mouse_right_keyboard_ctrl((movement, cartesian) => {
|
||||
if (selectPoint) {
|
||||
that.options.positions.pop()
|
||||
that.sdk.viewer.entities.remove(that.nodePoints[that.nodePoints.length - 1])
|
||||
that.nodePoints.pop()
|
||||
if (selectPoint.index === that.options.positions.length) {
|
||||
if (that.nodePoints[selectPoint.index - 1]) {
|
||||
selectPoint = that.nodePoints[selectPoint.index - 1]
|
||||
this.options.positions.pop()
|
||||
this.sdk.viewer.entities.remove(this.nodePoints[this.nodePoints.length - 1])
|
||||
this.nodePoints.pop()
|
||||
if (selectPoint.index === this.options.positions.length) {
|
||||
if (this.nodePoints[selectPoint.index - 1]) {
|
||||
selectPoint = this.nodePoints[selectPoint.index - 1]
|
||||
}
|
||||
else {
|
||||
selectPoint.index = 0
|
||||
@ -692,7 +682,7 @@ class StandText extends Base {
|
||||
}
|
||||
})
|
||||
|
||||
that.event.gesture_pinck_start((movement, cartesian) => {
|
||||
this.event.gesture_pinck_start((movement, cartesian) => {
|
||||
let startTime = new Date()
|
||||
let pos = {
|
||||
position: {
|
||||
@ -700,7 +690,7 @@ class StandText extends Base {
|
||||
y: (movement.position1.y + movement.position2.y) / 2
|
||||
}
|
||||
}
|
||||
that.event.gesture_pinck_end(() => {
|
||||
this.event.gesture_pinck_end(() => {
|
||||
let endTime = new Date()
|
||||
if (endTime - startTime >= 500) {
|
||||
// 长按取消
|
||||
@ -712,20 +702,20 @@ class StandText extends Base {
|
||||
})
|
||||
})
|
||||
|
||||
for (let i = 0; i < that.options.positions.length; i++) {
|
||||
let entity = that.sdk.viewer.entities.add({
|
||||
for (let i = 0; i < this.options.positions.length; i++) {
|
||||
let entity = this.sdk.viewer.entities.add({
|
||||
name: 'node-secondary-edit-point',
|
||||
index: i,
|
||||
position: Cesium.Cartesian3.fromDegrees(that.options.positions[i].lng, that.options.positions[i].lat, that.options.positions[i].alt),
|
||||
position: Cesium.Cartesian3.fromDegrees(this.options.positions[i].lng, this.options.positions[i].lat, this.options.positions[i].alt),
|
||||
billboard: {
|
||||
image: that.getSourceRootPath() + '/img/point.png',
|
||||
image: this.getSourceRootPath() + '/img/point.png',
|
||||
width: 15,
|
||||
height: 15,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
color: Cesium.Color.WHITE.withAlpha(0.99)
|
||||
},
|
||||
})
|
||||
that.nodePoints.push(entity)
|
||||
this.nodePoints.push(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user