diff --git a/__test__/FileSystem/__snapshots__/file.test.ts.snap b/__test__/FileSystem/__snapshots__/file.test.ts.snap index f832feabc..6a5dbf5b3 100644 --- a/__test__/FileSystem/__snapshots__/file.test.ts.snap +++ b/__test__/FileSystem/__snapshots__/file.test.ts.snap @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`changev 1`] = `"[11,101,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[2,3,4],[0,0,0],2,4,0,0,4,0,2,3,0,0,4,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[0,0,0],[0,0,0]],\\"\\",\\"\\",100,2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,4,0,0,null]"`; +exports[`changev 1`] = `"[11,101,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[2,3,4],[0,0,0],2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[0,0,0],[0,0,0]],\\"\\",\\"\\",100,2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null]"`; -exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[11,101,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[1,2,3],[0,0,0],2,4,0,0,4,0,2,3,0,0,4,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[1,2,3],[0,0,0]],\\"\\",2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,4,0,0,null]"`; +exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[11,101,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[1,2,3],[0,0,0],2,4,0,0,5,0,2,3,0,0,5,0,0,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[1,2,3],[0,0,0]],\\"\\",2,5,0,0,0,1,2,6,0,0,0,1,2,7,0,0,1,\\"\\",2,8,0,0,0,2,9,0,0,0,1,2,10,0,0,1,\\"\\",2,11,0,0,0,0,1,2,12,0,0,5,0,0,null]"`; exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[\\"HistoricManage\\",1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",10,2,100,0,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,1,[1,2,3],[0,0,0]],\\"\\"]"`; diff --git a/__test__/FileSystem/__snapshots__/wblockClone.test.ts.snap b/__test__/FileSystem/__snapshots__/wblockClone.test.ts.snap index cb44c28b2..28d5c7135 100644 --- a/__test__/FileSystem/__snapshots__/wblockClone.test.ts.snap +++ b/__test__/FileSystem/__snapshots__/wblockClone.test.ts.snap @@ -20,7 +20,7 @@ Array [ 4, 0, 0, - 4, + 5, 1, "TextureTableRecord", 2, @@ -42,7 +42,7 @@ Array [ 3, 0, 0, - 4, + 5, 1, "PhysicalMaterialRecord", 2, @@ -106,6 +106,7 @@ Array [ 0, 0, 0, + 0, 1, -1, 0, @@ -155,7 +156,7 @@ Array [ 12, 0, 0, - 4, + 5, 0, 0, null, @@ -182,7 +183,7 @@ Array [ 4, 0, 0, - 4, + 5, 2, "TextureTableRecord", 2, @@ -220,7 +221,7 @@ Array [ 3, 0, 0, - 4, + 5, 2, "PhysicalMaterialRecord", 2, @@ -343,6 +344,7 @@ Array [ 0, 0, 0, + 0, 1, -1, 0, @@ -392,7 +394,7 @@ Array [ 12, 0, 0, - 4, + 5, 0, 0, null, @@ -419,7 +421,7 @@ Array [ 4, 0, 0, - 4, + 5, 1, "TextureTableRecord", 2, @@ -441,7 +443,7 @@ Array [ 3, 0, 0, - 4, + 5, 1, "PhysicalMaterialRecord", 2, @@ -505,6 +507,7 @@ Array [ 0, 0, 0, + 0, 1, -1, 0, @@ -554,7 +557,7 @@ Array [ 12, 0, 0, - 4, + 5, 0, 0, null, diff --git a/src/ApplicationServices/HostApplicationServices.ts b/src/ApplicationServices/HostApplicationServices.ts index 2aafc39b4..0dc72f4f4 100644 --- a/src/ApplicationServices/HostApplicationServices.ts +++ b/src/ApplicationServices/HostApplicationServices.ts @@ -10,6 +10,7 @@ export class IHostApplicationServices DefaultMeshMaterial?: MeshBasicMaterial | MeshStandardMaterial; DefaultFloorMaterial?: MeshBasicMaterial | MeshStandardMaterial; DefaultWallMaterial?: MeshBasicMaterial | MeshStandardMaterial; + DefaultBulkheadCeilingMaterial?: MeshBasicMaterial | MeshStandardMaterial; IsRoomEntityVisible = true;//室内实体可见 @@ -86,7 +87,6 @@ export class IHostApplicationServices checkSealType: "1", sealMaxValue: 10,//封边最大值 sealValues: ''//封边值列表 - }; @ProxyValue viewSize = { diff --git a/src/DatabaseServices/Database.ts b/src/DatabaseServices/Database.ts index bfc5f78d1..6f018ac16 100644 --- a/src/DatabaseServices/Database.ts +++ b/src/DatabaseServices/Database.ts @@ -158,6 +158,7 @@ export class Database HostApplicationServices.DefaultMeshMaterial = (this.MaterialTable.CurBoardMtl?.Object as PhysicalMaterialRecord)?.Material ?? this.DefaultMaterial.Material; HostApplicationServices.DefaultWallMaterial = (this.MaterialTable.CurWallMtl?.Object as PhysicalMaterialRecord)?.Material ?? this.DefaultMaterial.Material; HostApplicationServices.DefaultFloorMaterial = (this.MaterialTable.CurFloorMtl?.Object as PhysicalMaterialRecord)?.Material ?? this.DefaultMaterial.Material; + HostApplicationServices.DefaultBulkheadCeilingMaterial = (this.MaterialTable.CurBulkCeilingFaceMaterial?.Object as PhysicalMaterialRecord)?.Material ?? this.DefaultMaterial.Material; HostApplicationServices.CurrentDimStyle = this.DimStyleTable.Current; } diff --git a/src/DatabaseServices/MaterialTable.ts b/src/DatabaseServices/MaterialTable.ts index 8d969b1f6..c3e0ba647 100644 --- a/src/DatabaseServices/MaterialTable.ts +++ b/src/DatabaseServices/MaterialTable.ts @@ -10,11 +10,12 @@ export class MaterialTable extends SymbolTable @observable protected _CurFloorMtl: ObjectId;//默认地板材质 @observable protected _CurWallMtl: ObjectId;//默认墙体材质 @observable protected _CurDrawMtl: ObjectId;//默认实体材质 + @observable protected _CurBulkCeilingFaceMaterial: ObjectId;//吊顶底面默认材质 get CurFloorMtl() { return this._CurFloorMtl; } get CurWallMtl() { return this._CurWallMtl; } get CurBoardMtl() { return this._CurDrawMtl; } - + get CurBulkCeilingFaceMaterial() { return this._CurBulkCeilingFaceMaterial; } set CurFloorMtl(id) { @@ -45,6 +46,16 @@ export class MaterialTable extends SymbolTable HostApplicationServices.DefaultMeshMaterial = (id.Object as PhysicalMaterialRecord).Material; } + set CurBulkCeilingFaceMaterial(id) + { + if (id === this._CurBulkCeilingFaceMaterial) return; + this.WriteAllObjectRecord(); + this._CurBulkCeilingFaceMaterial = id; + + if (this._db && this._db.IsDefaultDatabase) + HostApplicationServices.DefaultBulkheadCeilingMaterial = (id.Object as PhysicalMaterialRecord).Material; + } + get Materials() { return this.Symbols as Map; @@ -90,7 +101,10 @@ export class MaterialTable extends SymbolTable } if (this._FileVer > 3) - this._CurDrawMtl = file.ReadHardObjectId(); + this._CurDrawMtl = file.ReadObjectId(); + + if (this._FileVer > 4) + this._CurBulkCeilingFaceMaterial = file.ReadObjectId(); } //对象将自身数据写入到文件. @@ -100,8 +114,8 @@ export class MaterialTable extends SymbolTable file.WriteObjectId(this._CurFloorMtl); file.WriteObjectId(this._CurWallMtl); - file.WriteObjectId(this._CurDrawMtl); + file.WriteObjectId(this._CurBulkCeilingFaceMaterial); } //#endregion } diff --git a/src/DatabaseServices/Room/Entity/Ceiling/BulkheadCeiling.ts b/src/DatabaseServices/Room/Entity/Ceiling/BulkheadCeiling.ts index 076172eb3..4fc6a7617 100644 --- a/src/DatabaseServices/Room/Entity/Ceiling/BulkheadCeiling.ts +++ b/src/DatabaseServices/Room/Entity/Ceiling/BulkheadCeiling.ts @@ -1,6 +1,7 @@ import { BufferAttribute, BufferGeometry, Float32BufferAttribute, InstancedInterleavedBuffer, InterleavedBufferAttribute, Intersection, LineSegments, Material, Mesh, Object3D, ShapeBufferGeometry, Vector3 } from "three"; import { Line2 } from "three/examples/jsm/lines/Line2"; import { LineGeometry } from "three/examples/jsm/lines/LineGeometry"; +import { HostApplicationServices } from "../../../../ApplicationServices/HostApplicationServices"; import { ColorMaterial } from "../../../../Common/ColorPalette"; import { DisposeThreeObj, Object3DRemoveAll } from "../../../../Common/Dispose"; import { BufferGeometryUtils } from "../../../../Geometry/BufferGeometryUtils"; @@ -79,6 +80,13 @@ export class BulkheadCeiling extends Entity @AutoRecord RelativeRoomFlatTop: ObjectId; + get MeshMaterial(): Material + { + if (this._MaterialId && this._MaterialId.Object) + return (this._MaterialId.Object).Material; + return HostApplicationServices.DefaultBulkheadCeilingMaterial; + } + private _EdgeGeometrys: BufferGeometry[]; get EdgeGeometrys(): BufferGeometry[] { @@ -303,7 +311,7 @@ export class BulkheadCeiling extends Entity // 单一绘制对象 TODO:因为没有实现材质槽 所以暂时不用这个 // obj.add(new Mesh(this.MeshGeomtry2, this.Materials2)); - obj.add(new Mesh(this.FaceGeometry, (this.Material?.Object as PhysicalMaterialRecord)?.Material ?? this.MeshMaterial)); + obj.add(new Mesh(this.FaceGeometry, this.MeshMaterial)); for (let meshGeo of this.MeshGeometry) obj.add(new Mesh(meshGeo, this.GetMaterials(this._GemoIdMap.get(meshGeo.id)))); diff --git a/src/DatabaseServices/SymbolTable.ts b/src/DatabaseServices/SymbolTable.ts index 359d19123..9885b96db 100644 --- a/src/DatabaseServices/SymbolTable.ts +++ b/src/DatabaseServices/SymbolTable.ts @@ -106,7 +106,7 @@ export class SymbolTable extends CADObject WriteFile(file: CADFiler) { super.WriteFile(file); - file.Write(4); + file.Write(5); file.Write(this.Symbols.size); for (let [key, record] of this.Symbols) { diff --git a/src/UI/Components/ToolBar/ModifyModel/RoomFlatTopParams.tsx b/src/UI/Components/ToolBar/ModifyModel/RoomFlatTopParams.tsx index abe28c53a..1d4231908 100644 --- a/src/UI/Components/ToolBar/ModifyModel/RoomFlatTopParams.tsx +++ b/src/UI/Components/ToolBar/ModifyModel/RoomFlatTopParams.tsx @@ -5,6 +5,7 @@ import { Matrix4, Vector3 } from "three"; import { SelectExtrudeContour, selectOutlinePosition } from "../../../../Add-on/DrawBoard/DrawSpecialShapeBoardTool"; import { ViewChange } from "../../../../Add-on/ViewChange"; import { app } from "../../../../ApplicationServices/Application"; +import { HostApplicationServices } from "../../../../ApplicationServices/HostApplicationServices"; import { MaterialUrls } from "../../../../Common/HostUrl"; import { NormalMatrix } from "../../../../Common/Matrix4Utils"; import { DirectoryId, PostJson, RequestStatus } from "../../../../Common/Request"; @@ -16,6 +17,7 @@ import { Contour } from "../../../../DatabaseServices/Contour"; import { Database } from "../../../../DatabaseServices/Database"; import { Curve } from "../../../../DatabaseServices/Entity/Curve"; import { Polyline } from "../../../../DatabaseServices/Entity/Polyline"; +import { DefaultParamMap, SetMaterialParams } from "../../../../DatabaseServices/IMaterialDefaultParam"; import { ObjectId } from "../../../../DatabaseServices/ObjectId"; import { PhysicalMaterialRecord } from "../../../../DatabaseServices/PhysicalMaterialRecord"; import { BulkheadCeiling, BulkheadCeiling_ContourType } from "../../../../DatabaseServices/Room/Entity/Ceiling/BulkheadCeiling"; @@ -51,6 +53,34 @@ interface ContourData @observer export default class RoomFlatTopParams extends Component { + //获取吊顶地面面材质 默认乳胶漆 + SetBulkCeilingFaceDefaultMaterial() + { + if (!app.Database.MaterialTable.CurBulkCeilingFaceMaterial) + { + for (let [, mtl] of app.Database.MaterialTable.Materials) + { + if (mtl.type === "乳胶漆") + { + app.Database.MaterialTable.CurBulkCeilingFaceMaterial = mtl.Id; + break; + } + } + + if (!app.Database.MaterialTable.CurBulkCeilingFaceMaterial) + { + let mtl = new PhysicalMaterialRecord; + SetMaterialParams(mtl, DefaultParamMap.乳胶漆); + mtl.type = "乳胶漆"; + mtl.Name = "乳胶漆"; + mtl.Update(); + app.Database.MaterialTable.Add(mtl); + app.Database.MaterialTable.CurBulkCeilingFaceMaterial = mtl.Id; + HostApplicationServices.DefaultBulkheadCeilingMaterial = mtl.Material; + } + } + } + //提取天花板轮廓 _PickUpModelingOnFlatTop = async () => { @@ -172,7 +202,9 @@ export default class RoomFlatTopParams extends Component