Changeset 2196
- Timestamp:
- Apr 5, 2016 5:24:38 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r2185 r2196 3723 3723 if dlg2.ShowModal() == wx.ID_OK: 3724 3724 Id = 0 3725 self.G2plotNB.setReplotFlags() # mark all plots as old 3725 3726 self.PatternTree.DeleteChildren(self.root) 3726 3727 self.HKL = [] 3727 G2IO.ProjFileOpen(self )3728 G2IO.ProjFileOpen(self,False) 3728 3729 Id = self.root 3729 3730 txt = None … … 3734 3735 self.PatternTree.SelectItem(Id) 3735 3736 G2gd.MovePatternTreeToGrid(self,Id) 3737 self.G2plotNB.replotAll() # refresh any plots not yet updated 3736 3738 finally: 3737 3739 dlg2.Destroy() … … 3780 3782 if dlg.ShowModal() == wx.ID_OK: 3781 3783 Id = 0 3784 self.G2plotNB.setReplotFlags() # mark all plots as old 3782 3785 self.PickIdText = None #force reload of PickId contents 3783 3786 self.PatternTree.DeleteChildren(self.root) … … 3785 3788 if self.G2plotNB.plotList: 3786 3789 self.G2plotNB.clear() 3787 G2IO.ProjFileOpen(self )3790 G2IO.ProjFileOpen(self,False) 3788 3791 Id = G2gd.GetPatternTreeItemId(self,self.root,'Sequential results') 3789 3792 self.PatternTree.SelectItem(Id) 3790 3793 self.G2plotNB.replotAll() # refresh any plots not yet updated 3791 3794 finally: 3792 3795 dlg.Destroy() -
trunk/GSASIIIO.py
r2167 r2196 762 762 return head,data,Npix,image 763 763 764 def ProjFileOpen(G2frame ):764 def ProjFileOpen(G2frame,showProvenance=True): 765 765 'Read a GSAS-II project file and load into the G2 data tree' 766 766 if not os.path.exists(G2frame.GSASprojectfile): … … 770 770 LastSavedUsing = None 771 771 file = open(G2frame.GSASprojectfile,'rb') 772 print 'loadfrom file: ',G2frame.GSASprojectfile772 if showProvenance: print 'loading from file: ',G2frame.GSASprojectfile 773 773 G2frame.SetTitle("GSAS-II data tree: "+ 774 774 os.path.split(G2frame.GSASprojectfile)[1]) … … 795 795 if datum[0] == 'Controls' and 'LastSavedUsing' in datum[1]: 796 796 LastSavedUsing = datum[1]['LastSavedUsing'] 797 if datum[0] == 'Controls' and 'PythonVersions' in datum[1] and GSASIIpath.GetConfigValue('debug') :797 if datum[0] == 'Controls' and 'PythonVersions' in datum[1] and GSASIIpath.GetConfigValue('debug') and showProvenance: 798 798 print('Packages used to create .GPX file:') 799 799 if 'dict' in str(type(datum[1]['PythonVersions'])): #patch -
trunk/GSASIIplot.py
r2193 r2196 68 68 nxs = np.newaxis 69 69 70 class G2PlotMpl(wx.Panel): 70 class _tabPlotWin(wx.Panel): 71 'Creates a basic tabbed plot window for GSAS-II graphics' 72 def __init__(self,parent,id=-1,dpi=None,**kwargs): 73 self.ReplotRoutine = None 74 self.ReplotArgs = [] 75 self.ReplotKwArgs = {} 76 self.needsUpdate = True 77 wx.Panel.__init__(self,parent,id=id,**kwargs) 78 79 def AddRefresh(self,ReplotRoutine,ReplotArgs=[],ReplotKwArgs={}): 80 '''Define a routine used to refresh the plot 81 82 :param function ReplotRoutine: function to be called 83 :param list ReplotArgs: list of positional parameters, if any 84 :param dict ReplotKwArgs: dict of keyword parameters, if any 85 ''' 86 self.ReplotRoutine = ReplotRoutine 87 self.ReplotArgs = ReplotArgs 88 self.ReplotKwArgs = ReplotKwArgs 89 90 def Refresh(self): 91 'Replots the selected tab' 92 if self.ReplotRoutine: 93 #print 'Refresh G2PlotMpl with',self.ReplotRoutine 94 if not self.needsUpdate: 95 #print 'already updated\n' 96 return True 97 #if self.ReplotArgs: print '...args',self.ReplotArgs 98 #if self.ReplotKwArgs: print '...KWargs',self.ReplotKwArgs 99 self.ReplotRoutine(*self.ReplotArgs,**self.ReplotKwArgs) 100 return True 101 else: 102 return False 103 class G2PlotMpl(_tabPlotWin): 71 104 'Creates a Matplotlib 2-D plot in the GSAS-II graphics window' 72 105 def __init__(self,parent,id=-1,dpi=None,**kwargs): 73 wx.Panel.__init__(self,parent,id=id,**kwargs)106 _tabPlotWin.__init__(self,parent,id=id,**kwargs) 74 107 mpl.rcParams['legend.fontsize'] = 10 75 108 self.figure = mpl.figure.Figure(dpi=dpi,figsize=(5,6)) … … 84 117 self.SetSizer(sizer) 85 118 86 class G2PlotOgl( wx.Panel):119 class G2PlotOgl(_tabPlotWin): 87 120 'Creates an OpenGL plot in the GSAS-II graphics window' 88 121 def __init__(self,parent,id=-1,dpi=None,**kwargs): 89 self.figure = wx.Panel.__init__(self,parent,id=id,**kwargs)122 self.figure = _tabPlotWin.__init__(self,parent,id=id,**kwargs) 90 123 if 'win' in sys.platform: #Windows (& Mac) already double buffered 91 124 self.canvas = wx.glcanvas.GLCanvas(self,-1,**kwargs) … … 105 138 self.SetSizer(sizer) 106 139 107 class G2Plot3D( wx.Panel):140 class G2Plot3D(_tabPlotWin): 108 141 'Creates a 3D Matplotlib plot in the GSAS-II graphics window' 109 142 def __init__(self,parent,id=-1,dpi=None,**kwargs): 110 wx.Panel.__init__(self,parent,id=id,**kwargs)143 _tabPlotWin.__init__(self,parent,id=id,**kwargs) 111 144 self.figure = mpl.figure.Figure(dpi=dpi,figsize=(6,6)) 112 145 self.canvas = Canvas(self,-1,self.figure) … … 124 157 def __init__(self,parent,id=-1): 125 158 wx.Panel.__init__(self,parent,id=id) 126 #so one can't delete a plot page !!159 #so one can't delete a plot page from tab!! 127 160 self.nb = wx.aui.AuiNotebook(self, \ 128 161 style=wx.aui.AUI_NB_DEFAULT_STYLE ^ wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB) … … 136 169 self.nb.Bind(wx.EVT_KEY_UP,self.OnNotebookKey) 137 170 138 self.plotList = [] 171 self.plotList = [] # contains the tab label for each plot 172 self.panelList = [] # contains the panel object for each plot 173 self.figList = [] # contains the figure object for each plot 174 self.pageOnTop = None # keep track of top page during refresh all 175 self.skipPageChange = False 139 176 140 177 def OnNotebookKey(self,event): … … 156 193 pass 157 194 195 def _addPage(self,name,page): 196 'Add the newly created page to the notebook and associated lists' 197 self.skipPageChange = True 198 self.nb.AddPage(page,name) 199 self.plotList.append(name) 200 self.panelList.append(page) # panel object for plot 201 self.figList.append(page.figure) # figure object for plot 202 self.skipPageChange = False 203 204 def registerReplot(self,name,ReplotRoutine,ReplotArgs=[],ReplotKwArgs={}): 205 'Define the routine and args needed to replot a figure' 206 try: 207 plotNum = self.plotList.index(name) 208 except ValueError: 209 print('No plot tab labeled '+name) 210 GSASIIpath.IPyBreak() 211 page = self.panelList[plotNum] 212 page.AddRefresh(ReplotRoutine,ReplotArgs,ReplotKwArgs) 213 214 def setReplotFlags(self): 215 'Flag all plots as needing a redraw' 216 for page in self.panelList: 217 page.needsUpdate = True 218 self.pageOnTop = self.nb.GetSelection() 219 220 def clearReplotFlag(self,name): 221 'Set when redrawing a plot so that it is not done twice' 222 try: 223 plotNum = self.plotList.index(name) 224 except ValueError: 225 print('clearReplotFlag: No plot tab labeled '+name) 226 page = self.panelList[plotNum] 227 page.needsUpdate = False 228 229 def ResetOnTop(self): 230 'Put the saved page back on top' 231 self.SetSelectionNoRefresh(self.pageOnTop) 232 233 def SetSelectionNoRefresh(self,plotNum): 234 'Raises a plot tab without triggering a refresh via OnPageChanged' 235 self.skipPageChange = True 236 self.nb.SetSelection(plotNum) # raises plot tab 237 self.skipPageChange = False 238 239 def RaisePageNoRefresh(self,Page): 240 'Raises a plot tab without triggering a refresh via OnPageChanged' 241 self.skipPageChange = True 242 Page.SetFocus() 243 self.skipPageChange = False 244 245 def replotAll(self): 246 'refresh all current plots, if not already redrawn' 247 for page,label in zip(self.panelList,self.plotList): 248 if page.Refresh(): 249 pass 250 elif GSASIIpath.GetConfigValue('debug'): 251 print('No refresh for '+label) 252 if self.pageOnTop is not None: 253 wx.CallLater(150,self.ResetOnTop) 254 158 255 def addMpl(self,name=""): 159 256 'Add a tabbed page with a matplotlib plot' 160 257 page = G2PlotMpl(self.nb) 161 self.nb.AddPage(page,name) 162 163 self.plotList.append(name) 164 258 self._addPage(name,page) 165 259 return page.figure 166 260 … … 168 262 'Add a tabbed page with a 3D plot' 169 263 page = G2Plot3D(self.nb) 170 self.nb.AddPage(page,name) 171 172 self.plotList.append(name) 173 264 self._addPage(name,page) 174 265 return page.figure 175 266 … … 177 268 'Add a tabbed page with an openGL plot' 178 269 page = G2PlotOgl(self.nb) 179 self.nb.AddPage(page,name) 180 181 self.plotList.append(name) 182 270 self._addPage(name,page) 271 self.RaisePageNoRefresh(page) # need to give window focus before GL use 183 272 return page.figure 184 273 … … 188 277 item = self.plotList.index(name) 189 278 del self.plotList[item] 279 del self.panelList[item] 280 del self.figList[item] 190 281 self.nb.DeletePage(item) 191 282 except ValueError: #no plot of this name - do nothing … … 197 288 self.nb.DeletePage(0) 198 289 self.plotList = [] 290 self.panelList = [] 291 self.figList = [] 199 292 self.status.DestroyChildren() 200 293 … … 209 302 210 303 def OnPageChanged(self,event): 211 'respond to someone pressing a tab on the plot window' 212 if self.plotList: 304 '''respond to someone pressing a tab on the plot window. 305 Called when a plot tab is clicked. on some platforms (Mac for sure) this 306 is also called when a plot is created or selected with .SetSelection() or 307 .SetFocus(). The self.skipPageChange is used variable is set to suppress 308 repeated replotting. 309 ''' 310 if self.skipPageChange: 311 # print 'skipping OnPageChanged' 312 self.skipPageChange = False 313 return 314 # print 'OnPageChanged' 315 self.status.DestroyChildren() #get rid of special stuff on status bar 316 self.status.SetStatusText('',1) # clear old status message 317 page = self.nb.GetCurrentPage() 318 page.needsUpdate = True 319 if page.Refresh(): # refresh plot, if possible 320 pass 321 elif self.plotList: 213 322 self.status.SetStatusText('Better to select this from GSAS-II data tree',1) 214 self.status.DestroyChildren() #get rid of special stuff on status bar215 323 216 324 class GSASIItoolbar(Toolbar): … … 409 517 Page.figure.clf() 410 518 Plot = Page.figure.gca() #get a fresh plot after clf() 519 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 411 520 except ValueError: 412 521 Plot = G2frame.G2plotNB.addMpl('Structure Factors').gca() … … 424 533 if 'HKLF' in Name: 425 534 Page.Choice += ('w: select |DFsq|/sig','1: select |DFsq|>sig','3: select |DFsq|>3sig',) 426 Page.SetFocus()535 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 427 536 Plot.set_aspect(aspect='equal') 428 537 … … 1010 1119 plotNum = G2frame.G2plotNB.plotList.index('3D Structure Factors') 1011 1120 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 1121 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 1012 1122 except ValueError: 1013 1123 Plot = G2frame.G2plotNB.addOgl('3D Structure Factors') … … 1018 1128 altDown = False 1019 1129 Font = Page.GetFont() 1020 Page.SetFocus()1130 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 1021 1131 Page.Choice = None 1022 1132 choice = [' save as/key:','jpeg','tiff','bmp','h: view down h','k: view down k','l: view down l', … … 1049 1159 ################################################################################ 1050 1160 1051 def PlotPatterns(G2frame,newPlot=False,plotType='PWDR' ):1161 def PlotPatterns(G2frame,newPlot=False,plotType='PWDR',TreeItemText=None): 1052 1162 '''Powder pattern plotting package - displays single or multiple powder patterns as intensity vs 1053 1163 2-theta, q or TOF. Can display multiple patterns as "waterfall plots" or contour plots. Log I 1054 1164 plotting available. 1165 1166 The histogram to be plotted is found in G2frame.PatternId unless the histogram name is specified 1167 as TreeItemText 1055 1168 ''' 1056 1169 global exclLines … … 1059 1172 global Pattern 1060 1173 plottype = plotType 1174 if TreeItemText: 1175 G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,TreeItemText) 1176 else: 1177 TreeItemText = G2frame.PatternTree.GetItemText(G2frame.PatternId) 1178 1061 1179 if not G2frame.PatternId: 1062 1180 return … … 1185 1303 Page.canvas.SetCursor(wx.CROSS_CURSOR) 1186 1304 try: 1187 Parms,Parms2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters')) 1305 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters') 1306 if not Id: return 1307 Parms,Parms2 = G2frame.PatternTree.GetItemPyData(Id) 1188 1308 if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype: 1189 1309 q = xpos … … 1517 1637 Page.figure.clf() 1518 1638 Plot = Page.figure.gca() #get a fresh plot after clf() 1639 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 1519 1640 except ValueError: 1520 1641 if plottype == 'SASD': … … 1531 1652 Page.canvas.mpl_connect('button_release_event', OnRelease) 1532 1653 Page.canvas.mpl_connect('button_press_event',OnPress) 1533 if plottype == 'PWDR': # avoids a very nasty clash with KILL_FOCUS in SASD TextCtrl? 1534 Page.SetFocus() 1654 G2frame.G2plotNB.registerReplot('Powder Patterns', 1655 ReplotRoutine=PlotPatterns, 1656 ReplotKwArgs={'G2frame':G2frame, 'plotType':plottype, 1657 'TreeItemText':TreeItemText, 'newPlot':True 1658 }) 1659 G2frame.G2plotNB.status.SetStatusText('histogram: '+TreeItemText,1) 1660 G2frame.G2plotNB.clearReplotFlag('Powder Patterns') 1661 # if plottype == 'PWDR': # avoids a very nasty clash with KILL_FOCUS in SASD TextCtrl? 1662 # Page.SetFocus() 1535 1663 G2frame.G2plotNB.status.DestroyChildren() 1536 1664 if G2frame.Contour: … … 1976 2104 Page.figure.clf() 1977 2105 Plot = Page.figure.gca() #get a fresh plot after clf() 2106 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 1978 2107 except ValueError: 1979 2108 newPlot = True … … 2002 2131 if ref[6+im] > 0.: 2003 2132 DS.append((ref[5+im]-ref[7+im])/ref[6+im]) 2004 Page.SetFocus()2133 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2005 2134 G2frame.G2plotNB.status.DestroyChildren() 2006 2135 DS.sort() … … 2122 2251 Page.figure.clf() 2123 2252 Plot = Page.figure.gca() 2253 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 2124 2254 except ValueError: 2125 2255 newPlot = True … … 2131 2261 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 2132 2262 2133 Page.SetFocus()2263 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2134 2264 G2frame.G2plotNB.status.DestroyChildren() 2135 2265 if G2frame.Contour: … … 2277 2407 Page.figure.clf() 2278 2408 Plot = Page.figure.gca() 2409 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 2279 2410 except ValueError: 2280 2411 newPlot = True … … 2285 2416 2286 2417 Page.Choice = None 2287 Page.SetFocus()2418 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2288 2419 G2frame.G2plotNB.status.DestroyChildren() 2289 2420 Plot.set_title(Title) … … 2357 2488 Page.figure.clf() 2358 2489 Plot = Page.figure.gca() 2490 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 2359 2491 except ValueError: 2360 2492 newPlot = True … … 2365 2497 2366 2498 Page.Choice = None 2367 Page.SetFocus()2499 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2368 2500 G2frame.G2plotNB.status.DestroyChildren() 2369 2501 Plot.set_title(Title) … … 2452 2584 xylim = Plot.get_xlim(),Plot.get_ylim() 2453 2585 Page.figure.clf() 2454 Plot = Page.figure.gca() 2586 Plot = Page.figure.gca() 2587 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 2455 2588 except ValueError: 2456 2589 newPlot = True … … 2463 2596 Page.Choice = (' key press','d: lower contour max','u: raise contour max','o: reset contour max', 2464 2597 'i: interpolation method','s: color scheme') 2465 Page.SetFocus()2598 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2466 2599 G2frame.G2plotNB.status.DestroyChildren() 2467 2600 Nxy = Z.shape … … 2521 2654 Page.figure.clf() 2522 2655 Plot = Page.figure.gca() 2656 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 2523 2657 except ValueError: 2524 2658 newPlot = True … … 2529 2663 2530 2664 Page.Choice = None 2531 Page.SetFocus()2665 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2532 2666 G2frame.G2plotNB.status.DestroyChildren() 2533 2667 Plot.set_title('Strain') … … 2578 2712 Page.figure.clf() 2579 2713 Plot = Page.figure.gca() #get a fresh plot after clf() 2714 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 2580 2715 except ValueError: 2581 2716 newPlot = True … … 2586 2721 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 2587 2722 Page.Choice = None 2588 Page.SetFocus()2723 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2589 2724 PatternId = G2frame.PatternId 2590 2725 data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Models')) … … 2634 2769 Page.figure.clf() 2635 2770 Plot = Page.figure.gca() 2771 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 2636 2772 except ValueError: 2637 2773 Plot = G2frame.G2plotNB.addMpl('Powder Lines').gca() … … 2641 2777 2642 2778 Page.Choice = None 2643 Page.SetFocus()2779 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2644 2780 Plot.set_title('Powder Pattern Lines') 2645 2781 Plot.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14) … … 2663 2799 ################################################################################ 2664 2800 2665 def PlotPeakWidths(G2frame ):2801 def PlotPeakWidths(G2frame,TreeItemText=None): 2666 2802 ''' Plotting of instrument broadening terms as function of 2-theta 2667 2803 Seen when "Instrument Parameters" chosen from powder pattern data tree … … 2671 2807 # gamFW = lambda s,g: np.exp(np.log(s**5+2.69269*s**4*g+2.42843*s**3*g**2+4.47163*s**2*g**3+0.07842*s*g**4+g**5)/5.) 2672 2808 # gamFW2 = lambda s,g: math.sqrt(s**2+(0.4654996*g)**2)+.5345004*g #Ubaldo Bafile - private communication 2809 if TreeItemText: 2810 G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,TreeItemText) 2811 else: 2812 TreeItemText = G2frame.PatternTree.GetItemText(G2frame.PatternId) 2673 2813 PatternId = G2frame.PatternId 2674 2814 limitID = G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits') … … 2700 2840 Page.figure.clf() 2701 2841 Plot = Page.figure.gca() 2842 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 2702 2843 except ValueError: 2703 2844 Plot = G2frame.G2plotNB.addMpl('Peak Widths').gca() 2704 2845 plotNum = G2frame.G2plotNB.plotList.index('Peak Widths') 2705 2846 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 2847 G2frame.G2plotNB.registerReplot('Peak Widths', 2848 ReplotRoutine=PlotPeakWidths, 2849 ReplotKwArgs={'G2frame':G2frame, 'TreeItemText':TreeItemText}) 2850 G2frame.G2plotNB.status.SetStatusText('histogram: '+TreeItemText,1) 2851 G2frame.G2plotNB.clearReplotFlag('Peak Widths') 2706 2852 Page.Choice = None 2707 Page.SetFocus()2853 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2708 2854 2709 2855 Page.canvas.SetToolTipString('') … … 3055 3201 if not Page.IsShown(): 3056 3202 Page.Show() 3203 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 3057 3204 except ValueError: 3058 3205 if '3D' in SHData['PlotType']: … … 3065 3212 3066 3213 Page.Choice = None 3067 Page.SetFocus()3214 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 3068 3215 G2frame.G2plotNB.status.SetFields(['','']) 3069 3216 PH = np.array(SHData['PFhkl']) … … 3210 3357 if not Page.IsShown(): 3211 3358 Page.Show() 3359 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 3212 3360 except ValueError: 3213 3361 Plot = G2frame.G2plotNB.addMpl('Modulation').gca() … … 3217 3365 Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress) 3218 3366 3219 Page.SetFocus()3367 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 3220 3368 General = data['General'] 3221 3369 cx,ct,cs,cia = General['AtomPtrs'] … … 3349 3497 if not Page.IsShown(): 3350 3498 Page.Show() 3499 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 3351 3500 except ValueError: 3352 3501 Plot = G2frame.G2plotNB.addMpl('Covariance').gca() … … 3357 3506 Page.Choice = ['s: to change colors'] 3358 3507 Page.keyPress = OnPlotKeyPress 3359 Page.SetFocus()3508 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 3360 3509 G2frame.G2plotNB.status.SetFields(['','']) 3361 3510 acolor = mpl.cm.get_cmap(G2frame.VcovColor) … … 3418 3567 if not Page.IsShown(): 3419 3568 Page.Show() 3569 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 3420 3570 except ValueError: 3421 3571 Plot = G2frame.G2plotNB.addMpl('Torsion').gca() … … 3425 3575 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 3426 3576 3427 Page.SetFocus()3577 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 3428 3578 G2frame.G2plotNB.status.SetFields(['','Use mouse LB to identify torsion atoms']) 3429 3579 Plot.plot(X,torsion,'b+') … … 3501 3651 if not Page.IsShown(): 3502 3652 Page.Show() 3653 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 3503 3654 except ValueError: 3504 3655 Plot = G2frame.G2plotNB.addMpl('Ramachandran').gca() … … 3511 3662 Page.Choice = ['s: to change colors'] 3512 3663 Page.keyPress = OnPlotKeyPress 3513 Page.SetFocus()3664 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 3514 3665 G2frame.G2plotNB.status.SetFields(['','Use mouse LB to identify phi/psi atoms']) 3515 3666 acolor = mpl.cm.get_cmap(G2frame.RamaColor) … … 3588 3739 def Draw(): 3589 3740 global Title,xLabel,yLabel 3590 Page.SetFocus()3741 G2frame.G2plotNB.RaisePageNoRefresh(Page) 3591 3742 G2frame.G2plotNB.status.SetStatusText( \ 3592 3743 'press L to toggle lines, S to select X axis, T to change titles (reselect column to show?)',1) … … 3671 3822 3672 3823 Draw() 3673 G2frame.G2plotNB. nb.SetSelection(plotNum) # raises plot tab3824 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 3674 3825 3675 3826 ################################################################################ … … 4051 4202 Page.figure.clf() 4052 4203 Plot = Page.figure.gca() #get a fresh plot after clf() 4204 if not event: #event from GUI TextCtrl - don't want focus to change to plot!!! 4205 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 4053 4206 except ValueError: 4054 4207 Plot = G2frame.G2plotNB.addMpl('2D Powder Image').gca() … … 4061 4214 xylim = [] 4062 4215 Page.Choice = None 4063 if not event: #event from GUI TextCtrl - don't want focus to change to plot!!!4064 Page.SetFocus()4216 # if not event: #event from GUI TextCtrl - don't want focus to change to plot!!! 4217 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 4065 4218 Title = G2frame.PatternTree.GetItemText(G2frame.Image)[4:] 4066 4219 G2frame.G2plotNB.status.DestroyChildren() … … 4292 4445 Page.figure.clf() 4293 4446 Plot = Page.figure.gca() #get a fresh plot after clf() 4447 if not event: 4448 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 4294 4449 4295 4450 except ValueError: … … 4301 4456 view = False 4302 4457 Page.Choice = None 4303 if not event:4304 Page.SetFocus()4458 # if not event: 4459 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 4305 4460 4306 4461 Data = G2frame.PatternTree.GetItemPyData( … … 4358 4513 Page.figure.clf() 4359 4514 Plot = Page.figure.gca() #get a fresh plot after clf() 4515 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 4360 4516 4361 4517 except ValueError: … … 4367 4523 view = False 4368 4524 Page.Choice = None 4369 Page.SetFocus()4525 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 4370 4526 4371 4527 Data = G2frame.PatternTree.GetItemPyData( … … 5463 5619 plotNum = G2frame.G2plotNB.plotList.index(generalData['Name']) 5464 5620 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 5621 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 5465 5622 except ValueError: 5466 5623 Plot = G2frame.G2plotNB.addOgl(generalData['Name']) … … 5470 5627 view = False 5471 5628 altDown = False 5472 G2frame.G2plotNB.nb.SetSelection(plotNum) # make sure plot tab is raised for wx >2.85473 5629 Font = Page.GetFont() 5474 Page.SetFocus()5630 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 5475 5631 Page.Choice = None 5476 5632 if mapData.get('Flip',False): … … 5766 5922 plotNum = G2frame.G2plotNB.plotList.index('Rigid body') 5767 5923 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 5924 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 5768 5925 except ValueError: 5769 5926 Plot = G2frame.G2plotNB.addOgl('Rigid body') … … 5773 5930 view = False 5774 5931 altDown = False 5775 Page.SetFocus()5932 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 5776 5933 Font = Page.GetFont() 5777 5934 Page.canvas.Bind(wx.EVT_MOUSEWHEEL, OnMouseWheel) … … 6149 6306 plotNum = G2frame.G2plotNB.plotList.index('Layer') 6150 6307 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 6308 G2frame.G2plotNB.SetSelectionNoRefresh(plotNum) # raises plot tab 6151 6309 except ValueError: 6152 6310 Plot = G2frame.G2plotNB.addOgl('Layer') … … 6159 6317 choice = [' save as:','jpeg','tiff','bmp'] 6160 6318 Page.keyPress = OnPlotKeyPress 6161 Page.SetFocus()6319 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 6162 6320 Font = Page.GetFont() 6163 6321 cb = wx.ComboBox(G2frame.G2plotNB.status,style=wx.CB_DROPDOWN|wx.CB_READONLY,choices=choice)
Note: See TracChangeset
for help on using the changeset viewer.