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
|
|
@ -90,12 +90,11 @@ type Object struct {
|
|||
LabelDimensions d2target.TextDimensions `json:"label_dimensions"`
|
||||
References []Reference `json:"references,omitempty"`
|
||||
|
||||
*geo.Box `json:"box,omitempty"`
|
||||
LabelPosition *string `json:"labelPosition,omitempty"`
|
||||
LabelWidth *int `json:"labelWidth,omitempty"`
|
||||
LabelHeight *int `json:"labelHeight,omitempty"`
|
||||
IconPosition *string `json:"iconPosition,omitempty"`
|
||||
IsInsideNearContainer bool `json:"isInsideNearContainer,omitempty"`
|
||||
*geo.Box `json:"box,omitempty"`
|
||||
LabelPosition *string `json:"labelPosition,omitempty"`
|
||||
LabelWidth *int `json:"labelWidth,omitempty"`
|
||||
LabelHeight *int `json:"labelHeight,omitempty"`
|
||||
IconPosition *string `json:"iconPosition,omitempty"`
|
||||
|
||||
Class *d2target.Class `json:"class,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
|
||||
}
|
||||
|
||||
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 {
|
||||
Index int `json:"index"`
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,6 @@ func pluckOutNearObjectAndEdges(g *d2graph.Graph, obj *d2graph.Object) (descenda
|
|||
if temp.AbsID() == obj.AbsID() {
|
||||
descendantsObjects = append(descendantsObjects, obj)
|
||||
g.Objects = append(g.Objects[:i], g.Objects[i+1:]...)
|
||||
obj.IsInsideNearContainer = true
|
||||
for _, child := range obj.ChildrenArray {
|
||||
subObjects, subEdges := pluckOutNearObjectAndEdges(g, child)
|
||||
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)
|
||||
}
|
||||
} else {
|
||||
if obj.IsInsideNearContainer {
|
||||
if obj.IsInsideNearContainer() {
|
||||
continue
|
||||
}
|
||||
x1 = math.Min(x1, obj.TopLeft.X)
|
||||
|
|
|
|||
Loading…
Reference in a new issue