Changeset 3900


Ignore:
Timestamp:
Apr 15, 2019 4:15:37 PM (4 years ago)
Author:
vondreele
Message:

cursor now reports position/density on contour slice. Contour control has slide bar for setting max; renames the other contour slide bar as Rho max for the green density point plots
contours grid set to match map grid resolution.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r3896 r3900  
    36673667        return Rhos
    36683668       
    3669     Blk = 8     #8 seems optimal
     3669    Blk = 400     #400 doesn't seem to matter
    36703670    nBlk = len(XYZ)//Blk        #select Blk so this is an exact divide
    36713671    mapShape = np.array(rho.shape)
  • trunk/GSASIIphsGUI.py

    r3897 r3900  
    51935193            'backColor':[0,0,0],'depthFog':False,'Zclip':50.0,'cameraPos':50.,'Zstep':0.5,
    51945194            'radiusFactor':0.85,'contourLevel':1.,'bondRadius':0.1,'ballScale':0.33,
    5195             'vdwScale':0.67,'ellipseProb':50,'sizeH':0.50,'unitCellBox':True,
     5195            'vdwScale':0.67,'ellipseProb':50,'sizeH':0.50,'unitCellBox':True,'contourMax':1.0,
    51965196            'showABC':True,'selectedAtoms':[],'Atoms':[],'oldxy':[],'magMult':1.0,
    51975197            'bondList':{},'viewDir':[1,0,0],'Plane':[[0,0,1],False,False,0.0,[255,255,0]]}
     
    52125212        if 'contourLevel' not in drawingData:
    52135213            drawingData['contourLevel'] = 1.
     5214        if 'contourMax' not in drawingData:
     5215            drawingData['contourMax'] = 1.
    52145216        if 'viewDir' not in drawingData:
    52155217            drawingData['viewDir'] = [0,0,1]
     
    61306132            def OnContourLevel(event):
    61316133                drawingData['contourLevel'] = contourLevel.GetValue()/100.
    6132                 contourLevelTxt.SetLabel(' Contour level: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax']))
     6134                contourLevelTxt.SetLabel(' Rho maximum: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax']))
    61336135                G2plt.PlotStructure(G2frame,data)
    61346136
     
    62096211           
    62106212            if generalData['Map']['rhoMax']:
    6211                 contourLevelTxt = wx.StaticText(drawOptions,-1,' Contour level: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax']))
     6213                contourLevelTxt = wx.StaticText(drawOptions,-1,' Rho maximum: '+'%.2f'%(drawingData['contourLevel']*generalData['Map']['rhoMax']))
    62126214                slideSizer.Add(contourLevelTxt,0,WACV)
    62136215                contourLevel = wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,value=int(100*drawingData['contourLevel']))
     
    62566258                G2plt.PlotStructure(G2frame,data)
    62576259               
     6260            def OnContourMax(event):
     6261                drawingData['contourMax'] = contourMax.GetValue()/100.
     6262                contourMaxTxt.SetLabel(' Max.: '+'%.2f'%(drawingData['contourMax']*generalData['Map']['rhoMax']))
     6263                G2plt.PlotStructure(G2frame,data)
     6264
    62586265            def OnViewPoint(event):
    62596266                event.Skip()
     
    63456352            showSizer.Add(line2Sizer)
    63466353           
    6347             if generalData['Map']['rhoMax'] and drawingData['unitCellBox']:
     6354            if generalData['Map']['rhoMax']:
    63486355                line3Sizer = wx.BoxSizer(wx.HORIZONTAL)
    63496356           
     
    63526359                showCS.SetValue(drawingData['showSlice'])           
    63536360                line3Sizer.Add(showCS,0,WACV)
     6361                contourMaxTxt = wx.StaticText(drawOptions,-1,' Max.: '+'%.2f'%(drawingData['contourMax']*generalData['Map']['rhoMax']))
     6362                line3Sizer.Add(contourMaxTxt,0,WACV)
     6363                contourMax = wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,size=(150,25),value=int(100*drawingData['contourMax']))
     6364                contourMax.SetRange(1,100)
     6365                contourMax.Bind(wx.EVT_SLIDER, OnContourMax)
     6366                line3Sizer.Add(contourMax,1,wx.EXPAND|wx.RIGHT)
    63546367               
    63556368                showSizer.Add(line3Sizer)
  • trunk/GSASIIplot.py

    r3899 r3900  
    79837983                    G2frame.G2plotNB.status.SetStatusText('New quaternion: %.2f+, %.2fi+ ,%.2fj+, %.2fk'%(Q[0],Q[1],Q[2],Q[3]),1)
    79847984                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           
    79857993       
    79867994    def OnMouseWheel(event):
     
    87828790                for plane in Planes:
    87838791                    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)
    88138825               
    88148826        try:
Note: See TracChangeset for help on using the changeset viewer.