拆分的区段标签居中

This commit is contained in:
Yuan 2023-07-04 09:21:34 +08:00
parent 2c219da3a2
commit e149b0764a

View File

@ -101,8 +101,6 @@ export class SectionDraw extends GraphicDrawAssistant<
prepareData(data: ISectionData): boolean {
data.points = this.points;
data.code = 'G000';
console.log(data.points[1].x);
console.log(data.points[0].x);
data.childTransforms = [
new ChildTransform(
'label',
@ -400,6 +398,25 @@ export class SectionPointEditPlugin extends GraphicInteractionPlugin<Section> {
(p) => new graphicData.Point({ x: p.x, y: p.y })
);
data.id = this.drawAssistant.nextId();
data.childTransforms = [
new ChildTransform(
'label',
new GraphicTransform(
{
x:
data.points[0].x +
(data.points[1].x - data.points[0].x) / 2,
y:
data.points[0].y +
(data.points[1].y - data.points[0].y) / 2 +
20,
},
{ x: 0, y: 0 },
0,
{ x: 0, y: 0 }
)
),
];
const g = this.drawAssistant.graphicTemplate.new();
g.loadData(data);
this.drawAssistant.storeGraphic(g);