Skip to content

Commit 6b6945f

Browse files
Share render depth between all instances...
1 parent 3b4a07a commit 6b6945f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

matplotview/_view_axes.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
DEFAULT_RENDER_DEPTH = 10
1111

12+
1213
class BoundRendererArtist:
1314
def __init__(self, artist: Artist, renderer: RendererBase, clip_box: Bbox):
1415
self._artist = artist
@@ -43,6 +44,10 @@ def draw(self, renderer: RendererBase):
4344
self._artist.set_clip_box(clip_box_orig)
4445

4546

47+
class SharedRenderDepth:
48+
current_depth = 0
49+
50+
4651
def view_wrapper(axes_class: Type[Axes]) -> Type[Axes]:
4752
"""
4853
Construct a ViewAxes, which subclasses, or wraps a specific Axes subclass.
@@ -144,7 +149,6 @@ def _init_vars(
144149
self.__image_interpolation = image_interpolation
145150
self.__max_render_depth = render_depth
146151
self.__filter_function = filter_function
147-
self._render_depth = 0
148152
self.__scale_lines = True
149153
self.__renderer = None
150154

@@ -182,9 +186,9 @@ def draw(self, renderer: RendererBase = None):
182186
# It is possible to have two axes which are views of each other
183187
# therefore we track the number of recursions and stop drawing
184188
# at a certain depth
185-
if(self._render_depth >= self.__max_render_depth):
189+
if(SharedRenderDepth.current_depth >= self.__max_render_depth):
186190
return
187-
self._render_depth += 1
191+
SharedRenderDepth.current_depth += 1
188192
# Set the renderer, causing get_children to return the view's
189193
# children also...
190194
self.__renderer = renderer
@@ -193,7 +197,7 @@ def draw(self, renderer: RendererBase = None):
193197

194198
# Get rid of the renderer...
195199
self.__renderer = None
196-
self._render_depth -= 1
200+
SharedRenderDepth.current_depth -= 1
197201

198202
def get_linescaling(self) -> bool:
199203
"""

0 commit comments

Comments
 (0)