From fc14480f3450644b961ea1f911d44840745eca93 Mon Sep 17 00:00:00 2001 From: xiange Date: Sat, 30 Dec 2023 00:07:58 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20Fix=20the=20selection=20b?= =?UTF-8?q?ug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/chili/src/commands/boolean.ts | 6 +++++- packages/chili/src/commands/create/converter.ts | 8 ++++++++ packages/chili/src/commands/create/createCommand.ts | 8 +++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/chili/src/commands/boolean.ts b/packages/chili/src/commands/boolean.ts index c915fde2..eb7b506f 100644 --- a/packages/chili/src/commands/boolean.ts +++ b/packages/chili/src/commands/boolean.ts @@ -33,7 +33,11 @@ export abstract class BooleanOperate extends CreateCommand { protected override getSteps(): IStep[] { return [ new SelectModelStep("prompt.select.shape", false), - new SelectModelStep("prompt.select.shape", false), + new SelectModelStep("prompt.select.shape", false, { + allow: (shape) => { + return !this.stepDatas[0].models?.map((x) => x.shape()).includes(shape); + }, + }), ]; } } diff --git a/packages/chili/src/commands/create/converter.ts b/packages/chili/src/commands/create/converter.ts index d1b8b2b6..59a17708 100644 --- a/packages/chili/src/commands/create/converter.ts +++ b/packages/chili/src/commands/create/converter.ts @@ -22,6 +22,10 @@ export class ConvertToWire extends CreateCommand { return new GeometryModel(this.document, `Wire ${count++}`, wireBody); } + protected override shouldClearSelectedBeforeExcute() { + return false; + } + protected override getSteps(): IStep[] { return [ new SelectModelStep("prompt.select.edges", true, { @@ -47,6 +51,10 @@ export class ConvertToFace extends CreateCommand { return new GeometryModel(this.document, `Face ${count++}`, wireBody); } + protected override shouldClearSelectedBeforeExcute() { + return false; + } + protected override getSteps(): IStep[] { return [ new SelectModelStep("prompt.select.edges", true, { diff --git a/packages/chili/src/commands/create/createCommand.ts b/packages/chili/src/commands/create/createCommand.ts index 84a60134..4e110d8b 100644 --- a/packages/chili/src/commands/create/createCommand.ts +++ b/packages/chili/src/commands/create/createCommand.ts @@ -14,8 +14,14 @@ export abstract class CreateCommand extends MultistepCommand { protected abstract create(): GeometryModel; + protected shouldClearSelectedBeforeExcute() { + return true; + } + protected override beforeExecute(): Promise { - this.document.selection.clearSelected(); + if (this.shouldClearSelectedBeforeExcute()) { + this.document.selection.clearSelected(); + } return super.beforeExecute(); } }