task(A4.5): migrate revcloud/hatch/measure tools to v2

This commit is contained in:
Agent Zero
2026-08-27 00:48:28 +02:00
parent af46f0028a
commit 464ddb91cc
5 changed files with 255 additions and 8 deletions
@@ -48,16 +48,53 @@ export const selectTool: ToolExtensionV2 = {
},
};
/** V2-Plugin: Kern-Bearbeitungswerkzeuge (Pilot: nur select). */
/**
* hatch-Werkzeug (A4.5): Klick auf geschlossenes Element (rect/circle/polygon)
* aktiviert Schraffur — Portierung aus Legacy handleHatchDown, aber jetzt via
* doc.updateElement (eigene Undo-Transaktion statt Callback-Direktaufruf).
*/
export const hatchTool: ToolExtensionV2 = {
manifest: {
id: 'hatch', label: 'Schraffur', icon: '\u2593', ribbonTab: 'format', tags: ['pro'],
description: 'Geschlossenes Element anklicken zum Schraffieren',
},
optionsSchema: [
{ key: 'hatchPattern', label: 'Muster', type: 'select', options: [
{ value: 'lines', label: 'Linien' },
{ value: 'cross', label: 'Kreuz' },
] },
{ key: 'hatchSpacing', label: 'Abstand', type: 'number', min: 2, max: 40 },
],
handlers: {
down(e, ctx) {
const c = ctx as import('../../types').FullToolContext;
const bridge = c.selection;
if (!bridge || !c.doc) return;
const hit = bridge.hitTest(e.world.x, e.world.y, 5);
if (!hit || !['rect', 'circle', 'polygon'].includes(hit.type)) {
ctx.setStatus('Schraffur: nur rect/circle/polygon');
return;
}
const pattern = (c.options.hatchPattern as string | undefined) ?? 'lines';
const spacing = (c.options.hatchSpacing as number | undefined) ?? 8;
c.doc.updateElement(hit.id, {
properties: { hatch: true, hatchPattern: pattern, hatchSpacing: spacing },
});
ctx.setStatus(`Schraffur auf ${hit.id} (${pattern})`);
},
},
};
/** V2-Plugin: Kern-Bearbeitungswerkzeuge (Pilot: select; A4.5: hatch). */
export const coreModifyPlugin: PluginV2 = {
manifest: {
id: 'core-modify',
name: 'Bearbeiten (Kern)',
version: '1.0.0',
version: '1.1.0',
author: 'web-cad team',
description: 'Auswahl und Bearbeitung (V2-Pilot: Selektion).',
description: 'Auswahl und Bearbeitung (V2: Selektion, Schraffur).',
category: 'tools',
enabledByDefault: true,
},
tools: [selectTool],
tools: [selectTool, hatchTool],
};