/** * 工具栏-对象 */ import Bus from "@tools/Bus"; export default { methods: { // 添加标绘对象到工程树 addSimpleGraphicTotree(entity) { let style = sgworld.Creator.SimpleGraphic.getStyle(entity); let data = { id: entity.id, name: entity.name, sourceType: 'SimpleGraphic', class: style.type, item: entity, style: style } Bus.$emit("addOtherData", '对象', data); }, // 添加军标对象到工程树 addArmyLabelTotree(entity) { let feature = sgworld.Creator.MilitaryPlotting.getFeature(entity); let data = { id: entity.id, name: entity.name, sourceType: 'MilitaryPlotting', feature, item: entity, } Bus.$emit("addOtherData", '对象', data); }, // 对象 - POI文字 poiText() { sgworld.Creator.createSimpleGraphic("label", {}, (label) => { this.addSimpleGraphicTotree(label) }); }, // 对象 - 图像 labelImage() { sgworld.Creator.createSimpleGraphic( "billboard", {}, (imageLabel) => { this.addSimpleGraphicTotree(imageLabel); } ); }, // 对象 - 3d投影视频 Video3D() { this.$refs.AddVideo.open(); }, // 对象 - 2d投影视频 Video2D() { this.$refs.AddVideo.open('2d'); }, // 对象 - 折线 twoDPolyline() { sgworld.Creator.createSimpleGraphic("polyline", {}, (entity) => { this.addSimpleGraphicTotree(entity); }); }, // 对象 - 面 twoDPolygon() { sgworld.Creator.createSimpleGraphic("polygon", {}, (entity) => { this.addSimpleGraphicTotree(entity); }); }, pathwayCartoon() { this.$refs.PathAnimation.open() // this.popupInter( // "路径动画", // 350, // 400, // window.SmartEarthRootUrl + "Workers/path/PathAnimation.html", // null // ); }, popupInter(title, width, height, url, fn) { //获取相关回调事件 var cancelFn = null; var successFn = null; var endFn = null; for (key in fn) { cancelFn = key == "cancel" ? fn[key] : cancelFn; successFn = key == "success" ? fn[key] : successFn; endFn = key == "end" ? fn[key] : endFn; } layer.open({ title: title, type: 2, //0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层) skin: "other-class", shade: 0, shadeClose: true, zIndex: 99999999, anim: -1, resize: false, isOutAnim: false, area: [ width + "px", typeof height === "number" ? height + "px" : height, ], content: url, success: function (layero, index) { //弹出框iframe高度调整 layero .find("iframe") .css("height", layero.find("iframe").height() - 6); if (successFn && typeof successFn === "function") { successFn(); } }, cancel: function () { if (cancelFn && typeof cancelFn === "function") { cancelFn(); } }, end: function () { if (endFn && typeof endFn === "function") { endFn(); } }, }); }, // 对象 - 军标 armyLabel(type, parentName) { // 2D情况 if (parentName == "twoDArmyLabel") { // 贝塞尔曲线 贝塞尔箭头 if (type == "Bezierline" || type == "BezierArrow") { sgworld.Creator.militaryPlotting(type, '', (entity) => { this.addArmyLabelTotree(entity); }); } else { sgworld.drawObj = sgworld.Creator.militaryPlotting( type, "polygon", (entity) => { this.addArmyLabelTotree(entity); } ); } } // 3D情况 else { if (type == 'MissileModel') { sgworld.drawObj = sgworld.Creator.createSimpleGraphic("model", { url: window.SmartEarthRootUrl + "Workers/Model/sa5.gltf", name: "导弹模型", scale: 0.1 }, (entity) => { let style = sgworld.Creator.SimpleGraphic.getStyle(entity); let data = { id: entity.id, name: "导弹模型", sourceType: "SimpleGraphic", class: style.type, style: style, item: entity, }; Bus.$emit("addOtherData", "对象", data); }); } sgworld.drawObj = sgworld.Creator.militaryPlotting( type, "box", (entity) => { this.addArmyLabelTotree(entity); } ); } }, // 对象 - 2D,3D图形 graphObject(type, parentName) { if (type == 'Sector') { sgworld.Creator.militaryPlotting("Sector", "polygon", function () { }); sgworld.Creator.startModify("Sector"); } else { sgworld.Creator.createSimpleGraphic( type, { clampToGround: true }, (entity) => { this.addSimpleGraphicTotree(entity); } ); } }, // 对象 - 模型仓库 modelLibrary() { this.$refs.ModelLibrary.open(); }, deleteObject() { sgworld.Creator.SimpleGraphic.clear() sgworld.Creator.MilitaryPlotting.clear() Bus.$emit("clearFirstParentNode", "对象"); Bus.$emit("clearFirstParentNode", "视频投影"); this.$message.info("添加对象已全部清除"); } } }