fix: 修复在存在异常指针的情况下外部指针的位置错位bug
This commit is contained in:
parent
fccd90d176
commit
15c3d0b33a
2
dist/sv.js
vendored
2
dist/sv.js
vendored
File diff suppressed because one or more lines are too long
@ -169,6 +169,7 @@ export class Element extends Model {
|
|||||||
groupName: string;
|
groupName: string;
|
||||||
layouterName: string;
|
layouterName: string;
|
||||||
freed: boolean;
|
freed: boolean;
|
||||||
|
pointers: { [key: string]: Pointer };
|
||||||
|
|
||||||
constructor(id: string, type: string, group: string, layouter: string, sourceElement: SourceElement) {
|
constructor(id: string, type: string, group: string, layouter: string, sourceElement: SourceElement) {
|
||||||
super(id, type);
|
super(id, type);
|
||||||
@ -189,6 +190,11 @@ export class Element extends Model {
|
|||||||
|
|
||||||
this.sourceId = this.id.split('.')[1];
|
this.sourceId = this.id.split('.')[1];
|
||||||
this.sourceElement = sourceElement;
|
this.sourceElement = sourceElement;
|
||||||
|
this.pointers = { };
|
||||||
|
}
|
||||||
|
|
||||||
|
getPointer(pointerType: string): Pointer {
|
||||||
|
return this.pointers[pointerType] || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected defineProps(option: ElementOption): G6NodeModel {
|
protected defineProps(option: ElementOption): G6NodeModel {
|
||||||
@ -261,6 +267,7 @@ export class Link extends Model {
|
|||||||
export class Pointer extends Model {
|
export class Pointer extends Model {
|
||||||
target: Element;
|
target: Element;
|
||||||
label: string | string[];
|
label: string | string[];
|
||||||
|
anchor: number;
|
||||||
|
|
||||||
constructor(id: string, type: string, label: string | string[], target: Element) {
|
constructor(id: string, type: string, label: string | string[], target: Element) {
|
||||||
super(id, type);
|
super(id, type);
|
||||||
@ -268,17 +275,24 @@ export class Pointer extends Model {
|
|||||||
this.label = label;
|
this.label = label;
|
||||||
|
|
||||||
this.target.set('externalPointerId', id);
|
this.target.set('externalPointerId', id);
|
||||||
|
this.target.pointers[type] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected defineProps(option: ElementOption): G6NodeModel {
|
setAnchor(anchor: number) {
|
||||||
|
this.anchor = anchor;
|
||||||
|
};
|
||||||
|
|
||||||
|
protected defineProps(option: PointerOption): G6NodeModel {
|
||||||
|
this.setAnchor(option.anchor);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
type: option.type || 'external-pointer',
|
type: option.type || 'external-pointer',
|
||||||
size: option.size || [8, 45],
|
size: option.size || [8, 50],
|
||||||
anchorPoints: option.anchorPoints,
|
anchorPoints: null,
|
||||||
label: typeof this.label === 'string'? this.label: this.label.join(', '),
|
label: typeof this.label === 'string'? this.label: this.label.join(', '),
|
||||||
style: Util.objectClone<Style>(option.style),
|
style: Util.objectClone<Style>(option.style),
|
||||||
labelCfg: Util.objectClone<ElementLabelOption>(option.labelOptions),
|
labelCfg: Util.objectClone<ElementLabelOption>(option.labelOptions),
|
||||||
|
@ -39,7 +39,7 @@ export class Layouter {
|
|||||||
pointers.forEach(item => {
|
pointers.forEach(item => {
|
||||||
const options: PointerOption = pointerOptions[item.getType()],
|
const options: PointerOption = pointerOptions[item.getType()],
|
||||||
offset = options.offset || 8,
|
offset = options.offset || 8,
|
||||||
anchor = options.anchor || 0;
|
anchor = item.anchor || 0;
|
||||||
|
|
||||||
let target = item.target,
|
let target = item.target,
|
||||||
targetBound: BoundingRect = target.getBound(),
|
targetBound: BoundingRect = target.getBound(),
|
||||||
@ -102,7 +102,7 @@ export class Layouter {
|
|||||||
private layoutModels(layoutGroupTable: LayoutGroupTable): Group[] {
|
private layoutModels(layoutGroupTable: LayoutGroupTable): Group[] {
|
||||||
const modelGroupList: Group[] = [];
|
const modelGroupList: Group[] = [];
|
||||||
|
|
||||||
layoutGroupTable.forEach((group, groupName) => {
|
layoutGroupTable.forEach(group => {
|
||||||
const options: LayoutOptions = group.options.layout,
|
const options: LayoutOptions = group.options.layout,
|
||||||
modelList: Model[] = group.modelList,
|
modelList: Model[] = group.modelList,
|
||||||
modelGroup: Group = new Group();
|
modelGroup: Group = new Group();
|
||||||
@ -111,14 +111,15 @@ export class Layouter {
|
|||||||
modelGroup.add(item);
|
modelGroup.add(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.initLayoutValue(group.element, group.pointer); // 初始化布局参数
|
this.initLayoutValue(group.element, group.pointer); // 初始化布局参数
|
||||||
group.layouter.layout(group.element, options); // 布局节点
|
group.layouter.layout(group.element, options); // 布局节点
|
||||||
this.layoutPointer(group.pointer, group.options.pointer); // 布局外部指针
|
|
||||||
|
|
||||||
modelGroupList.push(modelGroup);
|
modelGroupList.push(modelGroup);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
layoutGroupTable.forEach(group => {
|
||||||
|
this.layoutPointer(group.pointer, group.options.pointer); // 布局外部指针
|
||||||
|
});
|
||||||
|
|
||||||
return modelGroupList;
|
return modelGroupList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user