!2109 功能:斜酒格样式新增半格优先画法

pull/1970/MERGE
黄诗津 1 year ago committed by ChenX
parent b091bc6a9a
commit e5b45c110a

@ -8,7 +8,7 @@ import { AsVector2, equaln, equalv3, isParallelTo, MoveMatrix, polar, XAxis, YAx
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
import { IntersectOption } from "../../GraphicsSystem/IntersectWith";
import { BoardType } from "../../UI/Store/BoardInterface";
import { EFullDir, EFullType, EWRackArrayType, IR2WROption, IWineRackOption } from "../../UI/Store/WineRackInterface";
import { EFullDir, EFullType, EWineRackStyle, EWRackArrayType, IR2WROption, IWineRackOption } from "../../UI/Store/WineRackInterface";
import { DrawWineRackTool, SIN45 } from "./DrawWinRackTool";
export interface IWineRackData
@ -30,6 +30,17 @@ export interface IParsePlRes
isRo?: boolean;
}
interface GetWineRackDataOption
{
width: number,
height: number,
gripWidth: number,
brThick: number,
widthCount: number,
heightCount: number,
lWRDataList: IWineRackData[],
rWRDataList: IWineRackData[],
}
export const R2WRTolerance = 1e-3;
/**
@ -92,16 +103,17 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
let lWRData: IWineRackData[] = [];
let rWRData: IWineRackData[] = [];
let res: { width: number, height: number; };
let wineRackStyle = config.wineRackStyle;
switch (config.arrayType)
{
case EWRackArrayType.ByWidth:
res = this.CalcWineRackDataByWidth(lWRData, rWRData);
res = this.CalcWineRackDataByWidth(lWRData, rWRData, wineRackStyle);
break;
case EWRackArrayType.ByCount:
res = this.CalcWineRackDataByCount(lWRData, rWRData);
res = this.CalcWineRackDataByCount(lWRData, rWRData, wineRackStyle);
break;
case EWRackArrayType.Fixed:
res = this.CalcWineRackDataByFixed(lWRData, rWRData);
res = this.CalcWineRackDataByFixed(lWRData, rWRData, wineRackStyle);
}
let pls: Polyline[] = [];
for (let data of lWRData)
@ -164,7 +176,7 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
return false;
}
/**按格子宽获取酒格数据 */
private CalcWineRackDataByWidth(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
private CalcWineRackDataByWidth(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[], wineRackStyle: EWineRackStyle)
{
let size = this.space.Size;
let Config = this.Config;
@ -208,12 +220,12 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
width = widthCount * gripWidth + 2 * Config.boardThick * SIN45;
height = size.z;
}
this.GetWineRackData(width, height, gripWidth, Config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList);
this.GetWineRackData({ width, height, gripWidth, brThick: Config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList }, wineRackStyle);
return {
width: width, height: height
};
}
private CalcWineRackDataByCount(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
private CalcWineRackDataByCount(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[], wineRackStyle: EWineRackStyle)
{
const config = this.Config;
const size = this.space.Size;
@ -244,12 +256,12 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
height = size.z;
}
this.GetWineRackData(width, height, gripWidth, config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList);
this.GetWineRackData({ width, height, gripWidth, brThick: config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList }, wineRackStyle);
return {
width: width, height: height
};
}
CalcWineRackDataByFixed(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[])
CalcWineRackDataByFixed(lWRDataList: IWineRackData[], rWRDataList: IWineRackData[], wineRackStyle: EWineRackStyle)
{
const config = this.Config;
let widthCount = Math.floor(config.widthCount * 2);
@ -258,7 +270,7 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
let width = widthCount * gripWidth + 2 * config.boardThick * SIN45;
let height = heightCount * gripWidth + 2 * config.boardThick * SIN45;
this.GetWineRackData(width, height, gripWidth, config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList);
this.GetWineRackData({ width, height, gripWidth, brThick: config.boardThick, widthCount, heightCount, lWRDataList, rWRDataList }, wineRackStyle);
return {
width: width, height: height
};
@ -326,16 +338,197 @@ export class DrawObliqueWineRackTool extends DrawWineRackTool
pl.CloseMark = true;
return pl;
}
//获取酒格数据
GetWineRackData(width: number,
GetWineRackData(option: GetWineRackDataOption, wineRackStyle: EWineRackStyle)
{
switch (wineRackStyle)
{
case EWineRackStyle.Semilattice:
this.GetWineRackDataPreferentialSemilattice(option);
break;
case EWineRackStyle.WholeLattice:
this.GetWineRackDataPreferentialWholeLattice(option);
break;
}
}
/**
*
* @param {{width: number
* height: number
* gripWidth: number
* brThick: number
* widthCount: number
* heightCount: number
* lWRDataList: IWineRackData[],
* rWRDataList: IWineRackData[],
* }} option
* @memberof DrawObliqueWineRackTool
*/
GetWineRackDataPreferentialSemilattice(option: {
width: number,
height: number,
gripWidth: number,
brThick: number,
widthCount: number,
heightCount: number,
lWRDataList: IWineRackData[], //往左倒
rWRDataList: IWineRackData[], //往右倒
})
{
const { width, height, gripWidth, brThick, widthCount, heightCount, lWRDataList, rWRDataList } = option;
/** 板厚对角的一半 */
const brThickDiagonal = brThick * SIN45;
for (let i = 0, Lenght = Math.floor((widthCount + 1) / 2); i < Lenght; i++)
{
let p1 = brThickDiagonal + gripWidth * i * 2;
let data = {
basePt: new Vector3(p1, 0, 0),
brLength: 0
};
if (width - p1 >= height - brThickDiagonal)
{
data.brLength = (height - brThickDiagonal) / SIN45;
}
else
{
data.brLength = (width - p1) / SIN45;
}
rWRDataList.push(data);
}
for (let i = 0, Lenght = Math.floor((heightCount - 1) / 2); i < Lenght; i++)
{
let p1 = (i + 1) * gripWidth * 2;
let data = {
basePt: new Vector3(brThickDiagonal, p1, 0),
brLength: 0
};
if (height - p1 > width - brThickDiagonal)
{
data.brLength = (width - brThickDiagonal) / SIN45;
}
else
{
data.brLength = (height - p1 - brThickDiagonal) / SIN45;
}
rWRDataList.push(data);
}
for (let i = 0, flag = true, Lenght = Math.floor((widthCount - 1) / 2); i < Lenght; i++)
{
let p1 = brThickDiagonal + gripWidth * (i + 1) * 2;
let data = {
basePt: new Vector3(p1, brThickDiagonal * 2, 0),
brLength: 0
};
if (p1 >= height - brThickDiagonal)
{
if (flag && heightCount % 2 === 0)
data.brLength = (height - brThickDiagonal * 2) / SIN45;
else
data.brLength = (height - brThickDiagonal * 3) / SIN45;
flag = false;
}
else
{
data.brLength = (p1 - brThickDiagonal * 2) / SIN45;
}
lWRDataList.push(data);
}
if (widthCount % 2 === 0)
{
for (let i = 0, flag = true, Lenght = Math.ceil(heightCount / 2); i < Lenght; i++)
{
let p1 = height - gripWidth * 2 * (i - 1) - gripWidth * (heightCount % 2 === 0 ? 2 : 1);
let data = {
basePt: new Vector3(width - brThickDiagonal, p1, 0),
brLength: 0
};
if (i === 0)
{
data.basePt = new Vector3(width, brThickDiagonal, 0);
if (height === width)
{
data.brLength = (width - brThickDiagonal) / SIN45;
flag = false;
}
else
{
data.brLength = (Math.min(width, height) - brThickDiagonal * 2) / SIN45;
}
}
else
{
if (height - p1 + brThickDiagonal * 2 >= width)
{
if (flag)
data.brLength = (width - brThickDiagonal * 2) / SIN45;
else
data.brLength = (width - brThickDiagonal * 3) / SIN45;
flag = false;
}
else
{
data.brLength = (height - p1 - brThickDiagonal) / SIN45;
}
}
lWRDataList.push(data);
}
}
else
{
for (let i = 0, flag = true, Lenght = Math.floor(heightCount / 2); i < Lenght; i++)
{
let p1 = height - gripWidth * 2 * i - gripWidth * (heightCount % 2 === 0 ? 1 : 2);
let data = {
basePt: new Vector3(width - brThickDiagonal, p1, 0),
brLength: 0
};
if (height - p1 + brThickDiagonal * 2 >= width)
{
if (flag)
data.brLength = (width - brThickDiagonal * 2) / SIN45;
else
data.brLength = (width - brThickDiagonal * 3) / SIN45;
flag = false;
}
else
{
data.brLength = (height - p1 - brThickDiagonal) / SIN45;
}
lWRDataList.push(data);
}
}
}
/**
*
* @param {{width: number
* height: number
* gripWidth: number
* brThick: number
* widthCount: number
* heightCount: number
* lWRDataList: IWineRackData[], //往左倒
* rWRDataList: IWineRackData[], //往右倒
* }} option
* @memberof DrawObliqueWineRackTool
*/
GetWineRackDataPreferentialWholeLattice(option: {
width: number,
height: number,
gripWidth: number,
brThick: number,
widthCount: number,
heightCount: number,
lWRDataList: IWineRackData[],
rWRDataList: IWineRackData[])
lWRDataList: IWineRackData[], //往左倒
rWRDataList: IWineRackData[], //往右倒
})
{
const { width, height, gripWidth, brThick, widthCount, heightCount, lWRDataList, rWRDataList } = option;
let data: IWineRackData;
for (let i = 0; i < Math.floor(widthCount / 2); i++)
{

@ -120,11 +120,14 @@ export class TemplateWineRackRecord extends TemplateRecord
if (ver > 1)
this.option.followNarrow = file.Read();
if (ver > 2)
this.option.wineRackStyle = file.Read();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFiler)
{
file.Write(2);
file.Write(3);
super.WriteFile(file);
file.Write(this.option.type);
file.Write(this.option.arrayType);
@ -156,6 +159,8 @@ export class TemplateWineRackRecord extends TemplateRecord
file.Write(this.option.isDrawVer);
file.Write(this.option.brThick2);
file.Write(this.option.followNarrow);
file.Write(this.option.wineRackStyle);
}
//#endregion
}

@ -10,7 +10,7 @@ import { BehindBoardOption, BehindHeightPositon, BoardProcessOption, BoardType,
import { DoorPosType, HandleHorPos, HandleVePos, IDoorConfigOption, IDrawerConfigOption, IHingeConfigOption } from "../UI/Store/DoorInterface";
import { IHSOption } from "../UI/Store/HSInterface";
import { ELatticeArrayType, ILatticeOption } from "../UI/Store/LatticeInterface";
import { EFullDir, EFullType, EWineRackType, EWRackArrayType, IWineRackOption } from "../UI/Store/WineRackInterface";
import { EFullDir, EFullType, EWineRackStyle, EWineRackType, EWRackArrayType, IWineRackOption } from "../UI/Store/WineRackInterface";
import { EOrderType } from "./OrderType";
export const DefaultLayerBoardConfig: LayerBoardOption = {
@ -75,8 +75,9 @@ export const DefaultBehindBoardConfig: BehindBoardOption = {
Object.freeze(DefaultBehindBoardConfig);
export const DefaultWineRackConfig: IWineRackOption = {
version: 3,
version: 4,
type: EWineRackType.Oblique,
wineRackStyle: EWineRackStyle.WholeLattice,
arrayType: EWRackArrayType.ByWidth,
fullType: EFullType.ByWidth,
isFull: false,

@ -14,7 +14,7 @@ import { TemplateParam } from '../../../DatabaseServices/Template/Param/Template
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';
import { EFullDir, EFullType, EWineRackStyle, EWineRackType, EWRackArrayType } from '../../Store/WineRackInterface';
import { WineRackStore } from '../../Store/WineRackStore';
import { GetCompoentObjectIdString } from '../ComponentObjectId';
import { CommonModal } from '../Modal/ModalContainer';
@ -300,6 +300,23 @@ export class WineRackModal extends React.Component<{ store?: WineRackStore; }, {
<Radio label="斜酒格" value={EWineRackType.Oblique} />
<Radio label="正酒格" value={EWineRackType.Upright} />
</RadioGroup>
{
store.m_Option.type === EWineRackType.Oblique &&
<>
<H5></H5>
<RadioGroup
inline={true}
selectedValue={store.m_Option.wineRackStyle}
onChange={(e) =>
{
store.m_Option.wineRackStyle = parseInt(e.currentTarget.value);
}}
>
<Radio label="整格优先" value={EWineRackStyle.WholeLattice} />
<Radio label="半格优先" value={EWineRackStyle.Semilattice} />
</RadioGroup>
</>
}
<H5></H5>
<RadioGroup
selectedValue={store.m_Option.arrayType}

@ -7,6 +7,13 @@ export enum EWineRackType
Upright = 1,
}
/**酒格样式 */
export enum EWineRackStyle
{
WholeLattice = 0,//全格优先
Semilattice = 1, //半格优先
}
export enum EWRackArrayType
{
ByWidth = 0,
@ -32,6 +39,7 @@ export enum EFullDir
export interface IWineRackOption extends IBaseOption
{
type: EWineRackType;
wineRackStyle: EWineRackStyle,
arrayType: EWRackArrayType;
fullType: EFullType;
isFull: boolean;

@ -5,7 +5,7 @@ import { TemplateWineRackRecord } from "../../DatabaseServices/Template/ProgramT
import { DefaultWineRackConfig } from "../../Editor/DefaultConfig";
import { IConfigOption } from "../Components/Board/UserConfigComponent";
import { BoardStore } from "./BoardStore";
import { IWineRackOption } from "./WineRackInterface";
import { EWineRackStyle, IWineRackOption } from "./WineRackInterface";
export class WineRackStore extends BoardStore<IWineRackOption>
{
@ -39,6 +39,11 @@ export class WineRackStore extends BoardStore<IWineRackOption>
cof.option.version = 3;
cof.option.isInherit = false;
}
if (cof.option.version < 4)
{
cof.option.version = 4;
cof.option.wineRackStyle = EWineRackStyle.WholeLattice;
}
Object.assign(this.m_Option, cof.option);
if (this.m_UiOption)
Object.assign(this.m_UiOption, DataAdapter.ConvertUIData(cof.option));

Loading…
Cancel
Save