修改绘制板件命令

pull/93/head
Zoe 6 years ago
parent a15e778ddf
commit d22a78911e

@ -0,0 +1,20 @@
import { BoardStore } from "../../UI/Store/BoardStore";
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))
{
console.log(type);
await this.m_DrawMap.get(type)();
}
}
}

@ -12,6 +12,7 @@ import { PointPickSpaceParse } from '../../Geometry/SpaceParse/PointPickSpacePar
import { BoardModalType } from '../../UI/Components/Board/BoardModal';
import { BoardOption, ModalState } from '../../UI/Store/BoardInterface';
import { BehindBoardStore, BoardStore, LayerBoardStore, VerticalBoardStore } from '../../UI/Store/BoardStore';
import { DrawBoardServer } from './DrawBoardServer';
export abstract class DrawBoardTool implements Command
{
@ -19,10 +20,6 @@ export abstract class DrawBoardTool implements Command
protected drawType = BoardType.Layer;
async exec()
{
//原来禁用捕捉开启状态
let oldSnapState = app.m_Editor.m_GetpointServices.snapServices.m_Disabled;
app.m_Editor.m_GetpointServices.snapServices.m_Disabled = true;
let store: LayerBoardStore | VerticalBoardStore | BehindBoardStore;
let modalType: BoardModalType;
switch (this.drawType)
@ -42,18 +39,16 @@ export abstract class DrawBoardTool implements Command
}
app.m_Editor.m_ModalManage.RenderBoardModal(store, modalType);
let state = await store.GetBoardOption();
if (state !== ModalState.Ok)
return;
await this.SelectPoint(store, modalType)
//恢复原先状态
app.m_Editor.m_GetpointServices.snapServices.m_Disabled = oldSnapState;
DrawBoardServer.AddDrawBoardCmd(store.cmdType, async () =>
{
await this.SelectPoint(store, modalType)
})
}
private async SelectPoint(store: BoardStore, type: BoardModalType)
{
//原来禁用捕捉开启状态
let oldSnapState = app.m_Editor.m_GetpointServices.snapServices.m_Disabled;
app.m_Editor.m_GetpointServices.snapServices.m_Disabled = true;
// 板件数据
let opt = store.m_BoardOption;
@ -140,10 +135,12 @@ export abstract class DrawBoardTool implements Command
else if (ptRes.Status === PromptStatus.None)
{
app.m_Editor.m_ModalManage.RenderBoardModal(store, type);
let state = await store.GetBoardOption();
if (state !== ModalState.Ok) break;
// let state = await store.GetBoardOption();
// if (state !== ModalState.Ok) break;
} else break;
}
//恢复原先状态
app.m_Editor.m_GetpointServices.snapServices.m_Disabled = oldSnapState;
}
private async SelectBoxes(opt: BoardOption)
{

@ -9,7 +9,7 @@ import { BoardModalType } from '../../UI/Components/Board/BoardModal';
import { SideBoardStore } from '../../UI/Store/BoardStore';
import { ModalState } from '../../UI/Store/BoardInterface';
import { Singleton } from '../../Common/Singleton';
import { DrawBoardServer } from './DrawBoardServer';
export class DrawLeftRight implements Command
{
@ -17,12 +17,10 @@ export class DrawLeftRight implements Command
{
let store = Singleton.GetInstance(SideBoardStore);
app.m_Editor.m_ModalManage.RenderBoardModal(store, BoardModalType.LR)
let state = await store.GetBoardOption();
if (state === ModalState.Ok)
app.m_Editor.m_ModalManage.RenderBoardModal(store, BoardModalType.LR);
DrawBoardServer.AddDrawBoardCmd("zyc", async () =>
{
console.log(123);
let data = store.m_BoardOption;
let lenght = parseFloat(data.height);
let width = parseFloat(data.width);
@ -52,6 +50,7 @@ export class DrawLeftRight implements Command
rightBoard.Erase();
leftBarod.Erase();
}
}
})
}
}

@ -10,6 +10,7 @@ import { SurroundSpaceParse } from '../../Geometry/SpaceParse/SurroundSpaceParse
import { BoardModalType } from '../../UI/Components/Board/BoardModal';
import { ModalState, TBBoardOption } from '../../UI/Store/BoardInterface';
import { TopBottomBoardStore } from '../../UI/Store/BoardStore';
import { DrawBoardServer } from './DrawBoardServer';
export class DrawTopBottomBoard implements Command
{
@ -34,17 +35,14 @@ export class DrawTopBottomBoard implements Command
app.m_Editor.m_ModalManage.RenderBoardModal(store, BoardModalType.TB);
let state = await store.GetBoardOption();
if (state === ModalState.Ok)
DrawBoardServer.AddDrawBoardCmd("dd", () =>
{
let topOpt = store.topBoardOption;
let bottomOpt = store.bottomBoardOption;
topOpt.isDraw && this.buildTBBoard(spaceParse, topOpt, spaceParse.BaseTopUpPoint, spaceParse.BaseTopDownPoint, true)
bottomOpt.isDraw && this.buildTBBoard(spaceParse, bottomOpt, spaceParse.BaseBottomDownPoint, spaceParse.BaseBottomUpPoint);
}
})
}
else
{

@ -150,9 +150,6 @@ export class BoardModal extends React.Component<BoardModalProps, BoardModalState
async componentWillMount()
{
let modal = document.getElementById("modal");
let dbstore = await IndexedDbStore.CADStore();
let type = this.props.type;
let brDataMap = await dbstore.Get(StoreName.ConfigData, type) as Map<string, configOption> || new Map();

@ -13,7 +13,6 @@ import { BoardModal } from '../Board/BoardModal';
import { LightModal } from './LightModal';
import './Modal.less';
export class ModalManage
{
private m_SelectedObj: Entity;
@ -60,10 +59,6 @@ export class ModalManage
{
this.Clear();
}
else if (e.keyCode === KeyBoard.Enter)
{
console.log("确认");
}
e.stopPropagation();
}
RenderBoardModal(store: BoardStore, type: string)

@ -6,6 +6,7 @@ import { KeyBoard } from '../../Common/KeyEnum';
import { ModalState, BoardOption, BehindBoardOption, BehindHeightPositon, BrRelativePos, LayerBoardOption, LayerNailOption, VerticalBoardOption, TBBoardOption, SingleBoardOption, ClosingStripOption, StripType } from './BoardInterface';
import { BoardType } from '../../DatabaseServices/Board';
import { configOption } from '../Components/Board/BoardModal';
import { DrawBoardServer } from '../../Add-on/DrawBoard/DrawBoardServer';
export class BoardStore
{
@ -13,40 +14,47 @@ export class BoardStore
name: string;
m_BoardOption: BoardOption;
title: string;
cmdType: string;
//事件
private events: Function[] = [];
constructor()
{
this.registerEvent();
}
//是否连续绘制
registerEvent()
{
this.events.push(
xaop.end(app.m_Editor.m_ModalManage, app.m_Editor.m_ModalManage.OnKeyDown, (e: KeyboardEvent) =>
xaop.end(app.m_Editor.m_ModalManage, app.m_Editor.m_ModalManage.OnKeyDown, (e: KeyboardEvent) =>
{
if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space)
{
if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space)
{
this.OnOk(ModalState.Ok, this.title !== "收口条");
}
else if (e.keyCode === KeyBoard.Escape)
{
this.OnOk(ModalState.Cancel);
}
e.stopPropagation();
})
)
console.log("回车");
this.OnOk(ModalState.Ok, this.title !== "收口条");
}
else if (e.keyCode === KeyBoard.Escape)
{
this.OnOk(ModalState.Cancel);
}
e.stopPropagation();
})
}
GetBoardOption()
{
this.registerEvent();
return new Promise<number>((res) =>
{
this.m_PromisRes = res;
});
}
OnOk(state: number, isClose: boolean = true)
async OnOk(state: number, isClose: boolean = true)
{
this.events.forEach(f => f())
this.events.length = 0;
isClose && app.m_Editor.m_ModalManage.Clear();
if (this.m_PromisRes) this.m_PromisRes(state);
if (state === ModalState.Ok)
{
await DrawBoardServer.ExecDrawBoardCmd(this.cmdType)
}
}
SaveConfig()
{
@ -92,6 +100,7 @@ export class SideBoardStore extends BoardStore
spaceSize: "836"
};
title = "左右侧板";
cmdType = "zyc";
}
export class TopBottomBoardStore extends BoardStore
@ -119,6 +128,8 @@ export class TopBottomBoardStore extends BoardStore
footThickness: "18"
};
title = "顶底板";
cmdType = "dd";
SaveConfig()
{
let newConfig: configOption = {};
@ -148,6 +159,8 @@ export class TopBottomBoardStore extends BoardStore
export class BehindBoardStore extends BoardStore
{
title = "背板";
cmdType = "bb";
@observable name = "背板";
@observable m_BoardOption: BehindBoardOption = {
leftExt: "0",
@ -171,6 +184,7 @@ export class BehindBoardStore extends BoardStore
export class LayerBoardStore extends BoardStore
{
title = "层板";
cmdType = "cb";
@observable name = "层板"
@observable m_BoardOption: LayerBoardOption = {
frontShrink: "0",
@ -223,6 +237,8 @@ export class LayerBoardStore extends BoardStore
export class VerticalBoardStore extends BoardStore
{
title = "立板";
cmdType = "lb";
@observable name = "立板";
@observable m_BoardOption: VerticalBoardOption = {
frontShrink: "0",

Loading…
Cancel
Save