|
|
|
@ -912,6 +912,7 @@ export class Database
|
|
|
|
|
//模型空间
|
|
|
|
|
ModelSpace: BlockTableRecord;
|
|
|
|
|
//材质字典...
|
|
|
|
|
MaterialDict: MaerialTableRecord;
|
|
|
|
|
|
|
|
|
|
private idCout = -1;
|
|
|
|
|
private idMap = new Map<number, ObjectId>();
|
|
|
|
@ -920,6 +921,9 @@ export class Database
|
|
|
|
|
{
|
|
|
|
|
this.ModelSpace = new BlockTableRecord();
|
|
|
|
|
this.ModelSpace.InitObjectId(this);
|
|
|
|
|
this.MaterialDict = new MaerialTableRecord();
|
|
|
|
|
this.MaterialDict.InitObjectId(this);
|
|
|
|
|
|
|
|
|
|
this.hm = new HistoricManage();
|
|
|
|
|
this.hm.SetDefaultDb(this);
|
|
|
|
|
}
|
|
|
|
@ -929,12 +933,14 @@ export class Database
|
|
|
|
|
let file = new CADFile();
|
|
|
|
|
file.Write(1);//ver;
|
|
|
|
|
file.WriteObject(this.ModelSpace);
|
|
|
|
|
file.WriteObject(this.MaterialDict);
|
|
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
FileRead(file: CADFile)
|
|
|
|
|
{
|
|
|
|
|
let ver = file.Read();
|
|
|
|
|
file.ReadObject(this, this.ModelSpace);
|
|
|
|
|
file.ReadObject(this, this.MaterialDict);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建一个id,自动递增它的索引号,并且会自动加入到db的id列表中.
|
|
|
|
@ -976,35 +982,16 @@ export class Database
|
|
|
|
|
@Factory
|
|
|
|
|
export class BlockTableRecord extends ObjectCollection<Entity>
|
|
|
|
|
{
|
|
|
|
|
constructor()
|
|
|
|
|
{
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#region -----------------------------File-----------------------------
|
|
|
|
|
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
|
|
|
|
|
//对象从文件中读取数据,初始化自身
|
|
|
|
|
ReadFile(file: CADFile)
|
|
|
|
|
{
|
|
|
|
|
super.ReadFile(file);
|
|
|
|
|
}
|
|
|
|
|
//对象将自身数据写入到文件.
|
|
|
|
|
WriteFile(file: CADFile)
|
|
|
|
|
{
|
|
|
|
|
super.WriteFile(file);
|
|
|
|
|
}
|
|
|
|
|
//局部撤销
|
|
|
|
|
ApplyPartialUndo(undoData: CADObject)
|
|
|
|
|
{
|
|
|
|
|
super.ApplyPartialUndo(undoData);
|
|
|
|
|
}
|
|
|
|
|
//#endregion-----------------------------File End-----------------------------
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//所有图元的基类
|
|
|
|
|
@Factory
|
|
|
|
|
export class Entity extends CADObject
|
|
|
|
|
{
|
|
|
|
|
protected m_DrawEntity = new Map<RenderType, Object3D>();
|
|
|
|
|
//材质id
|
|
|
|
|
protected m_MaterialId: ObjectId;
|
|
|
|
|
//绘制一个threeJs对象.
|
|
|
|
|
Draw(renderType: RenderType = RenderType.Wireframe): Object3D
|
|
|
|
|
{
|
|
|
|
@ -1088,3 +1075,70 @@ export class Line extends Entity
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Factory
|
|
|
|
|
export class MaerialTableRecord extends ObjectCollection<Material>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Factory
|
|
|
|
|
export class Material extends CADObject
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//颜色材质,对于二维图像来说可能有用,应该不对三维对象使用该材质
|
|
|
|
|
@Factory
|
|
|
|
|
export class ColorMaterial extends Material
|
|
|
|
|
{
|
|
|
|
|
private m_Color: THREE.Color;
|
|
|
|
|
constructor()
|
|
|
|
|
{
|
|
|
|
|
super();
|
|
|
|
|
this.m_Color = new THREE.Color();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get Color(): THREE.Color
|
|
|
|
|
{
|
|
|
|
|
return this.m_Color;
|
|
|
|
|
}
|
|
|
|
|
set Color(v: THREE.Color)
|
|
|
|
|
{
|
|
|
|
|
this.m_Color.copy(v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private m_Material: THREE.LineBasicMaterial;
|
|
|
|
|
get LineMaterial(): THREE.LineBasicMaterial
|
|
|
|
|
{
|
|
|
|
|
if (!this.m_Material)
|
|
|
|
|
{
|
|
|
|
|
this.m_Material = new THREE.LineBasicMaterial({ color: this.m_Color });
|
|
|
|
|
}
|
|
|
|
|
return this.m_Material;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//#region -------------------------File-------------------------
|
|
|
|
|
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
|
|
|
|
|
|
|
|
|
|
//对象从文件中读取数据,初始化自身
|
|
|
|
|
ReadFile(file: CADFile)
|
|
|
|
|
{
|
|
|
|
|
let ver = file.Read();
|
|
|
|
|
let hex = file.Read();
|
|
|
|
|
this.m_Color.setHex(hex);
|
|
|
|
|
}
|
|
|
|
|
//对象将自身数据写入到文件.
|
|
|
|
|
WriteFile(file: CADFile)
|
|
|
|
|
{
|
|
|
|
|
file.Write(1);
|
|
|
|
|
file.Write(this.m_Color.getHex());
|
|
|
|
|
}
|
|
|
|
|
//局部撤销
|
|
|
|
|
ApplyPartialUndo(undoData: CADObject)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
//#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|