|
|
@ -5,19 +5,26 @@ import { arrayRemoveOnce } from "../../Common/ArrayExt";
|
|
|
|
import { DisposeThreeObj } from "../../Common/Dispose";
|
|
|
|
import { DisposeThreeObj } from "../../Common/Dispose";
|
|
|
|
import { TemplateUrls } from "../../Common/HostUrl";
|
|
|
|
import { TemplateUrls } from "../../Common/HostUrl";
|
|
|
|
import { PostJson, RequestStatus, uploadLogo } from "../../Common/Request";
|
|
|
|
import { PostJson, RequestStatus, uploadLogo } from "../../Common/Request";
|
|
|
|
import { deflate, GetCurrentViewPreViewImage, TemplateOut, TemplateParamsOut, inflate, TemplateIn } from "../../Common/SerializeMaterial";
|
|
|
|
import { deflate, GetCurrentViewPreViewImage, inflate, TemplateIn, TemplateOut, TemplateParamsOut } from "../../Common/SerializeMaterial";
|
|
|
|
|
|
|
|
import { DuplicateRecordCloning } from "../../Common/Status";
|
|
|
|
import { StretchParse } from "../../Common/StretchParse";
|
|
|
|
import { StretchParse } from "../../Common/StretchParse";
|
|
|
|
import { FixedNotZero, log } from "../../Common/Utils";
|
|
|
|
import { FixedNotZero, log } from "../../Common/Utils";
|
|
|
|
|
|
|
|
import { CommandWrap } from "../../Editor/CommandMachine";
|
|
|
|
import { PromptStatus } from "../../Editor/PromptResult";
|
|
|
|
import { PromptStatus } from "../../Editor/PromptResult";
|
|
|
|
import { SelectBox } from "../../Editor/SelectBox";
|
|
|
|
import { SelectBox } from "../../Editor/SelectBox";
|
|
|
|
import { SelectPick } from "../../Editor/SelectPick";
|
|
|
|
import { SelectPick } from "../../Editor/SelectPick";
|
|
|
|
import { AxisSnapMode } from "../../Editor/SnapServices";
|
|
|
|
import { AxisSnapMode } from "../../Editor/SnapServices";
|
|
|
|
|
|
|
|
import { TempEditor } from "../../Editor/TempEditor";
|
|
|
|
import { userConfig } from "../../Editor/UserConfig";
|
|
|
|
import { userConfig } from "../../Editor/UserConfig";
|
|
|
|
import { Box3Ext } from "../../Geometry/Box";
|
|
|
|
import { Box3Ext } from "../../Geometry/Box";
|
|
|
|
import { AsVector3, equaln, isParallelTo, isPerpendicularityTo, ZAxis, ZeroVec } from "../../Geometry/GeUtils";
|
|
|
|
import { AsVector3, equaln, isParallelTo, isPerpendicularityTo, ZAxis, ZeroVec } from "../../Geometry/GeUtils";
|
|
|
|
import { RenderType } from "../../GraphicsSystem/RenderType";
|
|
|
|
import { RenderType } from "../../GraphicsSystem/RenderType";
|
|
|
|
import { AAType } from "../../GraphicsSystem/Viewer";
|
|
|
|
import { AAType } from "../../GraphicsSystem/Viewer";
|
|
|
|
|
|
|
|
import { ModalPosition } from "../../UI/Components/Modal/ModalsManage";
|
|
|
|
|
|
|
|
import { INeedUpdateParams } from "../../UI/Components/Template/TemplateComponent";
|
|
|
|
|
|
|
|
import { TemplateEditor } from "../../UI/Components/Template/TemplateEditor";
|
|
|
|
import { AppToaster } from "../../UI/Components/Toaster";
|
|
|
|
import { AppToaster } from "../../UI/Components/Toaster";
|
|
|
|
|
|
|
|
import { TempalteEditorStore } from "../../UI/Store/TemplateEditorStore";
|
|
|
|
import { CADFiler } from "../CADFiler";
|
|
|
|
import { CADFiler } from "../CADFiler";
|
|
|
|
import { Database } from "../Database";
|
|
|
|
import { Database } from "../Database";
|
|
|
|
import { Board } from "../Entity/Board";
|
|
|
|
import { Board } from "../Entity/Board";
|
|
|
@ -32,18 +39,11 @@ import { TemplateStretchGripAction } from "./Action/TemplateStretchGripAction";
|
|
|
|
import { TemplateStretchScaleBoxAction } from "./Action/TemplateStretchScaleBoxAction";
|
|
|
|
import { TemplateStretchScaleBoxAction } from "./Action/TemplateStretchScaleBoxAction";
|
|
|
|
import { TemplateParam } from "./Param/TemplateParam";
|
|
|
|
import { TemplateParam } from "./Param/TemplateParam";
|
|
|
|
import { TemplateRecord } from "./TemplateRecord";
|
|
|
|
import { TemplateRecord } from "./TemplateRecord";
|
|
|
|
import { INeedUpdateParams } from "../../UI/Components/Template/TemplateComponent";
|
|
|
|
|
|
|
|
import { TempEditor } from "../../Editor/TempEditor";
|
|
|
|
|
|
|
|
import { CommandWrap } from "../../Editor/CommandMachine";
|
|
|
|
|
|
|
|
import { DuplicateRecordCloning } from "../../Common/Status";
|
|
|
|
|
|
|
|
import { TempalteEditorStore } from "../../UI/Store/TemplateEditorStore";
|
|
|
|
|
|
|
|
import { TemplateEditor } from "../../UI/Components/Template/TemplateEditor";
|
|
|
|
|
|
|
|
import { ModalPosition } from "../../UI/Components/Modal/ModalsManage";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 得到最深处的模块节点
|
|
|
|
* 得到最深处的模块节点
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function GetDeepestTemplate(brs: Board[]): TemplateRecord | undefined
|
|
|
|
export function GetDeepestTemplate(brs: Entity[]): TemplateRecord | undefined
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let maxDepth = -Infinity;
|
|
|
|
let maxDepth = -Infinity;
|
|
|
|
let deepestTemplate: TemplateRecord;
|
|
|
|
let deepestTemplate: TemplateRecord;
|
|
|
@ -77,12 +77,24 @@ export function GetTempateBoards(template: TemplateRecord): Board[]
|
|
|
|
|
|
|
|
|
|
|
|
for (let id of template.Objects)
|
|
|
|
for (let id of template.Objects)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!id.IsErase)
|
|
|
|
if (!id.IsErase && id.Object instanceof Board)
|
|
|
|
brs.push(id.Object as Board);
|
|
|
|
brs.push(id.Object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return brs;
|
|
|
|
return brs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function GetTempateEntitys(template: TemplateRecord): Entity[]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let ents: Entity[] = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let id of template.Objects)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!id.IsErase && id.Object instanceof Entity)
|
|
|
|
|
|
|
|
ents.push(id.Object);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ents;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 初始化模块
|
|
|
|
* 初始化模块
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -90,13 +102,13 @@ export function GetTempateBoards(template: TemplateRecord): Board[]
|
|
|
|
* 如果所有板件都不在模块中,那么生成新模块.
|
|
|
|
* 如果所有板件都不在模块中,那么生成新模块.
|
|
|
|
* 如果板件在不同的模块中,那么询问用户是否生成新模块.
|
|
|
|
* 如果板件在不同的模块中,那么询问用户是否生成新模块.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param brs 板件列表
|
|
|
|
* @param ents 板件列表
|
|
|
|
* @returns 模块记录
|
|
|
|
* @returns 模块记录
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export async function InitTemplate(brs: Board[]): Promise<TemplateRecord | undefined>
|
|
|
|
export async function InitTemplate(ents: Entity[]): Promise<TemplateRecord | undefined>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let templates: Set<TemplateRecord> = new Set();
|
|
|
|
let templates: Set<TemplateRecord> = new Set();
|
|
|
|
for (let br of brs)
|
|
|
|
for (let br of ents)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!br.Template)
|
|
|
|
if (!br.Template)
|
|
|
|
templates.add(undefined);
|
|
|
|
templates.add(undefined);
|
|
|
@ -144,11 +156,11 @@ export async function InitTemplate(brs: Board[]): Promise<TemplateRecord | undef
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let templateSCSInv = brs[0].SpaceOCSInv;
|
|
|
|
let templateSCSInv = ents[0].SpaceOCSInv;
|
|
|
|
let templateSCS = brs[0].SpaceOCS;
|
|
|
|
let templateSCS = ents[0].SpaceOCS;
|
|
|
|
let box = new Box3();
|
|
|
|
let box = new Box3();
|
|
|
|
for (let br of brs)
|
|
|
|
for (let br of ents)
|
|
|
|
box.union(br.GetBoardBoxInMtx(templateSCSInv));
|
|
|
|
box.union(br.GetBoundingBoxInMtx(templateSCSInv));
|
|
|
|
|
|
|
|
|
|
|
|
templateSize = box.getSize(new Vector3());
|
|
|
|
templateSize = box.getSize(new Vector3());
|
|
|
|
templateSCS.setPosition(box.min.applyMatrix4(templateSCS));
|
|
|
|
templateSCS.setPosition(box.min.applyMatrix4(templateSCS));
|
|
|
@ -174,7 +186,7 @@ export async function InitTemplate(brs: Board[]): Promise<TemplateRecord | undef
|
|
|
|
}
|
|
|
|
}
|
|
|
|
app.Database.TemplateTable.Append(template);
|
|
|
|
app.Database.TemplateTable.Append(template);
|
|
|
|
|
|
|
|
|
|
|
|
for (let br of brs)
|
|
|
|
for (let br of ents)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
template.Objects.push(br.Id);
|
|
|
|
template.Objects.push(br.Id);
|
|
|
|
br.SpaceOCS = templateSCS;
|
|
|
|
br.SpaceOCS = templateSCS;
|
|
|
@ -199,7 +211,7 @@ export function UpdateTemplateSizeOffBoards(template: TemplateRecord)
|
|
|
|
if (!spaceCSInv)
|
|
|
|
if (!spaceCSInv)
|
|
|
|
spaceCSInv = br.SpaceOCSInv;
|
|
|
|
spaceCSInv = br.SpaceOCSInv;
|
|
|
|
|
|
|
|
|
|
|
|
let brbox = br.GetBoardBoxInMtx(spaceCSInv);
|
|
|
|
let brbox = br.GetBoundingBoxInMtx(spaceCSInv);
|
|
|
|
|
|
|
|
|
|
|
|
box.union(brbox);
|
|
|
|
box.union(brbox);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -332,7 +344,7 @@ export function InitTempateSizeActions(template: TemplateRecord, useScaleBox = t
|
|
|
|
let topBox = new Box3Ext(new Vector3(-1, -1, size.z / 2), max);
|
|
|
|
let topBox = new Box3Ext(new Vector3(-1, -1, size.z / 2), max);
|
|
|
|
|
|
|
|
|
|
|
|
//板件列表
|
|
|
|
//板件列表
|
|
|
|
let brs = GetTempateBoards(template);
|
|
|
|
let ents = GetTempateEntitys(template);
|
|
|
|
|
|
|
|
|
|
|
|
//动作列表
|
|
|
|
//动作列表
|
|
|
|
let ActionType = useScaleBox ? TemplateStretchScaleBoxAction : TemplateStretchGripAction;
|
|
|
|
let ActionType = useScaleBox ? TemplateStretchScaleBoxAction : TemplateStretchGripAction;
|
|
|
@ -340,9 +352,9 @@ export function InitTempateSizeActions(template: TemplateRecord, useScaleBox = t
|
|
|
|
let wAction = new ActionType(new Vector3(0, 1, 0));
|
|
|
|
let wAction = new ActionType(new Vector3(0, 1, 0));
|
|
|
|
let hAction = new ActionType(new Vector3(0, 0, 1));
|
|
|
|
let hAction = new ActionType(new Vector3(0, 0, 1));
|
|
|
|
|
|
|
|
|
|
|
|
for (let br of brs)
|
|
|
|
for (let ent of ents)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let sps = br.GetStretchPoints();
|
|
|
|
let sps = ent.GetStretchPoints();
|
|
|
|
|
|
|
|
|
|
|
|
let boxContainsIndexMap = [
|
|
|
|
let boxContainsIndexMap = [
|
|
|
|
{ box: rightBox, indexs: [], action: lAction },
|
|
|
|
{ box: rightBox, indexs: [], action: lAction },
|
|
|
@ -363,30 +375,34 @@ export function InitTempateSizeActions(template: TemplateRecord, useScaleBox = t
|
|
|
|
|
|
|
|
|
|
|
|
let spaceToLocalMtx: Matrix4;
|
|
|
|
let spaceToLocalMtx: Matrix4;
|
|
|
|
if (useScaleBox)
|
|
|
|
if (useScaleBox)
|
|
|
|
spaceToLocalMtx = br.OCSInv.multiply(scs);
|
|
|
|
spaceToLocalMtx = ent.OCSInv.multiply(scs);
|
|
|
|
|
|
|
|
|
|
|
|
for (let d of boxContainsIndexMap)
|
|
|
|
for (let d of boxContainsIndexMap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (d.indexs.length === 0)
|
|
|
|
if (d.indexs.length === 0)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
if (d.indexs.length === sps.length || br.IsStretchThickness(d.indexs))
|
|
|
|
if (d.indexs.length === sps.length || (ent instanceof Board && ent.IsStretchThickness(d.indexs)))
|
|
|
|
d.action.MoveEntitys.push(br.Id);
|
|
|
|
d.action.MoveEntitys.push(ent.Id);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (useScaleBox)
|
|
|
|
if (useScaleBox)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let scaleBox = d.box.clone().applyMatrix4(spaceToLocalMtx);
|
|
|
|
let scaleBox = d.box.clone().applyMatrix4(spaceToLocalMtx);
|
|
|
|
let size = new Vector3(br.Width, br.Height, br.Thickness);
|
|
|
|
let size: Vector3;
|
|
|
|
|
|
|
|
if (ent instanceof Board)
|
|
|
|
|
|
|
|
size = new Vector3(ent.Width, ent.Height, ent.Thickness);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
size = ent.BoundingBoxInOCS.getSize(new Vector3);
|
|
|
|
scaleBox.min.divide(size);
|
|
|
|
scaleBox.min.divide(size);
|
|
|
|
scaleBox.max.divide(size);
|
|
|
|
scaleBox.max.divide(size);
|
|
|
|
let action = d.action as TemplateStretchScaleBoxAction;
|
|
|
|
let action = d.action as TemplateStretchScaleBoxAction;
|
|
|
|
action.EntityStretchData.push({ entity: br.Id, scaleBox });
|
|
|
|
action.EntityStretchData.push({ entity: ent.Id, scaleBox });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let action = d.action as TemplateStretchGripAction;
|
|
|
|
let action = d.action as TemplateStretchGripAction;
|
|
|
|
action.EntityStretchPointMap.push({ entity: br.Id, indexs: d.indexs });
|
|
|
|
action.EntityStretchPointMap.push({ entity: ent.Id, indexs: d.indexs });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|