mirror of https://gitee.com/cf-fz/WebCAD.git
!93 优化模态框管理
commit
42faf4229f
@ -0,0 +1,23 @@
|
||||
import { app } from "../../ApplicationServices/Application";
|
||||
import { commandMachine } from "../../Editor/CommandMachine";
|
||||
|
||||
export class DrawBoardServer
|
||||
{
|
||||
static m_DrawMap: Map<string, Function> = new Map();
|
||||
static AddDrawBoardCmd(type, Callback)
|
||||
{
|
||||
if (!this.m_DrawMap.has(type))
|
||||
this.m_DrawMap.set(type, Callback);
|
||||
}
|
||||
static async ExecDrawBoardCmd(type)
|
||||
{
|
||||
if (this.m_DrawMap.has(type))
|
||||
{
|
||||
app.m_Editor.m_CommandStore.isCmdIng = true;
|
||||
app.m_Database.hm.StartCmd(type);
|
||||
await this.m_DrawMap.get(type)();
|
||||
commandMachine.CommandEnd(type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,38 +1,39 @@
|
||||
import { app } from '../../ApplicationServices/Application';
|
||||
import { Singleton } from '../../Common/Singleton';
|
||||
import { Board } from '../../DatabaseServices/Board';
|
||||
import { Command } from '../../Editor/CommandMachine';
|
||||
import { PromptStatus } from '../../Editor/PromptResult';
|
||||
import { MoveMatrix } from '../../Geometry/GeUtils';
|
||||
import { BoardModalType } from '../../UI/Components/Board/BoardModal';
|
||||
import { ModalState } from '../../UI/Store/BoardInterface';
|
||||
import { BoardModal, BoardModalType } from '../../UI/Components/Board/BoardModal';
|
||||
import { ModalPosition } from '../../UI/Components/Modal/ModalsManage';
|
||||
import { SingleBoardStore } from '../../UI/Store/BoardStore';
|
||||
import { Singleton } from '../../Common/Singleton';
|
||||
|
||||
export class DrawSingleBoard implements Command
|
||||
{
|
||||
async exec()
|
||||
{
|
||||
let store = Singleton.GetInstance(SingleBoardStore);
|
||||
app.m_Editor.m_ModalManage.RenderBoardModal(store, BoardModalType.Sg);
|
||||
let state = await store.GetBoardOption();
|
||||
app.m_Editor.m_ModalManage.RenderModeless(BoardModal, ModalPosition.Center, { store, type: BoardModalType.Sg });
|
||||
|
||||
if (state !== ModalState.Ok) return;
|
||||
let opt = store.m_BoardOption;
|
||||
let board = Board.CreateBoard(parseFloat(opt.height), parseFloat(opt.width), parseFloat(opt.thickness), opt.type);
|
||||
app.m_Database.ModelSpace.Append(board);
|
||||
app.m_Editor.m_ModalManage.Callback = async () =>
|
||||
{
|
||||
let opt = store.m_BoardOption;
|
||||
let board = Board.CreateBoard(parseFloat(opt.height), parseFloat(opt.width), parseFloat(opt.thickness), opt.type);
|
||||
app.m_Database.ModelSpace.Append(board);
|
||||
|
||||
let ptRes = await app.m_Editor.GetPoint({
|
||||
Msg: "选择基点",
|
||||
Callback: v =>
|
||||
let ptRes = await app.m_Editor.GetPoint({
|
||||
Msg: "选择基点",
|
||||
Callback: v =>
|
||||
{
|
||||
let oldPt = board.Position;
|
||||
let vec = v.clone().sub(oldPt);
|
||||
board.ApplyMatrix(MoveMatrix(vec));
|
||||
}
|
||||
});
|
||||
if (ptRes.Status === PromptStatus.Cancel)
|
||||
{
|
||||
let oldPt = board.Position;
|
||||
let vec = v.clone().sub(oldPt);
|
||||
board.ApplyMatrix(MoveMatrix(vec));
|
||||
board.Erase();
|
||||
}
|
||||
});
|
||||
if (ptRes.Status === PromptStatus.Cancel)
|
||||
{
|
||||
board.Erase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue