From ad31bfcf86d53bcae1cdfdd40c52c881b346a09d Mon Sep 17 00:00:00 2001 From: Dimitris Zervas Date: Sat, 25 May 2024 16:59:48 +0300 Subject: [PATCH] Procedurally generate the toolbar buttons/icons Signed-off-by: Dimitris Zervas --- .../src/routes/(CADmium)/MainDisplay.svelte | 4 +- .../src/routes/(CADmium)/PassiveSketch.svelte | 4 -- .../web/src/routes/(CADmium)/Sketch.svelte | 4 +- .../web/src/routes/(CADmium)/ToolBar.svelte | 28 +++++---- .../(CADmium)/tools/ToolInstance.svelte | 9 ++- applications/web/static/actions/arc.svg | 58 +++++++++++++++++++ 6 files changed, 86 insertions(+), 21 deletions(-) create mode 100644 applications/web/static/actions/arc.svg diff --git a/applications/web/src/routes/(CADmium)/MainDisplay.svelte b/applications/web/src/routes/(CADmium)/MainDisplay.svelte index d5d6fb67..3b0d3db1 100644 --- a/applications/web/src/routes/(CADmium)/MainDisplay.svelte +++ b/applications/web/src/routes/(CADmium)/MainDisplay.svelte @@ -53,9 +53,7 @@
{ if ($selectingFor.length > 0) { diff --git a/applications/web/src/routes/(CADmium)/PassiveSketch.svelte b/applications/web/src/routes/(CADmium)/PassiveSketch.svelte index 30486dba..83189b5c 100644 --- a/applications/web/src/routes/(CADmium)/PassiveSketch.svelte +++ b/applications/web/src/routes/(CADmium)/PassiveSketch.svelte @@ -10,10 +10,6 @@ import Face from "./Face.svelte" import { LineMaterial } from "three/addons/lines/LineMaterial.js" import { LineGeometry } from "three/addons/lines/LineGeometry.js" - import NewLineTool from "./tools/Line.svelte" - import NewCircleTool from "./tools/Circle.svelte" - import NewRectangleTool from "./tools/Rectangle.svelte" - import SelectTool from "./tools/Select.svelte" import type { ArcTuple, CircleTuple, diff --git a/applications/web/src/routes/(CADmium)/Sketch.svelte b/applications/web/src/routes/(CADmium)/Sketch.svelte index e779d855..b7360fc4 100644 --- a/applications/web/src/routes/(CADmium)/Sketch.svelte +++ b/applications/web/src/routes/(CADmium)/Sketch.svelte @@ -2,7 +2,7 @@ import type { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js" import PassiveSketch from "./PassiveSketch.svelte" import { currentlySelected, previewGeometry, sketchTool } from "shared/stores" - import type { PlaneRealized, SketchTuple } from "shared/types" + import type { PlaneRealized, SketchTuple, ToolType } from "shared/types" // prettier-ignore const log = (function () { const context = "[Sketch.svelte]"; const color="gray"; return Function.prototype.bind.call(console.log, console, `%c${context}`, `font-weight:bold;color:${color};`)})() @@ -18,7 +18,7 @@ solidSelectedMaterial: LineMaterial, collisionLineMaterial: LineMaterial - function setTool(tool: string): void { + function setTool(tool: ToolType): void { $sketchTool = tool $currentlySelected = [] $previewGeometry = [] diff --git a/applications/web/src/routes/(CADmium)/ToolBar.svelte b/applications/web/src/routes/(CADmium)/ToolBar.svelte index 7022e7ef..7a1446b8 100644 --- a/applications/web/src/routes/(CADmium)/ToolBar.svelte +++ b/applications/web/src/routes/(CADmium)/ToolBar.svelte @@ -1,4 +1,4 @@ -
diff --git a/applications/web/src/routes/(CADmium)/tools/ToolInstance.svelte b/applications/web/src/routes/(CADmium)/tools/ToolInstance.svelte index b3e5d5bc..4cecf3d6 100644 --- a/applications/web/src/routes/(CADmium)/tools/ToolInstance.svelte +++ b/applications/web/src/routes/(CADmium)/tools/ToolInstance.svelte @@ -11,7 +11,6 @@ interface ToolComponentInstance { name: string - // component: (new (...args: any[]) => AllTools.ToolComponentType) component: AllTools.ToolComponentType } @@ -31,6 +30,10 @@ }) })) + export function getToolNames(): ToolType[] { + return instances.map(i => i.name as ToolType) + } + export function meshMouseMove(event: Event, data: Vector2) { const inst = instances.find(i => i.name === $sketchTool) inst !== undefined && inst.component.mouseMove(event, data) @@ -41,3 +44,7 @@ inst !== undefined && inst.component.click(event, data) } + +
diff --git a/applications/web/static/actions/arc.svg b/applications/web/static/actions/arc.svg new file mode 100644 index 00000000..55f178d7 --- /dev/null +++ b/applications/web/static/actions/arc.svg @@ -0,0 +1,58 @@ + + + + + + + +