!1830 优化:酒格补板添加板厚继承支持

pull/1837/MERGE
黄诗津 2 years ago committed by ChenX
parent 4be0349aed
commit af2b76e4a6

@ -2,6 +2,7 @@ import { Vector3 } from "three";
import { safeEval } from "../../Common/eval";
import { Log } from "../../Common/Log";
import { Board } from "../../DatabaseServices/Entity/Board";
import { TemplateWineRackRecord } from "../../DatabaseServices/Template/ProgramTempate/TemplateWineRackRecord";
import { TemplateRecord } from "../../DatabaseServices/Template/TemplateRecord";
import { MoveMatrix } from "../../Geometry/GeUtils";
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
@ -258,3 +259,24 @@ export function ExtendsBoardThickness(temp: TemplateRecord, thickness: number)
}
}
}
export function ExtendsbrThick2(temp: TemplateWineRackRecord)
{
let bh2Par = temp.GetParam("BH2");
if (bh2Par)
{
let bh2 = temp.Option.brThick2;
bh2Par.value = bh2;
if (temp.Option.isExtendsBH2)
{
if (temp.Parent)
{
let rootBh = safeEval(temp.Root.GetParam("BH")?.value as string);
bh2Par.expr = rootBh === bh2 ? "$BH" : bh2;
}
}
else
{
bh2Par.expr = "";
}
}
}

@ -1,4 +1,6 @@
import { app } from "../../ApplicationServices/Application";
import { TemplateParam } from "../../DatabaseServices/Template/Param/TemplateParam";
import { TemplateParamType } from "../../DatabaseServices/Template/Param/TemplateParamType";
import { TemplateWineRackRecord } from "../../DatabaseServices/Template/ProgramTempate/TemplateWineRackRecord";
import { SetTemplatePositionAndSetParent } from "../../DatabaseServices/Template/TempateUtils";
import { Command } from "../../Editor/CommandMachine";
@ -19,6 +21,15 @@ export class DrawWineRack implements Command
await userConfigStore.InitWinerackConfig();
let wineRack = new TemplateWineRackRecord().InitBaseParams();
if (!wineRack.GetParam("BH2"))
{
let bh2 = new TemplateParam();
bh2.name = "BH2";
bh2.description = "补板厚";
bh2.type = TemplateParamType.Float;
bh2.value = wineRack.Option.brThick2;
wineRack.Params.push(bh2);
}
wineRack.Option = userConfig.winerackConfig;
app.Database.TemplateTable.Append(wineRack);

@ -35,11 +35,13 @@ export class TemplateWineRackRecord extends TemplateRecord
{
await super.Update();
let thickness = this.GetParam("BH")?.value as number;
if (thickness)
{
this.option.boardThick = thickness;
}
let bh = this.GetParam("BH")?.value as number;
if (bh)
this.option.boardThick = bh;
let bh2 = this.GetParam("BH2")?.value as number;
if (bh2)
this.option.brThick2 = bh2;
let wineRack: DrawWineRackTool;
if (this.option.type === EWineRackType.Oblique)

@ -1,5 +1,6 @@
import { Intent } from "@blueprintjs/core";
import { Box3, Matrix4, Vector3 } from "three";
import { ExtendsbrThick2 } from "../../Add-on/DrawBoard/BuildBoardTool";
import { app } from "../../ApplicationServices/Application";
import { arrayRemoveOnce } from "../../Common/ArrayExt";
import { safeEval } from "../../Common/eval";
@ -46,6 +47,7 @@ import { TemplateStretchScaleBoxAction } from "./Action/TemplateStretchScaleBoxA
import { PositioningClampSpace } from './Positioning/PositioningClampSpace';
import { PositioningTemporary } from "./Positioning/PositioningTemporary";
import { TemplateVisualSpace } from "./ProgramTempate/TemplateVisualSpace";
import { TemplateWineRackRecord } from "./ProgramTempate/TemplateWineRackRecord";
import { TemplateRecord } from "./TemplateRecord";
/**
@ -1359,6 +1361,11 @@ export async function SetTemplatePositionAndSetParent(spaceParse: ISpaceParse, t
template.GetParam("BH").expr = "_BH";
}
if (template instanceof TemplateWineRackRecord)
{
ExtendsbrThick2(template);
}
await template.UpdateTemplateTree();
//特殊情况 还没预料到的 (我们已经处理了 (抽屉 门板)(虚拟空间) (酒格 左侧版 层板 立板 背板)(自动生成板) 应该都是没有问题的)

@ -74,7 +74,7 @@ export const DefaultBehindBoardConfig: BehindBoardOption = {
Object.freeze(DefaultBehindBoardConfig);
export const DefaultWineRackConfig: IWineRackOption = {
version: 2,
version: 3,
type: EWineRackType.Oblique,
arrayType: EWRackArrayType.ByWidth,
fullType: EFullType.ByWidth,
@ -101,6 +101,7 @@ export const DefaultWineRackConfig: IWineRackOption = {
isDrawLy: false,
isDrawVer: false,
brThick2: 18,
isExtendsBH2: false,
followNarrow: false,
};
Object.freeze(DefaultWineRackConfig);

@ -3,11 +3,14 @@ import { IconNames } from '@blueprintjs/icons';
import { observer } from 'mobx-react';
import * as React from 'react';
import * as xaop from 'xaop';
import { ExtendsbrThick2 } from '../../../Add-on/DrawBoard/BuildBoardTool';
import { app } from '../../../ApplicationServices/Application';
import { CheckObjectType } from '../../../Common/CheckoutVaildValue';
import { safeEval } from '../../../Common/eval';
import { KeyBoard } from '../../../Common/KeyEnum';
import { FixedNotZero } from '../../../Common/Utils';
import { TemplateParam } from '../../../DatabaseServices/Template/Param/TemplateParam';
import { TemplateParamType } from '../../../DatabaseServices/Template/Param/TemplateParamType';
import { commandMachine, CommandWrap } from '../../../Editor/CommandMachine';
import { userConfig } from '../../../Editor/UserConfig';
import { EFullDir, EFullType, EWineRackType, EWRackArrayType } from '../../Store/WineRackInterface';
@ -18,6 +21,9 @@ import { AppToaster, ToasterValueError } from '../Toaster';
import { Input5Or4Component, SetBoardDataBlock, SetBoardDataItem } from './BoardCommon';
import { BoardModalType } from './BoardModal';
const titleLenght: React.CSSProperties = {
width: "3.5rem"
};
@observer
export class WineRackModal extends React.Component<{ store?: WineRackStore; }, {}>
{
@ -49,7 +55,17 @@ export class WineRackModal extends React.Component<{ store?: WineRackStore; }, {
await CommandWrap(async () =>
{
let temp = this.props.store.EditorTemplate;
if (!temp.GetParam("BH2"))
{
let bh2 = new TemplateParam();
bh2.name = "BH2";
bh2.description = "补板厚";
bh2.type = TemplateParamType.Float;
bh2.value = 0;
temp.Params.push(bh2);
}
temp.Option = opt;
ExtendsbrThick2(temp);
await temp.UpdateTemplateTree();
app.Editor.UpdateScreen();
this.props.store.EditorTemplate = undefined;
@ -340,13 +356,25 @@ export class WineRackModal extends React.Component<{ store?: WineRackStore; }, {
</div>
</div>
<H5></H5>
<SetBoardDataItem
type={CheckObjectType.WR}
optKey="brThick2"
option={m_Option}
uiOption={UIOption}
title="补板厚"
/>
<div style={{ display: "flex" }}>
<SetBoardDataItem
type={CheckObjectType.WR}
optKey="brThick2"
titleStyle={titleLenght}
option={m_Option}
uiOption={UIOption}
title="补板厚"
/>
<Checkbox
checked={m_Option.isExtendsBH2}
label="继承"
inline={true}
style={{ marginRight: 0, marginLeft: 3 }}
onChange={() =>
{
m_Option.isExtendsBH2 = !m_Option.isExtendsBH2;
}} />
</div>
<div>
<Checkbox
checked={m_Option.isDrawLy}

@ -57,6 +57,7 @@ export interface IWineRackOption extends IBaseOption
isDrawLy: boolean;
isDrawVer: boolean;
brThick2: number; //补板厚
isExtendsBH2: boolean;//是否继承
followNarrow: boolean;//酒格补板前缩跟随
}

@ -24,18 +24,24 @@ export class WineRackStore extends BoardStore<IWineRackOption>
{
//新的配置
let newConfig: IConfigOption<IWineRackOption> = {};
this.m_Option.version = 2;
newConfig.option = toJS(this.m_Option);
return newConfig;
}
UpdateOption(cof: IConfigOption)
{
if (cof.option.version < 2)
{
cof.option.version = 2;
cof.option.followNarrow = false;
}
if (cof.option.version < 3)
{
cof.option.version = 3;
cof.option.isInherit = false;
}
Object.assign(this.m_Option, cof.option);
if (this.m_UiOption)
Object.assign(this.m_UiOption, DataAdapter.ConvertUIData(cof.option));
if (cof.option.version < 2)
this.m_Option.followNarrow = false;
else
this.m_Option.followNarrow = Boolean(cof.option.followNarrow);
}
}

Loading…
Cancel
Save