| 166 | self.children[np.ix_(np.atleast_1d(i), np.atleast_1d(j))] = child |
| 167 | |
| 168 | def parent_constraints(self, parent): |
| 169 | # constraints that are due to the parent... |
| 170 | # i.e. the first column's left is equal to the |
| 171 | # parent's left, the last column right equal to the |
| 172 | # parent's right... |
| 173 | if not isinstance(parent, LayoutGrid): |
| 174 | # specify a rectangle in figure coordinates |
| 175 | hc = [self.lefts[0] == parent[0], |
| 176 | self.rights[-1] == parent[0] + parent[2], |
| 177 | # top and bottom reversed order... |
| 178 | self.tops[0] == parent[1] + parent[3], |
| 179 | self.bottoms[-1] == parent[1]] |
| 180 | else: |
| 181 | rows, cols = self.parent_pos |
| 182 | rows = np.atleast_1d(rows) |
| 183 | cols = np.atleast_1d(cols) |
| 184 | |
| 185 | left = parent.lefts[cols[0]] |
| 186 | right = parent.rights[cols[-1]] |
| 187 | top = parent.tops[rows[0]] |
| 188 | bottom = parent.bottoms[rows[-1]] |
| 189 | if self.parent_inner: |
| 190 | # the layout grid is contained inside the inner |
| 191 | # grid of the parent. |
| 192 | left += parent.margins['left'][cols[0]] |
| 193 | left += parent.margins['leftcb'][cols[0]] |
| 194 | right -= parent.margins['right'][cols[-1]] |
| 195 | right -= parent.margins['rightcb'][cols[-1]] |
| 196 | top -= parent.margins['top'][rows[0]] |
| 197 | top -= parent.margins['topcb'][rows[0]] |
| 198 | bottom += parent.margins['bottom'][rows[-1]] |
| 199 | bottom += parent.margins['bottomcb'][rows[-1]] |
| 200 | hc = [self.lefts[0] == left, |
| 201 | self.rights[-1] == right, |
| 202 | # from top to bottom |
| 203 | self.tops[0] == top, |
| 204 | self.bottoms[-1] == bottom] |
| 205 | for c in hc: |
| 206 | self.solver.addConstraint(c | 'required') |
| 207 | |
| 208 | def grid_constraints(self): |
| 209 | # constrain the ratio of the inner part of the grids |