@@ -38,7 +38,6 @@ def __init__(self, parent=None, parent_pos=(0, 0),
38
38
h_pad = None , w_pad = None , width_ratios = None ,
39
39
height_ratios = None ):
40
40
Variable = kiwi .Variable
41
- self .parent = parent
42
41
self .parent_pos = parent_pos
43
42
self .parent_inner = parent_inner
44
43
self .name = name + seq_id ()
@@ -57,12 +56,10 @@ def __init__(self, parent=None, parent_pos=(0, 0),
57
56
if not isinstance (parent , LayoutGrid ):
58
57
# parent can be a rect if not a LayoutGrid
59
58
# allows specifying a rectangle to contain the layout.
60
- self .parent = parent
61
59
self .solver = kiwi .Solver ()
62
60
else :
63
- self .parent = parent
64
61
parent .add_child (self , * parent_pos )
65
- self .solver = self . parent .solver
62
+ self .solver = parent .solver
66
63
# keep track of artist associated w/ this layout. Can be none
67
64
self .artists = np .empty ((nrows , ncols ), dtype = object )
68
65
self .children = np .empty ((nrows , ncols ), dtype = object )
@@ -77,14 +74,8 @@ def __init__(self, parent=None, parent_pos=(0, 0),
77
74
78
75
sol = self .solver
79
76
80
- # These are redundant, but make life easier if
81
- # we define them all. All that is really
82
- # needed is left/right, margin['left'], and margin['right']
83
- self .widths = [Variable (f'{ sn } widths[{ i } ]' ) for i in range (ncols )]
84
77
self .lefts = [Variable (f'{ sn } lefts[{ i } ]' ) for i in range (ncols )]
85
78
self .rights = [Variable (f'{ sn } rights[{ i } ]' ) for i in range (ncols )]
86
- self .inner_widths = [Variable (f'{ sn } inner_widths[{ i } ]' )
87
- for i in range (ncols )]
88
79
for todo in ['left' , 'right' , 'leftcb' , 'rightcb' ]:
89
80
self .margins [todo ] = [Variable (f'{ sn } margins[{ todo } ][{ i } ]' )
90
81
for i in range (ncols )]
@@ -95,9 +86,6 @@ def __init__(self, parent=None, parent_pos=(0, 0),
95
86
self .margins [todo ] = np .empty ((nrows ), dtype = object )
96
87
self .margin_vals [todo ] = np .zeros (nrows )
97
88
98
- self .heights = [Variable (f'{ sn } heights[{ i } ]' ) for i in range (nrows )]
99
- self .inner_heights = [Variable (f'{ sn } inner_heights[{ i } ]' )
100
- for i in range (nrows )]
101
89
self .bottoms = [Variable (f'{ sn } bottoms[{ i } ]' ) for i in range (nrows )]
102
90
self .tops = [Variable (f'{ sn } tops[{ i } ]' ) for i in range (nrows )]
103
91
for todo in ['bottom' , 'top' , 'bottomcb' , 'topcb' ]:
@@ -109,7 +97,7 @@ def __init__(self, parent=None, parent_pos=(0, 0),
109
97
# set these margins to zero by default. They will be edited as
110
98
# children are filled.
111
99
self .reset_margins ()
112
- self .add_constraints ()
100
+ self .add_constraints (parent )
113
101
114
102
self .h_pad = h_pad
115
103
self .w_pad = w_pad
@@ -119,14 +107,14 @@ def __repr__(self):
119
107
for i in range (self .nrows ):
120
108
for j in range (self .ncols ):
121
109
str += f'{ i } , { j } : ' \
122
- f'L( { self .lefts [j ].value ():1.3f} , ' \
110
+ f'L{ self .lefts [j ].value ():1.3f} , ' \
123
111
f'B{ self .bottoms [i ].value ():1.3f} , ' \
124
- f'W{ self .widths [j ].value ():1.3f} , ' \
125
- f'H{ self .heights [i ].value ():1.3f} , ' \
126
- f'innerW{ self .inner_widths [j ].value ():1.3f} , ' \
127
- f'innerH{ self .inner_heights [i ].value ():1.3f} , ' \
112
+ f'R{ self .rights [j ].value ():1.3f} , ' \
113
+ f'T{ self .tops [i ].value ():1.3f} , ' \
128
114
f'ML{ self .margins ["left" ][j ].value ():1.3f} , ' \
129
- f'MR{ self .margins ["right" ][j ].value ():1.3f} , \n '
115
+ f'MR{ self .margins ["right" ][j ].value ():1.3f} , ' \
116
+ f'MB{ self .margins ["bottom" ][i ].value ():1.3f} , ' \
117
+ <
67E6
div class="diff-text-inner"> f'MT{ self .margins ["top" ][i ].value ():1.3f} , \n '
130
118
return str
131
119
132
120
def reset_margins (self ):
@@ -139,11 +127,11 @@ def reset_margins(self):
139
127
'leftcb' , 'rightcb' , 'bottomcb' , 'topcb' ]:
140
128
self .edit_margins (todo , 0.0 )
141
129
142
- def add_constraints (self ):
130
+ def add_constraints (self , parent ):
143
131
# define self-consistent constraints
144
132
self .hard_constraints ()
145
133
# define relationship with parent layoutgrid:
146
- self .parent_constraints ()
134
+ self .parent_constraints (parent )
147
135
# define relative widths of the grid cells to each other
148
136
# and stack horizontally and vertically.
149
137
self .grid_constraints ()
@@ -177,12 +165,11 @@ def add_child(self,
8013
child, i=0, j=0):
177
165
# np.ix_ returns the cross product of i and j indices
178
166
self .children [np .ix_ (np .atleast_1d (i ), np .atleast_1d (j ))] = child
179
167
180
- def parent_constraints (self ):
168
+ def parent_constraints (self , parent ):
181
169
# constraints that are due to the parent...
182
170
# i.e. the first column's left is equal to the
183
171
# parent's left, the last column right equal to the
184
172
# parent's right...
185
- parent = self .parent
186
173
if not isinstance (parent , LayoutGrid ):
187
174
# specify a rectangle in figure coordinates
188
175
hc = [self .lefts [0 ] == parent [0 ],
0 commit comments