Compare commits

...

2 Commits

Author SHA1 Message Date
zh
8ca3576c3e 删除地形时清除绘制的局部等高线 2025-07-23 16:42:47 +08:00
zh
a79c09b45d 优化颜色选择插件 2025-07-23 16:42:01 +08:00
8 changed files with 97 additions and 79 deletions

View File

@ -48,6 +48,15 @@ class BaseDialog {
<button class="close">关闭</button> <button class="close">关闭</button>
` `
this._element.body.appendChild(this._element.foot) this._element.body.appendChild(this._element.foot)
let curtain = await document.createElement('div')
curtain.style.position = 'absolute'
curtain.style.top = '0'
curtain.style.left = '0'
curtain.style.width = '100%'
curtain.style.height = '100%'
curtain.style.backdropFilter = 'blur(2px)'
curtain.style.zIndex = '-999999'
this._element.body.appendChild(curtain)
// 关闭 // 关闭
let closeBtnsBox = this._element.body.getElementsByClassName('close-box')[0]; let closeBtnsBox = this._element.body.getElementsByClassName('close-box')[0];

View File

@ -47,6 +47,11 @@ class ContourAnalysis {
YJ.Analysis.AnalysesResults.push(this) YJ.Analysis.AnalysesResults.push(this)
this.createNewLine(); this.createNewLine();
} }
get type() {
return 'ContourAnalysis'
}
createNewLine() { createNewLine() {
ContourAnalysis.interpolatePoint(this); ContourAnalysis.interpolatePoint(this);
} }

View File

@ -78,6 +78,11 @@ class BaseTerrain extends BaseSource {
close() { close() {
this.sdk.viewer.scene.terrainProvider = this.sdk.viewer.scene.terrainProvider =
new Cesium.EllipsoidTerrainProvider({}) new Cesium.EllipsoidTerrainProvider({})
for (let i = 0; i < YJ.Analysis.AnalysesResults.length; i++) {
if (YJ.Analysis.AnalysesResults[i].type === 'ContourAnalysis') {
YJ.Analysis.AnalysesResults[i].destroy()
}
}
syncSplitData(this.sdk, this.options.id) syncSplitData(this.sdk, this.options.id)
clearTimeout(this.#updateModelTimeout) clearTimeout(this.#updateModelTimeout)

View File

@ -417,71 +417,11 @@ class StandText extends Base {
this.color = 'rgba(255,255,255,1)' this.color = 'rgba(255,255,255,1)'
},//点击清空按钮事件回调 },//点击清空按钮事件回调
}) })
let labelColorPicker = new YJColorPicker({
el: contentElm.getElementsByClassName("labelColor")[0],
size: 'mini',//颜色box类型
alpha: true,//是否开启透明度
defaultColor: this.labelColor,
disabled: false,//是否禁止打开颜色选择器
openPickerAni: 'opacity',//打开颜色选择器动画
sure: (color) => {
this.labelColor = color
},//点击确认按钮事件回调
clear: () => {
this.labelColor = 'rgba(255,255,255,1)'
},//点击清空按钮事件回调
})
let lineColorPicker = new YJColorPicker({
el: contentElm.getElementsByClassName("labelLineColor")[0],
size: 'mini',//颜色box类型
alpha: true,//是否开启透明度
defaultColor: this.labelLineColor,
disabled: false,//是否禁止打开颜色选择器
openPickerAni: 'opacity',//打开颜色选择器动画
sure: (color) => {
this.labelLineColor = color
},//点击确认按钮事件回调
clear: () => {
this.labelLineColor = 'rgba(255,255,255,1)'
},//点击清空按钮事件回调
})
let labelBackgroundColorStartPicker = new YJColorPicker({
el: contentElm.getElementsByClassName("labelBackgroundColorStart")[0],
size: 'mini',
alpha: true,
defaultColor: this.labelBackgroundColorStart,
disabled: false,
openPickerAni: 'opacity',
sure: (color) => {
this.labelBackgroundColorStart = color
},
clear: () => {
this.labelBackgroundColorStart = 'rgba(255,255,255,1)'
},
})
let labelBackgroundColorEndPicker = new YJColorPicker({
el: contentElm.getElementsByClassName("labelBackgroundColorEnd")[0],
size: 'mini',
alpha: true,
defaultColor: this.labelBackgroundColorEnd,
disabled: false,
openPickerAni: 'opacity',
sure: (color) => {
this.labelBackgroundColorEnd = color
},
clear: () => {
this.labelBackgroundColorEnd = 'rgba(255,255,255,1)'
},
})
let all_elm = contentElm.getElementsByTagName("*") let all_elm = contentElm.getElementsByTagName("*")
this._EventBinding.on(this, all_elm) this._EventBinding.on(this, all_elm)
this._elms = this._EventBinding.element this._elms = this._EventBinding.element
this._elms.color = [colorPicker] this._elms.color = [colorPicker]
this._elms.labelColor = [labelColorPicker]
this._elms.labelLineColor = [lineColorPicker]
this._elms.labelBackgroundColorStart = [labelBackgroundColorStartPicker]
this._elms.labelBackgroundColorEnd = [labelBackgroundColorEndPicker]
} else { } else {
if (this._DialogObject && this._DialogObject.remove) { if (this._DialogObject && this._DialogObject.remove) {
this._DialogObject.remove() this._DialogObject.remove()

View File

@ -99,7 +99,7 @@ class TrajectoryMotion extends Base {
color: options.label.color || '#ffffff', color: options.label.color || '#ffffff',
lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4, lineWidth: (options.label.lineWidth || options.label.lineWidth === 0) ? options.label.lineWidth : 4,
pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20, pixelOffset: (options.label.pixelOffset || options.label.pixelOffset === 0) ? options.label.pixelOffset : 20,
backgroundColor: options.label.backgroundColor || ['#42c6ef', '#42c6ef'], backgroundColor: options.label.backgroundColor || ['#00ffff80', '#00ffff80'],
lineColor: options.label.lineColor || '#00ffff80', lineColor: options.label.lineColor || '#00ffff80',
scaleByDistance: options.label.scaleByDistance || false, scaleByDistance: options.label.scaleByDistance || false,
near: (options.label.near || options.label.near === 0) ? options.label.near : 2000, near: (options.label.near || options.label.near === 0) ? options.label.near : 2000,

View File

@ -13,13 +13,16 @@ class YJColorPicker {
openPickerAni: 'opacity', openPickerAni: 'opacity',
defaultColor: options.defaultColor, defaultColor: options.defaultColor,
startMainCallback: (t) => { startMainCallback: (t) => {
_this.colorPicker && (_this.colorPicker.picker.style.opacity = 0)
setTimeout(() => {
customizeStyle() customizeStyle()
}, 0);
} }
} }
this.el = options.el this.el = options.el
if (options.sure) { if (options.sure) {
config.sure = (color) => { config.sure = (color) => {
this.colorPicker.config.defaultColor = this.colorPicker.pickerInput.value // this.colorPicker.config.defaultColor = this.colorPicker.pickerInput.value
let c = Cesium.Color.fromCssColorString(color) let c = Cesium.Color.fromCssColorString(color)
if (pickAlphaInput) { if (pickAlphaInput) {
c = c.withAlpha(pickAlphaInput.value / 100) c = c.withAlpha(pickAlphaInput.value / 100)
@ -61,19 +64,40 @@ class YJColorPicker {
// } // }
config.predefineColor = ['rgba(255, 255, 255, 1)', 'rgba(255, 0, 0, 1)', 'rgba(208, 132, 209, 1)', 'rgba(100, 182, 217, 1)', 'rgba(42, 130, 228, 1)', 'rgba(214, 36, 36, 1)', 'rgba(252, 222, 111, 1)', 'rgba(67, 207, 124, 1)', 'rgba(176, 243, 143, 1)', 'rgba(121, 72, 234, 1)', 'rgba(255, 195, 0, 1)', 'rgba(0, 186, 173, 1)', 'rgba(165, 214, 63, 1)', 'rgba(0, 0, 0, 1)', 'rgba(46, 47, 51, 1)', 'rgba(172, 51, 193, 1)', 'rgba(130, 21, 21, 1)', 'rgba(255, 87, 51, 1)', 'rgba(255, 140, 0, 1)', 'rgba(125, 191, 255, 1)'] config.predefineColor = ['rgba(255, 255, 255, 1)', 'rgba(255, 0, 0, 1)', 'rgba(208, 132, 209, 1)', 'rgba(100, 182, 217, 1)', 'rgba(42, 130, 228, 1)', 'rgba(214, 36, 36, 1)', 'rgba(252, 222, 111, 1)', 'rgba(67, 207, 124, 1)', 'rgba(176, 243, 143, 1)', 'rgba(121, 72, 234, 1)', 'rgba(255, 195, 0, 1)', 'rgba(0, 186, 173, 1)', 'rgba(165, 214, 63, 1)', 'rgba(0, 0, 0, 1)', 'rgba(46, 47, 51, 1)', 'rgba(172, 51, 193, 1)', 'rgba(130, 21, 21, 1)', 'rgba(255, 87, 51, 1)', 'rgba(255, 140, 0, 1)', 'rgba(125, 191, 255, 1)']
this.colorPicker = new ewPlugins('colorpicker', config) this.colorPicker = new ewPlugins('colorpicker', config)
// window.colorPicker = this.colorPicker window.colorPicker = this.colorPicker
customizeStyle() customizeStyle()
function customizeStyle() { function customizeStyle() {
if (!_this.colorPicker) { if (!_this.colorPicker || !_this.colorPicker.picker) {
return return
} }
let isSubtract = false let isSubtract = false
let box = _this.colorPicker.box let box = _this.colorPicker.box
let picker = _this.colorPicker.picker let picker = _this.colorPicker.picker
let x = box.getBoundingClientRect().x
let y = box.getBoundingClientRect().y
let height = 0
// if (picker.style.display === 'none') {
// picker.style.display = 'block'
// height = picker.offsetHeight
// console.log('picker.style.display.opacity', picker.style.display.opacity)
// picker.style.display = 'none'
// }
// console.log('===========================================')
// console.log((y + box.offsetHeight + 4), height, window.innerHeight)
// if ((y + box.offsetHeight + 4) + height > window.innerHeight) {
// console.log(y, height)
// picker.style.top = y - height + 'px'
// }
// else {
// picker.style.top = (y + box.offsetHeight + 4) + 'px'
// }
picker.style.left = x + 'px'
picker.style.minWidth = '325px' picker.style.minWidth = '325px'
let pickerContent = picker.getElementsByClassName('ew-color-picker-content')[0] // let pickerContent = picker.getElementsByClassName('ew-color-picker-content')[0]
let pickAlphaSliderBar = picker.getElementsByClassName('ew-alpha-slider-bar')[0] let pickAlphaSliderBar = picker.getElementsByClassName('ew-alpha-slider-bar')[0]
if (pickAlphaSliderBar) { if (pickAlphaSliderBar) {
pickAlphaSliderBar.parentNode.style.width = '16px' pickAlphaSliderBar.parentNode.style.width = '16px'
@ -101,7 +125,7 @@ class YJColorPicker {
let pickAlpha = document.createElement('div') let pickAlpha = document.createElement('div')
pickAlpha.className = 'input-number input-number-unit-1 color-alpha' pickAlpha.className = 'input-number input-number-unit-1 color-alpha'
pickAlpha.innerHTML = ` pickAlpha.innerHTML = `
<input class="input" type="number" title="" step="0.01" min="0" max="100"> <input class="input" type="number" title="" step="1" min="0" max="100">
<span class="unit">%</span> <span class="unit">%</span>
<span class="arrow"></span>` <span class="arrow"></span>`
pickerInput.parentNode.insertBefore(pickAlpha, pickerInput.nextSibling) pickerInput.parentNode.insertBefore(pickAlpha, pickerInput.nextSibling)
@ -121,14 +145,14 @@ class YJColorPicker {
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) { if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
value = Number(e.target.dataset.min) value = Number(e.target.dataset.min)
} }
pickAlphaInput.value = Number(value.toFixed(2)) pickAlphaInput.value = Number(value.toFixed(0))
} }
}) })
if (_this.pickAlphaInputValue || _this.pickAlphaInputValue === 0 || _this.pickAlphaInputValue === '0') { if (_this.pickAlphaInputValue || _this.pickAlphaInputValue === 0 || _this.pickAlphaInputValue === '0') {
pickAlphaInput.value = Number(Number(_this.pickAlphaInputValue).toFixed(2)) pickAlphaInput.value = Number(Number(_this.pickAlphaInputValue).toFixed(0))
} }
else { else {
pickAlphaInput.value = CesiumColor ? Number((CesiumColor.alpha * 100).toFixed(2)) : 100 pickAlphaInput.value = CesiumColor ? Number((CesiumColor.alpha * 100).toFixed(0)) : 100
} }
_this.pickAlphaInputValue = pickAlphaInput.value _this.pickAlphaInputValue = pickAlphaInput.value
box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(pickAlphaInput.value / 100).toCssColorString() box.style.background = Cesium.Color.fromCssColorString(_this.colorPicker.config.defaultColor || '#ffffff').withAlpha(pickAlphaInput.value / 100).toCssColorString()
@ -270,12 +294,26 @@ class YJColorPicker {
} }
}) })
} }
height = picker.offsetHeight
if (picker.style.display === 'none') {
picker.style.display = 'block'
height = picker.offsetHeight
picker.style.display = 'none'
}
if ((y + box.offsetHeight + 4) + height > window.innerHeight) {
picker.style.top = y - height + 'px'
}
else {
picker.style.top = (y + box.offsetHeight + 4) + 'px'
}
_this.colorPicker.pancelTop = parseFloat(picker.style.top) - 2
} }
function clickDefineColor(color) { function clickDefineColor(color) {
if (pickAlphaInput) { if (pickAlphaInput) {
let c = Cesium.Color.fromCssColorString(color) let c = Cesium.Color.fromCssColorString(color)
pickAlphaInput.value = Number((c.alpha * 100).toFixed(2)) pickAlphaInput.value = Number((c.alpha * 100).toFixed(0))
} }
} }

View File

@ -809,6 +809,7 @@
} }
this.close = () => { this.close = () => {
this.pickerFlag = !this.pickerFlag, this.pickerFlag = !this.pickerFlag,
this.picker.style.opacity = 0
this.render(this.box.parentNode, this.config), this.render(this.box.parentNode, this.config),
d(this), d(this),
g(this, this.panelWidth, this.panelHeight) g(this, this.panelWidth, this.panelHeight)
@ -965,6 +966,7 @@
} }
, ,
f.prototype.startMain = function(e, t) { f.prototype.startMain = function(e, t) {
// console.log(e,t)
var r = this; var r = this;
this.box = l(e, "ew-color-picker-box"), this.box = l(e, "ew-color-picker-box"),
this.box.setAttribute("color-box-id", this.uid), this.box.setAttribute("color-box-id", this.uid),
@ -1002,8 +1004,21 @@
c += s.offsetParent.offsetTop, c += s.offsetParent.offsetTop,
f += s.offsetParent.offsetLeft, f += s.offsetParent.offsetLeft,
s = s.offsetParent; s = s.offsetParent;
this.pancelLeft = f, this.pancelLeft = f;
this.pancelTop = c + e.offsetHeight, let defineColorContainer = this.picker.getElementsByClassName('ew-pre-define-color-container')[0]
let customColorHeight = 0
if(defineColorContainer) {
let colorList = localStorage.getItem('custom-color') || '{}'
colorList = JSON.parse(colorList)
customColorHeight = (Math.floor((Object.keys(colorList).length+2) / 11)+1) * 30
}
this.picker.style.display = 'block'
this.pancelTop = e.getBoundingClientRect().y + (e.offsetHeight + customColorHeight) + 2
if((this.picker.offsetHeight + customColorHeight) + this.pancelTop > window.innerHeight) {
this.pancelTop = e.getBoundingClientRect().y - (this.picker.offsetHeight + customColorHeight)
this.picker.style.top = this.pancelTop + 2 + 'px'
}
this.picker.style.display = 'none'
this.preDefineItem = l(e, "ew-pre-define-color", !0), this.preDefineItem = l(e, "ew-pre-define-color", !0),
this.preDefineItem.length && (0, this.preDefineItem.length && (0,
n.ewObjToArray)(this.preDefineItem).map(function(e) { n.ewObjToArray)(this.preDefineItem).map(function(e) {
@ -1054,7 +1069,7 @@
}, !1), }, !1),
this.pickerClear.addEventListener("click", function() { this.pickerClear.addEventListener("click", function() {
!function(e, t) { !function(e, t) {
t.config.defaultColor = "rgba(255,255,255,1)", t.config.defaultColor = "",
t.pickerFlag = !t.pickerFlag, t.pickerFlag = !t.pickerFlag,
t.render(e, t.config), t.render(e, t.config),
d(t), d(t),
@ -1070,6 +1085,8 @@
o.colorHsbaToRgba)(e.hsba) : (0, o.colorHsbaToRgba)(e.hsba) : (0,
o.colorRgbaToHex)((0, o.colorRgbaToHex)((0,
o.colorHsbaToRgba)(e.hsba)); o.colorHsbaToRgba)(e.hsba));
e.config.defaultColor = e.pickerInput.value
e.render(e.box.parentNode, e.config),
e.config.sure(t, e) e.config.sure(t, e)
}(r) }(r)
}), }),
@ -1097,6 +1114,7 @@
}(r, e) }(r, e)
}, !1), }, !1),
this.bindEvent(this.pickerCursor, function(e, t, r, n) { this.bindEvent(this.pickerCursor, function(e, t, r, n) {
// console.log(e)
r=r-7 r=r-7
n=n-7 n=n-7
u(e, Math.max(0, Math.min(r - e.pancelLeft, i)), Math.max(0, Math.min(n - e.pancelTop, a)), i, a) u(e, Math.max(0, Math.min(r - e.pancelLeft, i)), Math.max(0, Math.min(n - e.pancelTop, a)), i, a)
@ -1119,7 +1137,8 @@
a = i, a = i,
o.moveX = n.eventType[0].indexOf("touch") > -1 ? a.changedTouches[0].clientX : a.clientX, o.moveX = n.eventType[0].indexOf("touch") > -1 ? a.changedTouches[0].clientX : a.clientX,
o.moveY = n.eventType[0].indexOf("touch") > -1 ? a.changedTouches[0].clientY : a.clientY, o.moveY = n.eventType[0].indexOf("touch") > -1 ? a.changedTouches[0].clientY : a.clientY,
r ? t(o, o.moveX, o.moveY) : t(o, e, o.moveX, o.moveY) r ? t(o, o.moveX, o.moveY) : t(o, e, o.moveX, o.moveY);
// console.log('222222', i, t,e, o.moveX, o.moveY)
}; };
document.addEventListener(n.eventType[1], a, { document.addEventListener(n.eventType[1], a, {
capture: !1, capture: !1,

View File

@ -68,7 +68,6 @@
z-index: 999999; z-index: 999999;
background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6); background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6);
border: 1.5px solid; border: 1.5px solid;
backdrop-filter: blur(2px);
border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1; border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1;
text-align: left; text-align: left;
font-family: 'sy-boldface'; font-family: 'sy-boldface';
@ -1033,6 +1032,7 @@
background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6); background: linear-gradient(0deg, var(--color-sdk-bg-gradual)), rgba(0, 0, 0, 0.6);
border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1; border-image: linear-gradient(to bottom, var(--color-sdk-gradual)) 1;
padding: 5px; padding: 5px;
position: fixed !important;
} }
.YJ-custom-base-dialog .ew-color-picker>.ew-color-picker-content { .YJ-custom-base-dialog .ew-color-picker>.ew-color-picker-content {
@ -1160,6 +1160,7 @@
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
line-height: 20px;
} }
.YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color:hover { .YJ-custom-base-dialog .ew-color-picker>.yj-pre-collect-color-container>.yj-pre-collect-color:hover {
@ -1180,6 +1181,7 @@
.YJ-custom-base-dialog .ew-color-picker-box { .YJ-custom-base-dialog .ew-color-picker-box {
border-width: 4px; border-width: 4px;
border-color: #ffffff; border-color: #ffffff;
display: block;
} }
.YJ-custom-base-dialog .ew-color-picker-box>.ew-color-picker-no, .YJ-custom-base-dialog .ew-color-picker-box>.ew-color-picker-no,