Files
4.0/src/renderer/components/LeftMenu/test.js

341 lines
11 KiB
JavaScript
Raw Normal View History

2025-07-03 17:39:09 +08:00
import { get_source_list } from "../../api/gisAPI";
const test = {
data() {
return {
earthsDom: ["earth", "map2d"],
};
},
mounted() {},
methods: {
callback(Event) {
console.log(Event);
this.earthsDom.forEach((dom) => {
$("#" + dom).removeClass("selectedEarthCss");
});
$("#" + Event.path[4].id).addClass("selectedEarthCss");
if (Event.path[4].id == "earths") {
window.Earth1 = window.Earths;
copy(window.right_entityMap);
} else {
window.Earth1 = window.Earth;
copy(window.left_entityMap);
}
function copy(map) {
if (map == "undefined") {
map = new Map();
}
window._entityMap.clear();
// empty = null
window._entityMap = new Map([...map]);
console.log("copy之后");
console.log(_entityMap);
console.log(right_entityMap);
// console.log(Earth1)
// console.log(Earth)
// console.log(Earths)
}
},
tongbu() {
let _this = this.$refs.tree;
// this.$refs.tree.
// $("#earths").click()
window.Earth1 = window.Earths;
$("#earths").addClass("selectedEarthCss");
$("#earth").removeClass("selectedEarthCss");
get_source_list().then((response) => {
if ([0, 200].includes(response.code)) {
let data = JSON.parse(JSON.stringify(response.data.list || []));
data.sort(_this.keysort("tree_index"));
//给node设置树形如icon是否允许添加子节点以及右键菜单
if (window.right_entityMap == "undefined")
window.right_entityMap = new Map();
console.log("被同步的数据", data);
console.log("被同步的数据", window.Earth1);
console.log("window.right_entityMap", window.right_entityMap);
data.forEach((node) => {
console.log(
"node.source_type",
node.source_type,
[
"point",
"line",
"panel",
"circle",
"attackArrow",
"pincerArrow",
"groundImage",
"layer",
"ArcgisWXImagery",
].includes(node.source_type)
);
if (
!window.right_entityMap.get(node.source_id) &&
[
"model",
"point",
"line",
"panel",
"circle",
"attackArrow",
"pincerArrow",
"groundImage",
"layer",
"ArcgisWXImagery",
].includes(node.source_type)
) {
if (node.detail) node.detail = JSON.parse(node.detail);
//设置树上图标,并渲染到地球上
_this.setOptions(node);
}
});
if (window.right_entityMap == "undefined")
window.right_entityMap = new Map();
window.right_entityMap = new Map([...window._entityMap]);
}
});
},
/* twoscreen() {
// window.earth = null
//
this.$changeComponentShow(".tongbu", true)
this.halfEarth = !this.halfEarth
console.log(this.halfEarth)
if (this.halfEarth) {
$("#earth").addClass("halfEarth")
$("#earths").addClass("halfEarth")
$("#earths")[0].style.left = "50%"
let earths = new YJ.YJEarth('earths')
// YJ.setSecondEarth(earths.earth)
// earths.earth.czm.viewer.scene.mode = Cesium.SceneMode.SCENE2D
// earths.earth.czm.viewer.scene.screenSpaceCameraController.enableTranslate = true
window.Earths = earths
// console.log("earth", earths)
// console.log(
// earths.earth.sceneTree.$refs
// )
YJ.Global.setMode2D(earths.earth)
$("#earth").addClass("selectedEarthCss")
this.earthsDom.forEach(dom => {
$("#" + dom)[0].addEventListener("click", this.callback, {capture: true})
})
window.right_entityMap = new Map()
window.left_entityMap = new Map([...window._entityMap])
} else {
this.$changeComponentShow(".tongbu", false)
this.earthsDom.forEach(dom => {
$("#" + dom)[0].removeEventListener("click", this.callback, {capture: true})
$("#" + dom).removeClass("halfEarth")
$("#" + dom).removeClass("selectedEarthCss")
})
window._entityMap = window.left_entityMap
window.Earth1 = window.Earth
window.Earths.earth.destroy()
$("#earths").empty();
window.Earths = null
}
},*/
tongbu2D() {
let _this = $root_home_index.$refs.tree;
get_source_list().then((response) => {
if ([0, 200].includes(response.code)) {
let data = JSON.parse(JSON.stringify(response.data.list || []));
data.sort(_this.keysort("tree_index"));
//给node设置树形如icon是否允许添加子节点以及右键菜单
if (!window.right_entityMap) window.right_entityMap = new Map();
console.log("被同步的数据", data);
console.log("被同步的数据", window.Earth1);
console.log("window.right_entityMap", window.right_entityMap);
data.forEach((node) => {
if (
!window.right_entityMap.get(node.source_id) &&
[
"point",
"line",
"panel",
"circle",
"attackArrow",
"pincerArrow",
"layer",
].includes(node.source_type)
) {
if (node.detail) node.detail = JSON.parse(node.detail);
//设置树上图标,并渲染到地球上
_this.setOptions2d(node);
}
});
/*if (window.right_entityMap == 'undefined')
window.right_entityMap = new Map()
window.right_entityMap = new Map([...window._entityMap])*/
}
});
},
map2d() {
console.log('window.splitScreen',window.splitScreen,'window.multiViewportMode',window.multiViewportMode);
// 判断window.menuList是否存在
if (window.checkAuthIsValid) {
if (window.menuList) {
let tool = window.menuList[5].list;
tool.forEach((item) => {
if (item.name == "splitScreen") {
if (item.status == true) {
item.status = false;
this.halfEarth = false;
}
}
});
}
this.halfEarth = !this.halfEarth;
if (this.halfEarth) {
YJ.Global.multiViewportMode.on(window.Earth1);
window.multiViewportMode = true;
window.splitScreen = false
2025-07-03 17:39:09 +08:00
} else {
YJ.Global.multiViewportMode.off(window.Earth1);
window.multiViewportMode = false;
2025-07-03 17:39:09 +08:00
}
} else {
this.$message({
message: "您没有该功能的权限",
type: "warning",
});
}
// this.$changeComponentShow(".tongbu", true)
// if (this.halfEarth) {
// $("#earth").addClass("halfEarth")
// $("#map2d").removeClass("zIndex1")
// $(".ol-control")[0].style.bottom = ".5em"
// $(".ol-zoom").css("top", '')
// } else {
// this.$changeComponentShow(".tongbu", false)
// // $("#" + dom)[0].removeEventListener("click", this.callback, {capture: true})
// $("#earth").removeClass("halfEarth")
// $("#map2d").addClass("zIndex1")
// }
/* this.$changeComponentShow(".tongbu", true)
this.halfEarth = !this.halfEarth
console.log(this.halfEarth)
if (this.halfEarth) {
$("#earth").addClass("halfEarth")
$("#map2d").addClass("halfEarth")
$("#map2d")[0].style.left = "50%"
// window.map2d = new YJMap.Map("map2d")
/!* new YJMap.Obj.Tms(map2d, {
url: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer',
})*!/
/!* const projection = new ol.proj.Projection({
code: 'EPSG:4326',
extent: [-180, -90, 180, 90],
metersPerUnit: 2 * Math.PI * 6378137 / 360
})
let GGLWLayer = new ol.layer.Tile({
source: new ol.source.XYZ({
attributions:
'Tiles © <a href="https://services.arcgisonline.com/ArcGIS/' +
'rest/services/World_Topo_Map/MapServer">ArcGIS</a>',
url:
'https://server.arcgisonline.com/ArcGIS/rest/services/' +
'World_Topo_Map/MapServer/tile/{z}/{y}/{x}',
}),
/!* source: new ol.source.XYZ({
url: "http://t4.tianditu.com/DataServer?T=vec_c&x={x}&y={y}&l={z}&tk=d0cf74b31931aab68af181d23fa23d8d"
}),
visible: false*!/
})
window.Map = new ol.Map({
target: "map2d",
layers: [
GGLWLayer
],
view: new ol.View({
center: [106.814931000, 34.945231000, 16000],
projection: projection,
minZoom: 4,
maxZoom: 21,
// extent : maxExtent, //限定到地图视图拖动范围
zoom: 5 // 地图初始化的缩放级别
})
})*!/
$(".ol-control")[0].style.bottom = ".5em"
$(".ol-zoom").css("top", '')
} else {
this.$changeComponentShow(".tongbu", false)
this.earthsDom.forEach(dom => {
$("#" + dom)[0].removeEventListener("click", this.callback, {capture: true})
$("#" + dom).removeClass("halfEarth")
$("#" + dom).removeClass("selectedEarthCss")
})
// window._entityMap = window.left_entityMap
// window.Earth1 = window.Earth
// window.Earths.earth.destroy()
// window.map2d.map.setTarget(null);
// window.map2d.map.dispose();
// $("#map2d").empty();
// window.Earths = null
// window._rightMap.clear()
}*/
},
testglb() {
// let rocketPrimitive: Cesium.Model
let position = Cesium.Cartesian3.fromDegrees(
106.31598580143364,
29.62610729142745,
264.2444551526038
);
const hpRoll = new Cesium.HeadingPitchRoll();
const fixedFrameTransform = Cesium.Transforms.localFrameToFixedFrameGenerator(
"north",
"west"
);
const rocketPrimitive = window.Earth1.earth._viewer.scene.primitives.add(
Cesium.Model.fromGltf({
url: "https://assets.agi.com/models/launchvehicle.glb",
modelMatrix: Cesium.Transforms.headingPitchRollToFixedFrame(
position,
hpRoll,
Cesium.Ellipsoid.WGS84,
fixedFrameTransform
),
minimumPixelSize: 128,
})
);
/*rocketPrimitive.setArticulationStage( //对应属性改变参数值
'SRBFlames Size',
1
);
rocketPrimitive.applyArticulations(); //使得修改的属性生效*/
window.rocketPrimitive = rocketPrimitive;
},
},
};
export default test;