!2003 功能:酷家乐使用名称可切换和酷家乐封边值映射

pull/2028/head
黄诗津 2 years ago committed by ChenX
parent 5265f5094d
commit 9a879e0b32

@ -0,0 +1,61 @@
import { arrayLast } from "../../../Common/ArrayExt";
import { KJLImportConfigOption } from "../../../UI/Store/BoardInterface";
import { KJL_Parameter, KJL_ParamModel } from "./KJLInterface";
export class KJLEdgeParse
{
//(酷家乐封边值) -> 导入实际值
KjlEdgeValueMap = new Map<number, number>();
async LoadKJLEdgeValueMap(config: { [key: string]: KJLImportConfigOption; })
{
if (!config?.option?.edgeValueMap) return;
for (const [key, value] of config.option.edgeValueMap)
{
if (key === 0 && value === 0) continue;
this.KjlEdgeValueMap.set(key, value);
}
}
//解析封边
ParseSeals(model: KJL_ParamModel): number[] | undefined
{
let seals: number[] = [];
let maxIndex = 0;//避免漏掉,我们保存了最大的索引
const Parse = (params: KJL_Parameter[]) =>
{
if (!params) return;
for (let param of params)
{
if (param.name === "ET")
{
seals.push(parseFloat(param.value));
for (let i = 0; i < maxIndex - 1; i++)
seals[i] = arrayLast(seals);
maxIndex++;
break;
}
else if (param.name.startsWith("ET"))
{
let index = parseInt(param.name.substring(2)) - 1;
seals[index] = parseFloat(param.value);
maxIndex = Math.max(index, maxIndex);
}
}
};
Parse(model.constParameters);
Parse(model.ignoreParameters);
Parse(model.parameters);
for (let i = 0; i < maxIndex; i++)
{
if (seals[i] === undefined)
seals[i] = seals[maxIndex];
}
if (seals.length > 0)
return seals.map(e => this.KjlEdgeValueMap.get(e) ?? e);
}
}

@ -29,9 +29,11 @@ import { BoardType, DrillType, FaceDirection, IHighSealedItem, KJLImportConfigOp
import { TopPanelStore } from "../../../UI/Store/TopPanelStore"; import { TopPanelStore } from "../../../UI/Store/TopPanelStore";
import { EZengZhiBaoId, userConfigStore } from "../../../UI/Store/UserConfigStore"; import { EZengZhiBaoId, userConfigStore } from "../../../UI/Store/UserConfigStore";
import { CuttingBoardByBoard } from "../../BoardCutting/CuttingUtils2"; import { CuttingBoardByBoard } from "../../BoardCutting/CuttingUtils2";
import { KJLUseName } from "../KJLImportConfig/KJLConfig";
import { KJLEdgeParse } from "./KJLEdgeParse";
import { KJL_DrillData, KJL_JsonFile, KJL_ModelType, KJL_Parameter, KJL_ParamModel, KJL_ParamModel_Board, KJL_ParamModel_Hardware } from "./KJLInterface"; import { KJL_DrillData, KJL_JsonFile, KJL_ModelType, KJL_Parameter, KJL_ParamModel, KJL_ParamModel_Board, KJL_ParamModel_Hardware } from "./KJLInterface";
import { KJLMaterialLoader } from "./KJLMaterialLoader"; import { KJLMaterialLoader } from "./KJLMaterialLoader";
import { ParseBCBZ, ParseBT, ParseCabNameMap, ParseDrilling, ParseEdgeBanding, ParseEdges, ParseKMFX, ParsePathOutlineAndHole, ParseRoomNameMap, ParseTopline } from "./KJLParse"; import { ParseBCBZ, ParseBT, ParseCabNameMap, ParseDrilling, ParseEdges, ParseKMFX, ParsePathOutlineAndHole, ParseRoomNameMap, ParseTopline } from "./KJLParse";
import { ApplyMaterial, CreateHardware, ParseHardwareParam } from "./KJLUtils"; import { ApplyMaterial, CreateHardware, ParseHardwareParam } from "./KJLUtils";
@ -100,13 +102,15 @@ export async function ImportKJLData(fileData: KJL_JsonFile)
let mtlLoader = new KJLMaterialLoader; let mtlLoader = new KJLMaterialLoader;
await mtlLoader.LoadKJLConfigMaterials(config); await mtlLoader.LoadKJLConfigMaterials(config);
let edgeParse = new KJLEdgeParse;
await edgeParse.LoadKJLEdgeValueMap(config);
let toplines: HardwareTopline[] = []; let toplines: HardwareTopline[] = [];
for (let m of fileData.paramModel) for (let m of fileData.paramModel)
{ {
let roomName = roomNameMap.get(m.roomId); let roomName = roomNameMap.get(m.roomId);
let gName = cabNameMap.get(m.id) ?? m.modelBrandGoodName; let gName = cabNameMap.get(m.id) ?? m.modelBrandGoodName;
await ParseModel(m, roomName, gName, mtlLoader, config, toplines); await ParseModel(m, roomName, gName, mtlLoader, edgeParse, config, toplines);
} }
let ents = app.CommandReactor._createObejcts.filter(obj => obj instanceof Entity) as Entity[]; let ents = app.CommandReactor._createObejcts.filter(obj => obj instanceof Entity) as Entity[];
@ -182,6 +186,7 @@ async function ParseModel(model: KJL_ParamModel,
roomName: string, roomName: string,
gName: string, gName: string,
mtlLoader: KJLMaterialLoader, mtlLoader: KJLMaterialLoader,
edgeParse: KJLEdgeParse,
config: { [key: string]: KJLImportConfigOption; }, config: { [key: string]: KJLImportConfigOption; },
outToplines: HardwareTopline[], outToplines: HardwareTopline[],
parentMatrix?: Matrix4, parentMatrix?: Matrix4,
@ -303,7 +308,7 @@ async function ParseModel(model: KJL_ParamModel,
} }
let br = new Board(); let br = new Board();
br.Name = model.modelName ?? ""; br.Name = (config.option.kjlUseName !== KJLUseName.modelBrandGoodName ? model.modelName : model.modelBrandGoodName) ?? "";
br.BoardProcessOption[EBoardKeyList.Mat] = model.textureName ?? ""; br.BoardProcessOption[EBoardKeyList.Mat] = model.textureName ?? "";
br.BoardProcessOption[EBoardKeyList.BrMat] = model.baseTexture ?? ""; br.BoardProcessOption[EBoardKeyList.BrMat] = model.baseTexture ?? "";
br.BoardProcessOption[EBoardKeyList.RoomName] = roomName; br.BoardProcessOption[EBoardKeyList.RoomName] = roomName;
@ -502,7 +507,7 @@ async function ParseModel(model: KJL_ParamModel,
let templates: TemplateRecord[] = []; let templates: TemplateRecord[] = [];
for (let m of model.subModels) for (let m of model.subModels)
{ {
let edgeBandings = ParseEdgeBanding(model); let edgeBandings = edgeParse.ParseSeals(model);
let holeFaceData = ParseDrilling(model.parameters) ?? ParseDrilling(model.ignoreParameters) ?? ParseDrilling(model.constParameters); let holeFaceData = ParseDrilling(model.parameters) ?? ParseDrilling(model.ignoreParameters) ?? ParseDrilling(model.constParameters);
let edgesData = ParseEdges(model.parameters) ?? ParseEdges(model.ignoreParameters) ?? ParseEdges(model.constParameters); let edgesData = ParseEdges(model.parameters) ?? ParseEdges(model.ignoreParameters) ?? ParseEdges(model.constParameters);
@ -510,7 +515,7 @@ async function ParseModel(model: KJL_ParamModel,
if (holeFaceData) drillData.bigHole = holeFaceData.bigHole; if (holeFaceData) drillData.bigHole = holeFaceData.bigHole;
let boardType = ParseBT(model.parameters) ?? ParseBT(model.ignoreParameters) ?? ParseBT(model.constParameters); let boardType = ParseBT(model.parameters) ?? ParseBT(model.ignoreParameters) ?? ParseBT(model.constParameters);
let obj = await ParseModel(m, roomName, gName, mtlLoader, config, outToplines, mtx, edgeBandings, drillData); let obj = await ParseModel(m, roomName, gName, mtlLoader, edgeParse, config, outToplines, mtx, edgeBandings, drillData);
if (obj) if (obj)
{ {
if (obj instanceof Board) if (obj instanceof Board)
@ -523,7 +528,7 @@ async function ParseModel(model: KJL_ParamModel,
if (bcbz !== undefined) if (bcbz !== undefined)
obj.BoardProcessOption.remarks.push(["KJLBCBZ", bcbz]); obj.BoardProcessOption.remarks.push(["KJLBCBZ", bcbz]);
if (model.modelBrandGoodName !== gName) if (config.option.kjlUseName !== KJLUseName.modelName && model.modelBrandGoodName !== gName)
obj.Name = model.modelBrandGoodName; obj.Name = model.modelBrandGoodName;
if (boardType & 1) if (boardType & 1)
obj.IsChaiDan = false; obj.IsChaiDan = false;

@ -39,50 +39,6 @@ export function ParseCabNameMap(data: KJL_AssemblyModel[]): Map<string, string>
return map; return map;
} }
//解析封边
export function ParseEdgeBanding(model: KJL_ParamModel): number[] | undefined
{
let edgeBandings: number[] = [];
let maxIndex = 0;
const Parse = (params: KJL_Parameter[]) =>
{
if (!params) return;
// console.table(params.map(p =>
// {
// return { name: p.name, value: p.value };
// }));
for (let param of params)
{
if (param.name === "ET")
{
edgeBandings.push(parseFloat(param.value));
for (let i = 0; i < maxIndex - 1; i++)
edgeBandings[i] = arrayLast(edgeBandings);
maxIndex++;
break;
}
else if (param.name.startsWith("ET"))
{
let index = parseInt(param.name.substring(2)) - 1;
edgeBandings[index] = parseFloat(param.value);
maxIndex = Math.max(index, maxIndex);
}
}
};
Parse(model.constParameters);
Parse(model.ignoreParameters);
Parse(model.parameters);
for (let i = 0; i < maxIndex; i++)
{
if (edgeBandings[i] === undefined)
edgeBandings[i] = edgeBandings[maxIndex];
}
if (edgeBandings.length > 0)
return edgeBandings;
}
export async function ParseTopline(model: KJL_ParamModel, mtlLoader: KJLMaterialLoader, roomName: string, gName: string) export async function ParseTopline(model: KJL_ParamModel, mtlLoader: KJLMaterialLoader, roomName: string, gName: string)
{ {

@ -1,25 +1,70 @@
import { Checkbox } from "@blueprintjs/core"; import { Checkbox, Radio, RadioGroup } from "@blueprintjs/core";
import { observer } from "mobx-react"; import { observer } from "mobx-react";
import React from "react"; import React from "react";
import { KJLImportConfigStore } from "./KJLImportConfigStore"; import { KJLImportConfigStore } from "./KJLImportConfigStore";
export enum KJLUseName
{
modelName = 0,
modelBrandGoodName = 1,
}
@observer @observer
export default class KJLConfig extends React.Component<{ store: KJLImportConfigStore; }> export default class KJLConfig extends React.Component<{ store: KJLImportConfigStore; }>
{ {
EdgeValueMap = (edgeValueMap: [string, string][]) =>
{
return (
<div className="edge-value-map">
<div className="edge-head"></div>
<div className="edge-body">
<div className="edge-title">
<span></span>
<div></div>
<div></div>
</div>
<div className="edge-massage">
{
edgeValueMap.map((d, i) =>
<div className="edge-massage-item" key={i}>
<span>{i + 1}</span>
<input type="text" value={d[0]} onChange={e => d[0] = e.target.value} />
<input type="text" value={d[1]} onChange={e => d[1] = e.target.value} />
</div>)
}
</div>
</div>
</div>
);
};
render() render()
{ {
let store = this.props.store; let store = this.props.store;
return ( return (
<div className="frame"> <div className="kjl-config frame">
<div></div> <div></div>
<div> <div>
<div > <div>
<RadioGroup
label="对接使用名称"
selectedValue={store.m_Option.kjlUseName}
inline={true}
className={"radioGroup"}
onChange={(e) => { store.m_Option.kjlUseName = parseInt(e.currentTarget.value); }}
>
<Radio label="模型名称" value={KJLUseName.modelName} />
<Radio label="商品名称" value={KJLUseName.modelBrandGoodName} />
</RadioGroup>
<Checkbox <Checkbox
label="导入虚拟五金" label="导入虚拟五金"
style={{ margin: 10 }} style={{ margin: 10 }}
checked={store.m_Option.isImportVirtualModel} checked={store.m_Option.isImportVirtualModel}
onChange={() => { store.m_Option.isImportVirtualModel = !store.m_Option.isImportVirtualModel; }} onChange={() => { store.m_Option.isImportVirtualModel = !store.m_Option.isImportVirtualModel; }}
/> />
<div style={{ margin: 10 }}>
{
this.EdgeValueMap(store.UIOption)
}
</div>
</div> </div>
</div> </div>
</div> </div>

@ -3,7 +3,7 @@
height: 550px; height: 550px;
.bp3-tab-list { .bp3-tab-list {
font-weight:bold; font-weight: bold;
margin-left: 20px; margin-left: 20px;
.bp3-tab { .bp3-tab {
@ -24,7 +24,7 @@
.frame { .frame {
border: 1px solid #ccc; border: 1px solid #ccc;
&>:nth-child(1) { & > :nth-child(1) {
font-size: 15px; font-size: 15px;
font-weight: bold; font-weight: bold;
margin-left: 20px; margin-left: 20px;
@ -35,17 +35,65 @@
width: fit-content; width: fit-content;
} }
&>:nth-child(2) { & > :nth-child(2) {
height: 480px; height: 480px;
margin-left: 10px; margin-left: 10px;
overflow: scroll; overflow: scroll;
&>div{ & > div {
border: 1px solid #ccc; border: 1px solid #ccc;
} }
} }
} }
.kjl-config {
.radioGroup {
margin: 10px;
}
.edge-value-map {
.edge-head {
margin: 3px;
font-weight: bold;
}
.edge-body {
display: inline-block;
height: 234px;
border: 1px solid;
padding: 2px 10px;
.edge-title {
padding-left: 20px;
display: flex;
& > div {
width: 147px;
text-align: center;
}
}
.edge-massage {
height: 209px;
overflow-y: scroll;
.edge-massage-item {
:first-child {
display: inline-block;
width: 20px;
height: 20px;
text-align: center;
}
input {
height: 20px;
}
}
}
}
}
}
.KJLMaterialMap { .KJLMaterialMap {
.bp3-control { .bp3-control {
margin-bottom: 0; margin-bottom: 0;
@ -57,11 +105,11 @@
grid-template-columns: 70px 1fr 289px 70px; grid-template-columns: 70px 1fr 289px 70px;
&>:nth-child(1) { & > :nth-child(1) {
margin-left: 10px; margin-left: 10px;
} }
&>:nth-child(2) { & > :nth-child(2) {
margin-left: 20px; margin-left: 20px;
} }
} }
@ -72,11 +120,11 @@
align-items: center; align-items: center;
grid-template-columns: 70px 1fr 289px 70px; grid-template-columns: 70px 1fr 289px 70px;
&>:nth-child(1) { & > :nth-child(1) {
margin-left: 10px; margin-left: 10px;
} }
&>:nth-child(2) { & > :nth-child(2) {
margin-left: 20px; margin-left: 20px;
input { input {
@ -102,7 +150,7 @@
cursor: pointer; cursor: pointer;
} }
&>:nth-child(3) { & > :nth-child(3) {
padding: 5px 0; padding: 5px 0;
height: 52px; height: 52px;
display: grid; display: grid;

@ -7,8 +7,9 @@ import { Singleton } from "../../../Common/Singleton";
import { DefaultKJImportOption } from "../../../Editor/DefaultConfig"; import { DefaultKJImportOption } from "../../../Editor/DefaultConfig";
import { IConfigOption } from "../../../UI/Components/Board/UserConfig"; import { IConfigOption } from "../../../UI/Components/Board/UserConfig";
import { AppToaster } from "../../../UI/Components/Toaster"; import { AppToaster } from "../../../UI/Components/Toaster";
import { KJLImportConfigOption } from "../../../UI/Store/BoardInterface"; import { IUiOption, KJLImportConfigOption } from "../../../UI/Store/BoardInterface";
import { IConfigStore } from "../../../UI/Store/BoardStore"; import { IConfigStore } from "../../../UI/Store/BoardStore";
import { KJLUseName } from "./KJLConfig";
export interface MaterialOption export interface MaterialOption
{ {
@ -24,6 +25,7 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore
@observable configName: string = "默认"; @observable configName: string = "默认";
@observable configsNames: string[] = []; @observable configsNames: string[] = [];
@observable m_Option: KJLImportConfigOption = { ...DefaultKJImportOption }; @observable m_Option: KJLImportConfigOption = { ...DefaultKJImportOption };
@observable m_uiEdgeValueMap: IUiOption<[string, string][]>;
@observable materialList: MaterialOption[] = []; @observable materialList: MaterialOption[] = [];
@observable selectAll = false; @observable selectAll = false;
private queue = new PQueue({ concurrency: 100 }); private queue = new PQueue({ concurrency: 100 });
@ -31,9 +33,17 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore
InitOption() InitOption()
{ {
Object.assign(this.m_Option, DefaultKJImportOption); Object.assign(this.m_Option, DefaultKJImportOption);
this.m_uiEdgeValueMap = Array.from({ length: 20 }, () => ["", ""]);
this.LoadMaterials(); this.LoadMaterials();
}; };
get UIOption(): IUiOption<[string, string][]>
{
if (!this.m_uiEdgeValueMap)
this.m_uiEdgeValueMap = this.m_Option.edgeValueMap.map((d) => { return d[0] === 0 && d[1] === 0 ? ["", ""] : [d[0].toString(), d[1].toString()]; });
return this.m_uiEdgeValueMap;
}
SaveConfig() SaveConfig()
{ {
//保证保存的信息有效性 //保证保存的信息有效性
@ -53,6 +63,14 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore
this.LoadMaterials(); this.LoadMaterials();
} }
let filter = this.m_uiEdgeValueMap.filter(d => { return !isNaN(parseFloat(d[0])) && !isNaN(parseFloat(d[1])); });
this.m_uiEdgeValueMap = Array.from({ length: 20 }, () => ["", ""]);
for (let i = 0; i < filter.length; i++)
{
this.m_uiEdgeValueMap[i] = filter[i];
}
this.m_Option.edgeValueMap = this.m_uiEdgeValueMap.map(d => { return [Number(d[0]), Number(d[1])]; });
//新的配置 //新的配置
let newConfig: IConfigOption = {}; let newConfig: IConfigOption = {};
newConfig.option = toJS(this.m_Option); newConfig.option = toJS(this.m_Option);
@ -65,6 +83,16 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore
cof.option.version = 2; cof.option.version = 2;
cof.option.isImportVirtualModel = true; cof.option.isImportVirtualModel = true;
} }
if (cof.option.version < 3)
{
cof.option.version = 3;
cof.option.edgeValueMap = Array.from({ length: 20 }, () => [0, 0]);
}
if (cof.option.version < 4)
{
cof.option.version = 4;
cof.option.kjlUseName = KJLUseName.modelName;
}
Object.assign(this.m_Option, cof.option); Object.assign(this.m_Option, cof.option);
this.LoadMaterials(); this.LoadMaterials();
} }

@ -1,3 +1,4 @@
import { KJLUseName } from "../Add-on/KJL/KJLImportConfig/KJLConfig";
import { Curve2RecOption } from "../Add-on/twoD2threeD/Modals/Curve2RecOption"; import { Curve2RecOption } from "../Add-on/twoD2threeD/Modals/Curve2RecOption";
import { IParseBoardNameOption, IRec2BrOption, IRect2Br2Option } from "../Add-on/twoD2threeD/R2bInterface"; import { IParseBoardNameOption, IRec2BrOption, IRect2Br2Option } from "../Add-on/twoD2threeD/R2bInterface";
import { EBoardKeyList } from "../Common/BoardKeyList"; import { EBoardKeyList } from "../Common/BoardKeyList";
@ -191,9 +192,11 @@ export const DefaultModifyTextsOption: ModifyTextsConfigOption = {
Object.freeze(DefaultModifyTextsOption); Object.freeze(DefaultModifyTextsOption);
export const DefaultKJImportOption: KJLImportConfigOption = { export const DefaultKJImportOption: KJLImportConfigOption = {
version: 2, version: 4,
materials: [], materials: [],
isImportVirtualModel: true isImportVirtualModel: true,
edgeValueMap: Array.from({ length: 20 }, () => [0, 0]),
kjlUseName: KJLUseName.modelName
}; };
Object.freeze(DefaultKJImportOption); Object.freeze(DefaultKJImportOption);

@ -1,3 +1,4 @@
import { KJLUseName } from "../../Add-on/KJL/KJLImportConfig/KJLConfig";
import { EBoardKeyList } from "../../Common/BoardKeyList"; import { EBoardKeyList } from "../../Common/BoardKeyList";
import { ObjectId } from "../../DatabaseServices/ObjectId"; import { ObjectId } from "../../DatabaseServices/ObjectId";
@ -205,6 +206,8 @@ export interface KJLImportConfigOption extends IBaseOption
{ {
materials: MaterialMapOption[]; materials: MaterialMapOption[];
isImportVirtualModel: boolean; isImportVirtualModel: boolean;
edgeValueMap: [number, number][];
kjlUseName: KJLUseName;
} }
export interface MaterialMapOption export interface MaterialMapOption
{ {

Loading…
Cancel
Save