An OffsetBox with an auxiliary transform. All child artists are first transformed with *aux_transform*, then translated with an offset (the same for all children) so the bounding box of the children matches the drawn box. (In other words, adding an arbitrary translation to *au
| 826 | |
| 827 | |
| 828 | class AuxTransformBox(OffsetBox): |
| 829 | """ |
| 830 | An OffsetBox with an auxiliary transform. |
| 831 | |
| 832 | All child artists are first transformed with *aux_transform*, then |
| 833 | translated with an offset (the same for all children) so the bounding |
| 834 | box of the children matches the drawn box. (In other words, adding an |
| 835 | arbitrary translation to *aux_transform* has no effect as it will be |
| 836 | cancelled out by the later offsetting.) |
| 837 | |
| 838 | `AuxTransformBox` is similar to `.DrawingArea`, except that the extent of |
| 839 | the box is not predetermined but calculated from the window extent of its |
| 840 | children, and the extent of the children will be calculated in the |
| 841 | transformed coordinate. |
| 842 | """ |
| 843 | def __init__(self, aux_transform): |
| 844 | self.aux_transform = aux_transform |
| 845 | super().__init__() |
| 846 | self.offset_transform = mtransforms.Affine2D() |
| 847 | # ref_offset_transform makes offset_transform always relative to the |
| 848 | # lower-left corner of the bbox of its children. |
| 849 | self.ref_offset_transform = mtransforms.Affine2D() |
| 850 | |
| 851 | def add_artist(self, a): |
| 852 | """Add an `.Artist` to the container box.""" |
| 853 | self._children.append(a) |
| 854 | a.set_transform(self.get_transform()) |
| 855 | self.stale = True |
| 856 | |
| 857 | def get_transform(self): |
| 858 | """Return the `.Transform` applied to the children.""" |
| 859 | return (self.aux_transform |
| 860 | + self.ref_offset_transform |
| 861 | + self.offset_transform) |
| 862 | |
| 863 | def set_transform(self, t): |
| 864 | """ |
| 865 | set_transform is ignored. |
| 866 | """ |
| 867 | |
| 868 | def set_offset(self, xy): |
| 869 | """ |
| 870 | Set the offset of the container. |
| 871 | |
| 872 | Parameters |
| 873 | ---------- |
| 874 | xy : (float, float) |
| 875 | The (x, y) coordinates of the offset in display units. |
| 876 | """ |
| 877 | self._offset = xy |
| 878 | self.offset_transform.clear() |
| 879 | self.offset_transform.translate(xy[0], xy[1]) |
| 880 | self.stale = True |
| 881 | |
| 882 | def get_offset(self): |
| 883 | """Return offset of the container.""" |
| 884 | return self._offset |
| 885 |
no outgoing calls
searching dependent graphs…