Changeset 4641 for trunk


Ignore:
Timestamp:
Nov 3, 2020 8:30:31 AM (13 months ago)
Author:
vondreele
Message:

add color contouring to map slice display. Will plot lines, colors or lines+colors. Allows color scheme selection

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r4634 r4641  
    75157515            drawingData['showRigidBodies'] = True
    75167516        if 'showSlice' not in drawingData:
    7517             drawingData['showSlice'] = False
     7517            drawingData['showSlice'] = 0
     7518        if 'contourColor' not in drawingData:
     7519            drawingData['contourColor'] = 'RdYlGn'
    75187520        if 'Plane' not in drawingData:
    75197521            drawingData['Plane'] = [[0,0,1],False,False,0.0,[255,255,0]]
     
    88068808               
    88078809            def OnShowSlice(event):
    8808                 drawingData['showSlice'] = G2frame.phaseDisplay.showCS.GetValue()
     8810                drawingData['showSlice'] = G2frame.phaseDisplay.showCS.GetSelection()
     8811                G2frame.phaseDisplay.showCS.SetValue(slices[drawingData['showSlice']])
    88098812                G2plt.PlotStructure(G2frame,data)
    88108813               
     
    88828885            showSizer = wx.BoxSizer(wx.VERTICAL)           
    88838886            lineSizer = wx.BoxSizer(wx.HORIZONTAL)
    8884             lineSizer.Add(wx.StaticText(drawOptions,-1,' Background color:'),0,WACV)
    8885             backColor = wcs.ColourSelect(drawOptions, -1,colour=drawingData['backColor'],size=wx.Size(25,25))
     8887            lineSizer.Add(wx.StaticText(drawOptions,label=' Background color:'),0,WACV)
     8888            backColor = wcs.ColourSelect(drawOptions,colour=drawingData['backColor'],size=wx.Size(25,25))
    88868889            backColor.Bind(wcs.EVT_COLOURSELECT, OnBackColor)
    88878890            lineSizer.Add(backColor,0,WACV)
     
    89518954                line3Sizer = wx.BoxSizer(wx.HORIZONTAL)
    89528955           
    8953                 G2frame.phaseDisplay.showCS = wx.CheckBox(drawOptions,-1,label=' Show contour slice?')
    8954                 G2frame.phaseDisplay.showCS.Bind(wx.EVT_CHECKBOX, OnShowSlice)
    8955                 G2frame.phaseDisplay.showCS.SetValue(drawingData['showSlice'])           
     8956                slices = ['','lines','colors','lines+colors']
     8957                line3Sizer.Add(wx.StaticText(drawOptions,label=' Show map slice as '),0,WACV)
     8958                G2frame.phaseDisplay.showCS = wx.ComboBox(drawOptions,value=slices[drawingData['showSlice']],
     8959                    choices=slices,style=wx.CB_READONLY|wx.CB_DROPDOWN)
     8960                G2frame.phaseDisplay.showCS.Bind(wx.EVT_COMBOBOX, OnShowSlice)
     8961                G2frame.phaseDisplay.showCS.SetValue(slices[drawingData['showSlice']])           
    89568962                line3Sizer.Add(G2frame.phaseDisplay.showCS,0,WACV)
    8957                 contourMaxTxt = wx.StaticText(drawOptions,-1,' Max.: '+'%.2f'%(drawingData['contourMax']*generalData['Map']['rhoMax']))
     8963                contourMaxTxt = wx.StaticText(drawOptions,label=' Max.: '+'%.2f'%(drawingData['contourMax']*generalData['Map']['rhoMax']))
    89588964                line3Sizer.Add(contourMaxTxt,0,WACV)
    89598965                contourMax = wx.Slider(drawOptions,style=wx.SL_HORIZONTAL,size=(150,25),value=int(100*drawingData['contourMax']))
     
    94069412        shSizer = wx.FlexGridSizer(0,6,5,5)
    94079413        shSizer.Add(wx.StaticText(Texture,-1,' Texture model: '),0,WACV)
    9408         shModel = wx.ComboBox(Texture,-1,value=textureData['Model'],choices=shModels,
     9414        shModel = wx.ComboBox(Texture,value=textureData['Model'],choices=shModels,
    94099415            style=wx.CB_READONLY|wx.CB_DROPDOWN)
    94109416        shModel.Bind(wx.EVT_COMBOBOX,OnShModel)
    94119417        shSizer.Add(shModel,0,WACV)
    94129418        shSizer.Add(wx.StaticText(Texture,-1,'  Harmonic order: '),0,WACV)
    9413         shOrder = wx.ComboBox(Texture,-1,value=str(textureData['Order']),choices=[str(2*i) for i in range(18)],
     9419        shOrder = wx.ComboBox(Texture,value=str(textureData['Order']),choices=[str(2*i) for i in range(18)],
    94149420            style=wx.CB_READONLY|wx.CB_DROPDOWN)
    94159421        shOrder.Bind(wx.EVT_COMBOBOX,OnShOrder)
  • trunk/GSASIIplot.py

    r4639 r4641  
    81488148           
    81498149        elif key in ['K'] and generalData['Map']['MapType']:
    8150             drawingData['showSlice'] = not drawingData.get('showSlice',False)
     8150            drawingData['showSlice'] = (drawingData['showSlice']+1)%4
    81518151            SetShowCS(drawingData['showSlice'])
     8152           
     8153        elif key in ['S']:
     8154            choice = [m for m in mpl.cm.datad.keys()]   # if not m.endswith("_r")
     8155            choice.sort()
     8156            dlg = wx.SingleChoiceDialog(G2frame,'Select','Color scheme',choice)
     8157            if dlg.ShowModal() == wx.ID_OK:
     8158                sel = dlg.GetSelection()
     8159                drawingData['contourColor'] = choice[sel]
     8160            dlg.Destroy()
    81528161               
    81538162        elif key in ['P']:
     
    83888397                    G2frame.G2plotNB.status.SetStatusText('New quaternion: %.2f+, %.2fi+ ,%.2fj+, %.2fk'%(Q[0],Q[1],Q[2],Q[3]),1)
    83898398                Draw('move')
    8390         elif drawingData.get('showSlice'):
     8399        elif drawingData['showSlice']:
    83918400            View = GL.glGetIntegerv(GL.GL_VIEWPORT)
    83928401            Tx,Ty,Tz = drawingData['viewPoint'][0]
     
    83948403            Cx,Cy,Cz = GLU.gluUnProject(newxy[0],View[3]-newxy[1],tz)
    83958404            rho = G2mth.getRho([Cx,Cy,Cz],mapData)
    8396             contlevels = contourSet.get_array()
    8397             contstr = str(contlevels).strip('[]')
    8398             G2frame.G2plotNB.status.SetStatusText('Cursor position: %.4f, %.4f, %.4f; density: %.4f, contours at: %s'%(Cx,Cy,Cz,rho,contstr),1)
     8405            if drawingData['showSlice'] in [1,3]:
     8406                contlevels = contourSet.get_array()
     8407                contstr = str(contlevels).strip('[]')
     8408                G2frame.G2plotNB.status.SetStatusText('Cursor position: %.4f, %.4f, %.4f; density: %.4f, contours at: %s'%(Cx,Cy,Cz,rho,contstr),1)
     8409            else:
     8410                G2frame.G2plotNB.status.SetStatusText('Cursor position: %.4f, %.4f, %.4f; density: %.4f'%(Cx,Cy,Cz,rho),1)
    83998411       
    84008412    def OnMouseWheel(event):
     
    94159427                for plane in Planes:
    94169428                    RenderPlane(plane,color)
    9417         if drawingData.get('showSlice',False):      #must be done last to properly show things behind as faded
     9429        if drawingData.get('showSlice',0):      #must be done last to properly show things behind as faded
    94189430            global contourSet,Zslice
    94199431            if len(D4mapData.get('rho',[])):        #preferentially select 4D map if there
     
    94419453                Zslice = np.reshape(map_coordinates(rho,(SXYZ%1.*rho.shape).T,order=1,mode='wrap'),(npts,npts))
    94429454            Z = np.where(Zslice<=Rmax,Zslice,Rmax)
     9455            ZU = np.flipud(Z)
    94439456            plt.rcParams['figure.facecolor'] = (1.,1.,1.,.5)
    94449457            oldSize = plt.rcParams['figure.figsize']
    94459458            plt.rcParams['figure.figsize'] = [6.0,6.0]
    94469459            plt.cla()
    9447             contourSet = plt.contour(Z,colors='k',linewidths=1)
     9460            if drawingData['showSlice'] in [1,]:
     9461                contourSet = plt.contour(Z,colors='k',linewidths=1)
     9462            if drawingData['showSlice'] in [2,3]:
     9463                acolor = mpl.cm.get_cmap(drawingData.get('contourColor','Paired'))                   
     9464                plt.imshow(ZU,aspect='equal',cmap=acolor,alpha=0.75,interpolation='bilinear')
     9465                if drawingData['showSlice'] in [3,]:
     9466                    contourSet = plt.contour(ZU,colors='k',linewidths=1)
    94489467            plt.axis("off")
    94499468            plt.subplots_adjust(bottom=0.,top=1.,left=0.,right=1.,wspace=0.,hspace=0.)
     
    95759594    choice = [' save as/key:','jpeg','tiff','bmp','c: center on 1/2,1/2,1/2']
    95769595    if mapData['MapType']:
    9577         choice += ['k: toggle contour plot',]
     9596        choice += ['k: none, lines, color, color+lines contour plot switch',]
     9597        choice += ['s: select map slice color scheme',]
    95789598    if mapData.get('Flip',False):
    95799599        choice += ['u: roll up','d: roll down','l: roll left','r: roll right']
Note: See TracChangeset for help on using the changeset viewer.