Changeset 3900 for trunk/GSASIIplot.py
- Timestamp:
- Apr 15, 2019 4:15:37 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r3899 r3900 7983 7983 G2frame.G2plotNB.status.SetStatusText('New quaternion: %.2f+, %.2fi+ ,%.2fj+, %.2fk'%(Q[0],Q[1],Q[2],Q[3]),1) 7984 7984 Draw('move') 7985 elif drawingData['showSlice']: 7986 View = GL.glGetIntegerv(GL.GL_VIEWPORT) 7987 Tx,Ty,Tz = drawingData['viewPoint'][0] 7988 tx,ty,tz = GLU.gluProject(Tx,Ty,Tz) 7989 Cx,Cy,Cz = GLU.gluUnProject(newxy[0],View[3]-newxy[1],tz) 7990 rho = G2mth.getRho([Cx,Cy,Cz],mapData) 7991 G2frame.G2plotNB.status.SetStatusText('Cursor position: %.4f, %.4f, %.4f; density: %.4f'%(Cx,Cy,Cz,rho),1) 7992 7985 7993 7986 7994 def OnMouseWheel(event): … … 8782 8790 for plane in Planes: 8783 8791 RenderPlane(plane,color) 8784 if drawingData['showSlice']: 8785 if len(D4mapData.get('rho',[])): #preferentially select 4D map if there 8786 rho = D4mapData['rho'][:,:,:,int(G2frame.tau*10)] #pick current tau 3D slice 8787 elif len(mapData['rho']): #ordinary 3D map 8788 rho = mapData['rho'] 8789 else: 8790 return 8791 from matplotlib.backends.backend_agg import FigureCanvasAgg 8792 import matplotlib.pyplot as plt 8793 Model = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX) 8794 invModel = nl.inv(Model) 8795 msize = 5. #-5A - 5A slice 8796 npts = int(2*msize/0.25) 8797 VP = np.array(drawingData['viewPoint'][0]) 8798 SX,SY = np.meshgrid(np.linspace(-1.,1.,npts),np.linspace(-1.,1.,npts)) 8799 SXYZ = msize*np.dstack((SX,SY,np.zeros_like(SX))) 8800 SXYZ = np.reshape(np.inner(SXYZ,invModel[:3,:3].T)+VP[nxs,nxs,:],(-1,3)) 8801 Z = np.reshape(G2mth.getRhos(SXYZ,rho),(npts,npts)) 8802 plt.rcParams['figure.facecolor'] = (1.,1.,1.,.5) 8803 plt.cla() 8804 plt.contour(Z,colors='k',linewidths=1) 8805 plt.axis("off") 8806 plt.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.) 8807 canvas = plt.get_current_fig_manager().canvas 8808 agg = canvas.switch_backends(FigureCanvasAgg) 8809 agg.draw() 8810 img, (width, height) = agg.print_to_buffer() 8811 Zimg = np.frombuffer(img, np.uint8).reshape((height, width, 4)) 8812 RenderViewPlane(msize*eplane,Zimg,width,height) 8792 if drawingData['showSlice']: 8793 if len(D4mapData.get('rho',[])): #preferentially select 4D map if there 8794 rho = D4mapData['rho'][:,:,:,int(G2frame.tau*10)] #pick current tau 3D slice 8795 elif len(mapData['rho']): #ordinary 3D map 8796 rho = mapData['rho'] 8797 else: 8798 return 8799 Rmax = np.max(rho)*drawingData['contourMax'] 8800 from matplotlib.backends.backend_agg import FigureCanvasAgg 8801 import matplotlib.pyplot as plt 8802 Model = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX) 8803 invModel = nl.inv(Model) 8804 msize = 5. #-5A - 5A slice 8805 mRes = generalData['Map']['Resolution']/2. 8806 npts = int(2*msize/mRes) 8807 VP = np.array(drawingData['viewPoint'][0]) 8808 SX,SY = np.meshgrid(np.linspace(-1.,1.,npts),np.linspace(-1.,1.,npts)) 8809 SXYZ = msize*np.dstack((SX,SY,np.zeros_like(SX))) 8810 SXYZ = np.reshape(np.inner(SXYZ,invModel[:3,:3].T)+VP[nxs,nxs,:],(-1,3)) 8811 Z = np.reshape(G2mth.getRhos(SXYZ,rho),(npts,npts)) 8812 Z = np.where(Z<=Rmax,Z,Rmax) 8813 plt.rcParams['figure.facecolor'] = (1.,1.,1.,.5) 8814 plt.rcParams['figure.figsize'] = [6.0,6.0] 8815 plt.cla() 8816 plt.contour(Z,colors='k',linewidths=1) 8817 plt.axis("off") 8818 plt.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.) 8819 canvas = plt.get_current_fig_manager().canvas 8820 agg = canvas.switch_backends(FigureCanvasAgg) 8821 agg.draw() 8822 img, (width, height) = agg.print_to_buffer() 8823 Zimg = np.frombuffer(img, np.uint8).reshape((height, width, 4)) 8824 RenderViewPlane(msize*eplane,Zimg,width,height) 8813 8825 8814 8826 try:
Note: See TracChangeset
for help on using the changeset viewer.