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 { app } from '../../ApplicationServices/Application';
|
||||||
|
import { Singleton } from '../../Common/Singleton';
|
||||||
import { Board } from '../../DatabaseServices/Board';
|
import { Board } from '../../DatabaseServices/Board';
|
||||||
import { Command } from '../../Editor/CommandMachine';
|
import { Command } from '../../Editor/CommandMachine';
|
||||||
import { PromptStatus } from '../../Editor/PromptResult';
|
import { PromptStatus } from '../../Editor/PromptResult';
|
||||||
import { MoveMatrix } from '../../Geometry/GeUtils';
|
import { MoveMatrix } from '../../Geometry/GeUtils';
|
||||||
import { BoardModalType } from '../../UI/Components/Board/BoardModal';
|
import { BoardModal, BoardModalType } from '../../UI/Components/Board/BoardModal';
|
||||||
import { ModalState } from '../../UI/Store/BoardInterface';
|
import { ModalPosition } from '../../UI/Components/Modal/ModalsManage';
|
||||||
import { SingleBoardStore } from '../../UI/Store/BoardStore';
|
import { SingleBoardStore } from '../../UI/Store/BoardStore';
|
||||||
import { Singleton } from '../../Common/Singleton';
|
|
||||||
|
|
||||||
export class DrawSingleBoard implements Command
|
export class DrawSingleBoard implements Command
|
||||||
{
|
{
|
||||||
async exec()
|
async exec()
|
||||||
{
|
{
|
||||||
let store = Singleton.GetInstance(SingleBoardStore);
|
let store = Singleton.GetInstance(SingleBoardStore);
|
||||||
app.m_Editor.m_ModalManage.RenderBoardModal(store, BoardModalType.Sg);
|
app.m_Editor.m_ModalManage.RenderModeless(BoardModal, ModalPosition.Center, { store, type: BoardModalType.Sg });
|
||||||
let state = await store.GetBoardOption();
|
|
||||||
|
|
||||||
if (state !== ModalState.Ok) return;
|
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);
|
let opt = store.m_BoardOption;
|
||||||
app.m_Database.ModelSpace.Append(board);
|
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({
|
let ptRes = await app.m_Editor.GetPoint({
|
||||||
Msg: "选择基点",
|
Msg: "选择基点",
|
||||||
Callback: v =>
|
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;
|
board.Erase();
|
||||||
let vec = v.clone().sub(oldPt);
|
|
||||||
board.ApplyMatrix(MoveMatrix(vec));
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if (ptRes.Status === PromptStatus.Cancel)
|
|
||||||
{
|
|
||||||
board.Erase();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue