A `Bbox` where some elements may be locked at certain values. When the child bounding box changes, the bounds of this bbox will update accordingly with the exception of the locked elements.
| 1205 | |
| 1206 | |
| 1207 | class LockableBbox(BboxBase): |
| 1208 | """ |
| 1209 | A `Bbox` where some elements may be locked at certain values. |
| 1210 | |
| 1211 | When the child bounding box changes, the bounds of this bbox will update |
| 1212 | accordingly with the exception of the locked elements. |
| 1213 | """ |
| 1214 | def __init__(self, bbox, x0=None, y0=None, x1=None, y1=None, **kwargs): |
| 1215 | """ |
| 1216 | Parameters |
| 1217 | ---------- |
| 1218 | bbox : `Bbox` |
| 1219 | The child bounding box to wrap. |
| 1220 | |
| 1221 | x0 : float or None |
| 1222 | The locked value for x0, or None to leave unlocked. |
| 1223 | |
| 1224 | y0 : float or None |
| 1225 | The locked value for y0, or None to leave unlocked. |
| 1226 | |
| 1227 | x1 : float or None |
| 1228 | The locked value for x1, or None to leave unlocked. |
| 1229 | |
| 1230 | y1 : float or None |
| 1231 | The locked value for y1, or None to leave unlocked. |
| 1232 | |
| 1233 | """ |
| 1234 | _api.check_isinstance(BboxBase, bbox=bbox) |
| 1235 | super().__init__(**kwargs) |
| 1236 | self._bbox = bbox |
| 1237 | self.set_children(bbox) |
| 1238 | self._points = None |
| 1239 | fp = [x0, y0, x1, y1] |
| 1240 | mask = [val is None for val in fp] |
| 1241 | self._locked_points = np.ma.array(fp, float, mask=mask).reshape((2, 2)) |
| 1242 | |
| 1243 | __str__ = _make_str_method("_bbox", "_locked_points") |
| 1244 | |
| 1245 | def get_points(self): |
| 1246 | # docstring inherited |
| 1247 | if self._invalid: |
| 1248 | points = self._bbox.get_points() |
| 1249 | self._points = np.where(self._locked_points.mask, |
| 1250 | points, |
| 1251 | self._locked_points) |
| 1252 | self._invalid = 0 |
| 1253 | return self._points |
| 1254 | |
| 1255 | if DEBUG: |
| 1256 | _get_points = get_points |
| 1257 | |
| 1258 | def get_points(self): |
| 1259 | points = self._get_points() |
| 1260 | self._check(points) |
| 1261 | return points |
| 1262 | |
| 1263 | @property |
| 1264 | def locked_x0(self): |
nothing calls this directly
no test coverage detected
searching dependent graphs…