From f22953f3f2c0c4eeaa0387e3f2b30fa2a75c7a0b Mon Sep 17 00:00:00 2001 From: Yuan Date: Tue, 20 Jun 2023 17:38:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E6=AE=B5=E5=8F=98=E6=8D=A2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/section/Section.ts | 3 +++ src/graphics/section/SectionDrawAssistant.ts | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/graphics/section/Section.ts b/src/graphics/section/Section.ts index b7272ff..c83c6b0 100644 --- a/src/graphics/section/Section.ts +++ b/src/graphics/section/Section.ts @@ -47,6 +47,9 @@ export class Section extends JlGraphic implements ILineGraphic { this.labelGraphic.setVectorFontSize(14); this.labelGraphic.anchor.set(0.5); this.labelGraphic.style.fill = '#0f0'; + this.labelGraphic.transformSave = true; + this.labelGraphic.name = 'label'; + this.transformSave = true; this.addChild(this.lineGraphic); this.addChild(this.labelGraphic); } diff --git a/src/graphics/section/SectionDrawAssistant.ts b/src/graphics/section/SectionDrawAssistant.ts index 030c596..f0f81bc 100644 --- a/src/graphics/section/SectionDrawAssistant.ts +++ b/src/graphics/section/SectionDrawAssistant.ts @@ -1,8 +1,10 @@ import { + ChildTransform, DraggablePoint, GraphicApp, GraphicDrawAssistant, GraphicInteractionPlugin, + GraphicTransform, GraphicTransformEvent, JlDrawApp, JlGraphic, @@ -86,6 +88,20 @@ export class SectionDraw extends GraphicDrawAssistant< prepareData(data: ISectionData): boolean { data.points = this.points; data.code = 'G000'; + data.childTransforms?.push( + new ChildTransform( + 'label', + new GraphicTransform( + { + x: data.points[1].x - data.points[0].x, + y: data.points[1].y - data.points[0].y + 20, + }, + { x: 0, y: 0 }, + 0, + { x: 0, y: 0 } + ) + ) + ); return true; } @@ -215,8 +231,6 @@ export class SectionPointEditPlugin extends GraphicInteractionPlugin
{ g.labelGraphic.eventMode = 'static'; g.labelGraphic.cursor = 'pointer'; g.labelGraphic.draggable = true; - g.labelGraphic.transformSave = true; - g.labelGraphic.name = 'label'; g.on('selected', this.onSelected, this); g.on('unselected', this.onUnselected, this); }