def draw(self, renderer): v = None if isSupportedRenderer(renderer): self._sort_zpos = None renderer.use_gl = True glcanvas = get_glcanvas() if self.axes is not None: tag = self.axes trans = self.axes.transAxes elif self.figure is not None: tag = self.figure trans = self.figure.transFigure do_proj = False if glcanvas.has_vbo_data(self): d = glcanvas.get_vbo_data(self) if self._update_v: d[0]['v'].need_update = True self._gl_facecolor = self.to_rgba(self._gl_3dpath[2]) if self._update_ec: d[0]['ec'].need_update = True self._gl_edgecolor = self.to_rgba(self._gl_3dpath[2]) if self._update_ec: self.update_scalarmappable() gc = renderer.new_gc() glcanvas.frame_request(self, trans) # if not glcanvas.has_vbo_data(self): # renderer.do_stencil_test = self.do_stencil_test glcanvas.start_draw_request(self) if self._gl_3dpath is not None: renderer.gl_draw_path_collection_e( gc, None, self._gl_3dpath, self.get_transforms(), self._gl_offset, None, None, self._gl_edgecolor, self._linewidths, self._linestyles, self._antialiaseds, self._urls, self._offset_position, lighting = self._gl_lighting, stencil_test = self.do_stencil_test, view_offset = self._gl_voffset) # renderer.do_stencil_test = False glcanvas.end_draw_request() gc.restore() self._update_ec = False self._update_v = False finish_gl_drawing(glcanvas, renderer, tag, trans) renderer.use_gl = False else: v = Line3DCollectionGL.draw(self, renderer)
def draw(self, renderer): v = None if isSupportedRenderer(renderer): renderer.use_gl = True glcanvas = get_glcanvas() if self.axes is not None: tag = self.axes trans = self.axes.transAxes elif self.figure is not None: tag = self.figure trans = self.figure.transFigure glcanvas.frame_request(self, trans) # if not glcanvas.has_vbo_data(self): glcanvas.start_draw_request(self) if self._gl_3dpath is not None: try: im = self.to_rgba(self._A) im = (im * 255).astype(int) except: # this is for an old version of matplotlib im = self.make_image(renderer.get_image_magnification()) idx_none = im[..., 3] == 0 im[idx_none, 0:3] = 255 self._im_cache = im gc = renderer.new_gc() gc.set_alpha(self.get_alpha()) if self._gl_rgbacache_id != id(self._rgbacache): if glcanvas.has_vbo_data(self): d = glcanvas.get_vbo_data(self) for x in d: x['im_update'] = True renderer.gl_draw_image(gc, self._gl_3dpath, trans, np.transpose(self._im_cache, (1, 0, 2)), interp=self._gl_interp, always_noclip=self._gl_always_noclip) self._gl_rgbacache_id = id(self._rgbacache) gc.restore() else: pass glcanvas.end_draw_request() finish_gl_drawing(glcanvas, renderer, tag, trans) renderer.use_gl = False else: pass
def draw(self, renderer): v = None if isSupportedRenderer(renderer): renderer.use_gl = True glcanvas = get_glcanvas() if self.axes is not None: tag = self.axes trans = self.axes.transAxes elif self.figure is not None: tag = self.figure trans = self.figure.transFigure glcanvas.frame_request(self, trans) # if not glcanvas.has_vbo_data(self): glcanvas.start_draw_request(self) if self._gl_3dpath is not None: try: im = self.to_rgba(self._A) im = (im*255).astype(int) except: # this is for an old version of matplotlib im = self.make_image(renderer.get_image_magnification()) self._im_cache = im gc = renderer.new_gc() gc.set_alpha(self.get_alpha()) if self._gl_rgbacache_id != id(self._rgbacache): if glcanvas.has_vbo_data(self): d = glcanvas.get_vbo_data(self) for x in d: x['im_update'] = True renderer.gl_draw_image(gc, self._gl_3dpath, trans, np.transpose(self._im_cache, (1,0,2)), interp = self._gl_interp) self._gl_rgbacache_id = id(self._rgbacache) gc.restore() else: pass glcanvas.end_draw_request() finish_gl_drawing(glcanvas, renderer, tag, trans) renderer.use_gl = False else: pass
def draw(self, renderer): if isSupportedRenderer(renderer): renderer.use_gl = True glcanvas = get_glcanvas() if self.axes is not None: tag = self.axes trans = self.axes.transAxes elif self.figure is not None: tag = self.figure trans = self.figure.transFigure gc = renderer.new_gc() rgbFace = self._facecolor gc.set_foreground(self._edgecolor, isRGBA=True) glcanvas.frame_request(self, trans) # if not glcanvas.has_vbo_data(self): glcanvas.start_draw_request(self) if self._invalidz: if glcanvas.has_vbo_data(self): d = glcanvas.get_vbo_data(self) d[0]['v'].need_update = True self._invalidz = False renderer.gl_draw_path(gc, self._verts3d, trans, rgbFace=rgbFace, stencil_test=self.do_stencil_test) # glcanvas.update_gc(self, gc) glcanvas.end_draw_request() # else: # glcanvas.update_gc(self, gc) gc.restore() renderer.use_gl = False finish_gl_drawing(glcanvas, renderer, tag, trans) else: Polygon.draw(self, renderer)
def draw(self, renderer): if isSupportedRenderer(renderer): renderer.use_gl = True glcanvas = get_glcanvas() if self.axes is not None: tag = self.axes trans = self.axes.transAxes elif self.figure is not None: tag = self.figure trans = self.figure.transFigure gc = renderer.new_gc() rgbFace = self._facecolor gc.set_foreground(self._edgecolor, isRGBA=True) glcanvas.frame_request(self, trans) # if not glcanvas.has_vbo_data(self): glcanvas.start_draw_request(self) if self._invalidz: if glcanvas.has_vbo_data(self): d = glcanvas.get_vbo_data(self) d[0]['v'].need_update = True self._invalidz = False renderer.gl_draw_path(gc, self._verts3d, trans, rgbFace = rgbFace, stencil_test = self.do_stencil_test) # glcanvas.update_gc(self, gc) glcanvas.end_draw_request() # else: # glcanvas.update_gc(self, gc) gc.restore() renderer.use_gl = False finish_gl_drawing(glcanvas, renderer, tag, trans) else: Polygon.draw(self, renderer)
def draw(self, renderer): # if self._use_gl and isSupportedRenderer(renderer): gl_len = 0 if isSupportedRenderer(renderer): self._matrix_cache = self.get_proj2() artists = [] artists.extend(self.images) artists.extend(self.collections) artists.extend(self.patches) artists.extend(self.lines) artists.extend(self.texts) artists.extend(self.artists) gl_obj = [a for a in artists if hasattr(a, 'is_gl')] gl_len = len(gl_obj) if gl_obj > 0: glcanvas = get_glcanvas() if (glcanvas is not None and glcanvas.init): glcanvas.set_lighting(**self._lighting) glcanvas._gl_scale = self._gl_scale else: return renderer._num_globj = gl_len renderer._k_globj = 0 ### axes3D seems to change frameon status.... frameon = self.get_frame_on() self.set_frame_on(False) if self._show_3d_axes: self.draw_3d_axes() for a in self._3d_axes_icon: a().set_zorder(gl_len + 1) else: if self._3d_axes_icon is not None: self.lines.remove(self._3d_axes_icon[0]()) self.lines.remove(self._3d_axes_icon[1]()) self.lines.remove(self._3d_axes_icon[2]()) self.texts.remove(self._3d_axes_icon[3]()) self.texts.remove(self._3d_axes_icon[4]()) self.texts.remove(self._3d_axes_icon[5]()) self._3d_axes_icon = None if self._gl_scale != 1.0: print("gl_scale", self._gl_scale) xmin, xmax = self.get_xlim3d() ymin, ymax = self.get_ylim3d() zmin, zmax = self.get_zlim3d() dx = (xmax - xmin) / self._gl_scale / 2. dy = (ymax - ymin) / self._gl_scale / 2. dz = (zmax - zmin) / self._gl_scale / 2. xmid = (xmax + xmin) / 2. ymid = (ymax + ymin) / 2. zmid = (zmax + zmin) / 2. self.set_xlim3d([xmid - dx, xmid + dx]) self.set_ylim3d([ymid - dy, ymid + dy]) self.set_zlim3d([zmid - dz, zmid + dz]) val = Axes3D.draw(self, renderer) if self._gl_scale != 1.0: self.set_xlim3d([xmin, xmax]) self.set_ylim3d([ymin, ymax]) self.set_zlim3d([zmin, zmax]) self.set_frame_on(frameon) return val
def draw(self, renderer): # if self._use_gl and isSupportedRenderer(renderer): gl_len = 0 if isSupportedRenderer(renderer): self._matrix_cache = self.get_proj2() artists = [] artists.extend(self.images) artists.extend(self.collections) artists.extend(self.patches) artists.extend(self.lines) artists.extend(self.texts) artists.extend(self.artists) gl_obj = [a for a in artists if hasattr(a, 'is_gl')] gl_len = len(gl_obj) if gl_obj > 0: glcanvas = get_glcanvas() if (glcanvas is not None and glcanvas.init): glcanvas.set_lighting(**self._lighting) glcanvas._gl_scale = self._gl_scale else: return renderer._num_globj = gl_len renderer._k_globj = 0 ### axes3D seems to change frameon status.... frameon = self.get_frame_on() self.set_frame_on(False) if self._show_3d_axes: self.draw_3d_axes() for a in self._3d_axes_icon: a().set_zorder(gl_len+1) else: if self._3d_axes_icon is not None: self.lines.remove(self._3d_axes_icon[0]()) self.lines.remove(self._3d_axes_icon[1]()) self.lines.remove(self._3d_axes_icon[2]()) self.texts.remove(self._3d_axes_icon[3]()) self.texts.remove(self._3d_axes_icon[4]()) self.texts.remove(self._3d_axes_icon[5]()) self._3d_axes_icon = None if self._gl_scale != 1.0: print("gl_scale", self._gl_scale) xmin, xmax = self.get_xlim3d() ymin, ymax = self.get_ylim3d() zmin, zmax = self.get_zlim3d() dx = (xmax - xmin)/self._gl_scale/2. dy = (ymax - ymin)/self._gl_scale/2. dz = (zmax - zmin)/self._gl_scale/2. xmid = (xmax + xmin)/2. ymid = (ymax + ymin)/2. zmid = (zmax + zmin)/2. self.set_xlim3d([xmid-dx, xmid+dx]) self.set_ylim3d([ymid-dy, ymid+dy]) self.set_zlim3d([zmid-dz, zmid+dz]) val = Axes3D.draw(self, renderer) if self._gl_scale != 1.0: self.set_xlim3d([xmin, xmax]) self.set_ylim3d([ymin, ymax]) self.set_zlim3d([zmin, zmax]) self.set_frame_on(frameon) return val
def draw(self, renderer): v = None if isSupportedRenderer(renderer): self._sort_zpos = None renderer.use_gl = True glcanvas = get_glcanvas() if self.axes is not None: tag = self.axes trans = self.axes.transAxes elif self.figure is not None: tag = self.figure trans = self.figure.transFigure if glcanvas.has_vbo_data(self): d = glcanvas.get_vbo_data(self) if self._gl_cz: cz = self._gl_facecolordata elif self._gl_cz is not None: cz = self._gl_cz else: cz = self._gl_3dpath[2] if len(d) > 0 and d[0] is not None: if self._update_v: d[0]['v'].need_update = True self._gl_facecolor = self.to_rgba(cz) if self._update_fc: d[0]['fc'].need_update = True self._gl_facecolor = self.to_rgba(cz) if self._update_ec: d[0]['ec'].need_update = True self._gl_edgecolor = self.to_rgba(cz) if self._update_i: d[0]['i'].need_update = True if self._update_a: if 'vertex_id' in d[0] and d[0]['vertex_id'] is not None: d[0]['vertex_id'].need_update = True else: self._update_a = False self._update_v = False self._update_fc = False self._update_ec = False self._update_i = False # this happens when all surfaces are hidden. # if (len(d)) == 0: print('vbo zero length', self.figobj) if self._update_ec or self._update_fc: self.update_scalarmappable() gc = renderer.new_gc() glcanvas.frame_request(self, trans) # renderer.do_stencil_test = self.do_stencil_test glcanvas.start_draw_request(self) if self._gl_3dpath is not None: if isinstance(self._gl_3dpath[4], list): renderer.gl_draw_path_collection( gc, None, self._gl_3dpath, self.get_transforms(), self._gl_offset, None, self._gl_facecolor, self._gl_edgecolor, self._linewidths, self._linestyles, self._antialiaseds, self._urls, self._offset_position, stencil_test = self.do_stencil_test, view_offset = self._gl_voffset, array_idx = self._gl_array_idx) else: renderer.gl_draw_path_collection_e( gc, None, self._gl_3dpath, self.get_transforms(), self._gl_offset, None, self._gl_facecolor, self._gl_edgecolor, self._linewidths, self._linestyles, self._antialiaseds, self._urls, self._offset_position, stencil_test = self.do_stencil_test, view_offset = self._gl_voffset, array_idx = self._gl_array_idx, use_pointfill = self._gl_use_pointfill) # renderer.do_stencil_test = False glcanvas.end_draw_request() gc.restore() self._update_fc = False self._update_ec = False self._update_v = False self._update_i = False finish_gl_drawing(glcanvas, renderer, tag, trans) renderer.use_gl = False else: v = Collection.draw(self, renderer) return v
def draw(self, renderer): if isSupportedRenderer(renderer): if self._invalidy or self._invalidx or self._invalidz: self.recache() if self.get_zdata() is None: self._zorig = np.array([0]*len(self.get_xdata())) renderer.use_gl = True glcanvas = get_glcanvas() if self.axes is not None: tag = self.axes trans = self.axes.transAxes elif self.figure is not None: tag = self.figure trans = self.figure.transFpigure glcanvas.frame_request(self, trans) # if not glcanvas.has_vbo_data(self): glcanvas.start_draw_request(self) #3dpath = (self.get_xdata(), self.get_ydata(), self_zdata()) #path = Path(self._xy) if self._invalidz: self.set_3d_properties(zs=self.get_zdata(), zdir='z') if glcanvas.has_vbo_data(self): d = glcanvas.get_vbo_data(self) for x in d: x['v'].need_update = True # path.zvalues = self.get_zdata() self._invalidz = False gc = renderer.new_gc() ln_color_rgba = self._get_rgba_ln_color() gc.set_foreground(ln_color_rgba, isRGBA=True) gc.set_linewidth(self._linewidth) if self._marker.get_marker() == ',': gc.set_linewidth(0) if self._gl_3dpath is None: self.verts3d_to_3dpath() if len(self._gl_3dpath) == 3: renderer.gl_draw_path(gc, self._gl_3dpath, trans, rgbFace = self._facecolor, linestyle = self._linestyle) else: fc = None if self._facecolor is None else [self._facecolor] renderer.gl_draw_path_collection_e( gc, None, self._gl_3dpath, None, self._gl_offset, None, fc, [ln_color_rgba], [self._linewidth], self._linestyle, self._antialiased, self._url, None, lighting = self._gl_lighting, stencil_test = False, view_offset = self._gl_voffset, array_idx = self._gl_array_idx) if len(self._marker.get_path()) != 0: marker_path = None marker_trans = None m_facecolor = self.get_markerfacecolor() m_edgecolor = self.get_markeredgecolor() m_edgewidth = self.get_markeredgewidth() m_size = renderer.points_to_pixels(self._markersize) #marker_path is bitmap (texture) #marker_trans is marker_size and other info (liken marker_every) marker_path = self.update_marker_texture(renderer) marker_trans = (m_size,) renderer.gl_draw_markers(gc, marker_path, marker_trans, self._gl_3dpath[:3], trans, array_idx = self._gl_array_idx) glcanvas.end_draw_request() gc.restore() finish_gl_drawing(glcanvas, renderer, tag, trans) renderer.use_gl = False else: v = Line3D.draw(self, renderer)