优化:在封边扣除失败时,提示用户,并且可以直接查看

pull/2019/head
ChenX 2 years ago
parent ca66cfbc08
commit 1e38460ab1

@ -2,7 +2,7 @@ import { Vector3 } from "three";
import { HostApplicationServices } from "../../ApplicationServices/HostApplicationServices";
import { EBoardKeyList } from "../../Common/BoardKeyList";
import { ParseExpr, safeEval } from "../../Common/eval";
import { Intent, Toaster } from "../../Common/Toaster";
import { Intent, Toaster, ToasterShowEntityMsg } from "../../Common/Toaster";
import { FixedNotZero } from "../../Common/Utils";
import { CylinderHole, GangDrillType } from "../../DatabaseServices/3DSolid/CylinderHole";
import { ExtrudeHole } from "../../DatabaseServices/3DSolid/ExtrudeHole";
@ -217,7 +217,18 @@ class LookOverBoardInfosTool
}
//封边
let sealData = GetBoardSealingData(GetSealedBoardContour(b, true, true));
let sealContour = GetSealedBoardContour(b, true, true);
if (!sealContour)
{
ToasterShowEntityMsg({
intent: Intent.DANGER,
msg: "板件扣封边失败,请检查板件轮廓!",
timeout: 10000,
ent: b
});
throw "错误:板扣除封边失败!";
}
let sealData = GetBoardSealingData(sealContour);
let color = b.BoardProcessOption[EBoardKeyList.Color];
for (let data of sealData)

@ -1,3 +1,5 @@
//为了避免Core对UI库的依赖,导致测试用例失败,导致外部项目引用失败,我们分离了这个函数
export enum Intent
{
NONE = "none",
@ -25,3 +27,24 @@ export function Toaster(option: IToasterOption): void
for (let f of ToasterInjectFunctions)
f(option);
}
interface IToasterShowEntityErrorOption
{
intent: Intent,
msg: string,
timeout: number;
ent: any;
}
export const ToasterShowEntityMsgInjectFunctions: ((option: IToasterShowEntityErrorOption) => void)[] = [];
export function ToasterShowEntityMsg(option: {
intent: Intent,
msg: string,
timeout: number;
ent: any;
})
{
for (let f of ToasterShowEntityMsgInjectFunctions)
f(option);
}

@ -2,8 +2,10 @@ import { Intent, IToastOptions, Position, Toaster, Tooltip } from "@blueprintjs/
import { autorun, observable } from "mobx";
import { observer } from "mobx-react";
import * as React from 'react';
import { app } from "../../ApplicationServices/Application";
import { CheckObjectType, CheckoutValid } from "../../Common/CheckoutVaildValue";
import { safeEval } from "../../Common/eval";
import { Entity } from "../../DatabaseServices/Entity/Entity";
import { ISetItemOption } from "./Board/BoardCommon";
export const AppToaster = Toaster.create({
className: "recipe-toaster",
@ -202,3 +204,27 @@ export class ToasterInput extends React.Component<IToasterInputProps, {}>
);
}
}
/**请使用 ToasterShowEntityMsg 来避免依赖*/
export function __AppToasterShowEntityMsg(option: {
intent: Intent,
msg: string,
timeout: number;
ent: Entity;
})
{
let key = AppToaster.show({
intent: option.intent,
message: <>
{option.msg}
<button onClick={e =>
{
app.Editor.SetSelection([option.ent]);
app.Viewer.ZoomtoEntitys([option.ent]);
}}></button>
</>,
timeout: option.timeout,
});
return key;
}

@ -11,7 +11,7 @@ import { _LogInjectFunctions } from '../../Common/Log';
import { ReportFunctionList } from '../../Common/Report';
import { PostJson } from '../../Common/Request';
import { ShowObjectsFunctionList } from '../../Common/ShowSelectObjects';
import { IToasterOption, ToasterInjectFunctions } from '../../Common/Toaster';
import { IToasterOption, ToasterInjectFunctions, ToasterShowEntityMsgInjectFunctions } from '../../Common/Toaster';
import { ZINDEX } from '../../Common/ZIndex';
import { Entity } from '../../DatabaseServices/Entity/Entity';
import { FileServer } from '../../DatabaseServices/FileServer';
@ -22,7 +22,7 @@ import { MaterialContainer, MaterialContainerProps } from '../Components/Materia
import { DownPanel, TopPanel } from '../Components/Panel';
import { RightPanel } from '../Components/RightPanel/RightPanel';
import { PropertiesPanelButton, RightPanelButton } from '../Components/RightPanel/RightPanelButton';
import { ShowLinesToaster } from '../Components/Toaster';
import { ShowLinesToaster, __AppToasterShowEntityMsg } from '../Components/Toaster';
import { ToolbarContainer } from '../Components/ToolBar/ToolbarContainer';
import { TopToolBar } from '../Components/TopToolBar/TopToolBar';
import { DownPanelStore } from '../Store/DownPanelStore';
@ -77,6 +77,9 @@ export class WebCAD
intent: option.intent,
}, option.key ?? "");
});
ToasterShowEntityMsgInjectFunctions.push(__AppToasterShowEntityMsg);
let fileServer = FileServer.GetInstance() as FileServer;
ReportFunctionList.push(async (msg: string) =>
{

Loading…
Cancel
Save