Render the :class:`Plate`, :class:`Edge` and :class:`Node` objects in the model. This will create a new figure with the correct dimensions and plot the model in this area. :param dpi: (optional) The DPI value to use for rendering.
(self, dpi=None)
| 360 | return None |
| 361 | |
| 362 | def render(self, dpi=None): |
| 363 | """ |
| 364 | Render the :class:`Plate`, :class:`Edge` and :class:`Node` objects in |
| 365 | the model. This will create a new figure with the correct dimensions |
| 366 | and plot the model in this area. |
| 367 | |
| 368 | :param dpi: (optional) |
| 369 | The DPI value to use for rendering. |
| 370 | |
| 371 | """ |
| 372 | |
| 373 | if dpi is None: |
| 374 | self._ctx.dpi = self._dpi |
| 375 | else: |
| 376 | self._ctx.dpi = dpi |
| 377 | |
| 378 | def get_max(maxsize, artist): |
| 379 | if isinstance(artist, Ellipse): |
| 380 | maxsize = np.maximum( |
| 381 | maxsize, |
| 382 | artist.center |
| 383 | + np.array([artist.width, artist.height]) / 2, |
| 384 | dtype=np.float64, |
| 385 | ) |
| 386 | elif isinstance(artist, Rectangle): |
| 387 | maxsize = np.maximum( |
| 388 | maxsize, |
| 389 | np.array([artist._x0, artist._y0], dtype=np.float64) |
| 390 | + np.array([artist._width, artist._height]), |
| 391 | dtype=np.float64, |
| 392 | ) |
| 393 | return maxsize |
| 394 | |
| 395 | def get_min(minsize, artist): |
| 396 | if isinstance(artist, Ellipse): |
| 397 | minsize = np.minimum( |
| 398 | minsize, |
| 399 | artist.center |
| 400 | - np.array([artist.width, artist.height]) / 2, |
| 401 | dtype=np.float64, |
| 402 | ) |
| 403 | elif isinstance(artist, Rectangle): |
| 404 | minsize = np.minimum( |
| 405 | minsize, |
| 406 | np.array([artist._x0, artist._y0], dtype=np.float64), |
| 407 | ) |
| 408 | return minsize |
| 409 | |
| 410 | # Auto-set shape |
| 411 | # We pass through each object once to find the maximum coordinates |
| 412 | if self.shape is None: |
| 413 | |
| 414 | maxsize = np.copy(self._ctx.origin) |
| 415 | |
| 416 | for plate in self._plates: |
| 417 | artist = plate.render(self._ctx) |
| 418 | maxsize = get_max(maxsize, artist) |
| 419 |