Hi,
We opened an issue on Github and was recommended to follow it up here by open and “issue”. The problem background was described in the github issue 23736.(see link at topic)
In short the problem is that quiver, which is a result of mouse pick, will not shown until a mouse drag view change on a 3D scatter plot. We follow the suggestion that Thomas gave us by adding draw_artist to force copy buffer to the GUI widget and addding restore background to restore unchanged part, Unfortunatiley the solution does not work.
Our target is to display the quiver once the pick is done without changing view every time. We don’t plan to use canvas.show() as its performace is not satisfying when the scatter data become large, eg 1M pt. Appreciate if anyone can give us a hand.
ps. If copy git issue content to here is required pls. let us know.
The code of on pick part as following:
def pick(self,event):
# pt3d_art = event.artist
xx=event.mouseevent.x
yy=event.mouseevent.y
ind_min = self.find_closest(xx,yy)
px_flat = self.X[ind_min] ##
py_flat = self.Y[ind_min] ##self.Y
pz_flat = self.Z[ind_min] ##self.Z
pt_norm = self.data_pcd.normals[ind_min]
u,v,w=pt_norm[0],pt_norm[1],pt_norm[2]
Vnorm = v3dv.Vector(*pt_norm)
agl_z = v3dv.angle(self.Vz, Vnorm) ## degrees
print("norm to z angle is ",agl_z)
bg = self.canvas.copy_from_bbox(self.fig.bbox)
my_qvr = self.axes.quiver(px_flat, py_flat, pz_flat, u, v, w, colors ="r") #length=0.1, normalize=True)
self.canvas.blit(self.fig.bbox)
self.rdrer = self.canvas.get_renderer()
my_qvr.draw(self.rdrer) ## no effect
self.axes.draw_artist(my_qvr) ##
self.canvas.restore_region(bg)
draw_list = self.axes.get_children()
print("draw list is ",draw_list)
# self.axes.redraw_in_frame() ## poor performance
self.canvas.update()
# self.canvas.draw()
self.canvas.flush_events()
def find_closest(self,c_x,c_y):
imin=0
mat_c = self.axes.get_proj()
if not np.allclose(mat_c,self.mat_last):
x2, y2, z2=proj3d.proj_transform(self.X_flat, self.Y_flat, self.Z_flat, mat_c)
self.xy_2 = np.array((x2,y2)).T
self.mat_last = mat_c
invt = self.axes.transData.inverted()
cx_2, cy_2 = invt.transform((c_x,c_y))
cxy_2 = np.array([[cx_2,cy_2]])
d_c = self.xy_2 - cxy_2
d_pt = np.linalg.norm(d_c,axis=1)
imin = np.argmin(d_pt)
return imin
Regards