!2922 新增:画门板界面和铰链模块界面增加“铰链信息写入门板备注”选项

pull/2916/MERGE
林三 2 months ago committed by ChenX
parent 50e172185b
commit f4e9cb7212

@ -11,6 +11,8 @@ import { TemplateSplitType } from "../../../DatabaseServices/Template/TemplateTy
import { AppToaster } from "../../../UI/Components/Toaster";
import { DoorOpenDir, IDoorInfo } from "../../../UI/Store/DoorInterface";
import { DrillType } from "../../DrawDrilling/DrillType";
import { IsDoor } from "../../HideSelect/HideSelectUtils";
import { ParseHingeToDoor } from "../ParseHinge";
import { DrawDoorTool } from "./DrawDoorTool";
export class DrawLeftRightOpenDoor extends DrawDoorTool
@ -181,6 +183,10 @@ export class DrawLeftRightOpenDoor extends DrawDoorTool
intent: Intent.DANGER,
});
}
//写入铰链位置信息
if (this.option.parseHinge)
ParseHingeToDoor(templateSpace.AllEntitys.filter((ent) => ent && IsDoor(ent)), []);
}
protected GetRootTemplate()

@ -11,6 +11,8 @@ import { TemplateSplitType } from "../../../DatabaseServices/Template/TemplateTy
import { AppToaster } from "../../../UI/Components/Toaster";
import { DoorOpenDir, IDoorInfo } from "../../../UI/Store/DoorInterface";
import { DrillType } from "../../DrawDrilling/DrillType";
import { IsDoor } from "../../HideSelect/HideSelectUtils";
import { ParseHingeToDoor } from "../ParseHinge";
import { DrawDoorTool } from "./DrawDoorTool";
export class DrawUpDownOpenDoor extends DrawDoorTool
@ -182,6 +184,10 @@ export class DrawUpDownOpenDoor extends DrawDoorTool
intent: Intent.DANGER,
});
}
//写入铰链位置信息
if (this.option.parseHinge)
ParseHingeToDoor(templateSpace.AllEntitys.filter((ent) => ent && IsDoor(ent)), []);
}
protected GetRootTemplate()

@ -6,7 +6,6 @@ import { arrayPushArray } from "../../Common/ArrayExt";
import { Log } from "../../Common/Log";
import { Intent } from "../../Common/Toaster";
import { ParseExpr } from "../../Common/eval";
import { CADObject } from "../../DatabaseServices/CADObject";
import { Board } from "../../DatabaseServices/Entity/Board";
import { Entity } from "../../DatabaseServices/Entity/Entity";
import { HardwareCompositeEntity } from "../../DatabaseServices/Hardware/HardwareCompositeEntity";
@ -63,65 +62,7 @@ export class ParseHinge implements Command
else if (res.Status === PromptStatus.OK)
{
let doors = res.SelectSet.SelectEntityList as Entity[];
let succeedCount = 0;
let emptyCount = 0;
for (let door of doors)
{
let hingeMap = new Map<string, HingeRemarkInformation[]>();
let dataList: [string, string][] = [];
let hingeMarks: [string, string][] = [];
let hingObjId: ObjectId[] = [];
if (door instanceof Board)
{
hingObjId = door.RelativeHardware;
dataList = door.BoardProcessOption.remarks;
}
else if (door instanceof HardwareCompositeEntity)
{
hingObjId = door.RelevanceHardware;
dataList = door.DataList;
}
ParseHingeToDoor(door, hingObjId, hingeMap, this.options);
//会去掉所有之前的"jl"开头的备注
let remarks = dataList.filter(r => !(hingeMap.has(r[0]) || r[0].substring(0, 2) === "jl"));
convertToString(hingeMap, hingeMarks);
hingeMarks.sort((h1, h2) => h1[0].localeCompare(h2[0]));
if (hingeMarks.length)
{
arrayPushArray(remarks, hingeMarks);
if (door instanceof Board)
door.BoardProcessOption.remarks = remarks;
else if (door instanceof HardwareCompositeEntity)
door.DataList = remarks;
succeedCount++;
}
else
emptyCount++;
}
if (succeedCount)
{
AppToaster.show({
message: `成功分析${succeedCount}个门板的铰链位置!(已经写入到板件备注!)`,
timeout: 10000,
intent: Intent.SUCCESS,
});
}
if (emptyCount)
{
AppToaster.show({
message: `${emptyCount}个门板没有铰链!`,
timeout: 10000,
intent: Intent.WARNING,
});
}
ParseHingeToDoor(doors, this.options);
break;
}
else
@ -165,61 +106,117 @@ function convertToString(hingeMap: Map<string, HingeRemarkInformation[]>, hingeM
}
/**
*
* @param {Entity} door
* @param {ObjectId<CADObject>[]} hingObjId
* @param {Map<string, HingeRemarkInformation>} hingeMap <,{XY,}[]>
*
* @param {Entity[]} doors
* @param options
*/
function ParseHingeToDoor(door: Entity, hingObjId: ObjectId<CADObject>[], hingeMap: Map<string, HingeRemarkInformation[]>, options: { name: string; key: string; checked: boolean; }[])
export function ParseHingeToDoor(doors: Entity[], options: { name: string; key: string; checked: boolean; }[])
{
let doorBox = door.Clone().ApplyMatrix(door.SpaceOCSInv).BoundingBox;
let succeedCount = 0;
let emptyCount = 0;
let fuzz = new FuzzyFactory(1, 0.1);
for (let hid of hingObjId)
for (let door of doors)
{
let hw = hid?.Object;
if (!hw || hw.IsErase || !(hw instanceof HardwareCompositeEntity)) //过滤掉铰链模板其他类型实体
continue;
let hingeMap = new Map<string, HingeRemarkInformation[]>();
let dataList: [string, string][] = [];
let hingeMarks: [string, string][] = [];
let hingObjId: ObjectId[] = [];
if (hw.HardwareOption.name.includes("铰链"))
if (door instanceof Board)
{
hingObjId = door.RelativeHardware;
dataList = door.BoardProcessOption.remarks;
}
else if (door instanceof HardwareCompositeEntity)
{
const size = hw.BoundingBoxInOCS.getSize(new Vector3);
let pos = new Vector3().setFromMatrixPosition(hw.Clone().ApplyMatrix(door.SpaceOCSInv).SpaceOCS).sub(doorBox.min);
let key = "jl-" + hw.HardwareOption.name; //设置铰链名称
hingObjId = door.RelevanceHardware;
dataList = door.DataList;
}
let newDetailedInformation = ""; //获取铰链详细信息
const accuracy = HostApplicationServices.chaidanOption.hardwareExpressionFormattingAccuracy;
for (const { key, checked } of options)
{
if (!checked) continue;
newDetailedInformation += ParseExpr(hw.HardwareOption[key], accuracy, { L: size.x, W: size.y, H: size.z }) + " ";
}
let doorBox = door.Clone().ApplyMatrix(door.SpaceOCSInv).BoundingBox;
const newPosion = new Vector2(fuzz.lookupOrCreate([pos.x], parseFloat(pos.x.toFixed(1))), parseFloat(pos.z.toFixed(1)));//获取位置信息
let fuzz = new FuzzyFactory(1, 0.1);
const hingeRemarkInformations = hingeMap.get(key) || [] as HingeRemarkInformation[];
for (let hid of hingObjId)
{
let hw = hid?.Object;
if (!hw || hw.IsErase || !(hw instanceof HardwareCompositeEntity)) //过滤掉铰链模板其他类型实体
continue;
const hingeRemarkInformation = hingeRemarkInformations.find(info => info.detailedInformation === newDetailedInformation);
if (hingeRemarkInformation) //如果存在铰链详细信息且是相同的,将位置写入到一起
if (hw.HardwareOption.name.includes("铰链"))
{
let x = fuzz.lookupOrCreate([pos.x], parseFloat(pos.x.toFixed(1)));
let y = parseFloat(pos.z.toFixed(1));
//过滤重复点
let v2 = hingeRemarkInformation.postion.find((v) => equaln(v.x, x) && equaln(v.y, y));
if (!v2)
hingeRemarkInformation.postion.push(newPosion);
}
else //不存在就创建一条新的数据
{
const newHingeRemarkInformation = {
postion: [newPosion],
detailedInformation: newDetailedInformation
};
hingeRemarkInformations.push(newHingeRemarkInformation);
const size = hw.BoundingBoxInOCS.getSize(new Vector3);
let pos = new Vector3().setFromMatrixPosition(hw.Clone().ApplyMatrix(door.SpaceOCSInv).SpaceOCS).sub(doorBox.min);
let key = "jl-" + hw.HardwareOption.name; //设置铰链名称
let newDetailedInformation = ""; //获取铰链详细信息
const accuracy = HostApplicationServices.chaidanOption.hardwareExpressionFormattingAccuracy;
for (const { key, checked } of options)
{
if (!checked) continue;
newDetailedInformation += ParseExpr(hw.HardwareOption[key], accuracy, { L: size.x, W: size.y, H: size.z }) + " ";
}
const newPosion = new Vector2(fuzz.lookupOrCreate([pos.x], parseFloat(pos.x.toFixed(1))), parseFloat(pos.z.toFixed(1)));//获取位置信息
const hingeRemarkInformations = hingeMap.get(key) || [] as HingeRemarkInformation[];
const hingeRemarkInformation = hingeRemarkInformations.find(info => info.detailedInformation === newDetailedInformation);
if (hingeRemarkInformation) //如果存在铰链详细信息且是相同的,将位置写入到一起
{
let x = fuzz.lookupOrCreate([pos.x], parseFloat(pos.x.toFixed(1)));
let y = parseFloat(pos.z.toFixed(1));
//过滤重复点
let v2 = hingeRemarkInformation.postion.find((v) => equaln(v.x, x) && equaln(v.y, y));
if (!v2)
hingeRemarkInformation.postion.push(newPosion);
}
else //不存在就创建一条新的数据
{
const newHingeRemarkInformation = {
postion: [newPosion],
detailedInformation: newDetailedInformation
};
hingeRemarkInformations.push(newHingeRemarkInformation);
}
hingeMap.set(key, hingeRemarkInformations);
}
}
//会去掉所有之前的"jl"开头的备注
let remarks = dataList.filter(r => !(hingeMap.has(r[0]) || r[0].substring(0, 2) === "jl"));
hingeMap.set(key, hingeRemarkInformations);
convertToString(hingeMap, hingeMarks);
hingeMarks.sort((h1, h2) => h1[0].localeCompare(h2[0]));
if (hingeMarks.length)
{
arrayPushArray(remarks, hingeMarks);
if (door instanceof Board)
door.BoardProcessOption.remarks = remarks;
else if (door instanceof HardwareCompositeEntity)
door.DataList = remarks;
succeedCount++;
}
else
emptyCount++;
}
if (succeedCount)
{
AppToaster.show({
message: `成功分析${succeedCount}个门板的铰链位置!(已经写入到板件备注!)`,
timeout: 10000,
intent: Intent.SUCCESS,
});
}
if (emptyCount)
{
AppToaster.show({
message: `${emptyCount}个门板没有铰链!`,
timeout: 10000,
intent: Intent.WARNING,
});
}
}

@ -539,14 +539,17 @@ export const DefaultDoorOption: IDoorConfigOption = {
verticalEdgeRemarkDown: '',
verticalEdgeRemarkLeft: '',
verticalEdgeRemarkRight: '',
parseHinge: false,
};
Object.freeze(DefaultDoorOption);
export const DefaultHingeOption: IHingeConfigOption = {
version: 1,
hingeCount: 0,
hindeTopDist: 0,
hindeBottomDist: 0,
useRule: false,
deviation: 100
deviation: 100,
parseHinge: false,
};
Object.freeze(DefaultHingeOption);
export const DefaultDrawerOption: IDrawerConfigOption = {

@ -272,7 +272,6 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore;
store={store as DoorStore}
uiOption={this.uiOption}
/>
</>
);
};

@ -202,6 +202,7 @@ export class HingeRules extends React.Component<IHingeRulesProps> {
store.m_Option.hindeBottomDist = doorOption.hindeBottomDist;
store.m_Option.hindeTopDist = doorOption.hindeTopDist;
store.m_Option.hingeCount = doorOption.hingeCount;
store.m_Option.parseHinge = doorOption.parseHinge;
store.rules.length = 0;
Object.assign(store.rules, cof.other);
}}
@ -211,6 +212,15 @@ export class HingeRules extends React.Component<IHingeRulesProps> {
</Menu>
</PopoverContent>
}
<div>
<Checkbox
style={{ display: "block" }}
label="铰链信息写入门板备注"
inline
checked={store.m_Option.parseHinge}
onChange={() => store.m_Option.parseHinge = !store.m_Option.parseHinge}
/>
</div>
</>
);
}

@ -4,6 +4,7 @@ import { observer } from 'mobx-react';
import * as React from 'react';
import { Matrix4 } from 'three';
import { AutoCutting } from '../../../Add-on/BoardCutting/AutoCuttingReactor';
import { ParseHingeToDoor } from '../../../Add-on/DrawBoard/ParseHinge';
import { DrillType } from "../../../Add-on/DrawDrilling/DrillType";
import { IsDoor, IsHandle, IsHinge } from '../../../Add-on/HideSelect/HideSelectUtils';
import { templateTagCommand } from '../../../Add-on/Template/TemplateTagCommand';
@ -39,6 +40,7 @@ import { ISpaceParse } from '../../../Geometry/SpaceParse/ISpaceParse';
import { Point2SpaceParse } from '../../../Geometry/SpaceParse/Point2SpaceParse';
import { PointSelectSpaceClamp } from '../../../Geometry/SpaceParse/PointSelectSpaceClamp';
import { arrayRemoveOnce } from '../../../Nest/Common/ArrayExt';
import { HingeStore } from '../../Store/DoorDrawerStore/HingeStore';
import { IDrawerDoorTempInfo } from '../../Store/DoorInterface';
import { kuGanStore } from '../../Store/KuGanStore';
import { IDrawBoardAutoCutOption } from "../../Store/OptionInterface/IOptionInterface";
@ -782,6 +784,7 @@ export class TemplateManage extends React.Component<ITemplateManage, {}>
let doors = brRes.SelectSet.SelectEntityList as (Board | HardwareCompositeEntity)[];
let templateId = new Set<number>();
let isWarnHingeRules = false;
let successInsertDoors = new Set<Entity>();
for (let door of doors)
{
@ -805,7 +808,6 @@ export class TemplateManage extends React.Component<ITemplateManage, {}>
hasInvalidDoor = true;
continue;
}
let allEntitys: Entity[] = this.getSpaceAllEntitys(door);
this.TemplateDrawHingeTool = new TemplateDrawHingeTool();
let [isLROpen, isWarn] = await this.TemplateDrawHingeTool.addHingeToDoor(door, template, allEntitys);
@ -816,6 +818,8 @@ export class TemplateManage extends React.Component<ITemplateManage, {}>
let needReUpdate = this.TemplateDrawHingeTool.RelativeMetalsToBoard(allEntitys, isLROpen, door, tempSpace.Positioning?.SpaceCS ?? new Matrix4);
if (needReUpdate)
await tempSpace.Root.UpdateTemplateTree();
successInsertDoors.add(door);
}
if (isWarnHingeRules)
{
@ -825,6 +829,12 @@ export class TemplateManage extends React.Component<ITemplateManage, {}>
intent: Intent.DANGER,
});
}
//写入铰链位置信息
const hingestore = HingeStore.GetInstance();
if (hingestore.m_Option.parseHinge)
ParseHingeToDoor(Array.from(successInsertDoors), []);
}, "插入铰链");
if (hasInvalidDoor)

@ -3,11 +3,11 @@ import { observer } from 'mobx-react';
import * as React from 'react';
import { templateTagCommand } from '../../../Add-on/Template/TemplateTagCommand';
import { CheckObjectType } from '../../../Common/CheckoutVaildValue';
import { safeEval } from '../../../Common/eval';
import { CURRENT_HOST, TemplateUrls } from '../../../Common/HostUrl';
import { PostJson, RequestStatus } from '../../../Common/Request';
import { deflate, TemplateParamsOut } from '../../../Common/SerializeMaterial';
import { TemplateParamsOut, deflate } from '../../../Common/SerializeMaterial';
import { FixedNotZero } from '../../../Common/Utils';
import { safeEval } from '../../../Common/eval';
import { TemplateParam } from '../../../DatabaseServices/Template/Param/TemplateParam';
import { DoorStore } from '../../Store/DoorDrawerStore/DoorStore';
import { HingeStore } from '../../Store/DoorDrawerStore/HingeStore';
@ -141,10 +141,12 @@ export class TemplateDetail extends React.Component<ITemplateDetailProps>
return (
<div style={{ textAlign: "left" }}>
<Divider />
<HingeRules
store={store as HingeStore}
uiOption={store.UIOption}
/>
<div style={{ display: "inline-block" }}>
<HingeRules
store={store as HingeStore}
uiOption={store.UIOption}
/>
</div>
<div style={{ marginTop: 10 }}>
<UserConfigComponent store={store} type={BoardModalType.JL} configType={Config_ModalType.UserConfigModal} />
</div>

@ -247,6 +247,11 @@ export class DoorStore extends DoorDrawerStore
cof.option.verticalEdgeRemarkLeft = DefaultDoorOption.verticalEdgeRemarkLeft;
cof.option.verticalEdgeRemarkRight = DefaultDoorOption.verticalEdgeRemarkRight;
}
if (opt.version < 12)
{
cof.option.version = 12;
cof.option.parseHinge = DefaultDoorOption.parseHinge;
}
}
get UIRule()
{

@ -55,6 +55,12 @@ export class HingeStore extends BoardStore
}
UpdateOption(cof: IConfigOption<IHingeConfigOption>)
{
if (!cof.option.version)
{
cof.option.version = 1;
cof.option.parseHinge = false;
}
super.UpdateOption(cof);
this.rules.length = 0;
if (cof.other)

@ -77,6 +77,7 @@ export interface IDoorConfigOption extends IDoorAndDrawerConfigOption
layerEdgeRemarkDown: string;
layerEdgeRemarkLeft: string;
layerEdgeRemarkRight: string;
parseHinge: boolean;//铰链信息写入门板备注
}
/**
@ -87,8 +88,9 @@ export interface IHingeConfigOption extends IBaseOption
hingeCount: number; //铰链
hindeTopDist: number;
hindeBottomDist: number;
useRule: boolean,
useRule: boolean;
deviation: number; //铰链碰撞单次偏移量
parseHinge: boolean;
}
/**

Loading…
Cancel
Save