开发:优化布尔值序列化

pull/2100/MERGE
ChenX 2 years ago
parent 4dd44611dd
commit 5627075bb0

@ -3,10 +3,10 @@
exports[`板件镜像 1`] = ` exports[`板件镜像 1`] = `
Array [ Array [
"Board", "Board",
8, 9,
2, 2,
0, 0,
false, 0,
0, 0,
2, 2,
0, 0,
@ -30,7 +30,7 @@ Array [
], ],
0, 0,
0, 0,
true, 1,
Array [ Array [
1, 1,
0, 0,
@ -50,16 +50,17 @@ Array [
1, 1,
], ],
0, 0,
0,
3, 3,
764, 764,
500.00000000000006, 500.00000000000006,
18, 18,
true, true,
"Polyline", "Polyline",
8, 9,
2, 2,
0, 0,
false, 0,
0, 0,
7, 7,
0, 0,
@ -83,7 +84,7 @@ Array [
], ],
0, 0,
0, 0,
true, 1,
Array [ Array [
6.123233995736766e-17, 6.123233995736766e-17,
-1, -1,
@ -103,6 +104,7 @@ Array [
1, 1,
], ],
0, 0,
0,
2, 2,
4, 4,
Array [ Array [
@ -195,10 +197,10 @@ Array [
exports[`板镜像后板边数据错误 1`] = ` exports[`板镜像后板边数据错误 1`] = `
Array [ Array [
"Board", "Board",
8, 9,
2, 2,
0, 0,
false, 0,
0, 0,
8, 8,
0, 0,
@ -222,7 +224,7 @@ Array [
], ],
0, 0,
0, 0,
true, 1,
Array [ Array [
-1, -1,
0, 0,
@ -242,16 +244,17 @@ Array [
1, 1,
], ],
0, 0,
0,
3, 3,
569.9999999999945, 569.9999999999945,
88, 88,
17.5, 17.5,
false, false,
"Polyline", "Polyline",
8, 9,
2, 2,
0, 0,
false, 0,
0, 0,
7, 7,
0, 0,
@ -275,7 +278,7 @@ Array [
], ],
0, 0,
0, 0,
true, 1,
Array [ Array [
1, 1,
0, 0,
@ -295,6 +298,7 @@ Array [
1, 1,
], ],
0, 0,
0,
2, 2,
6, 6,
Array [ Array [

@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`changev 1`] = `"[10,101,1,2,1,false,0,1,\\"\\",2,2,false,0,1,\\"Line\\",8,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[2,3,4],[0,0,0],2,4,false,0,3,0,2,3,false,0,3,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",8,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[8,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[0,0,0],[0,0,0]],\\"\\",\\"\\",100,2,5,false,0,0,1,2,6,false,0,0,1,2,7,false,0,1,\\"\\",2,8,false,0,0,2,9,false,0,0,1,2,10,false,0,1,\\"\\",2,11,false,0,0,0,1,2,12,false,0,3,0,0]"`; exports[`changev 1`] = `"[10,101,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",9,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,[2,3,4],[0,0,0],2,4,0,0,3,0,2,3,0,0,3,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",9,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,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[9,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,[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,3,0,0]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[10,101,1,2,1,false,0,1,\\"\\",2,2,false,0,1,\\"Line\\",8,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[1,2,3],[0,0,0],2,4,false,0,3,0,2,3,false,0,3,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",8,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[1,2,3],[0,0,0]],\\"\\",2,5,false,0,0,1,2,6,false,0,0,1,2,7,false,0,1,\\"\\",2,8,false,0,0,2,9,false,0,0,1,2,10,false,0,1,\\"\\",2,11,false,0,0,0,1,2,12,false,0,3,0,0]"`; exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[10,101,1,2,1,0,0,1,\\"\\",2,2,0,0,1,\\"Line\\",9,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],[0,0,0],2,4,0,0,3,0,2,3,0,0,3,0,0,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",9,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],[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,3,0,0]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[\\"HistoricManage\\",1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",8,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[1,2,3],[0,0,0]],\\"\\"]"`; exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[\\"HistoricManage\\",1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",9,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],[0,0,0]],\\"\\"]"`;
exports[`测试创建 1`] = `"[\\"AllObjectData\\",1,[]]"`; exports[`测试创建 1`] = `"[\\"AllObjectData\\",1,[]]"`;
exports[`测试创建 2`] = `"[\\"BlockTableRecord\\",1,2,0,false,0,1,\\"\\",2,0,false,0,0]"`; exports[`测试创建 2`] = `"[\\"BlockTableRecord\\",1,2,0,0,0,1,\\"\\",2,0,0,0,0]"`;
exports[`测试创建 3`] = `"[\\"CommandHistoryRecord\\",1,\\"\\",0]"`; exports[`测试创建 3`] = `"[\\"CommandHistoryRecord\\",1,\\"\\",0]"`;
@ -16,7 +16,7 @@ exports[`测试创建 4`] = `"[\\"CreateObjectData\\",1,[]]"`;
exports[`测试创建 5`] = `"[\\"HistorycRecord\\",1,\\"\\",\\"\\",\\"\\"]"`; exports[`测试创建 5`] = `"[\\"HistorycRecord\\",1,\\"\\",\\"\\",\\"\\"]"`;
exports[`测试创建 6`] = `"[\\"Line\\",8,2,0,false,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,1,[0,0,0],[0,0,0]]"`; exports[`测试创建 6`] = `"[\\"Line\\",9,2,0,0,0,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,[0,0,0],[0,0,0]]"`;
exports[`测试创建 7`] = `"[\\"ObjectAllDataHistoryRecord\\",1,1,\\"\\",\\"\\",\\"\\",0]"`; exports[`测试创建 7`] = `"[\\"ObjectAllDataHistoryRecord\\",1,1,\\"\\",\\"\\",\\"\\",0]"`;

@ -7,25 +7,25 @@ Array [
1, 1,
2, 2,
1, 1,
false, 0,
0, 0,
1, 1,
"", "",
2, 2,
2, 2,
false, 0,
0, 0,
0, 0,
2, 2,
4, 4,
false, 0,
0, 0,
3, 3,
1, 1,
"TextureTableRecord", "TextureTableRecord",
2, 2,
100, 100,
false, 0,
4, 4,
1, 1,
"贴图1", "贴图1",
@ -40,14 +40,14 @@ Array [
0, 0,
2, 2,
3, 3,
false, 0,
0, 0,
3, 3,
1, 1,
"PhysicalMaterialRecord", "PhysicalMaterialRecord",
2, 2,
101, 101,
false, 0,
3, 3,
1, 1,
"材质1", "材质1",
@ -110,49 +110,49 @@ Array [
0, 0,
2, 2,
5, 5,
false, 0,
0, 0,
0, 0,
1, 1,
2, 2,
6, 6,
false, 0,
0, 0,
0, 0,
1, 1,
2, 2,
7, 7,
false, 0,
0, 0,
1, 1,
"", "",
2, 2,
8, 8,
false, 0,
0, 0,
0, 0,
2, 2,
9, 9,
false, 0,
0, 0,
0, 0,
1, 1,
2, 2,
10, 10,
false, 0,
0, 0,
1, 1,
"", "",
2, 2,
11, 11,
false, 0,
0, 0,
0, 0,
0, 0,
1, 1,
2, 2,
12, 12,
false, 0,
0, 0,
3, 3,
0, 0,
@ -167,25 +167,25 @@ Array [
1, 1,
2, 2,
1, 1,
false, 0,
0, 0,
1, 1,
"", "",
2, 2,
2, 2,
false, 0,
0, 0,
0, 0,
2, 2,
4, 4,
false, 0,
0, 0,
3, 3,
2, 2,
"TextureTableRecord", "TextureTableRecord",
2, 2,
100, 100,
false, 0,
4, 4,
1, 1,
"贴图1", "贴图1",
@ -201,7 +201,7 @@ Array [
"TextureTableRecord", "TextureTableRecord",
2, 2,
102, 102,
false, 0,
4, 4,
1, 1,
"贴图1(1)", "贴图1(1)",
@ -216,14 +216,14 @@ Array [
0, 0,
2, 2,
3, 3,
false, 0,
0, 0,
3, 3,
2, 2,
"PhysicalMaterialRecord", "PhysicalMaterialRecord",
2, 2,
101, 101,
false, 0,
3, 3,
1, 1,
"材质1", "材质1",
@ -282,7 +282,7 @@ Array [
"PhysicalMaterialRecord", "PhysicalMaterialRecord",
2, 2,
103, 103,
false, 0,
3, 3,
1, 1,
"材质1(1)", "材质1(1)",
@ -345,49 +345,49 @@ Array [
0, 0,
2, 2,
5, 5,
false, 0,
0, 0,
0, 0,
1, 1,
2, 2,
6, 6,
false, 0,
0, 0,
0, 0,
1, 1,
2, 2,
7, 7,
false, 0,
0, 0,
1, 1,
"", "",
2, 2,
8, 8,
false, 0,
0, 0,
0, 0,
2, 2,
9, 9,
false, 0,
0, 0,
0, 0,
1, 1,
2, 2,
10, 10,
false, 0,
0, 0,
1, 1,
"", "",
2, 2,
11, 11,
false, 0,
0, 0,
0, 0,
0, 0,
1, 1,
2, 2,
12, 12,
false, 0,
0, 0,
3, 3,
0, 0,
@ -402,25 +402,25 @@ Array [
1, 1,
2, 2,
1, 1,
false, 0,
0, 0,
1, 1,
"", "",
2, 2,
2, 2,
false, 0,
0, 0,
0, 0,
2, 2,
4, 4,
false, 0,
0, 0,
3, 3,
1, 1,
"TextureTableRecord", "TextureTableRecord",
2, 2,
101, 101,
false, 0,
4, 4,
1, 1,
"贴图1", "贴图1",
@ -435,14 +435,14 @@ Array [
0, 0,
2, 2,
3, 3,
false, 0,
0, 0,
3, 3,
1, 1,
"PhysicalMaterialRecord", "PhysicalMaterialRecord",
2, 2,
100, 100,
false, 0,
3, 3,
1, 1,
"材质1", "材质1",
@ -505,49 +505,49 @@ Array [
0, 0,
2, 2,
5, 5,
false, 0,
0, 0,
0, 0,
1, 1,
2, 2,
6, 6,
false, 0,
0, 0,
0, 0,
1, 1,
2, 2,
7, 7,
false, 0,
0, 0,
1, 1,
"", "",
2, 2,
8, 8,
false, 0,
0, 0,
0, 0,
2, 2,
9, 9,
false, 0,
0, 0,
0, 0,
1, 1,
2, 2,
10, 10,
false, 0,
0, 0,
1, 1,
"", "",
2, 2,
11, 11,
false, 0,
0, 0,
0, 0,
0, 0,
1, 1,
2, 2,
12, 12,
false, 0,
0, 0,
3, 3,
0, 0,

File diff suppressed because it is too large Load Diff

@ -128,7 +128,7 @@ export class CADFiler
return this._datas[this.readIndex++]; return this._datas[this.readIndex++];
} }
ReadBool(v: boolean) ReadBool()
{ {
return Boolean(this.Read()); return Boolean(this.Read());
} }

@ -144,7 +144,7 @@ export abstract class CADObject
this.objectId = id; this.objectId = id;
id.Object = this; id.Object = this;
} }
this._isErase = file.Read(); this._isErase = file.ReadBool();
if (ver > 1) this._Owner = file.ReadObjectId(); if (ver > 1) this._Owner = file.ReadObjectId();
} }
//对象将自身数据写入到文件. //对象将自身数据写入到文件.
@ -152,7 +152,7 @@ export abstract class CADObject
{ {
file.Write(2); file.Write(2);
file.WriteObjectId(this.objectId); file.WriteObjectId(this.objectId);
file.Write(this._isErase); file.WriteBool(this._isErase);
file.WriteObjectId(this._Owner); file.WriteObjectId(this._Owner);
} }
//局部撤销 //局部撤销

@ -808,7 +808,7 @@ export class Arc extends Curve
this._Radius = file.Read(); this._Radius = file.Read();
this._StartAngle = file.Read(); this._StartAngle = file.Read();
this._EndAngle = file.Read(); this._EndAngle = file.Read();
this._Clockwise = file.Read(); this._Clockwise = file.ReadBool();
} }
//对象将自身数据写入到文件. //对象将自身数据写入到文件.
WriteFile(file: CADFiler) WriteFile(file: CADFiler)
@ -818,7 +818,7 @@ export class Arc extends Curve
file.Write(this._Radius); file.Write(this._Radius);
file.Write(this._StartAngle); file.Write(this._StartAngle);
file.Write(this._EndAngle); file.Write(this._EndAngle);
file.Write(this._Clockwise); file.WriteBool(this._Clockwise);
} }
//#endregion //#endregion
} }

@ -735,7 +735,7 @@ export class Entity extends CADObject
this.GroupId = file.ReadHardObjectId(); this.GroupId = file.ReadHardObjectId();
if (ver > 5) if (ver > 5)
this._Visible = file.Read(); this._Visible = file.ReadBool();
if (ver > 6) if (ver > 6)
this._SpaceOCS.fromArray(file.Read()); this._SpaceOCS.fromArray(file.Read());
if (ver > 7) if (ver > 7)
@ -750,7 +750,7 @@ export class Entity extends CADObject
} }
if (ver > 8) if (ver > 8)
this._Freeze = file.Read(); this._Freeze = file.ReadBool();
else else
this._Freeze = false; this._Freeze = false;
} }
@ -764,7 +764,7 @@ export class Entity extends CADObject
file.Write(this._Matrix.toArray()); file.Write(this._Matrix.toArray());
file.WriteObjectId(this.Template); file.WriteObjectId(this.Template);
file.WriteHardObjectId(this.GroupId); file.WriteHardObjectId(this.GroupId);
file.Write(this._Visible); file.WriteBool(this._Visible);
file.Write(this._SpaceOCS.toArray()); file.Write(this._SpaceOCS.toArray());
file.Write(this.ProcessingGroupList.length); file.Write(this.ProcessingGroupList.length);

@ -6,12 +6,12 @@ export class EraseEntityData implements ISerialize
{ {
ReadFile(file: CADFiler): this ReadFile(file: CADFiler): this
{ {
this.isErase = file.Read(); this.isErase = file.ReadBool();
return this; return this;
} }
WriteFile(file: CADFiler): this WriteFile(file: CADFiler): this
{ {
file.Write(this.isErase); file.WriteBool(this.isErase);
return this; return this;
} }
constructor(public isErase = true) constructor(public isErase = true)

Loading…
Cancel
Save