Browse Source

增加接口 不显示空间名称

haojianlong 3 năm trước cách đây
mục cha
commit
bf5cd35d83
3 tập tin đã thay đổi với 39 bổ sung11 xóa
  1. 1 1
      package.json
  2. 18 0
      src/FloorScene.ts
  3. 20 10
      src/items/SpaceItem.ts

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/cad-engine",
-    "version": "2.0.591",
+    "version": "2.0.593",
     "description": "上格云 CAD图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 18 - 0
src/FloorScene.ts

@@ -78,6 +78,24 @@ export class FloorScene extends SGraphScene {
         );
     } // Set isShowSpace
 
+    /** 是否显示空间名称  */
+    private _isShowSpaceName: boolean = true;
+    get isShowSpaceName(): boolean {
+        return this._isShowSpaceName;
+    } // Get isShowSpace
+    set isShowSpaceName(v: boolean) {
+        if (this._isShowSpaceName === v) {
+            return;
+        }
+        this._isShowSpaceName = v;
+        this.spaceList.map(
+            (t: SpaceItem): SpaceItem => {
+                t.showBaseName = v;
+                return t;
+            }
+        );
+    } // Set isShowSpace
+
     /** 是否显示柱子  */
     private _isShowColumn: boolean = true;
     get isShowColumn(): boolean {

+ 20 - 10
src/items/SpaceItem.ts

@@ -62,6 +62,15 @@ export class SpaceItem extends SGraphItem {
         this._highLightFlag = value;
         this.update();
     } // Set highLightFlag
+    /** 是否显示名称    */
+    private _showBaseName: boolean = false;
+    get showBaseName(): boolean {
+        return this._showBaseName;
+    } // Get highLightFlag
+    set showBaseName(value: boolean) {
+        this._showBaseName = value;
+        this.update();
+    } // Set highLightFlag
 
     /**
      * 构造函数
@@ -190,15 +199,16 @@ export class SpaceItem extends SGraphItem {
         }
         painter.pen.lineWidth = 200;
         painter.drawPath(this.path);
-
-        painter.brush.color = SColor.Black;
-        // painter.font.size = painter.toPx(10);
-        painter.font.size = 500;
-        painter.font.textAlign = STextAlign.Center;
-        painter.drawText(
-            this.data.Name,
-            this.data.Location.Points[0].X,
-            -this.data.Location.Points[0].Y
-        );
+        if (this.showBaseName) {
+            painter.brush.color = SColor.Black;
+            // painter.font.size = painter.toPx(10);
+            painter.font.size = 500;
+            painter.font.textAlign = STextAlign.Center;
+            painter.drawText(
+                this.data.Name,
+                this.data.Location.Points[0].X,
+                -this.data.Location.Points[0].Y
+            );
+        }
     } // Function onDraw()
 } // Class SpaceItem