瀏覽代碼

点选添加

haojianlong 4 年之前
父節點
當前提交
a05cfeb988

+ 6 - 2
src/components/baseEditer.vue

@@ -272,8 +272,8 @@ export default {
                 OutLine: t.pointArr[0],
                 SubType: '',
                 Properties: {
-                  strokeColor: "#3d73c0",
-                  fillColor: "#eda986",
+                  StrokeColor: "#3d73c0",
+                  FillColor: "#72f5f980",
                   font: 0,
                   color: '',
                   TextPos: { X: 0, Y: 0 }
@@ -334,6 +334,10 @@ export default {
       bus.$on("changeitemExplain", val => {
         this.scene.upadatitemExplain(val);
       });
+      //创建区域是否点选
+      bus.$on("changeDrawType", val => {
+        this.scene.isSelecting = val == "select";
+      })
     },
     // 读取数据
     readGroup() {

+ 11 - 4
src/components/edit/left_toolbar.vue

@@ -80,10 +80,14 @@
         >
           <div class="drawer-model-body" v-if="!isExtract">
             <div class="btn-list">
-              <a-button-group>
-                <a-button type="primary">绘制</a-button>
-                <a-button>点选</a-button>
-              </a-button-group>
+              <a-radio-group default-value="draw" button-style="solid" @change="changeDrawType">
+                <a-radio-button value="draw">
+                  绘制
+                </a-radio-button>
+                <a-radio-button value="select">
+                  点选
+                </a-radio-button>
+              </a-radio-group>
             </div>
             <div class="list" v-for="(item,index) in itemList" :key="index">
               <div class="title">{{item.Name}}</div>
@@ -334,6 +338,9 @@ export default {
     },
     pickUp(text, record, index) {
       bus.$emit("exportByKey", record);
+    },
+    changeDrawType(v) {
+      bus.$emit('changeDrawType', v.target.value)
     }
   },
   watch: {

+ 60 - 1
src/components/mapClass/EditScence.ts

@@ -16,6 +16,7 @@ import { Relation } from '@/lib/types/Relation';
 import { uuid } from "@/components/mapClass/until";
 import { STextMarkerItem } from '@/lib/items/STextMarkerItem';
 import { SLineMarkerItem } from '@/lib/items/SLineMarkerItem';
+import { SSpaceItem } from '@saga-web/big/lib/items/floor/SSpaceItem';
 /**
  * 在线绘图
  *
@@ -47,6 +48,8 @@ export class EditScence extends SGraphScene {
             this.view.update();
         }
     };
+    /** 绘制区域时 是否为点选   */
+    isSelecting: boolean = false;
 
     /** 当前选中焦点Item */
     focusItem: SGraphItem | null = null;
@@ -94,6 +97,9 @@ export class EditScence extends SGraphScene {
             itemType = 'Image'
         } else if (obj.itemList[0] instanceof TipelineItem) {
             itemType = 'Line'
+        } else if (obj.itemList[0] instanceof SSpaceItem) { // 点选
+            this.clickToAddArea(obj.itemList[0]);
+            return
         } else {
             itemType = ''
         };
@@ -243,6 +249,54 @@ export class EditScence extends SGraphScene {
     }
 
     /**
+     * 点选创建区域
+    */
+    clickToAddArea(item: SSpaceItem): void {
+        if (this.cmd != 'Zone') {
+            return
+        }
+        if (this.isSelecting  && this._legend) {
+            const SubType = this._legend.SubType ? this._legend.SubType : ''
+            const LegendData: Legend = {
+                ID: uuid(),
+                Name: this._legend.Name,
+                GraphElementType: this._legend.Type,
+                Num: 1,
+                GraphElementId: this._legend.Id,
+                AttachObjectIds: [],
+                Type: "Zone",
+                Pos: { X: item.x, Y: item.y },
+                OutLine: item.pointArr[0],
+                SubType: SubType,
+                Properties: {
+                    StrokeColor: this._legend.Color,
+                    FillColor: this._legend.FillColor,
+                    LineDash: this._legend.LineDash,
+                    LineWidth: this._legend.LineWidth,
+                    font: 0,
+                    color: '',
+                    TextPos: { X: 0, Y: 0 }
+                },
+            }
+            let Polylines = null;
+            if (SubType == "SCPZ") {
+                Polylines = new SSCPZZoneLegendItem(null, LegendData);
+            } else if (SubType == "FHFQ") {
+                Polylines = new SFHFQZoneLegendItem(null, LegendData);
+            } else {
+                Polylines = new SZoneLegendItem(null, LegendData);
+            }
+            Polylines.selectable = true;
+            //设置状态
+            Polylines.status = SItemStatus.Normal;
+            this.addItem(Polylines);
+            Polylines.connect("finishCreated", this, this.finishCreated);
+            this.focusItem = Polylines;
+            this.Nodes.push(Polylines);
+        }
+    }
+
+    /**
      * 增加图片Item mark
      */
     addImgItem(event: SMouseEvent) {
@@ -656,7 +710,12 @@ export class EditScence extends SGraphScene {
                 this.addImgItem(event)
                 break;
             case 'Zone':
-                this.addPolygonItem(event);
+                if (!this.isSelecting) {
+                    this.addPolygonItem(event);
+                } else {
+                    // 点选创建区域
+                    return super.onMouseDown(event)
+                }
                 break;
             case 'Image':
                 this.addIconItem(event);

+ 0 - 1
src/lib/items/SZoneLegendItem.ts

@@ -103,7 +103,6 @@ export class SZoneLegendItem extends SPolygonItem {
             this.setPointList = [];
             let setPointList: SPoint[];
             if (data.OutLine) {
-                console.log(data.OutLine[0] instanceof SPoint)
                 if (data.OutLine[0] instanceof SPoint) {
                     // @ts-ignore
                     this.setPointList = data.OutLine;

+ 2 - 1
src/lib/types/Legend.ts

@@ -23,6 +23,7 @@ import { Anchor } from "./Anchor";
 import { SGraphElementType } from "./../enums/SGraphElementType";
 import { Point } from "@saga-web/big/lib/types/Point";
 import { Size } from "@saga-web/big/lib/types/Size";
+import { SPoint } from '@saga-web/draw/lib';
 
 /**
  * 图例节点接口
@@ -55,7 +56,7 @@ export interface Legend {
     /** 锚点List  */
     AnchorList?: Anchor[];
     /** 轮廓线  */
-    OutLine?: Point[];
+    OutLine?: Point[] | SPoint[];
     /** 由应用自己定义  */
     Properties?: any;
      /** zone 区分防火分区和石材铺装  */