Changeset 3652
- Timestamp:
- Oct 5, 2018 3:47:53 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIplot.py
r3592 r3652 1584 1584 PlotPatterns(G2frame,newPlot,plotType) 1585 1585 1586 def PlotPatterns(G2frame,newPlot=False,plotType='PWDR',data=None): 1586 def PlotPatterns(G2frame,newPlot=False,plotType='PWDR',data=None, 1587 extraKeys=[]): 1587 1588 '''Powder pattern plotting package - displays single or multiple powder patterns as intensity vs 1588 1589 2-theta, q or TOF. Can display multiple patterns as "waterfall plots" or contour plots. Log I … … 1804 1805 G2frame.Interpolate = 'nearest' 1805 1806 dlg.Destroy() 1807 elif event.key in [KeyItem[0] for KeyItem in extraKeys]: 1808 for KeyItem in extraKeys: 1809 if event.key == KeyItem[0]: 1810 KeyItem[1]() 1811 break 1806 1812 else: 1807 # print 'no binding for key',event.key 1813 print('no binding for key',event.key) 1808 1814 #GSASIIpath.IPyBreak() 1809 1815 return 1810 wx.CallAfter(PlotPatterns,G2frame,newPlot=newPlot,plotType=plottype )1816 wx.CallAfter(PlotPatterns,G2frame,newPlot=newPlot,plotType=plottype,extraKeys=extraKeys) 1811 1817 1812 1818 def OnMotion(event): … … 2051 2057 data['sigDict'] = {} #now invalid 2052 2058 G2pdG.UpdatePeakGrid(G2frame,data) 2053 PlotPatterns(G2frame,plotType=plottype )2059 PlotPatterns(G2frame,plotType=plottype,extraKeys=extraKeys) 2054 2060 else: #picked a peak list line 2055 2061 # prepare to animate move of line … … 2083 2089 G2frame.GPXtree.SetItemPyData(LimitId,data) 2084 2090 G2pdG.UpdateLimitsGrid(G2frame,data,plottype) 2085 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype )2091 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype,extraKeys=extraKeys) 2086 2092 else: #picked a limit line 2087 2093 # prepare to animate move of line … … 2104 2110 data[1][1] = max(xy[0],data[1][0]) 2105 2111 G2frame.GPXtree.SetItemPyData(LimitId,data) 2106 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype )2112 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype,extraKeys=extraKeys) 2107 2113 else: #picked a limit line 2108 2114 G2frame.itemPicked = pick … … 2168 2174 elif mode == 'Del': 2169 2175 del backDict['FixedPoints'][G2frame.fixPtMarker] 2170 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype )2176 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype,extraKeys=extraKeys) 2171 2177 return 2172 2178 … … 2183 2189 G2frame.cid = None 2184 2190 if event.xdata is None or event.ydata is None: # ignore drag if cursor is outside of plot 2185 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype )2191 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype,extraKeys=extraKeys) 2186 2192 return 2187 2193 if not G2frame.PickId: … … 2192 2198 if Page.toolbar._active: # prevent ops. if a toolbar zoom button pressed 2193 2199 # after any mouse release event (could be a zoom), redraw magnification lines 2194 if magLineList: wx.CallAfter(PlotPatterns,G2frame,plotType=plottype )2200 if magLineList: wx.CallAfter(PlotPatterns,G2frame,plotType=plottype,extraKeys=extraKeys) 2195 2201 return 2196 2202 # Background page, deal with fixed background points … … 2227 2233 backDict['FixedPoints'][G2frame.fixPtMarker] = xy 2228 2234 G2frame.itemPicked = None 2229 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype )2235 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype,extraKeys=extraKeys) 2230 2236 return 2231 2237 2232 2238 if G2frame.itemPicked is None: 2233 2239 # after any mouse release event (could be a zoom), redraw magnification lines 2234 if magLineList: wx.CallAfter(PlotPatterns,G2frame,plotType=plottype )2240 if magLineList: wx.CallAfter(PlotPatterns,G2frame,plotType=plottype,extraKeys=extraKeys) 2235 2241 return 2236 2242 if DifLine[0] is G2frame.itemPicked: # respond to dragging of the difference curve … … 2239 2245 Page.plotStyle['delOffset'] = -ypos 2240 2246 G2frame.itemPicked = None 2241 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype )2247 wx.CallAfter(PlotPatterns,G2frame,plotType=plottype,extraKeys=extraKeys) 2242 2248 return 2243 2249 elif G2frame.itemPicked in G2frame.MagLines: # drag of magnification marker … … 2326 2332 else: #1st row of refl ticks 2327 2333 Page.plotStyle['refOffset'] = event.ydata 2328 PlotPatterns(G2frame,plotType=plottype )2334 PlotPatterns(G2frame,plotType=plottype,extraKeys=extraKeys) 2329 2335 G2frame.itemPicked = None 2330 2336 … … 2339 2345 newPlot = True 2340 2346 G2frame.Cmax = 1.0 2341 Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress)2347 # Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress) 2342 2348 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 2343 2349 Page.canvas.mpl_connect('pick_event', OnPick) 2344 2350 Page.canvas.mpl_connect('button_release_event', OnRelease) 2345 2351 Page.canvas.mpl_connect('button_press_event',OnPress) 2352 Page.bindings = [] 2353 # redo OnPlotKeyPress binding each time the Plot is updated 2354 # since needs values that may have been changed after 1st call 2355 for b in Page.bindings: 2356 Page.canvas.mpl_disconnect(b) 2357 Page.bindings = [] 2358 Page.bindings.append( 2359 Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress) 2360 ) 2346 2361 if 'PWDR' in G2frame.GPXtree.GetItemText(G2frame.PickId): 2347 2362 Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree() … … 2414 2429 Page.plotStyle['logPlot'] or Page.plotStyle['sqrtPlot'] or G2frame.Contour): 2415 2430 Page.Choice = Page.Choice + ('a: add magnification region',) 2431 for KeyItem in extraKeys: 2432 Page.Choice = Page.Choice + (KeyItem[0] + ': '+KeyItem[2],) 2416 2433 magLineList = [] # null value indicates no magnification 2417 2434 Page.toolbar.updateActions = None # no update actions -
trunk/GSASIIpwdGUI.py
r3646 r3652 3369 3369 G2frame.GPXtree.SetItemPyData(UnitCellsId,data) 3370 3370 3371 KeyList = [] 3372 def ClearCurrentShowNext(): 3373 KeepShowNext(False) 3374 KeyList += [['j',ClearCurrentShowNext,'Show next Mag. Spc. Group, clear keep flag on current']] 3375 def KeepCurrentShowNext(): 3376 KeepShowNext(True) 3377 KeyList += [['k',KeepCurrentShowNext,'Show next Mag. Spc. Group, keep current']] 3378 def KeepShowNext(KeepCurrent=True): 3379 '''Show next "keep" item in Magnetic Space Group list, possibly resetting the 3380 keep flag for the current displayed cell 3381 ''' 3382 for i in range(len(magcells)): # find plotted setting 3383 if magcells[i]['Use']: break 3384 else: 3385 return # no Try is set 3386 if not KeepCurrent: # clear current 3387 magcells[i]['Keep'] = False 3388 MagCellsTable.SetValue(i,2,False) 3389 keeps = [j for j in range(i+1,len(magcells)) if magcells[j]['Keep']] 3390 if not keeps: 3391 if not KeepCurrent: magDisplay.ForceRefresh() 3392 return # no remaining Keep-flagged entries 3393 next = keeps[0] 3394 # update table 3395 magcells[i]['Use'] = False 3396 MagCellsTable.SetValue(i,1,False) 3397 magcells[next]['Use'] = True 3398 MagCellsTable.SetValue(next,1,True) 3399 # get SG info and plot 3400 SGData = magcells[next]['SGData'] 3401 A = G2lat.cell2A(magcells[next]['Cell'][:6]) 3402 G2frame.HKL = G2pwd.getHKLpeak(1.0,SGData,A,Inst) 3403 G2plt.PlotPatterns(G2frame,extraKeys=KeyList) 3404 magDisplay.ForceRefresh() 3405 # change Scroll to display new setting 3406 xscroll = G2frame.dataWindow.GetScrollPos(wx.HORIZONTAL) 3407 yscroll = magDisplay.CellToRect(next,1)[1]/G2frame.dataWindow.GetScrollPixelsPerUnit()[1] 3408 G2frame.dataWindow.Scroll(xscroll,yscroll) 3409 3371 3410 def RefreshMagCellsGrid(event): 3372 3411 controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(UnitCellsId) … … 3394 3433 A = G2lat.cell2A(magcells[r]['Cell'][:6]) 3395 3434 G2frame.HKL = G2pwd.getHKLpeak(1.0,mSGData,A,Inst) 3396 G2plt.PlotPatterns(G2frame )3435 G2plt.PlotPatterns(G2frame,extraKeys=KeyList) 3397 3436 elif c == 2: 3398 3437 if MagCellsTable.GetValue(r,c): … … 3661 3700 A = G2lat.cell2A(magcells[0]['Cell'][:6]) 3662 3701 G2frame.HKL = G2pwd.getHKLpeak(1.0,SGData,A,Inst) 3663 G2plt.PlotPatterns(G2frame )3702 G2plt.PlotPatterns(G2frame,extraKeys=KeyList) 3664 3703 data = [controls,bravais,cells,dmin,ssopt,magcells] 3665 3704 G2frame.GPXtree.SetItemPyData(pUCid,data) … … 3946 3985 G2frame.dataWindow.RunSubGroupsMag.Enable(True) 3947 3986 G2frame.dataWindow.CopyCell.Enable(False) 3948 Label = '\n Magnetic cells from Bilbao k-SUBGROUPSMAG for %s; kvec1: (%s), kvec2: (%s):'%(controls[13],''.join(controls[14][:3]),''.join(controls[14][3:])) 3987 Label = '\n Magnetic cells from Bilbao k-SUBGROUPSMAG for %s; kvec1=(%s)'%(controls[13],''.join(controls[14][:3])) 3988 kvec2 = ''.join(controls[14][3:]) 3989 if kvec2.strip(): 3990 Label += ', kvec2=(%s)' % kvec2 3991 Label += ':' 3949 3992 mainSizer.Add(wx.StaticText(parent=G2frame.dataWindow,label=Label),0,WACV) 3950 3993 rowLabels = []
Note: See TracChangeset
for help on using the changeset viewer.