!2565 功能:自由标注增加过滤标注数值UI

pull/2564/MERGE
林三 8 months ago committed by ChenX
parent 6f69bda20e
commit aa17bcd3b4

@ -66,48 +66,13 @@ export class DimBoards
this.DoDim();
}
/**
*
*/
FilterForBoardNameType = (br: Board) =>
{
if (this.FilterDimForBoardNameSet.size)
{
switch (this.ForBoardNameType)
{
case ForBoardNameType.Same:
return !this.FilterDimForBoardNameSet.has(br.Name);
case ForBoardNameType.NoSame:
return this.FilterDimForBoardNameSet.has(br.Name);
case ForBoardNameType.Include:
for (let name of this.FilterDimForBoardNameSet)
{
if (br.Name.includes(name))
return false;
}
return true;
case ForBoardNameType.NoInclude:
for (let name of this.FilterDimForBoardNameSet)
{
if (!br.Name.includes(name))
return false;
}
return true;
default:
break;
}
}
return true;
};
/**
* (+)
* (1:,2)
*/
private ParseBoardGroups(brs: Board[])
{
brs = brs.filter((br) => { return (this.FilterForBoardNameType(br) && FilterDimBoardFn(br)); });
brs = brs.filter((br) => { return (FilterForBoardNameType(br, this.FilterDimForBoardNameSet, this.ForBoardNameType) && FilterDimBoardFn(br)); });
while (brs.length)
{
@ -786,3 +751,37 @@ export function FilterDimBoardFn(br: Board): boolean
return true;
}
/**
*
*/
export function FilterForBoardNameType(br: Board, filterDimForBoardNames: Set<string>, forBoardNameType: ForBoardNameType)
{
if (filterDimForBoardNames.size)
{
switch (forBoardNameType)
{
case ForBoardNameType.Same:
return !filterDimForBoardNames.has(br.Name);
case ForBoardNameType.NoSame:
return filterDimForBoardNames.has(br.Name);
case ForBoardNameType.Include:
for (let name of filterDimForBoardNames)
{
if (br.Name.includes(name))
return false;
}
return true;
case ForBoardNameType.NoInclude:
for (let name of filterDimForBoardNames)
{
if (!br.Name.includes(name))
return false;
}
return true;
default:
break;
}
}
return true;
};

@ -1,15 +1,20 @@
import { Intent } from "@blueprintjs/core";
import { Box3, Vector3 } from "three";
import { app } from "../../ApplicationServices/Application";
import { arrayRemoveDuplicateBySort, arraySortByNumber } from "../../Common/ArrayExt";
import { Draw } from "../../Common/Draw";
import { LogType } from "../../Common/Log";
import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension";
import { Board } from "../../DatabaseServices/Entity/Board";
import { Command } from "../../Editor/CommandMachine";
import { JigUtils } from "../../Editor/JigUtils";
import { PromptSsgetResult, PromptStatus } from "../../Editor/PromptResult";
import { equalnn } from "../../Geometry/GeUtils";
import { DimBoards, FilterDimBoardFn } from "./DimBoards";
import { app } from "../../../ApplicationServices/Application";
import { arrayRemoveDuplicateBySort, arraySortByNumber } from "../../../Common/ArrayExt";
import { Draw } from "../../../Common/Draw";
import { LogType } from "../../../Common/Log";
import { AlignedDimension } from "../../../DatabaseServices/Dimension/AlignedDimension";
import { Board } from "../../../DatabaseServices/Entity/Board";
import { Command } from "../../../Editor/CommandMachine";
import { JigUtils } from "../../../Editor/JigUtils";
import { PromptSsgetResult, PromptStatus } from "../../../Editor/PromptResult";
import { equalnn } from "../../../Geometry/GeUtils";
import { ModalState } from "../../../UI/Components/Modal/ModalInterface";
import { AppToaster } from "../../../UI/Components/Toaster";
import { DimBoards, FilterDimBoardFn, FilterForBoardNameType } from "../DimBoards";
import { FastDimPanel } from "./FastDimPanel";
import { fastDimStore } from "./FastDimStore";
enum Direction
{
@ -42,14 +47,31 @@ export class Command_FastDimBrs implements Command
if (enRes.Status === PromptStatus.Cancel) return;
const store = fastDimStore;
const option = store.m_Option;
app.Editor.ModalManage.RenderModeless(FastDimPanel, { store }, { canMinimize: false });
let res = await app.Editor.ModalManage.Wait();
if (res.Status !== ModalState.Ok) return;
let brs = enRes.SelectSet.SelectEntityList as Board[];
let filterAppointForBoardNameValues: Set<string> = new Set();
//获取根据板名条件过滤的关键字
if (option.filterAppointForBoardName && option.filterAppointForBoardNameValues)
{
for (let str of option.filterAppointForBoardNameValues.split(/[' ','\,','\|']/))
if (str) filterAppointForBoardNameValues.add(str);
}
//根据板名条件过滤
brs = brs.filter((br) => FilterForBoardNameType(br, filterAppointForBoardNameValues, option.conditionType));
//排除旋转角度非90度倍数的板件
brs = brs.filter(FilterDimBoardFn);
if (brs.length === 0)
{
app.Editor.Prompt(`可标注板件数: 0, 已退出`, LogType.Error);
app.Editor.Prompt(`可标注板件数: 0, 已退出`, LogType.Error);
return;
}
@ -57,6 +79,13 @@ export class Command_FastDimBrs implements Command
let tool = new FastDimTool(brs);
tool.enableDimAll = dimAll;
tool.filterSmallSize = option.filterSmallSize;
tool.filterSmallSizeValue = option.filterSmallSizeValue;
tool.filterAppointSize = option.filterAppointSize;
if (tool.filterAppointSize && option.filterAppointSizeValues)
for (let str of option.filterAppointSizeValues.split(/[' ','\,','\|']/))
tool.filterAppointSizeValues.add(str);
let oldState = Direction.left;
@ -94,6 +123,18 @@ export class Command_FastDimBrs implements Command
while (true)
{
let als = CreateDims(new Vector3);
//al.Visible = false 为过滤的标注 以便标注避让的时候正常工作.只是我们不再画它
if (!als.filter(al => al.Visible).length)
{
AppToaster.show({
message: "没有符合的标注长度!",
timeout: 5000,
intent: Intent.WARNING,
});
return;
}
let ptRes = await app.Editor.GetPoint({
Msg: "指定尺寸线位置:",
KeyWordList: [{ msg: tool.enableDimAll ? "关闭整体标注" : "整体标注", key: "S" }],
@ -101,7 +142,8 @@ export class Command_FastDimBrs implements Command
{
let als = CreateDims(p);
for (let al of als)
JigUtils.Draw(al);
if (al.Visible) //al.Visible = false 为过滤的标注 以便标注避让的时候正常工作.只是我们不再画它
JigUtils.Draw(al);
}
});
@ -113,7 +155,8 @@ export class Command_FastDimBrs implements Command
{
let als = CreateDims(ptRes.Point);
for (let al of als)
Draw(al);
if (al.Visible) //al.Visible = false 为过滤的标注 以便标注避让的时候正常工作.只是我们不再画它
Draw(al);
}
return;
}
@ -124,13 +167,16 @@ export class Command_FastDimBrs implements Command
export class FastDimTool
{
//这个UCS会比适当的修改,保证绘图平面和选择的板在一个平面内
ucs = app.Editor.UCSMatrix;
ucsInv = app.Editor.UCSMatrixInv;
allBox = new Box3;
footss: [number[], number[]] = [[], []];
enableDimAll = true;//全长标注
filterSmallSize: boolean = false;
filterSmallSizeValue: number = 0;
filterAppointSize: boolean = false;
filterAppointSizeValues: Set<string> = new Set();
constructor(
public brs: Board[]
)
@ -188,6 +234,14 @@ export class FastDimTool
let alDim = new AlignedDimension(f1, f2, a1, a2);
alDim.ApplyMatrix(this.ucs);
let length = parseFloat(alDim.TextString);
//过滤小尺寸或过滤指定尺寸 al.Visible = false 为过滤的标注 以便标注避让的时候正常工作.只是我们不再画它
if (this.filterSmallSize && length <= this.filterSmallSizeValue ||
this.filterAppointSize && this.filterAppointSizeValues.has(alDim.TextString)
)
alDim.Visible = false;
als.push(alDim);
}

@ -0,0 +1,269 @@
import { Button, Checkbox, Classes, HTMLSelect, Intent, Position, Tooltip } from '@blueprintjs/core';
import { autorun, observable } from 'mobx';
import { observer } from 'mobx-react';
import React from 'react';
import { begin } from 'xaop';
import { app } from '../../../ApplicationServices/Application';
import { KeyBoard } from '../../../Common/KeyEnum';
import { safeEval } from '../../../Common/eval';
import { BoardModalType } from '../../../UI/Components/Board/BoardModalType';
import { UserConfigComponent } from '../../../UI/Components/Board/UserConfigComponent';
import { ModalHeader } from '../../../UI/Components/Modal/ModalContainer';
import { ModalState } from '../../../UI/Components/Modal/ModalInterface';
import { ForBoardNameType } from '../../../UI/Store/OptionInterface/AutoDimBrsOption';
import { FastDimStore } from './FastDimStore';
enum EDimType
{
filterSmallSize = "filterSmallSize", //过滤小尺寸
filterAppointSize = "filterAppointSize", //过滤指定尺寸
filterAppointForBoardName = "filterAppointForBoardName",///根据板名过滤
}
@observer
export class FastDimPanel extends React.Component<{ store: FastDimStore; }> {
_Event: Function[] = [];
@observable _StrIllegal = false;
_NoShowMinSizeInput: React.RefObject<HTMLInputElement> = React.createRef();
_NoShowAppointDimSizeInput: React.RefObject<HTMLInputElement> = React.createRef();
_ForBoardNameInput: React.RefObject<HTMLInputElement> = React.createRef();
componentDidMount()
{
this._Event.push(
begin(app.Editor.ModalManage, app.Editor.ModalManage.OnKeyDown, (e: KeyboardEvent) =>
{
if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space)
{
this._OnOk();
e.preventDefault();
}
e.stopPropagation();
return true;
})
);
this._Event.push(
autorun(() =>
{
if (this._NoShowAppointDimSizeInput)
this._NoShowAppointDimSizeInput.current.value = this.props.store.m_Option.filterAppointSizeValues;
if (this._NoShowMinSizeInput)
this._NoShowMinSizeInput.current.value = this.props.store.m_Option.filterSmallSizeValue.toFixed();
if (this._ForBoardNameInput)
this._ForBoardNameInput.current.value = this.props.store.m_Option.filterAppointForBoardNameValues;
})
);
}
componentWillUnmount()
{
for (let f of this._Event) f();
this._Event.length = 0;
}
render()
{
const option = this.props.store.m_Option;
return (
<div id='AutoDimBoardConfig' className={Classes.DIALOG_CONTAINER}>
<div className={Classes.DIALOG + " autoDimBoardConfig"}>
<ModalHeader
title={"自由标注配置"}
close={this._Cancel}
icon="cog"
/>
<div className={Classes.DIALOG_BODY}>
<div className='dimInputGroup'>
<Checkbox label="过滤小尺寸标注" checked={option.filterSmallSize} onChange={() => this._OnChange(EDimType.filterSmallSize)} />
<input
className="bp3-input br-process-input"
tabIndex={1}
ref={this._NoShowMinSizeInput}
defaultValue={option.filterSmallSizeValue}
min={1}
style={{ width: 50, height: 28 }}
onKeyDown={(e) =>
{
switch (e.keyCode)
{
case KeyBoard.Escape:
case KeyBoard.Space:
case KeyBoard.Enter:
e.currentTarget.blur();
e.stopPropagation();
break;
default:
break;
}
}}
onBlur={(e) =>
{
let val = safeEval(e.target.value);
if (!isNaN(val))
option.filterSmallSizeValue = parseFloat(e.currentTarget.value);
else
e.target.value = option.filterSmallSizeValue.toFixed();
}}
/>
</div>
<div className='dimInputGroup'>
<Checkbox label="过滤指定数值标注" checked={option.filterAppointSize} onChange={() => this._OnChange(EDimType.filterAppointSize)} />
<Tooltip
content={"请输入大于0的数字! 多个数字可以用 ' | ' 或 逗号 或 空格 相隔!"}
position={Position.TOP}
intent={Intent.WARNING}
isOpen={this._StrIllegal}
>
<Tooltip content="多个数字可以用 ' | ' 或 逗号 或 空格 相隔">
<input
className="bp3-input br-process-input"
tabIndex={1}
type={"text"}
ref={this._NoShowAppointDimSizeInput}
defaultValue={option.filterAppointSizeValues}
style={{ height: 28 }}
onKeyDown={(e) =>
{
switch (e.keyCode)
{
case KeyBoard.Escape:
case KeyBoard.Enter:
e.currentTarget.blur();
e.stopPropagation();
break;
case KeyBoard.Space:
e.stopPropagation();
break;
default:
break;
}
}}
onChange={(e) => { this._CheckStr(e); }}
onKeyUp={(e) => { e.currentTarget.value = e.currentTarget.value.replaceAll(//g, ','); }}
onBlur={(e) =>
{
if (this._StrIllegal)
{
e.currentTarget.value = option.filterAppointSizeValues;
this._StrIllegal = false;
}
else
{
if (e.currentTarget.value === '')
{
option.filterAppointSizeValues = '';
return;
}
//数字简化 0.100 => 0.1
let strArray = [];
let strArray2 = [];
let strArray3 = [];
for (let s1 of e.currentTarget.value.split(','))
{
strArray2 = [];
for (let s2 of s1.split(' '))
{
strArray3 = [];
for (let s3 of s2.split('|'))
{
strArray3.push(safeEval(s3));
}
strArray2.push(strArray3.join('|'));
}
strArray.push(strArray2.join(' '));
}
e.currentTarget.value = strArray.join(',');
option.filterAppointSizeValues = e.currentTarget.value;
}
}}
/>
</Tooltip>
</Tooltip>
</div>
<div className='dimInputGroup forBoardName'>
<Checkbox label="过滤指定板名条件标注" checked={option.filterAppointForBoardName} onChange={() => this._OnChange(EDimType.filterAppointForBoardName)} />
<HTMLSelect
style={{ width: 88 }}
options={
[
{ label: "相等", value: ForBoardNameType.Same },
{ label: "不相等", value: ForBoardNameType.NoSame },
{ label: "包含", value: ForBoardNameType.Include },
{ label: "不包含", value: ForBoardNameType.NoInclude },
]
}
value={option.conditionType}
onChange={e => option.conditionType = e.target.value as ForBoardNameType}
/>
</div>
<div className='dimInputGroup'>
<Tooltip content="多个板名可以用 ' | ' 或 逗号 或 空格 相隔">
<input
className="bp3-input br-process-input"
tabIndex={1}
type={"text"}
ref={this._ForBoardNameInput}
defaultValue={option.filterAppointForBoardNameValues}
style={{ height: 28, width: 248 }}
onKeyDown={(e) =>
{
switch (e.keyCode)
{
case KeyBoard.Escape:
case KeyBoard.Enter:
e.currentTarget.blur();
e.stopPropagation();
break;
case KeyBoard.Space:
e.stopPropagation();
break;
default:
break;
}
}}
onKeyUp={(e) => { e.currentTarget.value = e.currentTarget.value.replaceAll(//g, ','); }}
onBlur={(e) =>
{
option.filterAppointForBoardNameValues = e.currentTarget.value;
}}
/>
</Tooltip>
</div>
</div>
<div className={Classes.DIALOG_FOOTER}>
<UserConfigComponent type={BoardModalType.FastDim} store={this.props.store} />
<Button text="确定" intent={Intent.SUCCESS} onClick={this._OnOk} />
<Button text="取消" intent={Intent.DANGER} onClick={this._Cancel} />
</div>
</div>
</div>
);
}
_CheckStr = (e: React.ChangeEvent<HTMLInputElement>) =>
{
if (e.currentTarget.value === '') return;
let str = e.currentTarget.value.replaceAll(//g, ',');
//支持 ',' '|' '空格'
this._StrIllegal = !str.split(',').every(str1 => str1.split('|').every(str2 => str2.split(' ').every(str3 => { return !isNaN(safeEval(str3)) && safeEval(str3) > 0; })));
};
_OnChange = (key: string) =>
{
this.props.store.m_Option[key] = !this.props.store.m_Option[key];
};
_OnOk = () =>
{
app.Editor.ModalManage.DestoryAndExec({ Status: ModalState.Ok, });
};
_Cancel = () =>
{
app.Editor.ModalManage.Destory();
};
}

@ -0,0 +1,50 @@
import { observable, toJS } from "mobx";
import { DefaultFastDimOption } from "../../../Editor/DefaultConfig";
import { IConfigOption } from "../../../UI/Components/Board/UserConfigComponent";
import { IConfigStore } from "../../../UI/Store/BoardStore";
import { IFastDimOption } from "../../../UI/Store/OptionInterface/AutoDimBrsOption";
export class FastDimStore implements IConfigStore
{
@observable configName = "默认";
@observable configsNames: string[] = [];
@observable m_Option: IFastDimOption = { ...DefaultFastDimOption };
InitOption()
{
Object.assign(this.m_Option, DefaultFastDimOption);
}
InitConfigs()
{
let config: IConfigOption = {};
config.option = toJS(this.m_Option);
let configs: { [key: string]: IConfigOption; } = {};
configs["默认"] = config;
return configs;
}
SaveConfig()
{
//新的配置
let newConfig: IConfigOption = {};
newConfig.option = toJS(this.m_Option);
return newConfig;
};
UpdateOption(conf: IConfigOption<any>)
{
Object.assign(this.m_Option, conf.option);
}
private static _SingleInstance: FastDimStore;
static GetInstance(): FastDimStore
{
if (this._SingleInstance) return this._SingleInstance;
this._SingleInstance = new FastDimStore;
return this._SingleInstance;
}
}
export const fastDimStore = FastDimStore.GetInstance();

@ -79,7 +79,7 @@ import { DrawAlignedDimension } from "../Add-on/DrawDim/DrawAlignedDimension";
import { DrawDiameterDim } from "../Add-on/DrawDim/DrawDiameterDim";
import { DrawLinearDimension } from "../Add-on/DrawDim/DrawLinearDimension";
import { DrawRadiusDim } from "../Add-on/DrawDim/DrawRadiusDim";
import { Command_FastDimBrs } from "../Add-on/DrawDim/FastDim";
import { Command_FastDimBrs } from "../Add-on/DrawDim/FastDim/FastDim";
import { Command_HideDim, Command_ShowDim } from "../Add-on/DrawDim/OneKeyHideOrShowDim";
import { CheckDrawHole } from "../Add-on/DrawDrilling/CheckDrawHole";
import { CheckHasHoleBoard } from "../Add-on/DrawDrilling/CheckHasHole";

@ -11,7 +11,7 @@ import { ECompareType, IBoardFindOption } from "../UI/Store/BoardFindInterface";
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 { ForBoardNameType, IAutoDimBrsOption } from "../UI/Store/OptionInterface/AutoDimBrsOption";
import { ForBoardNameType, IAutoDimBrsOption, IFastDimOption } from "../UI/Store/OptionInterface/AutoDimBrsOption";
import { CurtailType, IBoardBatchCurtailOption } from "../UI/Store/OptionInterface/BoardBatchCurtailOption ";
import { BoardProcessOption } from "../UI/Store/OptionInterface/BoardProcessOption";
import { BulkheadCeilingOption } from "../UI/Store/OptionInterface/BulkheadCeilingOption";
@ -1016,3 +1016,13 @@ export const DefaultDoorRelatesInfoOption: DoorRelatesInfoOption = {
hingeOption: []
};
Object.freeze(DefaultDoorRelatesInfoOption);
export const DefaultFastDimOption: IFastDimOption = {
filterSmallSize: false,
filterSmallSizeValue: 0,
filterAppointSize: false,
filterAppointSizeValues: "",
filterAppointForBoardName: false,
filterAppointForBoardNameValues: "",
conditionType: ForBoardNameType.Same,
};

@ -70,4 +70,5 @@ export enum BoardModalType
ConfigListMapStore = "ConfigListMapStore", //配置列表排序映射
DrawWallStore = "DrawWallStore",//画墙时使用的配置
BoardInfoDim = "BoardInfoDim", //板件信息标注
FastDim = "FastDim",//自由标注
}

@ -5,6 +5,7 @@
padding : 15px 15px 0 15px;
display : flex;
background-color : white;
border-radius : 4px;
.bp3-card{
padding : 10px;

@ -26,3 +26,14 @@ export interface IAutoDimBrsOption extends IBaseOption
forBoardNameStr: string;
forBoardNameType: ForBoardNameType;
}
export interface IFastDimOption extends IBaseOption
{
filterSmallSize: boolean; //过滤小尺寸
filterSmallSizeValue: number; //过滤小尺寸值
filterAppointSize: boolean; //过滤指定尺寸
filterAppointSizeValues: string;//过滤指定尺寸的值
filterAppointForBoardName: boolean;///根据板名过滤
conditionType: ForBoardNameType; //根据板名过滤条件
filterAppointForBoardNameValues: string;//根据板名过滤的值
}

Loading…
Cancel
Save