fix: cr, use method instead of attribute
This commit is contained in:
parent
ebab91b043
commit
77822318aa
2 changed files with 18 additions and 8 deletions
|
|
@ -95,7 +95,6 @@ type Object struct {
|
||||||
LabelWidth *int `json:"labelWidth,omitempty"`
|
LabelWidth *int `json:"labelWidth,omitempty"`
|
||||||
LabelHeight *int `json:"labelHeight,omitempty"`
|
LabelHeight *int `json:"labelHeight,omitempty"`
|
||||||
IconPosition *string `json:"iconPosition,omitempty"`
|
IconPosition *string `json:"iconPosition,omitempty"`
|
||||||
IsInsideNearContainer bool `json:"isInsideNearContainer,omitempty"`
|
|
||||||
|
|
||||||
Class *d2target.Class `json:"class,omitempty"`
|
Class *d2target.Class `json:"class,omitempty"`
|
||||||
SQLTable *d2target.SQLTable `json:"sql_table,omitempty"`
|
SQLTable *d2target.SQLTable `json:"sql_table,omitempty"`
|
||||||
|
|
@ -969,6 +968,18 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R
|
||||||
return &dims, nil
|
return &dims, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (obj *Object) IsInsideNearContainer() bool {
|
||||||
|
temp := obj
|
||||||
|
for temp != nil {
|
||||||
|
fmt.Println(temp.ID)
|
||||||
|
if temp.Attributes.NearKey != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
temp = temp.Parent
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
type Edge struct {
|
type Edge struct {
|
||||||
Index int `json:"index"`
|
Index int `json:"index"`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,6 @@ func pluckOutNearObjectAndEdges(g *d2graph.Graph, obj *d2graph.Object) (descenda
|
||||||
if temp.AbsID() == obj.AbsID() {
|
if temp.AbsID() == obj.AbsID() {
|
||||||
descendantsObjects = append(descendantsObjects, obj)
|
descendantsObjects = append(descendantsObjects, obj)
|
||||||
g.Objects = append(g.Objects[:i], g.Objects[i+1:]...)
|
g.Objects = append(g.Objects[:i], g.Objects[i+1:]...)
|
||||||
obj.IsInsideNearContainer = true
|
|
||||||
for _, child := range obj.ChildrenArray {
|
for _, child := range obj.ChildrenArray {
|
||||||
subObjects, subEdges := pluckOutNearObjectAndEdges(g, child)
|
subObjects, subEdges := pluckOutNearObjectAndEdges(g, child)
|
||||||
descendantsObjects = append(descendantsObjects, subObjects...)
|
descendantsObjects = append(descendantsObjects, subObjects...)
|
||||||
|
|
@ -229,7 +228,7 @@ func boundingBox(g *d2graph.Graph) (tl, br *geo.Point) {
|
||||||
y2 = math.Max(y2, obj.TopLeft.Y+obj.Height)
|
y2 = math.Max(y2, obj.TopLeft.Y+obj.Height)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if obj.IsInsideNearContainer {
|
if obj.IsInsideNearContainer() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
x1 = math.Min(x1, obj.TopLeft.X)
|
x1 = math.Min(x1, obj.TopLeft.X)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue