!1111 功能:根据板材修改颜色,命令CHANGECOLORBYMAT

pull/1111/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent a4546dde91
commit ae7d9f3e01

@ -0,0 +1,36 @@
import { Command } from "../Editor/CommandMachine";
import { app } from "../ApplicationServices/Application";
import { Board } from "../DatabaseServices/Entity/Board";
import { PromptStatus } from "../Editor/PromptResult";
import { EBoardKeyList } from "../Common/BoardKeyList";
export class ChangeColorByMaterial implements Command
{
async exec()
{
let brRes = await app.Editor.GetSelection({
Msg: "选择板件,根据板材名称修改颜色",
Filter: { filterTypes: [Board] }
});
if (brRes.Status === PromptStatus.Cancel) return;
let brs = brRes.SelectSet.SelectEntityList as Board[];
let cache: string[] = [];
for (let br of brs)
{
let key = `${br.BoardProcessOption[EBoardKeyList.BrMat]}-${br.BoardProcessOption[EBoardKeyList.Color]}-${br.BoardProcessOption[EBoardKeyList.Mat]}`;
let color = cache.indexOf(key);
if (color === -1)
{
color = cache.length + 1;
cache.push(key);
}
else
color += 1;
br.ColorIndex = color;
}
}
}

@ -163,4 +163,6 @@ export enum CommandNames
Text2Curve = "TEXT2CURVE", Text2Curve = "TEXT2CURVE",
R2b = "RECT2BOARD", R2b = "RECT2BOARD",
RecyleBin = "RECYCLEBIN", RecyleBin = "RECYCLEBIN",
ChangeColorByMaterial = "CHANGECOLORBYMATERIAL",
RestoreColor = "RESTORECOLOR",
} }

@ -184,6 +184,7 @@ import { ShowKinfeManageModal } from './../Add-on/showModal/ShowKnifeManageModal
import { commandMachine } from './CommandMachine'; import { commandMachine } from './CommandMachine';
import { ShowRecycleBin } from "../Add-on/ShowRecycleBin"; import { ShowRecycleBin } from "../Add-on/ShowRecycleBin";
import { Command_EntitytMoveToZ0 } from "../Add-on/EntityMoveToZ0"; import { Command_EntitytMoveToZ0 } from "../Add-on/EntityMoveToZ0";
import { ChangeColorByMaterial } from "../Add-on/ChangeColorByBoardMaterial";
export function registerCommand() export function registerCommand()
{ {
@ -192,7 +193,7 @@ export function registerCommand()
commandMachine.RegisterCommand("end", new Command_EndTempEditor()); commandMachine.RegisterCommand("end", new Command_EndTempEditor());
commandMachine.RegisterCommand("RestoreColor", new Command_RestoreColor()); commandMachine.RegisterCommand(CommandNames.RestoreColor, new Command_RestoreColor());
commandMachine.RegisterCommand("kjl", new Command_KJLImport()); commandMachine.RegisterCommand("kjl", new Command_KJLImport());
commandMachine.RegisterCommand(CommandNames.KJLExport, new KjlExport()); commandMachine.RegisterCommand(CommandNames.KJLExport, new KjlExport());
@ -514,6 +515,8 @@ export function registerCommand()
commandMachine.RegisterCommand(CommandNames.RecyleBin, new ShowRecycleBin()); commandMachine.RegisterCommand(CommandNames.RecyleBin, new ShowRecycleBin());
commandMachine.RegisterCommand(CommandNames.ChangeColorByMaterial, new ChangeColorByMaterial());
} }
export async function RegistCustomCommand() export async function RegistCustomCommand()

@ -57,7 +57,6 @@ export class CommandPanel extends React.Component<{}, CommandPanelState>
} }
componentDidMount() componentDidMount()
{ {
this.inputEl.focus();
this.UseLastScrollTop(); this.UseLastScrollTop();
app.Editor.MaskManage.events.push( app.Editor.MaskManage.events.push(
end(app.Editor.MaskManage, app.Editor.MaskManage.OnFocusEvent, () => end(app.Editor.MaskManage, app.Editor.MaskManage.OnFocusEvent, () =>
@ -65,6 +64,10 @@ export class CommandPanel extends React.Component<{}, CommandPanelState>
app.Editor.ModalManage.Destory(); app.Editor.ModalManage.Destory();
}) })
); );
setTimeout(() =>
{
this.inputEl.focus();
}, 0);
} }
handleTabsClick = async () => handleTabsClick = async () =>
@ -97,7 +100,6 @@ export class CommandPanel extends React.Component<{}, CommandPanelState>
className="bp3-input" className="bp3-input"
placeholder=">输入命令..." placeholder=">输入命令..."
type="search" type="search"
autoFocus={true}
onKeyDown={(e) => { e.stopPropagation(); }} onKeyDown={(e) => { e.stopPropagation(); }}
onChange={v => onChange={v =>
{ {

@ -516,6 +516,26 @@ export const CommandList: ICommand[] = [
chName: "根据板件名修改属性", chName: "根据板件名修改属性",
chDes: "根据板件名修改属性", chDes: "根据板件名修改属性",
}, },
{
icon: IconEnum.ChangeColorByMat,
typeId: "bjbj",
link: "#",
defaultCustom: "CHANGECOLORBYMAT",
command: CommandNames.ChangeColorByMaterial,
type: "板件编辑",
chName: "根据板材修改颜色",
chDes: "根据板材修改颜色",
},
{
icon: IconEnum.RestoreColor,
typeId: "bjbj",
link: "#",
defaultCustom: CommandNames.RestoreColor,
command: CommandNames.RestoreColor,
type: "板件编辑",
chName: "恢复板件颜色",
chDes: "恢复板件颜色",
},
//灯光命令 //灯光命令
{ {

@ -71,6 +71,8 @@ export class TopToolBar extends React.Component<{}, {}>
{ svg: IconEnum.Curve2Rec, title: "线条变矩形", command: CommandNames.Curve2Rect }, { svg: IconEnum.Curve2Rec, title: "线条变矩形", command: CommandNames.Curve2Rect },
{ svg: IconEnum.Rec2Br, title: "矩形变板件", command: CommandNames.R2b }, { svg: IconEnum.Rec2Br, title: "矩形变板件", command: CommandNames.R2b },
{ svg: IconEnum.UpdateInfo, title: "根据板名修改属性", command: CommandNames.UpdateBoardInfos }, { svg: IconEnum.UpdateInfo, title: "根据板名修改属性", command: CommandNames.UpdateBoardInfos },
{ svg: IconEnum.ChangeColorByMat, title: "根据板材修改颜色", command: CommandNames.ChangeColorByMaterial },
{ svg: IconEnum.RestoreColor, title: "恢复板件颜色", command: CommandNames.RestoreColor },
]; ];
store.iconList.brEdit = [ store.iconList.brEdit = [
{ svg: IconEnum.QG, title: "线性切割", command: CommandNames.LinearCutting }, { svg: IconEnum.QG, title: "线性切割", command: CommandNames.LinearCutting },

@ -164,4 +164,6 @@ export enum IconEnum
ExportView = "ExportView2.svg", ExportView = "ExportView2.svg",
UpdateInfo = "ChangeBoardAttributeFromBoardName.svg", UpdateInfo = "ChangeBoardAttributeFromBoardName.svg",
Revolve = "Revolve.svg", Revolve = "Revolve.svg",
RestoreColor = "RestoreColor.svg",
ChangeColorByMat = "ChangeColorByMat.svg",
} }

Loading…
Cancel
Save