!3002 优化:根据板件的纹路修改颜色改成选板,颜色改成黄色=正纹,绿色=反纹,青色=可翻转

pull/2925/MERGE
钱若寒 1 month ago committed by ChenX
parent 65487120e6
commit 4bbc3e9067

@ -8,6 +8,7 @@ import { KeyBoard } from "../../Common/KeyEnum";
import { Board } from "../../DatabaseServices/Entity/Board"; import { Board } from "../../DatabaseServices/Entity/Board";
import { LinesType } from "../../DatabaseServices/Entity/BoardInterface"; import { LinesType } from "../../DatabaseServices/Entity/BoardInterface";
import { Command } from "../../Editor/CommandMachine"; import { Command } from "../../Editor/CommandMachine";
import { PromptStatus } from "../../Editor/PromptResult";
import { SelectSetBase } from "../../Editor/SelectBase"; import { SelectSetBase } from "../../Editor/SelectBase";
import { CommonModal } from "../../UI/Components/Modal/ModalContainer"; import { CommonModal } from "../../UI/Components/Modal/ModalContainer";
import { AppToaster } from "../../UI/Components/Toaster"; import { AppToaster } from "../../UI/Components/Toaster";
@ -18,13 +19,14 @@ export class ChangeColorByLinesType implements Command
async exec() async exec()
{ {
AppToaster.show({ AppToaster.show({
message: "根据板件的纹路修改颜色,红色=正纹,黄色=反纹,绿色=可翻转", message: "根据板件的纹路修改颜色,黄色=正纹,绿色=反纹,青色=可翻转",
timeout: 5000, timeout: 5000,
intent: Intent.SUCCESS, intent: Intent.SUCCESS,
}, "ChangeColorByLinesType"); }, "ChangeColorByLinesType");
let ents = app.Database.ModelSpace.Entitys.filter(e => !e.IsErase && e instanceof Board) as Board[]; let ssRes = await app.Editor.GetSelection({ Filter: { filterTypes: [Board] }, UseSelect: true });
if (ssRes.Status !== PromptStatus.OK) return;
let ents = ssRes.SelectSet.SelectEntityList as Board[];
const oldColorMap = new Map<Board, number>(); const oldColorMap = new Map<Board, number>();
let boardMap = new Map<number, Board[]>(); let boardMap = new Map<number, Board[]>();
@ -32,11 +34,11 @@ export class ChangeColorByLinesType implements Command
{ {
oldColorMap.set(br, br.ColorIndex); oldColorMap.set(br, br.ColorIndex);
if (br.BoardProcessOption.lines === LinesType.Positive) if (br.BoardProcessOption.lines === LinesType.Positive)
br.ColorIndex = 1;
else if (br.BoardProcessOption.lines === LinesType.Reverse)
br.ColorIndex = 2; br.ColorIndex = 2;
else else if (br.BoardProcessOption.lines === LinesType.Reverse)
br.ColorIndex = 3; br.ColorIndex = 3;
else
br.ColorIndex = 4;
let arr = boardMap.get(br.ColorIndex); let arr = boardMap.get(br.ColorIndex);
if (!arr) if (!arr)
@ -46,6 +48,7 @@ export class ChangeColorByLinesType implements Command
} }
arr.push(br); arr.push(br);
} }
boardMap = new Map([...boardMap.entries()].sort((a, b) => a[0] - b[0]));
app.Editor.ModalManage.RenderModeless(BoardColorByLinesTypeDialog, { boardMap, oldColorMap }, { canMinimize: false }); app.Editor.ModalManage.RenderModeless(BoardColorByLinesTypeDialog, { boardMap, oldColorMap }, { canMinimize: false });
} }
} }
@ -117,7 +120,7 @@ export const BoardColorByLinesTypeDialog = observer((props: IBoardColorByLinesTy
if (br instanceof Board) if (br instanceof Board)
{ {
const type = br.BoardProcessOption.lines; const type = br.BoardProcessOption.lines;
selectIndex.current = [type === LinesType.Positive ? 1 : type === LinesType.Reverse ? 2 : 3]; selectIndex.current = [type === LinesType.Positive ? 2 : type === LinesType.Reverse ? 3 : 4];
setSelectbg([...selectIndex.current]); setSelectbg([...selectIndex.current]);
} }
}; };
@ -154,7 +157,7 @@ export const BoardColorByLinesTypeDialog = observer((props: IBoardColorByLinesTy
onClick={() => OnClick(index)} onClick={() => OnClick(index)}
style={{ background: selectbg.includes(index) ? ColorMaterial.GetColor(index)?.getStyle() : "" }}> style={{ background: selectbg.includes(index) ? ColorMaterial.GetColor(index)?.getStyle() : "" }}>
<span style={{ width: 15, height: 15, margin: "0px 5px 1px 0px", background: ColorMaterial.GetColor(index)?.getStyle() }}> </span> <span style={{ width: 15, height: 15, margin: "0px 5px 1px 0px", background: ColorMaterial.GetColor(index)?.getStyle() }}> </span>
<span>{`设计纹路:${index === 1 ? '正纹' : index === 2 ? '反纹' : '可翻转'} 实体颜色:${index}`}</span> <span>{`设计纹路:${index === 2 ? '正纹' : index === 3 ? '反纹' : '可翻转'} 实体颜色:${index}`}</span>
</li> </li>
)) ))
} }

Loading…
Cancel
Save