lixuliang
2024-04-19 1fef6dcc04ffe09336e4983c2b05962ad901e545
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/**
 * 工具栏-对象
 */
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("添加对象已全部清除");
        }
    }
}