|
|
|
@ -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();
|
|
|
|
|
};
|
|
|
|
|
}
|