mirror of https://gitee.com/cf-fz/WebCAD.git
parent
3175c14eed
commit
c853a7fed7
@ -0,0 +1,178 @@
|
||||
import { Vector3 } from "three";
|
||||
import { DrawBlisWineRackTool } from "../../Add-on/DrawWineRack/DrawBlisWineRackTool";
|
||||
import { app } from "../../ApplicationServices/Application";
|
||||
import { Box3Ext } from "../../Geometry/Box";
|
||||
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
|
||||
import { EFullDir, EFullType, EWineRackType, EWRackArrayType, IWineRackOption } from "../../UI/Store/WineRackInterface";
|
||||
import { Factory } from "../CADFactory";
|
||||
import { CADFiler } from "../CADFiler";
|
||||
import { Board } from "../Entity/Board";
|
||||
import { PositioningClampSpace } from "./Positioning/PositioningClampSpace";
|
||||
import { TemplateRecord } from "./TemplateRecord";
|
||||
|
||||
@Factory
|
||||
export class TemplateWineRackRecord extends TemplateRecord
|
||||
{
|
||||
option: IWineRackOption;
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
InitBaseParams()
|
||||
{
|
||||
super.InitBaseParams();
|
||||
this.option = {
|
||||
type: EWineRackType.Bias,
|
||||
arrayType: EWRackArrayType.ByWidth,
|
||||
fullType: EFullType.ByWidth,
|
||||
isFull: false,
|
||||
isLock: false,
|
||||
fullDir: EFullDir.Left,
|
||||
heightCount: 3.5,
|
||||
widthCount: 3.5,
|
||||
isTotalDepth: true,
|
||||
depth: 0,
|
||||
gripWidth: 100,
|
||||
calcDepth: "L",
|
||||
boardThick: 18,
|
||||
grooveWidthAdd: 0,
|
||||
leftEdge: 1,
|
||||
rightEdge: 1,
|
||||
topEdge: 1,
|
||||
bottomEdge: 1,
|
||||
frontCut: 0,
|
||||
leftCut: 0,
|
||||
rightCut: 0,
|
||||
topCut: 0,
|
||||
grooveLengthAdd: 3,
|
||||
isDrawLy: false,
|
||||
isDrawVer: false,
|
||||
brThick2: 18,
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
protected async Update()
|
||||
{
|
||||
await super.Update();
|
||||
|
||||
let wineRack = DrawBlisWineRackTool.GetInstance() as DrawBlisWineRackTool;
|
||||
|
||||
let brs: Board[] = [];
|
||||
if (this.Positioning && this.Positioning instanceof PositioningClampSpace)
|
||||
{
|
||||
brs = this.Positioning.Objects.map(id => id.Object as Board);
|
||||
}
|
||||
|
||||
let space = new ISpaceParse(brs, this._CacheSpaceCS);
|
||||
space.m_ParseOK = true;
|
||||
space.m_SpaceBox = new Box3Ext(new Vector3(), this._CacheSpaceSize);
|
||||
|
||||
wineRack.Parse(space, this.option);
|
||||
|
||||
let nbrs = wineRack.boardlist;
|
||||
|
||||
for (let i = nbrs.length; i < this.Objects.length; i++)
|
||||
this.Objects[i].Object.Erase();
|
||||
|
||||
if (this.Objects.length > nbrs.length)
|
||||
this.Objects.length = nbrs.length;
|
||||
|
||||
for (let i = 0; i < nbrs.length; i++)
|
||||
{
|
||||
if (i < this.Objects.length)
|
||||
{
|
||||
let br = this.Objects[i].Object as Board;
|
||||
br.Erase(false);
|
||||
br.CopyFrom(nbrs[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
app.Database.ModelSpace.Append(nbrs[i]);
|
||||
this.Objects.push(nbrs[i].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#region -------------------------File-------------------------
|
||||
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
|
||||
//对象从文件中读取数据,初始化自身
|
||||
ReadFile(file: CADFiler)
|
||||
{
|
||||
let ver = file.Read();
|
||||
super.ReadFile(file);
|
||||
|
||||
if (!this.option)
|
||||
//@ts-ignore
|
||||
this.option = {};
|
||||
|
||||
this.option.type = file.Read();
|
||||
this.option.arrayType = file.Read();
|
||||
this.option.fullType = file.Read();
|
||||
this.option.isFull = file.Read();
|
||||
this.option.fullDir = file.Read();
|
||||
this.option.isLock = file.Read();
|
||||
this.option.heightCount = file.Read();
|
||||
this.option.widthCount = file.Read();
|
||||
|
||||
this.option.isTotalDepth = file.Read();
|
||||
this.option.depth = file.Read();
|
||||
this.option.calcDepth = file.Read();
|
||||
this.option.gripWidth = file.Read();
|
||||
this.option.boardThick = file.Read();
|
||||
this.option.grooveWidthAdd = file.Read();
|
||||
|
||||
this.option.leftEdge = file.Read();
|
||||
this.option.rightEdge = file.Read();
|
||||
this.option.topEdge = file.Read();
|
||||
this.option.bottomEdge = file.Read();
|
||||
|
||||
this.option.frontCut = file.Read();
|
||||
this.option.leftCut = file.Read();
|
||||
this.option.rightCut = file.Read();
|
||||
this.option.topCut = file.Read();
|
||||
|
||||
this.option.grooveLengthAdd = file.Read();
|
||||
this.option.isDrawLy = file.Read();
|
||||
this.option.isDrawVer = file.Read();
|
||||
this.option.brThick2 = file.Read();
|
||||
}
|
||||
//对象将自身数据写入到文件.
|
||||
WriteFile(file: CADFiler)
|
||||
{
|
||||
file.Write(1);
|
||||
super.WriteFile(file);
|
||||
file.Write(this.option.type);
|
||||
file.Write(this.option.arrayType);
|
||||
file.Write(this.option.fullType);
|
||||
file.Write(this.option.isFull);
|
||||
file.Write(this.option.fullDir);
|
||||
file.Write(this.option.isLock);
|
||||
file.Write(this.option.heightCount);
|
||||
file.Write(this.option.widthCount);
|
||||
|
||||
file.Write(this.option.isTotalDepth);
|
||||
file.Write(this.option.depth);
|
||||
file.Write(this.option.calcDepth);
|
||||
file.Write(this.option.gripWidth);
|
||||
file.Write(this.option.boardThick);
|
||||
file.Write(this.option.grooveWidthAdd);
|
||||
file.Write(this.option.leftEdge);
|
||||
file.Write(this.option.rightEdge);
|
||||
file.Write(this.option.topEdge);
|
||||
file.Write(this.option.bottomEdge);
|
||||
|
||||
file.Write(this.option.frontCut);
|
||||
file.Write(this.option.leftCut);
|
||||
file.Write(this.option.rightCut);
|
||||
file.Write(this.option.topCut);
|
||||
|
||||
file.Write(this.option.grooveLengthAdd);
|
||||
file.Write(this.option.isDrawLy);
|
||||
file.Write(this.option.isDrawVer);
|
||||
file.Write(this.option.brThick2);
|
||||
}
|
||||
//#endregion
|
||||
}
|
Loading…
Reference in new issue