<s> """<STR_LIT>""" <EOL> import re <EOL> import weakref <EOL> from . . import visuals <EOL> from . node import Node <EOL> from . . visuals . filters import ColorFilter , PickingFilter <EOL> class VisualNode ( Node ) : <EOL> _next_id = <NUM_LIT:1> <EOL> _visual_ids = weakref . WeakValueDictionary ( ) <EOL> def __init__ ( self , parent = None , name = None ) : <EOL> Node . __init__ ( self , parent = parent , name = name , <EOL> transforms = self . transforms ) <EOL> self . interactive = False <EOL> self . _opacity_filter = ColorFilter ( ) <EOL> self . attach ( self . _opacity_filter ) <EOL> self . _id = VisualNode . _next_id <EOL> VisualNode . _visual_ids [ self . _id ] = self <EOL> VisualNode . _next_id += <NUM_LIT:1> <EOL> self . _picking_filter = PickingFilter ( id_ = self . _id ) <EOL> self . attach ( self . _picking_filter ) <EOL> def _update_opacity ( self ) : <EOL> self . _opacity_filter . color = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , self . _opacity ) <EOL> def _set_clipper ( self , node , clipper ) : <EOL> """<STR_LIT>""" <EOL> if node in self . _clippers : <EOL> self . detach ( self . _clippers . pop ( node ) ) <EOL> if clipper is not None : <EOL> self . attach ( clipper ) <EOL> self . _clippers [ node ] = clipper <EOL> @ property <EOL> def picking ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _picking <EOL> @ picking . setter <EOL> def picking ( self , p ) : <EOL> for c in self . children : <EOL> c . picking = p <EOL> if self . _picking == p : <EOL> return <EOL> self . _picking = p <EOL> self . _picking_filter . enabled = p <EOL> self . update_gl_state ( blend = not p ) <EOL> def _update_trsys ( self , event ) : <EOL> """<STR_LIT>""" <EOL> doc = self . document_node <EOL> scene = self . scene_node <EOL> root = self . root_node <EOL> self . transforms . visual_transform = self . node_transform ( scene ) <EOL> self . transforms . scene_transform = scene . node_transform ( doc ) <EOL> self . transforms . document_transform = doc . node_transform ( root ) <EOL> Node . _update_trsys ( self , event ) <EOL> @ property <EOL> def interactive ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _interactive <EOL> @ interactive . setter <EOL> def interactive ( self , i ) : <EOL> self . _interactive = i <EOL> def draw ( self ) : <EOL> if self . picking and not self . interactive : <EOL> return <EOL> self . _visual_superclass . draw ( self ) <EOL> def create_visual_node ( subclass ) : <EOL> clsname = subclass . __name__ <EOL> if not ( clsname . endswith ( '<STR_LIT>' ) and <EOL> issubclass ( subclass , visuals . BaseVisual ) ) : <EOL> raise RuntimeError ( '<STR_LIT>' <EOL> '<STR_LIT>' % clsname ) <EOL> clsname = clsname [ : - <NUM_LIT:6> ] <EOL> try : <EOL> doc = generate_docstring ( subclass , clsname ) <EOL> except Exception : <EOL> doc = subclass . __doc__ <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> parent = kwargs . pop ( '<STR_LIT>' , None ) <EOL> name = kwargs . pop ( '<STR_LIT:name>' , None ) <EOL> self . name = name <EOL> self . _visual_superclass = subclass <EOL> subclass . __init__ ( self , * args , ** kwargs ) <EOL> self . unfreeze ( ) <EOL> VisualNode . __init__ ( self , parent = parent , name = name ) <EOL> self . freeze ( ) <EOL> cls = type ( clsname , ( VisualNode , subclass ) , <EOL> { '<STR_LIT>' : __init__ , '<STR_LIT>' : doc } ) <EOL> return cls <EOL> def generate_docstring ( subclass , clsname ) : <EOL> sc_doc = subclass . __doc__ <EOL> if sc_doc is None : <EOL> sc_doc = "<STR_LIT>" <EOL> lines = sc_doc . split ( "<STR_LIT:\n>" ) <EOL> while lines and lines [ <NUM_LIT:0> ] . strip ( ) == '<STR_LIT>' : <EOL> lines . pop ( <NUM_LIT:0> ) <EOL> i = <NUM_LIT:0> <EOL> params_started = False <EOL> param_indent = None <EOL> first_blank = None <EOL> param_end = None <EOL> while i < len ( lines ) : <EOL> line = lines [ i ] <EOL> if re . search ( r'<STR_LIT>' , line ) : <EOL> indent = len ( line ) - len ( line . lstrip ( ) ) <EOL> if params_started : <EOL> if indent < param_indent : <EOL> break <EOL> elif indent == param_indent : <EOL> if re . match ( r'<STR_LIT>' , line ) is None : <EOL> break <EOL> param_end = i + <NUM_LIT:1> <EOL> elif re . match ( r'<STR_LIT>' , line ) : <EOL> params_started = True <EOL> param_indent = indent <EOL> if first_blank is None : <EOL> first_blank = i <EOL> elif first_blank is None and line . strip ( ) == '<STR_LIT>' : <EOL> first_blank = i <EOL> i += <NUM_LIT:1> <EOL> if i == len ( lines ) and param_end is None : <EOL> param_end = i <EOL> if not params_started : <EOL> lines . extend ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> param_end = len ( lines ) <EOL> if first_blank is None : <EOL> first_blank = param_end - <NUM_LIT:3> <EOL> params_started = True <EOL> class_desc = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( clsname ) ) <EOL> parm_doc = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> lines = ( lines [ : first_blank ] + <EOL> [ class_desc ] + <EOL> lines [ first_blank : param_end ] + <EOL> [ parm_doc ] + <EOL> lines [ param_end : ] ) <EOL> doc = '<STR_LIT:\n>' . join ( lines ) <EOL> return doc <EOL> Arrow = create_visual_node ( visuals . ArrowVisual ) <EOL> Axis = create_visual_node ( visuals . AxisVisual ) <EOL> Box = create_visual_node ( visuals . BoxVisual ) <EOL> ColorBar = create_visual_node ( visuals . ColorBarVisual ) <EOL> Compound = create_visual_node ( visuals . CompoundVisual ) <EOL> Cube = create_visual_node ( visuals . CubeVisual ) <EOL> Ellipse = create_visual_node ( visuals . EllipseVisual ) <EOL> GridLines = create_visual_node ( visuals . GridLinesVisual ) <EOL> GridMesh = create_visual_node ( visuals . GridMeshVisual ) <EOL> Histogram = create_visual_node ( visuals . HistogramVisual ) <EOL> Image = create_visual_node ( visuals . ImageVisual ) <EOL> Isocurve = create_visual_node ( visuals . IsocurveVisual ) <EOL> Isoline = create_visual_node ( visuals . IsolineVisual ) <EOL> Isosurface = create_visual_node ( visuals . IsosurfaceVisual ) <EOL> Line = create_visual_node ( visuals . LineVisual ) <EOL> LinePlot = create_visual_node ( visuals . LinePlotVisual ) <EOL> Markers = create_visual_node ( visuals . MarkersVisual ) <EOL> Mesh = create_visual_node ( visuals . MeshVisual ) <EOL> Plane = create_visual_node ( visuals . PlaneVisual ) <EOL> Polygon = create_visual_node ( visuals . PolygonVisual ) <EOL> Rectangle = create_visual_node ( visuals . RectangleVisual ) <EOL> RegularPolygon = create_visual_node ( visuals . RegularPolygonVisual ) <EOL> ScrollingLines = create_visual_node ( visuals . ScrollingLinesVisual ) <EOL> Spectrogram = create_visual_node ( visuals . SpectrogramVisual ) <EOL> Sphere = create_visual_node ( visuals . SphereVisual ) <EOL> SurfacePlot = create_visual_node ( visuals . SurfacePlotVisual ) <EOL> Text = create_visual_node ( visuals . TextVisual ) <EOL> Tube = create_visual_node ( visuals . TubeVisual ) <EOL> Volume = create_visual_node ( visuals . VolumeVisual ) <EOL> XYZAxis = create_visual_node ( visuals . XYZAxisVisual ) <EOL> __all__ = [ name for ( name , obj ) in globals ( ) . items ( ) <EOL> if isinstance ( obj , type ) and issubclass ( obj , VisualNode ) ] </s>
