123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <template>
- <div v-show="smashingComb">
- <div>
- <!-- <div class="sm-point media-hidden"></div>
- <label class="sm-function-module-sub-section-setting media-hidden">{{
- Resource.ObserverInformation
- }}</label> -->
- <div class="boxchild">
- <el-button type="primary" size="mini" @click="createSmashing"
- >倾斜压平</el-button
- >
- <el-button type="primary" size="mini" @click="clear">{{
- Resource.clear
- }}</el-button>
- </div>
- </div>
- </div>
- </template>
- <script>
- let cutFillAnalysis = null;
- export default {
- name: "Sm3dSmashing",
- props: {},
- data() {
- return {
- inited: false,
- sharedState: store.state,
- handler_Cut_fill: null,
- //存储压平数据名称
- flattenNames: [],
- handlerTemp: null,
- };
- },
- computed: {
- smashingComb: function () {
- return this.sharedState.analysis[5];
- },
- analysisShow: function () {
- return this.sharedState.toolBar[6];
- },
- },
- beforeDestroy() {},
- mounted() {},
- methods: {
- createSmashing() {
- //绘制多边形
- const that = this;
- let tooltip = createTooltip(document.body);
- that.clear();
- if (that.handler_Cut_fill == null) {
- that.handler_Cut_fill = new Cesium.DrawHandler(
- viewer,
- Cesium.DrawMode.Polygon,
- 0
- );
- }
- that.handler_Cut_fill.activeEvt.addEventListener(function (isActive) {
- if (isActive == true) {
- viewer.enableCursorStyle = false;
- viewer._element.style.cursor = "";
- } else {
- viewer.enableCursorStyle = true;
- }
- });
- that.handler_Cut_fill.movingEvt.addEventListener(function (
- windowPosition
- ) {
- if (windowPosition.x < 200 && windowPosition.y < 150) {
- tooltip.setVisible(false);
- return;
- }
- if (that.handler_Cut_fill.isDrawing) {
- tooltip.showAt(
- windowPosition,
- "<p>点击确定压平区域中间点</p><p>右键单击结束绘制,进行压平</p>"
- );
- } else {
- tooltip.showAt(windowPosition, "<p>点击绘制压平区域第一个点</p>");
- }
- });
- that.handler_Cut_fill.drawEvt.addEventListener(function (result) {
- if (!result.object.positions) {
- tooltip.showAt(result, "<p>请绘制正确的多边形</p>");
- that.handler_Cut_fill.polygon.show = false;
- that.handler_Cut_fill.polyline.show = false;
- that.handler_Cut_fill.deactivate();
- that.handler_Cut_fill.activate();
- return;
- }
- var array = [].concat(result.object.positions);
- tooltip.setVisible(false);
- var positions = [];
- for (var i = 0, len = array.length; i < len; i++) {
- var cartographic = Cesium.Cartographic.fromCartesian(array[i]);
- var longitude = Cesium.Math.toDegrees(cartographic.longitude);
- var latitude = Cesium.Math.toDegrees(cartographic.latitude);
- var h = cartographic.height;
- if (
- positions.indexOf(longitude) == -1 &&
- positions.indexOf(latitude) == -1
- ) {
- positions.push(longitude);
- positions.push(latitude);
- positions.push(h);
- }
- }
- viewer.scene.globe.removeAllExcavationRegion();
- let s3mLayers = store.state.tempLatData[0];
- //遍历所有s3m图层,设置压平
- for (var i = 0; i < s3mLayers.length; i++) {
- let nameStr = "flatten" + new Date().getTime(); //创建唯一名称
- //倾斜影像压平处理
- s3mLayers[i].addFlattenRegion({
- position: positions,
- name: nameStr,
- });
- //推送压平实体名称
- that.flattenNames.push(nameStr);
- }
- positions = [];
- that.handler_Cut_fill.polygon.show = false;
- that.handler_Cut_fill.polyline.show = false;
- that.handler_Cut_fill.deactivate();
- });
- that.handler_Cut_fill.activate();
- },
- clear() {
- const that = this;
- if (that.handler_Cut_fill != null) {
- that.handler_Cut_fill.clear();
- viewer.scene.globe.removeAllExcavationRegion();
- that.handler_Cut_fill.deactivate();
- that.handler_Cut_fill = null;
- that.value = "";
- }
- if (this.flattenNames.length) {
- //图层数据
- let layersData = store.state.tempLatData[0];
- //遍历所有s3m图层,删除压平
- for (var i = 0; i < layersData.length; i++) {
- layersData[i].removeFlattenRegion(this.flattenNames[i]);
- // this.flattenNames.push(nameStr);
- }
- this.flattenNames = [];
- }
- },
- },
- watch: {
- smashingComb(val) {
- if (!this.inited) {
- this.inited = !this.inited;
- this.handler_Cut_fill = new Cesium.DrawHandler(
- viewer,
- Cesium.DrawMode.Polygon,
- 0
- );
- this.handlerTemp = new Cesium.ScreenSpaceEventHandler(
- viewer.scene.canvas
- );
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped></style>
|