Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
make renderers singleton classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ohanar committed May 27, 2015
1 parent 80067fe commit 85f083e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/sage/plot/plot3d/renderers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@
"""
class Graphics3dRenderer(object):

# renderer's are singletons
_instance = None
def __new__(cls):
"""
TEST::
sage: from sage.plot.plot3d.renderers.api import Graphics3dRenderer
sage: Graphics3dRenderer() is Graphics3dRenderer()
True
"""
if cls._instance.__class__ is cls:
return cls._instance
else:
cls._instance = object.__new__(cls)
return cls._instance

def render_graphics3d(self, obj, render_params):
"""
Unless otherwise changed, all rendering methods fall back to this
one.
"""
return ''
return []

def render_graphics3d_group(self, obj, render_params):
"""
Expand Down Expand Up @@ -58,5 +74,3 @@ def render_mobius_strip(self, obj, render_params):
def render_implicit_surface(self, obj, render_params):
obj.triangulate()
return self.render_index_face_set(obj, render_params)


0 comments on commit 85f083e

Please sign in to comment.