1 | # -*- coding: utf-8 -*- |
---|
2 | #GSASIIgrid - data display routines |
---|
3 | ########### SVN repository information ################### |
---|
4 | # $Date: 2015-01-05 19:02:33 +0000 (Mon, 05 Jan 2015) $ |
---|
5 | # $Author: vondreele $ |
---|
6 | # $Revision: 1622 $ |
---|
7 | # $URL: trunk/GSASIIgrid.py $ |
---|
8 | # $Id: GSASIIgrid.py 1622 2015-01-05 19:02:33Z vondreele $ |
---|
9 | ########### SVN repository information ################### |
---|
10 | ''' |
---|
11 | *GSASIIgrid: Basic GUI routines* |
---|
12 | -------------------------------- |
---|
13 | |
---|
14 | ''' |
---|
15 | import wx |
---|
16 | import wx.grid as wg |
---|
17 | import wx.wizard as wz |
---|
18 | import wx.aui |
---|
19 | import wx.lib.scrolledpanel as wxscroll |
---|
20 | import time |
---|
21 | import copy |
---|
22 | import cPickle |
---|
23 | import sys |
---|
24 | import os |
---|
25 | import numpy as np |
---|
26 | import numpy.ma as ma |
---|
27 | import scipy.optimize as so |
---|
28 | import wx.html    # could postpone this for quicker startup |
---|
29 | import webbrowser   # could postpone this for quicker startup |
---|
30 | import GSASIIpath |
---|
31 | GSASIIpath.SetVersionNumber("$Revision: 1622 $") |
---|
32 | import GSASIImath as G2mth |
---|
33 | import GSASIIIO as G2IO |
---|
34 | import GSASIIstrIO as G2stIO |
---|
35 | import GSASIIlattice as G2lat |
---|
36 | import GSASIIplot as G2plt |
---|
37 | import GSASIIpwdGUI as G2pdG |
---|
38 | import GSASIIimgGUI as G2imG |
---|
39 | import GSASIIphsGUI as G2phG |
---|
40 | import GSASIIspc as G2spc |
---|
41 | import GSASIImapvars as G2mv |
---|
42 | import GSASIIconstrGUI as G2cnstG |
---|
43 | import GSASIIrestrGUI as G2restG |
---|
44 | import GSASIIpy3 as G2py3 |
---|
45 | import GSASIIobj as G2obj |
---|
46 | import GSASIIexprGUI as G2exG |
---|
47 | import GSASIIlog as log |
---|
48 | import GSASIIctrls as G2G |
---|
49 | |
---|
50 | # trig functions in degrees |
---|
51 | sind = lambda x: np.sin(x*np.pi/180.) |
---|
52 | tand = lambda x: np.tan(x*np.pi/180.) |
---|
53 | cosd = lambda x: np.cos(x*np.pi/180.) |
---|
54 | |
---|
55 | # globals we will use later |
---|
56 | __version__ = None # gets overridden in GSASII.py |
---|
57 | path2GSAS2 =Â os.path.dirname(os.path.realpath(__file__))Â # save location of this file |
---|
58 | helpLocDict =Â {} |
---|
59 | htmlPanel =Â None |
---|
60 | htmlFrame =Â None |
---|
61 | helpMode =Â 'browser' |
---|
62 | #if sys.platform.lower().startswith('win'): helpMode = 'internal' # need a global control to set this |
---|
63 | Â Â |
---|
64 | htmlFirstUse =Â True |
---|
65 | WACV =Â wx.ALIGN_CENTER_VERTICAL |
---|
66 | |
---|
67 | [ wxID_FOURCALC, wxID_FOURSEARCH, wxID_FOURCLEAR, wxID_PEAKSMOVE, wxID_PEAKSCLEAR, |
---|
68 |   wxID_CHARGEFLIP, wxID_PEAKSUNIQUE, wxID_PEAKSDELETE, wxID_PEAKSDA, |
---|
69 |   wxID_PEAKSDISTVP, wxID_PEAKSVIEWPT, wxID_FINDEQVPEAKS,wxID_SHOWBONDS,wxID_MULTIMCSA, |
---|
70 |   wxID_SINGLEMCSA, wxID_4DMAPCOMPUTE,wxID_4DCHARGEFLIP, |
---|
71 | ] = [wx.NewId() for item in range(17)] |
---|
72 | |
---|
73 | [ wxID_PWDRADD, wxID_HKLFADD, wxID_PWDANALYSIS, wxID_PWDCOPY, wxID_DATADELETE, |
---|
74 | ] = [wx.NewId() for item in range(5)] |
---|
75 | |
---|
76 | [ wxID_ATOMSEDITADD, wxID_ATOMSEDITINSERT, wxID_ATOMSEDITDELETE, wxID_ATOMSREFINE, |
---|
77 |   wxID_ATOMSMODIFY, wxID_ATOMSTRANSFORM, wxID_ATOMSVIEWADD, wxID_ATOMVIEWINSERT, |
---|
78 | Â Â wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,wxID_ATOMMOVE, |
---|
79 |   wxID_ASSIGNATMS2RB,wxID_ATOMSPDISAGL, wxID_ISODISP, |
---|
80 | ] = [wx.NewId() for item in range(14)] |
---|
81 | |
---|
82 | [ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR, |
---|
83 |   wxID_DRAWVIEWPOINT, wxID_DRAWTRANSFORM, wxID_DRAWDELETE, wxID_DRAWFILLCELL, |
---|
84 |   wxID_DRAWADDEQUIV, wxID_DRAWFILLCOORD, wxID_DRAWDISAGLTOR, wxID_DRAWPLANE, |
---|
85 | Â Â wxID_DRAWDISTVP, |
---|
86 | ] = [wx.NewId() for item in range(13)] |
---|
87 | |
---|
88 | [ wxID_DRAWRESTRBOND, wxID_DRAWRESTRANGLE, wxID_DRAWRESTRPLANE, wxID_DRAWRESTRCHIRAL, |
---|
89 | ] = [wx.NewId() for item in range(4)] |
---|
90 | |
---|
91 | [Â wxID_ADDMCSAATOM,wxID_ADDMCSARB,wxID_CLEARMCSARB,wxID_MOVEMCSA,wxID_MCSACLEARRESULTS, |
---|
92 | ] = [wx.NewId() for item in range(5)] |
---|
93 | |
---|
94 | [Â wxID_CLEARTEXTURE,wxID_REFINETEXTURE, |
---|
95 | ] = [wx.NewId() for item in range(2)] |
---|
96 | |
---|
97 | [ wxID_PAWLEYLOAD, wxID_PAWLEYESTIMATE, wxID_PAWLEYUPDATE, |
---|
98 | ] = [wx.NewId() for item in range(3)] |
---|
99 | |
---|
100 | [ wxID_IMCALIBRATE,wxID_IMRECALIBRATE,wxID_IMINTEGRATE, wxID_IMCLEARCALIB, |
---|
101 |   wxID_IMCOPYCONTROLS, wxID_INTEGRATEALL, wxID_IMSAVECONTROLS, wxID_IMLOADCONTROLS, |
---|
102 | ] = [wx.NewId() for item in range(8)] |
---|
103 | |
---|
104 | [ wxID_MASKCOPY, wxID_MASKSAVE, wxID_MASKLOAD, wxID_NEWMASKSPOT,wxID_NEWMASKARC,wxID_NEWMASKRING, |
---|
105 |   wxID_NEWMASKFRAME, wxID_NEWMASKPOLY, wxID_MASKLOADNOT, |
---|
106 | ] = [wx.NewId() for item in range(9)] |
---|
107 | |
---|
108 | [ wxID_STRSTACOPY, wxID_STRSTAFIT, wxID_STRSTASAVE, wxID_STRSTALOAD,wxID_STRSTSAMPLE, |
---|
109 | Â Â wxID_APPENDDZERO,wxID_STRSTAALLFIT,wxID_UPDATEDZERO, |
---|
110 | ] = [wx.NewId() for item in range(8)] |
---|
111 | |
---|
112 | [ wxID_BACKCOPY,wxID_LIMITCOPY, wxID_SAMPLECOPY, wxID_SAMPLECOPYSOME, wxID_BACKFLAGCOPY, wxID_SAMPLEFLAGCOPY, |
---|
113 |   wxID_SAMPLESAVE, wxID_SAMPLELOAD,wxID_ADDEXCLREGION,wxID_SETSCALE,wxID_SAMPLE1VAL,wxID_ALLSAMPLELOAD, |
---|
114 | ] = [wx.NewId() for item in range(12)] |
---|
115 | |
---|
116 | [ wxID_INSTPRMRESET,wxID_CHANGEWAVETYPE,wxID_INSTCOPY, wxID_INSTFLAGCOPY, wxID_INSTLOAD, |
---|
117 |   wxID_INSTSAVE, wxID_INST1VAL, wxID_INSTCALIB, |
---|
118 | ] = [wx.NewId() for item in range(8)] |
---|
119 | |
---|
120 | [Â wxID_UNDO,wxID_LSQPEAKFIT,wxID_LSQONECYCLE,wxID_RESETSIGGAM,wxID_CLEARPEAKS,wxID_AUTOSEARCH, |
---|
121 |   wxID_PEAKSCOPY, wxID_SEQPEAKFIT, |
---|
122 | ] = [wx.NewId() for item in range(8)] |
---|
123 | |
---|
124 | [ wxID_INDXRELOAD, wxID_INDEXPEAKS, wxID_REFINECELL, wxID_COPYCELL, wxID_MAKENEWPHASE, |
---|
125 | ] = [wx.NewId() for item in range(5)] |
---|
126 | |
---|
127 | [Â wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD,wxID_FUNCTADD, |
---|
128 |  wxID_CONSPHASE, wxID_CONSHIST, wxID_CONSHAP, wxID_CONSGLOBAL, |
---|
129 | ] = [wx.NewId() for item in range(8)] |
---|
130 | |
---|
131 | [ wxID_RESTRAINTADD, wxID_RESTSELPHASE,wxID_RESTDELETE, wxID_RESRCHANGEVAL, |
---|
132 | Â Â wxID_RESTCHANGEESD,wxID_AARESTRAINTADD,wxID_AARESTRAINTPLOT, |
---|
133 | ] = [wx.NewId() for item in range(7)] |
---|
134 | |
---|
135 | [Â wxID_RIGIDBODYADD,wxID_DRAWDEFINERB,wxID_RIGIDBODYIMPORT,wxID_RESIDUETORSSEQ, |
---|
136 | Â Â wxID_AUTOFINDRESRB,wxID_GLOBALRESREFINE,wxID_RBREMOVEALL,wxID_COPYRBPARMS, |
---|
137 | Â Â wxID_GLOBALTHERM,wxID_VECTORBODYADD |
---|
138 | ] = [wx.NewId() for item in range(10)] |
---|
139 | |
---|
140 | [Â wxID_RENAMESEQSEL,wxID_SAVESEQSEL,wxID_SAVESEQSELCSV,wxID_PLOTSEQSEL,wxID_ORGSEQSEL, |
---|
141 | Â wxADDSEQVAR,wxDELSEQVAR,wxEDITSEQVAR,wxCOPYPARFIT, |
---|
142 | Â wxADDPARFIT,wxDELPARFIT,wxEDITPARFIT,wxDOPARFIT, |
---|
143 | ] = [wx.NewId() for item in range(13)] |
---|
144 | |
---|
145 | [Â wxID_MODELCOPY,wxID_MODELFIT,wxID_MODELADD,wxID_ELEMENTADD,wxID_ELEMENTDELETE, |
---|
146 | Â Â wxID_ADDSUBSTANCE,wxID_LOADSUBSTANCE,wxID_DELETESUBSTANCE,wxID_COPYSUBSTANCE, |
---|
147 | Â Â wxID_MODELUNDO,wxID_MODELFITALL,wxID_MODELCOPYFLAGS, |
---|
148 | ] = [wx.NewId() for item in range(12)] |
---|
149 | |
---|
150 | [Â wxID_SELECTPHASE,wxID_PWDHKLPLOT,wxID_PWD3DHKLPLOT, |
---|
151 | ] = [wx.NewId() for item in range(3)] |
---|
152 | |
---|
153 | [ wxID_PDFCOPYCONTROLS, wxID_PDFSAVECONTROLS, wxID_PDFLOADCONTROLS, |
---|
154 |   wxID_PDFCOMPUTE, wxID_PDFCOMPUTEALL, wxID_PDFADDELEMENT, wxID_PDFDELELEMENT, |
---|
155 | ] = [wx.NewId() for item in range(7)] |
---|
156 | |
---|
157 | [Â wxID_MCRON,wxID_MCRLIST,wxID_MCRSAVE,wxID_MCRPLAY, |
---|
158 | ] = [wx.NewId() for item in range(4)] |
---|
159 | |
---|
160 | VERY_LIGHT_GREY =Â wx.Colour(235,235,235) |
---|
161 | ################################################################################ |
---|
162 | #### GSAS-II class definitions |
---|
163 | ################################################################################ |
---|
164 | |
---|
165 | class SGMessageBox(wx.Dialog): |
---|
166 | Â Â ''' Special version of MessageBox that displays space group & super space group text |
---|
167 | Â Â in two blocks |
---|
168 | Â Â ''' |
---|
169 |   def __init__(self,parent,title,text,table,): |
---|
170 | Â Â Â Â wx.Dialog.__init__(self,parent,wx.ID_ANY,title,pos=wx.DefaultPosition, |
---|
171 | Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) |
---|
172 | Â Â Â Â self.text=text |
---|
173 | Â Â Â Â self.table =Â table |
---|
174 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
175 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
176 | Â Â Â Â mainSizer.Add((0,10)) |
---|
177 |     for line in text: |
---|
178 |       mainSizer.Add(wx.StaticText(self.panel,label='   %s   '%(line)),0,WACV) |
---|
179 | Â Â Â Â ncol =Â self.table[0].count(',')+1 |
---|
180 | Â Â Â Â tableSizer =Â wx.FlexGridSizer(0,2*ncol+3,0,0) |
---|
181 |     for j,item in enumerate(self.table): |
---|
182 | Â Â Â Â Â Â num,flds =Â item.split(')') |
---|
183 |       tableSizer.Add(wx.StaticText(self.panel,label='   %s '%(num+')')),0,WACV|wx.ALIGN_LEFT)      |
---|
184 | Â Â Â Â Â Â flds =Â flds.replace(' ','').split(',') |
---|
185 |       for i,fld in enumerate(flds): |
---|
186 |         if i < ncol-1: |
---|
187 | Â Â Â Â Â Â Â Â Â Â tableSizer.Add(wx.StaticText(self.panel,label='%s, '%(fld)),0,WACV|wx.ALIGN_RIGHT) |
---|
188 | Â Â Â Â Â Â Â Â else: |
---|
189 | Â Â Â Â Â Â Â Â Â Â tableSizer.Add(wx.StaticText(self.panel,label='%s'%(fld)),0,WACV|wx.ALIGN_RIGHT) |
---|
190 |       if not j%2: |
---|
191 | Â Â Â Â Â Â Â Â tableSizer.Add((20,0)) |
---|
192 | Â Â Â Â mainSizer.Add(tableSizer,0,wx.ALIGN_LEFT) |
---|
193 | Â Â Â Â btnsizer =Â wx.StdDialogButtonSizer() |
---|
194 |     OKbtn = wx.Button(self.panel, wx.ID_OK) |
---|
195 | Â Â Â Â OKbtn.SetDefault() |
---|
196 | Â Â Â Â btnsizer.AddButton(OKbtn) |
---|
197 | Â Â Â Â btnsizer.Realize() |
---|
198 | Â Â Â Â mainSizer.Add((0,10)) |
---|
199 | Â Â Â Â mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER) |
---|
200 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
201 | Â Â Â Â self.panel.Fit() |
---|
202 | Â Â Â Â self.Fit() |
---|
203 | Â Â Â Â size =Â self.GetSize() |
---|
204 | Â Â Â Â self.SetSize([size[0]+20,size[1]]) |
---|
205 | |
---|
206 |   def Show(self): |
---|
207 | Â Â Â Â '''Use this method after creating the dialog to post it |
---|
208 | Â Â Â Â ''' |
---|
209 | Â Â Â Â self.ShowModal() |
---|
210 | Â Â Â Â return |
---|
211 | Â Â Â Â |
---|
212 | Â Â Â Â |
---|
213 | |
---|
214 | class G2LoggedButton(wx.Button): |
---|
215 | Â Â '''A version of wx.Button that creates logging events. Bindings are saved |
---|
216 | Â Â in the object, and are looked up rather than directly set with a bind. |
---|
217 | Â Â An index to these buttons is saved as log.ButtonBindingLookup |
---|
218 | Â Â :param wx.Panel parent: parent widget |
---|
219 | Â Â :param int id: Id for button |
---|
220 | Â Â :param str label: label for button |
---|
221 | Â Â :param str locationcode: a label used internally to uniquely indentify the button |
---|
222 | Â Â :param function handler: a routine to call when the button is pressed |
---|
223 | Â Â ''' |
---|
224 |   def __init__(self,parent,id=wx.ID_ANY,label='',locationcode='', |
---|
225 | Â Â Â Â Â Â Â Â Â handler=None,*args,**kwargs): |
---|
226 | Â Â Â Â super(self.__class__,self).__init__(parent,id,label,*args,**kwargs) |
---|
227 | Â Â Â Â self.label =Â label |
---|
228 | Â Â Â Â self.handler =Â handler |
---|
229 | Â Â Â Â self.locationcode =Â locationcode |
---|
230 | Â Â Â Â key =Â locationcode +Â '+'Â +Â label # hash code to find button |
---|
231 | Â Â Â Â self.Bind(wx.EVT_BUTTON,self.onPress) |
---|
232 | Â Â Â Â log.ButtonBindingLookup[key]Â =Â self |
---|
233 |   def onPress(self,event): |
---|
234 | Â Â Â Â 'create log event and call handler' |
---|
235 | Â Â Â Â log.MakeButtonLog(self.locationcode,self.label) |
---|
236 | Â Â Â Â self.handler(event) |
---|
237 | class EnumSelector(wx.ComboBox): |
---|
238 | Â Â '''A customized :class:`wxpython.ComboBox` that selects items from a list |
---|
239 | Â Â of choices, but sets a dict (list) entry to the corresponding |
---|
240 | Â Â entry from the input list of values. |
---|
241 | |
---|
242 | Â Â :param wx.Panel parent: the parent to the :class:`~wxpython.ComboBox` (usually a |
---|
243 | Â Â Â frame or panel) |
---|
244 | Â Â :param dict dct: a dict (or list) to contain the value set |
---|
245 | Â Â Â for the :class:`~wxpython.ComboBox`. |
---|
246 | Â Â :param item: the dict key (or list index) where ``dct[item]`` will |
---|
247 | Â Â Â be set to the value selected in the :class:`~wxpython.ComboBox`. Also, dct[item] |
---|
248 | Â Â Â contains the starting value shown in the widget. If the value |
---|
249 | Â Â Â does not match an entry in :data:`values`, the first value |
---|
250 | Â Â Â in :data:`choices` is used as the default, but ``dct[item]`` is |
---|
251 |    not changed.  |
---|
252 | Â Â :param list choices: a list of choices to be displayed to the |
---|
253 | Â Â Â user such as |
---|
254 | Â Â Â :: |
---|
255 | Â Â Â |
---|
256 | Â Â Â ["default","option 1","option 2",] |
---|
257 | |
---|
258 | Â Â Â Note that these options will correspond to the entries in |
---|
259 | Â Â Â :data:`values` (if specified) item by item. |
---|
260 | Â Â :param list values: a list of values that correspond to |
---|
261 | Â Â Â the options in :data:`choices`, such as |
---|
262 | Â Â Â :: |
---|
263 | Â Â Â |
---|
264 | Â Â Â [0,1,2] |
---|
265 | Â Â Â |
---|
266 | Â Â Â The default for :data:`values` is to use the same list as |
---|
267 | Â Â Â specified for :data:`choices`. |
---|
268 | Â Â :param (other): additional keyword arguments accepted by |
---|
269 | Â Â Â :class:`~wxpython.ComboBox` can be specified. |
---|
270 | Â Â ''' |
---|
271 |   def __init__(self,parent,dct,item,choices,values=None,**kw): |
---|
272 |     if values is None: |
---|
273 | Â Â Â Â Â Â values =Â choices |
---|
274 |     if dct[item] in values: |
---|
275 | Â Â Â Â Â Â i =Â values.index(dct[item]) |
---|
276 | Â Â Â Â else: |
---|
277 | Â Â Â Â Â Â i =Â 0 |
---|
278 | Â Â Â Â startval =Â choices[i] |
---|
279 | Â Â Â Â wx.ComboBox.__init__(self,parent,wx.ID_ANY,startval, |
---|
280 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â choices =Â choices, |
---|
281 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â style=wx.CB_DROPDOWN|wx.CB_READONLY, |
---|
282 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â **kw) |
---|
283 | Â Â Â Â self.choices =Â choices |
---|
284 | Â Â Â Â self.values =Â values |
---|
285 | Â Â Â Â self.dct =Â dct |
---|
286 | Â Â Â Â self.item =Â item |
---|
287 |     self.Bind(wx.EVT_COMBOBOX, self.onSelection) |
---|
288 |   def onSelection(self,event): |
---|
289 | Â Â Â Â # respond to a selection by setting the enum value in the CIF dictionary |
---|
290 |     if self.GetValue() in self.choices: # should always be true! |
---|
291 | Â Â Â Â Â Â self.dct[self.item]Â =Â self.values[self.choices.index(self.GetValue())] |
---|
292 | Â Â Â Â else: |
---|
293 | Â Â Â Â Â Â self.dct[self.item]Â =Â self.values[0]Â # unknown |
---|
294 | |
---|
295 | ################################################################################ |
---|
296 | ################################################################################ |
---|
297 | class G2ChoiceButton(wx.Choice): |
---|
298 | Â Â '''A customized version of a wx.Choice that automatically initializes |
---|
299 | Â Â the control to match a supplied value and saves the choice directly |
---|
300 | Â Â into an array or list. Optionally a function can be called each time a |
---|
301 | Â Â choice is selected. The widget can be used with an array item that is set to |
---|
302 | Â Â to the choice by number (``indLoc[indKey]``) or by string value |
---|
303 | Â Â (``strLoc[strKey]``) or both. The initial value is taken from ``indLoc[indKey]`` |
---|
304 | Â Â if not None or ``strLoc[strKey]`` if not None. |
---|
305 | |
---|
306 | Â Â :param wx.Panel parent: name of panel or frame that will be |
---|
307 | Â Â Â the parent to the widget. Can be None. |
---|
308 | Â Â :param list choiceList: a list or tuple of choices to offer the user. |
---|
309 | Â Â :param dict/list indLoc: a dict or list with the initial value to be |
---|
310 | Â Â Â placed in the Choice button. If this is None, this is ignored. |
---|
311 | Â Â :param int/str indKey: the dict key or the list index for the value to be |
---|
312 | Â Â Â edited by the Choice button. If indLoc is not None then this |
---|
313 | Â Â Â must be specified and the ``indLoc[indKey]`` will be set. If the value |
---|
314 | Â Â Â for ``indLoc[indKey]`` is not None, it should be an integer in |
---|
315 | Â Â Â range(len(choiceList)). The Choice button will be initialized to the |
---|
316 | Â Â Â choice corresponding to the value in this element if not None. |
---|
317 | Â Â :param dict/list strLoc: a dict or list with the string value corresponding to |
---|
318 | Â Â Â indLoc/indKey. Default (None) means that this is not used. |
---|
319 | Â Â :param int/str strKey: the dict key or the list index for the string value |
---|
320 | Â Â Â The ``strLoc[strKey]`` element must exist or strLoc must be None (default). |
---|
321 | Â Â :param function onChoice: name of a function to call when the choice is made. |
---|
322 | Â Â ''' |
---|
323 |   def __init__(self,parent,choiceList,indLoc=None,indKey=None,strLoc=None,strKey=None, |
---|
324 | Â Â Â Â Â Â Â Â Â onChoice=None,**kwargs): |
---|
325 | Â Â Â Â wx.Choice.__init__(self,parent,choices=choiceList,id=wx.ID_ANY,**kwargs) |
---|
326 | Â Â Â Â self.choiceList =Â choiceList |
---|
327 | Â Â Â Â self.indLoc =Â indLoc |
---|
328 | Â Â Â Â self.indKey =Â indKey |
---|
329 | Â Â Â Â self.strLoc =Â strLoc |
---|
330 | Â Â Â Â self.strKey =Â strKey |
---|
331 | Â Â Â Â self.onChoice =Â None |
---|
332 | Â Â Â Â self.SetSelection(wx.NOT_FOUND) |
---|
333 |     if self.indLoc is not None and self.indLoc.get(self.indKey) is not None: |
---|
334 | Â Â Â Â Â Â self.SetSelection(self.indLoc[self.indKey]) |
---|
335 |       if self.strLoc is not None: |
---|
336 | Â Â Â Â Â Â Â Â self.strLoc[self.strKey]Â =Â self.GetStringSelection() |
---|
337 | Â Â Â Â Â Â Â Â log.LogVarChange(self.strLoc,self.strKey) |
---|
338 |     elif self.strLoc is not None and self.strLoc.get(self.strKey) is not None: |
---|
339 | Â Â Â Â Â Â try: |
---|
340 | Â Â Â Â Â Â Â Â self.SetSelection(choiceList.index(self.strLoc[self.strKey])) |
---|
341 |         if self.indLoc is not None: |
---|
342 | Â Â Â Â Â Â Â Â Â Â self.indLoc[self.indKey]Â =Â self.GetSelection() |
---|
343 | Â Â Â Â Â Â Â Â Â Â log.LogVarChange(self.indLoc,self.indKey) |
---|
344 |       except ValueError: |
---|
345 | Â Â Â Â Â Â Â Â pass |
---|
346 |     self.Bind(wx.EVT_CHOICE, self._OnChoice) |
---|
347 | Â Â Â Â #if self.strLoc is not None: # make sure strLoc gets initialized |
---|
348 | Â Â Â Â #Â Â self._OnChoice(None) # note that onChoice will not be called |
---|
349 | Â Â Â Â self.onChoice =Â onChoice |
---|
350 |   def _OnChoice(self,event): |
---|
351 |     if self.indLoc is not None: |
---|
352 | Â Â Â Â Â Â self.indLoc[self.indKey]Â =Â self.GetSelection() |
---|
353 | Â Â Â Â Â Â log.LogVarChange(self.indLoc,self.indKey) |
---|
354 |     if self.strLoc is not None: |
---|
355 | Â Â Â Â Â Â self.strLoc[self.strKey]Â =Â self.GetStringSelection() |
---|
356 | Â Â Â Â Â Â log.LogVarChange(self.strLoc,self.strKey) |
---|
357 |     if self.onChoice: |
---|
358 | Â Â Â Â Â Â self.onChoice() |
---|
359 | |
---|
360 | ################################################################################ |
---|
361 | class SymOpDialog(wx.Dialog): |
---|
362 | Â Â '''Class to select a symmetry operator |
---|
363 | Â Â ''' |
---|
364 |   def __init__(self,parent,SGData,New=True,ForceUnit=False): |
---|
365 | Â Â Â Â wx.Dialog.__init__(self,parent,-1,'Select symmetry operator', |
---|
366 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
367 | Â Â Â Â panel =Â wx.Panel(self) |
---|
368 | Â Â Â Â self.SGData =Â SGData |
---|
369 | Â Â Â Â self.New =Â New |
---|
370 | Â Â Â Â self.Force =Â ForceUnit |
---|
371 | Â Â Â Â self.OpSelected =Â [0,0,0,[0,0,0],False,False] |
---|
372 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
373 |     if ForceUnit: |
---|
374 | Â Â Â Â Â Â choice =Â ['No','Yes'] |
---|
375 | Â Â Â Â Â Â self.force =Â wx.RadioBox(panel,-1,'Force to unit cell?',choices=choice) |
---|
376 |       self.force.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
377 | Â Â Â Â Â Â mainSizer.Add(self.force,0,WACV) |
---|
378 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
379 |     if SGData['SGInv']: |
---|
380 | Â Â Â Â Â Â choice =Â ['No','Yes'] |
---|
381 | Â Â Â Â Â Â self.inv =Â wx.RadioBox(panel,-1,'Choose inversion?',choices=choice) |
---|
382 |       self.inv.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
383 | Â Â Â Â Â Â mainSizer.Add(self.inv,0,WACV) |
---|
384 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
385 |     if SGData['SGLatt'] != 'P': |
---|
386 | Â Â Â Â Â Â LattOp =Â G2spc.Latt2text(SGData['SGLatt']).split(';') |
---|
387 | Â Â Â Â Â Â self.latt =Â wx.RadioBox(panel,-1,'Choose cell centering?',choices=LattOp) |
---|
388 |       self.latt.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
389 | Â Â Â Â Â Â mainSizer.Add(self.latt,0,WACV) |
---|
390 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
391 |     if SGData['SGLaue'] in ['-1','2/m','mmm','4/m','4/mmm']: |
---|
392 | Â Â Â Â Â Â Ncol =Â 2 |
---|
393 | Â Â Â Â else: |
---|
394 | Â Â Â Â Â Â Ncol =Â 3 |
---|
395 | Â Â Â Â OpList =Â [] |
---|
396 |     for Opr in SGData['SGOps']: |
---|
397 | Â Â Â Â Â Â OpList.append(G2spc.MT2text(Opr)) |
---|
398 | Â Â Â Â self.oprs =Â wx.RadioBox(panel,-1,'Choose space group operator?',choices=OpList, |
---|
399 | Â Â Â Â Â Â majorDimension=Ncol) |
---|
400 |     self.oprs.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
401 | Â Â Â Â mainSizer.Add(self.oprs,0,WACV) |
---|
402 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
403 | Â Â Â Â mainSizer.Add(wx.StaticText(panel,-1,"Â Â Choose unit cell?"),0,WACV) |
---|
404 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
405 | Â Â Â Â cellSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
406 | Â Â Â Â cellSizer.Add((5,0),0) |
---|
407 | Â Â Â Â cellName =Â ['X','Y','Z'] |
---|
408 | Â Â Â Â self.cell =Â [] |
---|
409 |     for i in range(3): |
---|
410 | Â Â Â Â Â Â self.cell.append(wx.SpinCtrl(panel,-1,cellName[i],size=wx.Size(50,20))) |
---|
411 | Â Â Â Â Â Â self.cell[-1].SetRange(-3,3) |
---|
412 | Â Â Â Â Â Â self.cell[-1].SetValue(0) |
---|
413 |       self.cell[-1].Bind(wx.EVT_SPINCTRL, self.OnOpSelect) |
---|
414 | Â Â Â Â Â Â cellSizer.Add(self.cell[-1],0,WACV) |
---|
415 | Â Â Â Â mainSizer.Add(cellSizer,0,) |
---|
416 |     if self.New: |
---|
417 | Â Â Â Â Â Â choice =Â ['No','Yes'] |
---|
418 | Â Â Â Â Â Â self.new =Â wx.RadioBox(panel,-1,'Generate new positions?',choices=choice) |
---|
419 |       self.new.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) |
---|
420 | Â Â Â Â Â Â mainSizer.Add(self.new,0,WACV) |
---|
421 | Â Â Â Â mainSizer.Add((5,5),0) |
---|
422 | |
---|
423 | Â Â Â Â OkBtn =Â wx.Button(panel,-1,"Ok") |
---|
424 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
425 | Â Â Â Â cancelBtn =Â wx.Button(panel,-1,"Cancel") |
---|
426 |     cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
427 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
428 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
429 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
430 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
431 | Â Â Â Â btnSizer.Add(cancelBtn) |
---|
432 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
433 | |
---|
434 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
435 | Â Â Â Â panel.SetSizer(mainSizer) |
---|
436 | Â Â Â Â panel.Fit() |
---|
437 | Â Â Â Â self.Fit() |
---|
438 | |
---|
439 |   def OnOpSelect(self,event): |
---|
440 |     if self.SGData['SGInv']: |
---|
441 | Â Â Â Â Â Â self.OpSelected[0]Â =Â self.inv.GetSelection() |
---|
442 |     if self.SGData['SGLatt'] != 'P': |
---|
443 | Â Â Â Â Â Â self.OpSelected[1]Â =Â self.latt.GetSelection() |
---|
444 | Â Â Â Â self.OpSelected[2]Â =Â self.oprs.GetSelection() |
---|
445 |     for i in range(3): |
---|
446 | Â Â Â Â Â Â self.OpSelected[3][i]Â =Â float(self.cell[i].GetValue()) |
---|
447 |     if self.New: |
---|
448 | Â Â Â Â Â Â self.OpSelected[4]Â =Â self.new.GetSelection() |
---|
449 |     if self.Force: |
---|
450 | Â Â Â Â Â Â self.OpSelected[5]Â =Â self.force.GetSelection() |
---|
451 | |
---|
452 |   def GetSelection(self): |
---|
453 |     return self.OpSelected |
---|
454 | |
---|
455 |   def OnOk(self,event): |
---|
456 | Â Â Â Â parent =Â self.GetParent() |
---|
457 | Â Â Â Â parent.Raise() |
---|
458 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
459 | |
---|
460 |   def OnCancel(self,event): |
---|
461 | Â Â Â Â parent =Â self.GetParent() |
---|
462 | Â Â Â Â parent.Raise() |
---|
463 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
464 | |
---|
465 | class DisAglDialog(wx.Dialog): |
---|
466 | Â Â '''Distance/Angle Controls input dialog. After |
---|
467 | Â Â :meth:`ShowModal` returns, the results are found in |
---|
468 | Â Â dict :attr:`self.data`, which is accessed using :meth:`GetData`. |
---|
469 | |
---|
470 | Â Â :param wx.Frame parent: reference to parent frame (or None) |
---|
471 | Â Â :param dict data: a dict containing the current |
---|
472 | Â Â Â search ranges or an empty dict, which causes default values |
---|
473 | Â Â Â to be used. |
---|
474 | Â Â Â Will be used to set element `DisAglCtls` in |
---|
475 | Â Â Â :ref:`Phase Tree Item <Phase_table>` |
---|
476 | Â Â :param dict default:Â A dict containing the default |
---|
477 | Â Â Â search ranges for each element. |
---|
478 | Â Â ''' |
---|
479 |   def __init__(self,parent,data,default): |
---|
480 | Â Â Â Â wx.Dialog.__init__(self,parent,wx.ID_ANY, |
---|
481 |               'Distance Angle Controls', |
---|
482 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
483 | Â Â Â Â self.default =Â default |
---|
484 | Â Â Â Â self.panel =Â wx.Panel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
485 | Â Â Â Â self._default(data,self.default) |
---|
486 | Â Â Â Â self.Draw(self.data) |
---|
487 | Â Â Â Â Â Â Â Â |
---|
488 |   def _default(self,data,default): |
---|
489 | Â Â Â Â '''Set starting values for the search values, either from |
---|
490 | Â Â Â Â the input array or from defaults, if input is null |
---|
491 | Â Â Â Â ''' |
---|
492 |     if data: |
---|
493 | Â Â Â Â Â Â self.data =Â copy.deepcopy(data)Â # don't mess with originals |
---|
494 | Â Â Â Â else: |
---|
495 | Â Â Â Â Â Â self.data =Â {} |
---|
496 | Â Â Â Â Â Â self.data['Name']Â =Â default['Name'] |
---|
497 | Â Â Â Â Â Â self.data['Factors']Â =Â [0.85,0.85] |
---|
498 | Â Â Â Â Â Â self.data['AtomTypes']Â =Â default['AtomTypes'] |
---|
499 | Â Â Â Â Â Â self.data['BondRadii']Â =Â default['BondRadii'][:] |
---|
500 | Â Â Â Â Â Â self.data['AngleRadii']Â =Â default['AngleRadii'][:] |
---|
501 | |
---|
502 |   def Draw(self,data): |
---|
503 | Â Â Â Â '''Creates the contents of the dialog. Normally called |
---|
504 | Â Â Â Â by :meth:`__init__`. |
---|
505 | Â Â Â Â ''' |
---|
506 | Â Â Â Â self.panel.Destroy() |
---|
507 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
508 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
509 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,-1,'Controls for phase '+data['Name']), |
---|
510 | Â Â Â Â Â Â 0,WACV|wx.LEFT,10) |
---|
511 | Â Â Â Â mainSizer.Add((10,10),1) |
---|
512 | Â Â Â Â |
---|
513 | Â Â Â Â radiiSizer =Â wx.FlexGridSizer(0,3,5,5) |
---|
514 | Â Â Â Â radiiSizer.Add(wx.StaticText(self.panel,-1,' Type'),0,WACV) |
---|
515 | Â Â Â Â radiiSizer.Add(wx.StaticText(self.panel,-1,'Bond radii'),0,WACV) |
---|
516 | Â Â Â Â radiiSizer.Add(wx.StaticText(self.panel,-1,'Angle radii'),0,WACV) |
---|
517 | Â Â Â Â self.objList =Â {} |
---|
518 |     for id,item in enumerate(self.data['AtomTypes']): |
---|
519 | Â Â Â Â Â Â radiiSizer.Add(wx.StaticText(self.panel,-1,' '+item),0,WACV) |
---|
520 | Â Â Â Â Â Â bRadii =Â wx.TextCtrl(self.panel,-1,value='%.3f'%(data['BondRadii'][id]),style=wx.TE_PROCESS_ENTER) |
---|
521 | Â Â Â Â Â Â self.objList[bRadii.GetId()]Â =Â ['BondRadii',id] |
---|
522 | Â Â Â Â Â Â bRadii.Bind(wx.EVT_TEXT_ENTER,self.OnRadiiVal) |
---|
523 | Â Â Â Â Â Â bRadii.Bind(wx.EVT_KILL_FOCUS,self.OnRadiiVal) |
---|
524 | Â Â Â Â Â Â radiiSizer.Add(bRadii,0,WACV) |
---|
525 | Â Â Â Â Â Â aRadii =Â wx.TextCtrl(self.panel,-1,value='%.3f'%(data['AngleRadii'][id]),style=wx.TE_PROCESS_ENTER) |
---|
526 | Â Â Â Â Â Â self.objList[aRadii.GetId()]Â =Â ['AngleRadii',id] |
---|
527 | Â Â Â Â Â Â aRadii.Bind(wx.EVT_TEXT_ENTER,self.OnRadiiVal) |
---|
528 | Â Â Â Â Â Â aRadii.Bind(wx.EVT_KILL_FOCUS,self.OnRadiiVal) |
---|
529 | Â Â Â Â Â Â radiiSizer.Add(aRadii,0,WACV) |
---|
530 | Â Â Â Â mainSizer.Add(radiiSizer,0,wx.EXPAND) |
---|
531 | Â Â Â Â factorSizer =Â wx.FlexGridSizer(0,2,5,5) |
---|
532 | Â Â Â Â Names =Â ['Bond','Angle'] |
---|
533 |     for i,name in enumerate(Names): |
---|
534 | Â Â Â Â Â Â factorSizer.Add(wx.StaticText(self.panel,-1,name+' search factor'),0,WACV) |
---|
535 | Â Â Â Â Â Â bondFact =Â wx.TextCtrl(self.panel,-1,value='%.3f'%(data['Factors'][i]),style=wx.TE_PROCESS_ENTER) |
---|
536 | Â Â Â Â Â Â self.objList[bondFact.GetId()]Â =Â ['Factors',i] |
---|
537 | Â Â Â Â Â Â bondFact.Bind(wx.EVT_TEXT_ENTER,self.OnRadiiVal) |
---|
538 | Â Â Â Â Â Â bondFact.Bind(wx.EVT_KILL_FOCUS,self.OnRadiiVal) |
---|
539 | Â Â Â Â Â Â factorSizer.Add(bondFact) |
---|
540 | Â Â Â Â mainSizer.Add(factorSizer,0,wx.EXPAND) |
---|
541 | Â Â Â Â |
---|
542 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,"Ok") |
---|
543 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
544 | Â Â Â Â ResetBtn =Â wx.Button(self.panel,-1,'Reset') |
---|
545 |     ResetBtn.Bind(wx.EVT_BUTTON, self.OnReset) |
---|
546 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
547 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
548 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
549 | Â Â Â Â btnSizer.Add(ResetBtn) |
---|
550 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
551 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
552 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
553 | Â Â Â Â self.panel.Fit() |
---|
554 | Â Â Â Â self.Fit() |
---|
555 | Â Â |
---|
556 |   def OnRadiiVal(self,event): |
---|
557 | Â Â Â Â Obj =Â event.GetEventObject() |
---|
558 | Â Â Â Â item =Â self.objList[Obj.GetId()] |
---|
559 | Â Â Â Â try: |
---|
560 | Â Â Â Â Â Â self.data[item[0]][item[1]]Â =Â float(Obj.GetValue()) |
---|
561 |     except ValueError: |
---|
562 | Â Â Â Â Â Â pass |
---|
563 | Â Â Â Â Obj.SetValue("%.3f"%(self.data[item[0]][item[1]]))Â Â Â Â Â #reset in case of error |
---|
564 | Â Â Â Â |
---|
565 |   def GetData(self): |
---|
566 | Â Â Â Â 'Returns the values from the dialog' |
---|
567 |     return self.data |
---|
568 | Â Â Â Â |
---|
569 |   def OnOk(self,event): |
---|
570 | Â Â Â Â 'Called when the OK button is pressed' |
---|
571 | Â Â Â Â parent =Â self.GetParent() |
---|
572 | Â Â Â Â parent.Raise() |
---|
573 | Â Â Â Â self.EndModal(wx.ID_OK)Â Â Â Â Â Â Â |
---|
574 | Â Â Â Â |
---|
575 |   def OnReset(self,event): |
---|
576 | Â Â Â Â 'Called when the Reset button is pressed' |
---|
577 | Â Â Â Â data =Â {} |
---|
578 | Â Â Â Â self._default(data,self.default) |
---|
579 | Â Â Â Â self.Draw(self.data) |
---|
580 | Â Â Â Â Â Â Â Â |
---|
581 | class SingleFloatDialog(wx.Dialog): |
---|
582 | Â Â 'Dialog to obtain a single float value from user' |
---|
583 |   def __init__(self,parent,title,prompt,value,limits=[0.,1.],format='%.5g'): |
---|
584 |     wx.Dialog.__init__(self,parent,-1,title, |
---|
585 | Â Â Â Â Â Â pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) |
---|
586 | Â Â Â Â self.panel =Â wx.Panel(self)Â Â Â Â Â #just a dummy - gets destroyed in Draw! |
---|
587 | Â Â Â Â self.limits =Â limits |
---|
588 | Â Â Â Â self.value =Â value |
---|
589 | Â Â Â Â self.prompt =Â prompt |
---|
590 | Â Â Â Â self.format =Â format |
---|
591 | Â Â Â Â self.Draw() |
---|
592 | Â Â Â Â |
---|
593 |   def Draw(self): |
---|
594 | Â Â Â Â |
---|
595 |     def OnValItem(event): |
---|
596 | Â Â Â Â Â Â try: |
---|
597 | Â Â Â Â Â Â Â Â val =Â float(valItem.GetValue()) |
---|
598 |         if val < self.limits[0] or val > self.limits[1]: |
---|
599 |           raise ValueError |
---|
600 |       except ValueError: |
---|
601 | Â Â Â Â Â Â Â Â val =Â self.value |
---|
602 | Â Â Â Â Â Â self.value =Â val |
---|
603 | Â Â Â Â Â Â valItem.SetValue(self.format%(self.value)) |
---|
604 | Â Â Â Â Â Â |
---|
605 | Â Â Â Â self.panel.Destroy() |
---|
606 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
607 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
608 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER) |
---|
609 | Â Â Â Â valItem =Â wx.TextCtrl(self.panel,-1,value=self.format%(self.value),style=wx.TE_PROCESS_ENTER) |
---|
610 | Â Â Â Â mainSizer.Add(valItem,0,wx.ALIGN_CENTER) |
---|
611 | Â Â Â Â valItem.Bind(wx.EVT_TEXT_ENTER,OnValItem) |
---|
612 | Â Â Â Â valItem.Bind(wx.EVT_KILL_FOCUS,OnValItem) |
---|
613 | Â Â Â Â OkBtn =Â wx.Button(self.panel,-1,"Ok") |
---|
614 |     OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) |
---|
615 | Â Â Â Â CancelBtn =Â wx.Button(self.panel,-1,'Cancel') |
---|
616 |     CancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) |
---|
617 | Â Â Â Â btnSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
618 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
619 | Â Â Â Â btnSizer.Add(OkBtn) |
---|
620 | Â Â Â Â btnSizer.Add(CancelBtn) |
---|
621 | Â Â Â Â btnSizer.Add((20,20),1) |
---|
622 |     mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
623 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
624 | Â Â Â Â self.panel.Fit() |
---|
625 | Â Â Â Â self.Fit() |
---|
626 | |
---|
627 |   def GetValue(self): |
---|
628 |     return self.value |
---|
629 | Â Â Â Â |
---|
630 |   def OnOk(self,event): |
---|
631 | Â Â Â Â parent =Â self.GetParent() |
---|
632 | Â Â Â Â parent.Raise() |
---|
633 | Â Â Â Â self.EndModal(wx.ID_OK)Â Â Â Â Â Â Â |
---|
634 | Â Â Â Â |
---|
635 |   def OnCancel(self,event): |
---|
636 | Â Â Â Â parent =Â self.GetParent() |
---|
637 | Â Â Â Â parent.Raise() |
---|
638 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
639 | |
---|
640 | ################################################################################ |
---|
641 | class SingleStringDialog(wx.Dialog): |
---|
642 | Â Â '''Dialog to obtain a single string value from user |
---|
643 | Â Â |
---|
644 | Â Â :param wx.Frame parent: name of parent frame |
---|
645 | Â Â :param str title: title string for dialog |
---|
646 | Â Â :param str prompt: string to tell use what they are inputting |
---|
647 | Â Â :param str value: default input value, if any |
---|
648 | Â Â ''' |
---|
649 |   def __init__(self,parent,title,prompt,value='',size=(200,-1)): |
---|
650 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,title, |
---|
651 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â pos=wx.DefaultPosition, |
---|
652 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) |
---|
653 | Â Â Â Â self.value =Â value |
---|
654 | Â Â Â Â self.prompt =Â prompt |
---|
655 | Â Â Â Â self.CenterOnParent() |
---|
656 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
657 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
658 | Â Â Â Â mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER) |
---|
659 | Â Â Â Â self.valItem =Â wx.TextCtrl(self.panel,-1,value=self.value,size=size) |
---|
660 | Â Â Â Â mainSizer.Add(self.valItem,0,wx.ALIGN_CENTER) |
---|
661 | Â Â Â Â btnsizer =Â wx.StdDialogButtonSizer() |
---|
662 |     OKbtn = wx.Button(self.panel, wx.ID_OK) |
---|
663 | Â Â Â Â OKbtn.SetDefault() |
---|
664 | Â Â Â Â btnsizer.AddButton(OKbtn) |
---|
665 |     btn = wx.Button(self.panel, wx.ID_CANCEL) |
---|
666 | Â Â Â Â btnsizer.AddButton(btn) |
---|
667 | Â Â Â Â btnsizer.Realize() |
---|
668 | Â Â Â Â mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER) |
---|
669 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
670 | Â Â Â Â self.panel.Fit() |
---|
671 | Â Â Â Â self.Fit() |
---|
672 | |
---|
673 |   def Show(self): |
---|
674 | Â Â Â Â '''Use this method after creating the dialog to post it |
---|
675 | Â Â Â Â :returns: True if the user pressed OK; False if the User pressed Cancel |
---|
676 | Â Â Â Â ''' |
---|
677 |     if self.ShowModal() == wx.ID_OK: |
---|
678 | Â Â Â Â Â Â self.value =Â self.valItem.GetValue() |
---|
679 |       return True |
---|
680 | Â Â Â Â else: |
---|
681 |       return False |
---|
682 | |
---|
683 |   def GetValue(self): |
---|
684 | Â Â Â Â '''Use this method to get the value entered by the user |
---|
685 | Â Â Â Â :returns: string entered by user |
---|
686 | Â Â Â Â ''' |
---|
687 |     return self.value |
---|
688 | |
---|
689 | ################################################################################ |
---|
690 | class MultiStringDialog(wx.Dialog): |
---|
691 | Â Â '''Dialog to obtain a multi string values from user |
---|
692 | Â Â |
---|
693 | Â Â :param wx.Frame parent: name of parent frame |
---|
694 | Â Â :param str title: title string for dialog |
---|
695 | Â Â :param str prompts: strings to tell use what they are inputting |
---|
696 | Â Â :param str values: default input values, if any |
---|
697 | Â Â ''' |
---|
698 |   def __init__(self,parent,title,prompts,values=[]):   #,size=(200,-1)? |
---|
699 | Â Â Â Â |
---|
700 |     wx.Dialog.__init__(self,parent,wx.ID_ANY,title, |
---|
701 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â pos=wx.DefaultPosition, |
---|
702 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) |
---|
703 | Â Â Â Â self.values =Â values |
---|
704 | Â Â Â Â self.prompts =Â prompts |
---|
705 | Â Â Â Â self.CenterOnParent() |
---|
706 | Â Â Â Â self.panel =Â wx.Panel(self) |
---|
707 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
708 | Â Â Â Â promptSizer =Â wx.FlexGridSizer(0,2,5,5) |
---|
709 | Â Â Â Â self.Indx =Â {} |
---|
710 |     for prompt,value in zip(prompts,values): |
---|
711 | Â Â Â Â Â Â promptSizer.Add(wx.StaticText(self.panel,-1,prompt),0,WACV) |
---|
712 | Â Â Â Â Â Â valItem =Â wx.TextCtrl(self.panel,-1,value=value,style=wx.TE_PROCESS_ENTER) |
---|
713 | Â Â Â Â Â Â self.Indx[valItem.GetId()]Â =Â prompt |
---|
714 | Â Â Â Â Â Â valItem.Bind(wx.EVT_TEXT,self.newValue) |
---|
715 | Â Â Â Â Â Â promptSizer.Add(valItem,0,WACV) |
---|
716 | Â Â Â Â mainSizer.Add(promptSizer,0) |
---|
717 | Â Â Â Â btnsizer =Â wx.StdDialogButtonSizer() |
---|
718 |     OKbtn = wx.Button(self.panel, wx.ID_OK) |
---|
719 | Â Â Â Â OKbtn.SetDefault() |
---|
720 | Â Â Â Â btnsizer.AddButton(OKbtn) |
---|
721 |     btn = wx.Button(self.panel, wx.ID_CANCEL) |
---|
722 | Â Â Â Â btnsizer.AddButton(btn) |
---|
723 | Â Â Â Â btnsizer.Realize() |
---|
724 | Â Â Â Â mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER) |
---|
725 | Â Â Â Â self.panel.SetSizer(mainSizer) |
---|
726 | Â Â Â Â self.panel.Fit() |
---|
727 | Â Â Â Â self.Fit() |
---|
728 | Â Â Â Â |
---|
729 |   def newValue(self,event): |
---|
730 | Â Â Â Â Obj =Â event.GetEventObject() |
---|
731 | Â Â Â Â item =Â self.Indx[Obj.GetId()] |
---|
732 |     id = self.prompts.index(item) |
---|
733 | Â Â Â Â self.values[id]Â =Â Obj.GetValue() |
---|
734 | |
---|
735 |   def Show(self): |
---|
736 | Â Â Â Â '''Use this method after creating the dialog to post it |
---|
737 | Â Â Â Â :returns: True if the user pressed OK; False if the User pressed Cancel |
---|
738 | Â Â Â Â ''' |
---|
739 |     if self.ShowModal() == wx.ID_OK: |
---|
740 |       return True |
---|
741 | Â Â Â Â else: |
---|
742 |       return False |
---|
743 | |
---|
744 |   def GetValues(self): |
---|
745 | Â Â Â Â '''Use this method to get the value entered by the user |
---|
746 | Â Â Â Â :returns: string entered by user |
---|
747 | Â Â Â Â ''' |
---|
748 |     return self.values |
---|
749 | |
---|
750 | ################################################################################ |
---|
751 | |
---|
752 | class G2MultiChoiceDialog(wx.Dialog): |
---|
753 | Â Â '''A dialog similar to MultiChoiceDialog except that buttons are |
---|
754 | Â Â added to set all choices and to toggle all choices. |
---|
755 | |
---|
756 | Â Â :param wx.Frame ParentFrame: reference to parent frame |
---|
757 | Â Â :param str title: heading above list of choices |
---|
758 | Â Â :param str header: Title to place on window frame |
---|
759 | Â Â :param list ChoiceList: a list of choices where one will be selected |
---|
760 | Â Â :param bool toggle: If True (default) the toggle and select all buttons |
---|
761 | Â Â Â are displayed |
---|
762 | Â Â :param bool monoFont: If False (default), use a variable-spaced font; |
---|
763 | Â Â Â if True use a equally-spaced font. |
---|
764 | Â Â :param bool filterBox: If True (default) an input widget is placed on |
---|
765 | Â Â Â the window and only entries matching the entered text are shown. |
---|
766 | Â Â :param kw: optional keyword parameters for the wx.Dialog may |
---|
767 | Â Â Â be included such as size [which defaults to `(320,310)`] and |
---|
768 | Â Â Â style (which defaults to `wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.CENTRE| wx.OK | wx.CANCEL`); |
---|
769 | Â Â Â note that `wx.OK` and `wx.CANCEL` controls |
---|
770 | Â Â Â the presence of the eponymous buttons in the dialog. |
---|
771 |   :returns: the name of the created dialog |
---|
772 | Â Â ''' |
---|
773 |   def __init__(self,parent, title, header, ChoiceList, toggle=True, |
---|
774 |          monoFont=False, filterBox=True, **kw): |
---|
775 | Â Â Â Â # process keyword parameters, notably style |
---|
776 |     options = {'size':(320,310), # default Frame keywords |
---|
777 | Â Â Â Â Â Â Â Â Â Â 'style':wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.CENTRE|Â wx.OK |Â wx.CANCEL, |
---|
778 | Â Â Â Â Â Â Â Â Â Â } |
---|
779 | Â Â Â Â options.update(kw) |
---|
780 | Â Â Â Â self.ChoiceList =Â ChoiceList # list of choices (list of str values) |
---|
781 | Â Â Â Â self.Selections =Â len(self.ChoiceList)Â *Â [False,]Â # selection status for each choice (list of bools) |
---|
782 | Â Â Â Â self.filterlist =Â range(len(self.ChoiceList))Â # list of the choice numbers that have been filtered (list of int indices) |
---|
783 |     if options['style'] & wx.OK: |
---|
784 | Â Â Â Â Â Â useOK =Â True |
---|
785 | Â Â Â Â Â Â options['style']Â ^=Â wx.OK |
---|
786 | Â Â Â Â else: |
---|
787 | Â Â Â Â Â Â useOK =Â False |
---|
788 |     if options['style'] & wx.CANCEL: |
---|
789 | Â Â Â Â Â Â useCANCEL =Â True |
---|
790 | Â Â Â Â Â Â options['style']Â ^=Â wx.CANCEL |
---|
791 | Â Â Â Â else: |
---|
792 |       useCANCEL = False    |
---|
793 | Â Â Â Â # create the dialog frame |
---|
794 | Â Â Â Â wx.Dialog.__init__(self,parent,wx.ID_ANY,header,**options) |
---|
795 | Â Â Â Â # fill the dialog |
---|
796 | Â Â Â Â Sizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
797 | Â Â Â Â topSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
798 | Â Â Â Â topSizer.Add( |
---|
799 | Â Â Â Â Â Â wx.StaticText(self,wx.ID_ANY,title,size=(-1,35)), |
---|
800 | Â Â Â Â Â Â 1,wx.ALL|wx.EXPAND|WACV,1) |
---|
801 |     if filterBox: |
---|
802 | Â Â Â Â Â Â self.timer =Â wx.Timer() |
---|
803 | Â Â Â Â Â Â self.timer.Bind(wx.EVT_TIMER,self.Filter) |
---|
804 | Â Â Â Â Â Â topSizer.Add(wx.StaticText(self,wx.ID_ANY,'Name \nFilter: '),0,wx.ALL|WACV,1) |
---|
805 |       self.filterBox = wx.TextCtrl(self, wx.ID_ANY, size=(80,-1),style=wx.TE_PROCESS_ENTER) |
---|
806 | Â Â Â Â Â Â self.filterBox.Bind(wx.EVT_CHAR,self.onChar) |
---|
807 | Â Â Â Â Â Â self.filterBox.Bind(wx.EVT_TEXT_ENTER,self.Filter) |
---|
808 | Â Â Â Â Â Â topSizer.Add(self.filterBox,0,wx.ALL|WACV,0) |
---|
809 | Â Â Â Â Sizer.Add(topSizer,0,wx.ALL|wx.EXPAND,8) |
---|
810 | Â Â Â Â self.trigger =Â False |
---|
811 |     self.clb = wx.CheckListBox(self, wx.ID_ANY, (30,30), wx.DefaultSize, ChoiceList) |
---|
812 | Â Â Â Â self.clb.Bind(wx.EVT_CHECKLISTBOX,self.OnCheck) |
---|
813 |     if monoFont: |
---|
814 | Â Â Â Â Â Â font1 =Â wx.Font(self.clb.GetFont().GetPointSize(), |
---|
815 |               wx.MODERN, wx.NORMAL, wx.NORMAL, False) |
---|
816 | Â Â Â Â Â Â self.clb.SetFont(font1) |
---|
817 | Â Â Â Â Sizer.Add(self.clb,1,wx.LEFT|wx.RIGHT|wx.EXPAND,10) |
---|
818 | Â Â Â Â Sizer.Add((-1,10)) |
---|
819 | Â Â Â Â # set/toggle buttons |
---|
820 |     if toggle: |
---|
821 | Â Â Â Â Â Â bSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
822 | Â Â Â Â Â Â setBut =Â wx.Button(self,wx.ID_ANY,'Set All') |
---|
823 | Â Â Â Â Â Â setBut.Bind(wx.EVT_BUTTON,self._SetAll) |
---|
824 | Â Â Â Â Â Â bSizer.Add(setBut,0,wx.ALIGN_CENTER) |
---|
825 | Â Â Â Â Â Â bSizer.Add((-1,5)) |
---|
826 | Â Â Â Â Â Â togBut =Â wx.Button(self,wx.ID_ANY,'Toggle All') |
---|
827 | Â Â Â Â Â Â togBut.Bind(wx.EVT_BUTTON,self._ToggleAll) |
---|
828 | Â Â Â Â Â Â bSizer.Add(togBut,0,wx.ALIGN_CENTER) |
---|
829 | Â Â Â Â Â Â Sizer.Add(bSizer,0,wx.LEFT,12) |
---|
830 | Â Â Â Â # OK/Cancel buttons |
---|
831 | Â Â Â Â btnsizer =Â wx.StdDialogButtonSizer() |
---|
832 |     if useOK: |
---|
833 |       self.OKbtn = wx.Button(self, wx.ID_OK) |
---|
834 | Â Â Â Â Â Â self.OKbtn.SetDefault() |
---|
835 | Â Â Â Â Â Â btnsizer.AddButton(self.OKbtn) |
---|
836 |     if useCANCEL: |
---|
837 |       btn = wx.Button(self, wx.ID_CANCEL) |
---|
838 | Â Â Â Â Â Â btnsizer.AddButton(btn) |
---|
839 | Â Â Â Â btnsizer.Realize() |
---|
840 | Â Â Â Â Sizer.Add((-1,5)) |
---|
841 | Â Â Â Â Sizer.Add(btnsizer,0,wx.ALIGN_RIGHT,50) |
---|
842 | Â Â Â Â Sizer.Add((-1,20)) |
---|
843 | Â Â Â Â # OK done, let's get outa here |
---|
844 | Â Â Â Â self.SetSizer(Sizer) |
---|
845 | Â Â Â Â self.CenterOnParent() |
---|
846 | Â Â Â Â |
---|
847 |   def GetSelections(self): |
---|
848 | Â Â Â Â 'Returns a list of the indices for the selected choices' |
---|
849 | Â Â Â Â # update self.Selections with settings for displayed items |
---|
850 |     for i in range(len(self.filterlist)): |
---|
851 | Â Â Â Â Â Â self.Selections[self.filterlist[i]]Â =Â self.clb.IsChecked(i) |
---|
852 | Â Â Â Â # return all selections, shown or hidden |
---|
853 |     return [i for i in range(len(self.Selections)) if self.Selections[i]] |
---|
854 | Â Â Â Â |
---|
855 |   def SetSelections(self,selList): |
---|
856 | Â Â Â Â '''Sets the selection indices in selList as selected. Resets any previous |
---|
857 | Â Â Â Â selections for compatibility with wx.MultiChoiceDialog. Note that |
---|
858 | Â Â Â Â the state for only the filtered items is shown. |
---|
859 | |
---|
860 | Â Â Â Â :param list selList: indices of items to be selected. These indices |
---|
861 | Â Â Â Â Â are referenced to the order in self.ChoiceList |
---|
862 | Â Â Â Â ''' |
---|
863 | Â Â Â Â self.Selections =Â len(self.ChoiceList)Â *Â [False,]Â # reset selections |
---|
864 |     for sel in selList: |
---|
865 | Â Â Â Â Â Â self.Selections[sel]Â =Â True |
---|
866 | Â Â Â Â self._ShowSelections() |
---|
867 | |
---|
868 |   def _ShowSelections(self): |
---|
869 | Â Â Â Â 'Show the selection state for displayed items' |
---|
870 | Â Â Â Â self.clb.SetChecked( |
---|
871 |       [i for i in range(len(self.filterlist)) if self.Selections[self.filterlist[i]]] |
---|
872 | Â Â Â Â Â Â )Â # Note anything previously checked will be cleared. |
---|
873 | Â Â Â Â Â Â |
---|
874 |   def _SetAll(self,event): |
---|
875 | Â Â Â Â 'Set all viewed choices on' |
---|
876 | Â Â Â Â self.clb.SetChecked(range(len(self.filterlist))) |
---|
877 | Â Â Â Â |
---|
878 |   def _ToggleAll(self,event): |
---|
879 | Â Â Â Â 'flip the state of all viewed choices' |
---|
880 |     for i in range(len(self.filterlist)): |
---|
881 |       self.clb.Check(i,not self.clb.IsChecked(i)) |
---|
882 | Â Â Â Â Â Â |
---|
883 |   def onChar(self,event): |
---|
884 | Â Â Â Â 'for keyboard events. self.trigger is used in self.OnCheck below' |
---|
885 | Â Â Â Â self.OKbtn.Enable(False) |
---|
886 |     if event.GetKeyCode() == wx.WXK_SHIFT: |
---|
887 | Â Â Â Â Â Â self.trigger =Â True |
---|
888 |     if self.timer.IsRunning(): |
---|
889 | Â Â Â Â Â Â self.timer.Stop() |
---|
890 | Â Â Â Â self.timer.Start(1000,oneShot=True) |
---|
891 | Â Â Â Â event.Skip() |
---|
892 | Â Â Â Â |
---|
893 |   def OnCheck(self,event): |
---|
894 | Â Â Â Â '''for CheckListBox events; if Shift key down this sets all unset |
---|
895 | Â Â Â Â Â Â entries below the selected one''' |
---|
896 |     if self.trigger: |
---|
897 |       id = event.GetSelection() |
---|
898 | Â Â Â Â Â Â name =Â self.clb.GetString(id)Â Â Â Â Â Â |
---|
899 | Â Â Â Â Â Â iB =Â id-1 |
---|
900 |       if iB < 0: |
---|
901 | Â Â Â Â Â Â Â Â return |
---|
902 |       while not self.clb.IsChecked(iB): |
---|
903 | Â Â Â Â Â Â Â Â self.clb.Check(iB) |
---|
904 | Â Â Â Â Â Â Â Â iB -=Â 1 |
---|
905 |         if iB < 0: |
---|
906 | Â Â Â Â Â Â Â Â Â Â break |
---|
907 |     self.trigger = not self.trigger |
---|
908 | Â Â Â Â |
---|
909 |   def Filter(self,event): |
---|
910 |     if self.timer.IsRunning(): |
---|
911 | Â Â Â Â Â Â self.timer.Stop() |
---|
912 | Â Â Â Â self.GetSelections()Â # record current selections |
---|
913 | Â Â Â Â txt =Â self.filterBox.GetValue() |
---|
914 | Â Â Â Â self.clb.Clear() |
---|
915 | Â Â Â Â |
---|
916 | Â Â Â Â self.Update() |
---|
917 | Â Â Â Â self.filterlist =Â [] |
---|
918 |     if txt: |
---|
919 | Â Â Â Â Â Â txt =Â txt.lower() |
---|
920 | Â Â Â Â Â Â ChoiceList =Â [] |
---|
921 |       for i,item in enumerate(self.ChoiceList): |
---|
922 |         if item.lower().find(txt) != -1: |
---|
923 | Â Â Â Â Â Â Â Â Â Â ChoiceList.append(item) |
---|
924 | Â Â Â Â Â Â Â Â Â Â self.filterlist.append(i) |
---|
925 | Â Â Â Â else: |
---|
926 | Â Â Â Â Â Â self.filterlist =Â range(len(self.ChoiceList)) |
---|
927 | Â Â Â Â Â Â ChoiceList =Â self.ChoiceList |
---|
928 | Â Â Â Â self.clb.AppendItems(ChoiceList) |
---|
929 | Â Â Â Â self._ShowSelections() |
---|
930 | Â Â Â Â self.OKbtn.Enable(True) |
---|
931 | |
---|
932 | ################################################################################ |
---|
933 | |
---|
934 | class G2SingleChoiceDialog(wx.Dialog): |
---|
935 | Â Â '''A dialog similar to wx.SingleChoiceDialog except that a filter can be |
---|
936 | Â Â added. |
---|
937 | |
---|
938 | Â Â :param wx.Frame ParentFrame: reference to parent frame |
---|
939 | Â Â :param str title: heading above list of choices |
---|
940 | Â Â :param str header: Title to place on window frame |
---|
941 | Â Â :param list ChoiceList: a list of choices where one will be selected |
---|
942 | Â Â :param bool monoFont: If False (default), use a variable-spaced font; |
---|
943 | Â Â Â if True use a equally-spaced font. |
---|
944 | Â Â :param bool filterBox: If True (default) an input widget is placed on |
---|
945 | Â Â Â the window and only entries matching the entered text are shown. |
---|
946 | Â Â :param kw: optional keyword parameters for the wx.Dialog may |
---|
947 | Â Â Â be included such as size [which defaults to `(320,310)`] and |
---|
948 | Â Â Â style (which defaults to ``wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.CENTRE | wx.OK | wx.CANCEL``); |
---|
949 | Â Â Â note that ``wx.OK`` and ``wx.CANCEL`` controls |
---|
950 | Â Â Â the presence of the eponymous buttons in the dialog. |
---|
951 | Â Â :returns: the name of the created dialog |
---|
952 | Â Â ''' |
---|
953 |   def __init__(self,parent, title, header, ChoiceList, |
---|
954 |          monoFont=False, filterBox=True, **kw): |
---|
955 | Â Â Â Â # process keyword parameters, notably style |
---|
956 |     options = {'size':(320,310), # default Frame keywords |
---|
957 | Â Â Â Â Â Â Â Â Â Â 'style':wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.CENTRE|Â wx.OK |Â wx.CANCEL, |
---|
958 | Â Â Â Â Â Â Â Â Â Â } |
---|
959 | Â Â Â Â options.update(kw) |
---|
960 | Â Â Â Â self.ChoiceList =Â ChoiceList |
---|
961 | Â Â Â Â self.filterlist =Â range(len(self.ChoiceList)) |
---|
962 |     if options['style'] & wx.OK: |
---|
963 | Â Â Â Â Â Â useOK =Â True |
---|
964 | Â Â Â Â Â Â options['style']Â ^=Â wx.OK |
---|
965 | Â Â Â Â else: |
---|
966 | Â Â Â Â Â Â useOK =Â False |
---|
967 |     if options['style'] & wx.CANCEL: |
---|
968 | Â Â Â Â Â Â useCANCEL =Â True |
---|
969 | Â Â Â Â Â Â options['style']Â ^=Â wx.CANCEL |
---|
970 | Â Â Â Â else: |
---|
971 |       useCANCEL = False    |
---|
972 | Â Â Â Â # create the dialog frame |
---|
973 | Â Â Â Â wx.Dialog.__init__(self,parent,wx.ID_ANY,header,**options) |
---|
974 | Â Â Â Â # fill the dialog |
---|
975 | Â Â Â Â Sizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
976 | Â Â Â Â topSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
977 | Â Â Â Â topSizer.Add( |
---|
978 | Â Â Â Â Â Â wx.StaticText(self,wx.ID_ANY,title,size=(-1,35)), |
---|
979 | Â Â Â Â Â Â 1,wx.ALL|wx.EXPAND|WACV,1) |
---|
980 |     if filterBox: |
---|
981 | Â Â Â Â Â Â self.timer =Â wx.Timer() |
---|
982 | Â Â Â Â Â Â self.timer.Bind(wx.EVT_TIMER,self.Filter) |
---|
983 | Â Â Â Â Â Â topSizer.Add(wx.StaticText(self,wx.ID_ANY,'Filter: '),0,wx.ALL,1) |
---|
984 |       self.filterBox = wx.TextCtrl(self, wx.ID_ANY, size=(80,-1), |
---|
985 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â style=wx.TE_PROCESS_ENTER) |
---|
986 | Â Â Â Â Â Â self.filterBox.Bind(wx.EVT_CHAR,self.onChar) |
---|
987 | Â Â Â Â Â Â self.filterBox.Bind(wx.EVT_TEXT_ENTER,self.Filter) |
---|
988 | Â Â Â Â topSizer.Add(self.filterBox,0,wx.ALL,0) |
---|
989 | Â Â Â Â Sizer.Add(topSizer,0,wx.ALL|wx.EXPAND,8) |
---|
990 |     self.clb = wx.ListBox(self, wx.ID_ANY, (30,30), wx.DefaultSize, ChoiceList) |
---|
991 | Â Â Â Â self.clb.Bind(wx.EVT_LEFT_DCLICK,self.onDoubleClick) |
---|
992 |     if monoFont: |
---|
993 | Â Â Â Â Â Â font1 =Â wx.Font(self.clb.GetFont().GetPointSize(), |
---|
994 |               wx.MODERN, wx.NORMAL, wx.NORMAL, False) |
---|
995 | Â Â Â Â Â Â self.clb.SetFont(font1) |
---|
996 | Â Â Â Â Sizer.Add(self.clb,1,wx.LEFT|wx.RIGHT|wx.EXPAND,10) |
---|
997 | Â Â Â Â Sizer.Add((-1,10)) |
---|
998 | Â Â Â Â # OK/Cancel buttons |
---|
999 | Â Â Â Â btnsizer =Â wx.StdDialogButtonSizer() |
---|
1000 |     if useOK: |
---|
1001 |       self.OKbtn = wx.Button(self, wx.ID_OK) |
---|
1002 | Â Â Â Â Â Â self.OKbtn.SetDefault() |
---|
1003 | Â Â Â Â Â Â btnsizer.AddButton(self.OKbtn) |
---|
1004 |     if useCANCEL: |
---|
1005 |       btn = wx.Button(self, wx.ID_CANCEL) |
---|
1006 | Â Â Â Â Â Â btnsizer.AddButton(btn) |
---|
1007 | Â Â Â Â btnsizer.Realize() |
---|
1008 | Â Â Â Â Sizer.Add((-1,5)) |
---|
1009 | Â Â Â Â Sizer.Add(btnsizer,0,wx.ALIGN_RIGHT,50) |
---|
1010 | Â Â Â Â Sizer.Add((-1,20)) |
---|
1011 | Â Â Â Â # OK done, let's get outa here |
---|
1012 | Â Â Â Â self.SetSizer(Sizer) |
---|
1013 |   def GetSelection(self): |
---|
1014 | Â Â Â Â 'Returns the index of the selected choice' |
---|
1015 | Â Â Â Â i =Â self.clb.GetSelection() |
---|
1016 |     if i < 0 or i >= len(self.filterlist): |
---|
1017 |       return wx.NOT_FOUND |
---|
1018 |     return self.filterlist[i] |
---|
1019 |   def onChar(self,event): |
---|
1020 | Â Â Â Â self.OKbtn.Enable(False) |
---|
1021 |     if self.timer.IsRunning(): |
---|
1022 | Â Â Â Â Â Â self.timer.Stop() |
---|
1023 | Â Â Â Â self.timer.Start(1000,oneShot=True) |
---|
1024 | Â Â Â Â event.Skip() |
---|
1025 |   def Filter(self,event): |
---|
1026 |     if self.timer.IsRunning(): |
---|
1027 | Â Â Â Â Â Â self.timer.Stop() |
---|
1028 | Â Â Â Â txt =Â self.filterBox.GetValue() |
---|
1029 | Â Â Â Â self.clb.Clear() |
---|
1030 | Â Â Â Â self.Update() |
---|
1031 | Â Â Â Â self.filterlist =Â [] |
---|
1032 |     if txt: |
---|
1033 | Â Â Â Â Â Â txt =Â txt.lower() |
---|
1034 | Â Â Â Â Â Â ChoiceList =Â [] |
---|
1035 |       for i,item in enumerate(self.ChoiceList): |
---|
1036 |         if item.lower().find(txt) != -1: |
---|
1037 | Â Â Â Â Â Â Â Â Â Â ChoiceList.append(item) |
---|
1038 | Â Â Â Â Â Â Â Â Â Â self.filterlist.append(i) |
---|
1039 | Â Â Â Â else: |
---|
1040 | Â Â Â Â Â Â self.filterlist =Â range(len(self.ChoiceList)) |
---|
1041 | Â Â Â Â Â Â ChoiceList =Â self.ChoiceList |
---|
1042 | Â Â Â Â self.clb.AppendItems(ChoiceList) |
---|
1043 | Â Â Â Â self.OKbtn.Enable(True) |
---|
1044 |   def onDoubleClick(self,event): |
---|
1045 | Â Â Â Â self.EndModal(wx.ID_OK) |
---|
1046 | |
---|
1047 | ################################################################################ |
---|
1048 | |
---|
1049 | class G2ColumnIDDialog(wx.Dialog): |
---|
1050 | Â Â '''A dialog for matching column data to desired items; some columns may be ignored. |
---|
1051 | Â Â |
---|
1052 | Â Â :param wx.Frame ParentFrame: reference to parent frame |
---|
1053 | Â Â :param str title: heading above list of choices |
---|
1054 | Â Â :param str header: Title to place on window frame |
---|
1055 | Â Â :param list ChoiceList: a list of possible choices for the columns |
---|
1056 | Â Â :param list ColumnData: lists of column data to be matched with ChoiceList |
---|
1057 | Â Â :param bool monoFont: If False (default), use a variable-spaced font; |
---|
1058 | Â Â Â if True use a equally-spaced font. |
---|
1059 | Â Â :param kw: optional keyword parameters for the wx.Dialog may |
---|
1060 | Â Â Â be included such as size [which defaults to `(320,310)`] and |
---|
1061 | Â Â Â style (which defaults to ``wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.CENTRE | wx.OK | wx.CANCEL``); |
---|
1062 | Â Â Â note that ``wx.OK`` and ``wx.CANCEL`` controls |
---|
1063 | Â Â Â the presence of the eponymous buttons in the dialog. |
---|
1064 | Â Â :returns: the name of the created dialog |
---|
1065 | Â Â |
---|
1066 | Â Â ''' |
---|
1067 | |
---|
1068 |   def __init__(self,parent, title, header,Comments,ChoiceList, ColumnData, |
---|
1069 |          monoFont=False, **kw): |
---|
1070 | |
---|
1071 |     def OnOk(sevent): |
---|
1072 | Â Â Â Â Â Â OK =Â True |
---|
1073 | Â Â Â Â Â Â selCols =Â [] |
---|
1074 |       for col in self.sel: |
---|
1075 | Â Â Â Â Â Â Â Â item =Â col.GetValue() |
---|
1076 |         if item != ' ' and item in selCols: |
---|
1077 | Â Â Â Â Â Â Â Â Â Â OK =Â False |
---|
1078 | Â Â Â Â Â Â Â Â Â Â break |
---|
1079 | Â Â Â Â Â Â Â Â else: |
---|
1080 | Â Â Â Â Â Â Â Â Â Â selCols.append(item) |
---|
1081 | Â Â Â Â Â Â parent =Â self.GetParent() |
---|
1082 |       if not OK: |
---|
1083 | Â Â Â Â Â Â Â Â parent.ErrorDialog('Duplicate',item+' selected more than once') |
---|
1084 | Â Â Â Â Â Â Â Â return |
---|
1085 | Â Â Â Â Â Â parent.Raise() |
---|
1086 | Â Â Â Â Â Â self.EndModal(wx.ID_OK) |
---|
1087 | Â Â Â Â Â Â |
---|
1088 |     def OnModify(event): |
---|
1089 | Â Â Â Â Â Â Obj =Â event.GetEventObject() |
---|
1090 | Â Â Â Â Â Â icol,colData =Â Indx[Obj.GetId()] |
---|
1091 | Â Â Â Â Â Â modify =Â Obj.GetValue() |
---|
1092 |       if not modify: |
---|
1093 | Â Â Â Â Â Â Â Â return |
---|
1094 |       print 'Modify column',icol,' by', modify |
---|
1095 |       for i,item in enumerate(self.ColumnData[icol]): |
---|
1096 | Â Â Â Â Â Â Â Â self.ColumnData[icol][i]Â =Â str(eval(item+modify)) |
---|
1097 | Â Â Â Â Â Â colData.SetValue('\n'.join(self.ColumnData[icol])) |
---|
1098 | Â Â Â Â Â Â Obj.SetValue('') |
---|
1099 | Â Â Â Â Â Â |
---|
1100 | Â Â Â Â # process keyword parameters, notably style |
---|
1101 |     options = {'size':(600,310), # default Frame keywords |
---|
1102 | Â Â Â Â Â Â Â Â Â Â 'style':wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.CENTRE|Â wx.OK |Â wx.CANCEL, |
---|
1103 | Â Â Â Â Â Â Â Â Â Â } |
---|
1104 | Â Â Â Â options.update(kw) |
---|
1105 | Â Â Â Â self.Comments =Â ''.join(Comments) |
---|
1106 | Â Â Â Â self.ChoiceList =Â ChoiceList |
---|
1107 | Â Â Â Â self.ColumnData =Â ColumnData |
---|
1108 | Â Â Â Â nCol =Â len(ColumnData) |
---|
1109 |     if options['style'] & wx.OK: |
---|
1110 | Â Â Â Â Â Â useOK =Â True |
---|
1111 | Â Â Â Â Â Â options['style']Â ^=Â wx.OK |
---|
1112 | Â Â Â Â else: |
---|
1113 | Â Â Â Â Â Â useOK =Â False |
---|
1114 |     if options['style'] & wx.CANCEL: |
---|
1115 | Â Â Â Â Â Â useCANCEL =Â True |
---|
1116 | Â Â Â Â Â Â options['style']Â ^=Â wx.CANCEL |
---|
1117 | Â Â Â Â else: |
---|
1118 |       useCANCEL = False    |
---|
1119 | Â Â Â Â # create the dialog frame |
---|
1120 | Â Â Â Â wx.Dialog.__init__(self,parent,wx.ID_ANY,header,**options) |
---|
1121 | Â Â Â Â panel =Â wxscroll.ScrolledPanel(self) |
---|
1122 | Â Â Â Â # fill the dialog |
---|
1123 | Â Â Â Â Sizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1124 | Â Â Â Â Sizer.Add((-1,5)) |
---|
1125 | Â Â Â Â Sizer.Add(wx.StaticText(panel,label=title),0,WACV) |
---|
1126 |     if self.Comments: |
---|
1127 | Â Â Â Â Â Â Sizer.Add(wx.StaticText(panel,label=' Header lines:'),0,WACV) |
---|
1128 | Â Â Â Â Â Â Sizer.Add(wx.TextCtrl(panel,value=self.Comments,size=(200,-1), |
---|
1129 | Â Â Â Â Â Â Â Â style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP),0,wx.ALL|wx.EXPAND|WACV,8) |
---|
1130 | Â Â Â Â columnsSizer =Â wx.FlexGridSizer(0,nCol,5,10) |
---|
1131 | Â Â Â Â self.sel =Â [] |
---|
1132 | Â Â Â Â self.mod =Â [] |
---|
1133 | Â Â Â Â Indx =Â {} |
---|
1134 |     for icol,col in enumerate(self.ColumnData): |
---|
1135 | Â Â Â Â Â Â colSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1136 |       colSizer.Add(wx.StaticText(panel,label=' Column #%d Select:'%(icol)),0,WACV) |
---|
1137 | Â Â Â Â Â Â self.sel.append(wx.ComboBox(panel,value=' ',choices=self.ChoiceList,style=wx.CB_READONLY|wx.CB_DROPDOWN)) |
---|
1138 | Â Â Â Â Â Â colSizer.Add(self.sel[-1]) |
---|
1139 | Â Â Â Â Â Â colData =Â wx.TextCtrl(panel,value='\n'.join(self.ColumnData[icol]),size=(120,-1), |
---|
1140 | Â Â Â Â Â Â Â Â style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP) |
---|
1141 | Â Â Â Â Â Â colSizer.Add(colData,0,WACV) |
---|
1142 | Â Â Â Â Â Â colSizer.Add(wx.StaticText(panel,label=' Modify by:'),0,WACV) |
---|
1143 | Â Â Â Â Â Â mod =Â wx.TextCtrl(panel,size=(120,-1),value='',style=wx.TE_PROCESS_ENTER) |
---|
1144 | Â Â Â Â Â Â mod.Bind(wx.EVT_TEXT_ENTER,OnModify) |
---|
1145 | Â Â Â Â Â Â mod.Bind(wx.EVT_KILL_FOCUS,OnModify) |
---|
1146 | Â Â Â Â Â Â Indx[mod.GetId()]Â =Â [icol,colData] |
---|
1147 | Â Â Â Â Â Â colSizer.Add(mod,0,WACV) |
---|
1148 | Â Â Â Â Â Â columnsSizer.Add(colSizer) |
---|
1149 | Â Â Â Â Sizer.Add(columnsSizer) |
---|
1150 | Â Â Â Â Sizer.Add(wx.StaticText(panel,label=' For modify by, enter arithmetic string eg. "-12345.67". "+","-","*","/","**" all allowed'),0,WACV)Â |
---|
1151 | Â Â Â Â Sizer.Add((-1,10)) |
---|
1152 | Â Â Â Â # OK/Cancel buttons |
---|
1153 | Â Â Â Â btnsizer =Â wx.StdDialogButtonSizer() |
---|
1154 |     if useOK: |
---|
1155 |       self.OKbtn = wx.Button(panel, wx.ID_OK) |
---|
1156 | Â Â Â Â Â Â self.OKbtn.SetDefault() |
---|
1157 | Â Â Â Â Â Â btnsizer.AddButton(self.OKbtn) |
---|
1158 |       self.OKbtn.Bind(wx.EVT_BUTTON, OnOk) |
---|
1159 |     if useCANCEL: |
---|
1160 |       btn = wx.Button(panel, wx.ID_CANCEL) |
---|
1161 | Â Â Â Â Â Â btnsizer.AddButton(btn) |
---|
1162 | Â Â Â Â btnsizer.Realize() |
---|
1163 | Â Â Â Â Sizer.Add((-1,5)) |
---|
1164 | Â Â Â Â Sizer.Add(btnsizer,0,wx.ALIGN_LEFT,20) |
---|
1165 | Â Â Â Â Sizer.Add((-1,5)) |
---|
1166 | Â Â Â Â # OK done, let's get outa here |
---|
1167 | Â Â Â Â panel.SetSizer(Sizer) |
---|
1168 | Â Â Â Â panel.SetAutoLayout(1) |
---|
1169 | Â Â Â Â panel.SetupScrolling() |
---|
1170 | Â Â Â Â Size =Â [450,375] |
---|
1171 | Â Â Â Â panel.SetSize(Size) |
---|
1172 | Â Â Â Â Size[0]Â +=Â 25;Â Size[1]+=Â 25 |
---|
1173 | Â Â Â Â self.SetSize(Size) |
---|
1174 | Â Â Â Â |
---|
1175 |   def GetSelection(self): |
---|
1176 | Â Â Â Â 'Returns the selected sample parm for each column' |
---|
1177 | Â Â Â Â selCols =Â [] |
---|
1178 |     for item in self.sel: |
---|
1179 | Â Â Â Â Â Â selCols.append(item.GetValue()) |
---|
1180 |     return selCols,self.ColumnData |
---|
1181 | |
---|
1182 | ################################################################################ |
---|
1183 | |
---|
1184 | def ItemSelector(ChoiceList, ParentFrame=None, |
---|
1185 | Â Â Â Â Â Â Â Â Â title='Select an item', |
---|
1186 |          size=None, header='Item Selector', |
---|
1187 | Â Â Â Â Â Â Â Â Â useCancel=True,multiple=False): |
---|
1188 | Â Â ''' Provide a wx dialog to select a single item or multiple items from list of choices |
---|
1189 | |
---|
1190 | Â Â :param list ChoiceList: a list of choices where one will be selected |
---|
1191 | Â Â :param wx.Frame ParentFrame: Name of parent frame (default None) |
---|
1192 | Â Â :param str title: heading above list of choices (default 'Select an item') |
---|
1193 | Â Â :param wx.Size size: Size for dialog to be created (default None -- size as needed) |
---|
1194 | Â Â :param str header: Title to place on window frame (default 'Item Selector') |
---|
1195 | Â Â :param bool useCancel: If True (default) both the OK and Cancel buttons are offered |
---|
1196 | Â Â :param bool multiple: If True then multiple items can be selected (default False) |
---|
1197 | Â Â |
---|
1198 | Â Â :returns: the selection index or None or a selection list if multiple is true |
---|
1199 | Â Â ''' |
---|
1200 |   if multiple: |
---|
1201 |     if useCancel: |
---|
1202 | Â Â Â Â Â Â dlg =Â G2MultiChoiceDialog( |
---|
1203 |         ParentFrame,title, header, ChoiceList) |
---|
1204 | Â Â Â Â else: |
---|
1205 | Â Â Â Â Â Â dlg =Â G2MultiChoiceDialog( |
---|
1206 |         ParentFrame,title, header, ChoiceList, |
---|
1207 | Â Â Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE) |
---|
1208 | Â Â else: |
---|
1209 |     if useCancel: |
---|
1210 | Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog( |
---|
1211 |         ParentFrame,title, header, ChoiceList) |
---|
1212 | Â Â Â Â else: |
---|
1213 | Â Â Â Â Â Â dlg =Â wx.SingleChoiceDialog( |
---|
1214 |         ParentFrame,title, header,ChoiceList, |
---|
1215 | Â Â Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE) |
---|
1216 |   if size: dlg.SetSize(size) |
---|
1217 |   if dlg.ShowModal() == wx.ID_OK: |
---|
1218 |     if multiple: |
---|
1219 | Â Â Â Â Â Â dlg.Destroy() |
---|
1220 |       return dlg.GetSelections() |
---|
1221 | Â Â Â Â else: |
---|
1222 | Â Â Â Â Â Â dlg.Destroy() |
---|
1223 |       return dlg.GetSelection() |
---|
1224 | Â Â else: |
---|
1225 | Â Â Â Â dlg.Destroy() |
---|
1226 |     return None |
---|
1227 | Â Â dlg.Destroy() |
---|
1228 | |
---|
1229 | ################################################################################ |
---|
1230 | class GridFractionEditor(wg.PyGridCellEditor): |
---|
1231 | Â Â '''A grid cell editor class that allows entry of values as fractions as well |
---|
1232 | Â Â as sine and cosine values [as s() and c()] |
---|
1233 | Â Â ''' |
---|
1234 |   def __init__(self,grid): |
---|
1235 | Â Â Â Â wg.PyGridCellEditor.__init__(self) |
---|
1236 | |
---|
1237 |   def Create(self, parent, id, evtHandler): |
---|
1238 |     self._tc = wx.TextCtrl(parent, id, "") |
---|
1239 | Â Â Â Â self._tc.SetInsertionPoint(0) |
---|
1240 | Â Â Â Â self.SetControl(self._tc) |
---|
1241 | |
---|
1242 |     if evtHandler: |
---|
1243 | Â Â Â Â Â Â self._tc.PushEventHandler(evtHandler) |
---|
1244 | |
---|
1245 |     self._tc.Bind(wx.EVT_CHAR, self.OnChar) |
---|
1246 | |
---|
1247 |   def SetSize(self, rect): |
---|
1248 |     self._tc.SetDimensions(rect.x, rect.y, rect.width+2, rect.height+2, |
---|
1249 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.SIZE_ALLOW_MINUS_ONE) |
---|
1250 | |
---|
1251 |   def BeginEdit(self, row, col, grid): |
---|
1252 |     self.startValue = grid.GetTable().GetValue(row, col) |
---|
1253 | Â Â Â Â self._tc.SetValue(str(self.startValue)) |
---|
1254 | Â Â Â Â self._tc.SetInsertionPointEnd() |
---|
1255 | Â Â Â Â self._tc.SetFocus() |
---|
1256 |     self._tc.SetSelection(0, self._tc.GetLastPosition()) |
---|
1257 | |
---|
1258 |   def EndEdit(self, row, col, grid, oldVal=None): |
---|
1259 | Â Â Â Â changed =Â False |
---|
1260 | |
---|
1261 | Â Â Â Â self.nextval =Â self.startValue |
---|
1262 | Â Â Â Â val =Â self._tc.GetValue().lower() |
---|
1263 |     if val != self.startValue: |
---|
1264 | Â Â Â Â Â Â changed =Â True |
---|
1265 | Â Â Â Â Â Â neg =Â False |
---|
1266 |       if '-' in val: |
---|
1267 | Â Â Â Â Â Â Â Â neg =Â True |
---|
1268 |       if '/' in val and '.' not in val: |
---|
1269 | Â Â Â Â Â Â Â Â val +=Â '.' |
---|
1270 |       elif 's' in val and not 'sind(' in val: |
---|
1271 |         if neg: |
---|
1272 | Â Â Â Â Â Â Â Â Â Â val =Â '-sind('+val.strip('-s')+')' |
---|
1273 | Â Â Â Â Â Â Â Â else: |
---|
1274 | Â Â Â Â Â Â Â Â Â Â val =Â 'sind('+val.strip('s')+')' |
---|
1275 |       elif 'c' in val and not 'cosd(' in val: |
---|
1276 |         if neg: |
---|
1277 | Â Â Â Â Â Â Â Â Â Â val =Â '-cosd('+val.strip('-c')+')' |
---|
1278 | Â Â Â Â Â Â Â Â else: |
---|
1279 | Â Â Â Â Â Â Â Â Â Â val =Â 'cosd('+val.strip('c')+')' |
---|
1280 | Â Â Â Â Â Â try: |
---|
1281 | Â Â Â Â Â Â Â Â self.nextval =Â val =Â float(eval(val)) |
---|
1282 |       except (SyntaxError,NameError,ZeroDivisionError): |
---|
1283 | Â Â Â Â Â Â Â Â val =Â self.startValue |
---|
1284 |         return None |
---|
1285 | Â Â Â Â Â Â |
---|
1286 |       if oldVal is None: # this arg appears in 2.9+; before, we should go ahead & change the table |
---|
1287 |         grid.GetTable().SetValue(row, col, val) # update the table |
---|
1288 | Â Â Â Â Â Â # otherwise self.ApplyEdit gets called |
---|
1289 | |
---|
1290 | Â Â Â Â self.startValue =Â '' |
---|
1291 | Â Â Â Â self._tc.SetValue('') |
---|
1292 |     return changed |
---|
1293 | Â Â |
---|
1294 |   def ApplyEdit(self, row, col, grid): |
---|
1295 | Â Â Â Â """ Called only in wx >= 2.9 |
---|
1296 | Â Â Â Â Save the value of the control into the grid if EndEdit() returns as True |
---|
1297 | Â Â Â Â """ |
---|
1298 |     grid.GetTable().SetValue(row, col, self.nextval) # update the table |
---|
1299 | |
---|
1300 |   def Reset(self): |
---|
1301 | Â Â Â Â self._tc.SetValue(self.startValue) |
---|
1302 | Â Â Â Â self._tc.SetInsertionPointEnd() |
---|
1303 | |
---|
1304 |   def Clone(self): |
---|
1305 |     return GridFractionEditor(grid) |
---|
1306 | |
---|
1307 |   def StartingKey(self, evt): |
---|
1308 | Â Â Â Â self.OnChar(evt) |
---|
1309 |     if evt.GetSkipped(): |
---|
1310 | Â Â Â Â Â Â self._tc.EmulateKeyPress(evt) |
---|
1311 | |
---|
1312 |   def OnChar(self, evt): |
---|
1313 | Â Â Â Â key =Â evt.GetKeyCode() |
---|
1314 |     if key == 15: |
---|
1315 | Â Â Â Â Â Â return |
---|
1316 |     if key > 255: |
---|
1317 | Â Â Â Â Â Â evt.Skip() |
---|
1318 | Â Â Â Â Â Â return |
---|
1319 | Â Â Â Â char =Â chr(key) |
---|
1320 |     if char in '.+-/0123456789cosind()': |
---|
1321 | Â Â Â Â Â Â self._tc.WriteText(char) |
---|
1322 | Â Â Â Â else: |
---|
1323 | Â Â Â Â Â Â evt.Skip() |
---|
1324 | |
---|
1325 | ################################################################################ |
---|
1326 | class ShowLSParms(wx.Dialog): |
---|
1327 | Â Â '''Create frame to show least-squares parameters |
---|
1328 | Â Â ''' |
---|
1329 |   def __init__(self,parent,title,parmDict,varyList,fullVaryList, |
---|
1330 | Â Â Â Â Â Â Â Â Â size=(300,430)): |
---|
1331 | Â Â Â Â wx.Dialog.__init__(self,parent,wx.ID_ANY,title,size=size, |
---|
1332 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) |
---|
1333 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1334 | |
---|
1335 | Â Â Â Â panel =Â wxscroll.ScrolledPanel( |
---|
1336 |       self, wx.ID_ANY, |
---|
1337 | Â Â Â Â Â Â #size=size, |
---|
1338 | Â Â Â Â Â Â style =Â wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER) |
---|
1339 | Â Â Â Â num =Â len(varyList) |
---|
1340 | Â Â Â Â mainSizer.Add(wx.StaticText(self,wx.ID_ANY,'Number of refined variables: '+str(num))) |
---|
1341 |     if len(varyList) != len(fullVaryList): |
---|
1342 | Â Â Â Â Â Â num =Â len(fullVaryList)Â -Â len(varyList) |
---|
1343 | Â Â Â Â Â Â mainSizer.Add(wx.StaticText(self,wx.ID_ANY,' + '+str(num)+' parameters are varied via constraints')) |
---|
1344 | Â Â Â Â subSizer =Â wx.FlexGridSizer(cols=4,hgap=2,vgap=2) |
---|
1345 | Â Â Â Â parmNames =Â parmDict.keys() |
---|
1346 | Â Â Â Â parmNames.sort() |
---|
1347 | Â Â Â Â subSizer.Add((-1,-1)) |
---|
1348 |     subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'Parameter name ')) |
---|
1349 | Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'refine?')) |
---|
1350 | Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'value'),0,wx.ALIGN_RIGHT) |
---|
1351 | Â Â Â Â explainRefine =Â False |
---|
1352 |     for name in parmNames: |
---|
1353 | Â Â Â Â Â Â # skip entries without numerical values |
---|
1354 |       if isinstance(parmDict[name],basestring): continue |
---|
1355 | Â Â Â Â Â Â try: |
---|
1356 | Â Â Â Â Â Â Â Â value =Â G2py3.FormatSigFigs(parmDict[name]) |
---|
1357 |       except TypeError: |
---|
1358 | Â Â Â Â Â Â Â Â value =Â str(parmDict[name])+' -?'Â # unexpected |
---|
1359 | Â Â Â Â Â Â Â Â #continue |
---|
1360 | Â Â Â Â Â Â v =Â G2obj.getVarDescr(name) |
---|
1361 |       if v is None or v[-1] is None: |
---|
1362 | Â Â Â Â Â Â Â Â subSizer.Add((-1,-1)) |
---|
1363 | Â Â Â Â Â Â else:Â Â Â Â Â Â Â Â |
---|
1364 | Â Â Â Â Â Â Â Â ch =Â HelpButton(panel,G2obj.fmtVarDescr(name)) |
---|
1365 | Â Â Â Â Â Â Â Â subSizer.Add(ch,0,wx.LEFT|wx.RIGHT|WACV|wx.ALIGN_CENTER,1) |
---|
1366 | Â Â Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,str(name))) |
---|
1367 |       if name in varyList: |
---|
1368 | Â Â Â Â Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'R')) |
---|
1369 |       elif name in fullVaryList: |
---|
1370 | Â Â Â Â Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,'C')) |
---|
1371 | Â Â Â Â Â Â Â Â explainRefine =Â True |
---|
1372 | Â Â Â Â Â Â else: |
---|
1373 | Â Â Â Â Â Â Â Â subSizer.Add((-1,-1)) |
---|
1374 | Â Â Â Â Â Â subSizer.Add(wx.StaticText(panel,wx.ID_ANY,value),0,wx.ALIGN_RIGHT) |
---|
1375 | |
---|
1376 | Â Â Â Â # finish up ScrolledPanel |
---|
1377 | Â Â Â Â panel.SetSizer(subSizer) |
---|
1378 | Â Â Â Â panel.SetAutoLayout(1) |
---|
1379 | Â Â Â Â panel.SetupScrolling() |
---|
1380 |     mainSizer.Add(panel,1, wx.ALL|wx.EXPAND,1) |
---|
1381 | |
---|
1382 |     if explainRefine: |
---|
1383 | Â Â Â Â Â Â mainSizer.Add( |
---|
1384 | Â Â Â Â Â Â Â Â wx.StaticText(self,wx.ID_ANY, |
---|
1385 | Â Â Â Â Â Â Â Â Â Â Â Â Â '"R" indicates a refined variable\n'+ |
---|
1386 | Â Â Â Â Â Â Â Â Â Â Â Â Â '"C" indicates generated from a constraint' |
---|
1387 | Â Â Â Â Â Â Â Â Â Â Â Â Â ), |
---|
1388 |         0, wx.ALL,0) |
---|
1389 | Â Â Â Â # make OK button |
---|
1390 | Â Â Â Â btnsizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1391 |     btn = wx.Button(self, wx.ID_CLOSE,"Close") |
---|
1392 | Â Â Â Â btn.Bind(wx.EVT_BUTTON,self._onClose) |
---|
1393 | Â Â Â Â btnsizer.Add(btn) |
---|
1394 |     mainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5) |
---|
1395 | Â Â Â Â # Allow window to be enlarged but not made smaller |
---|
1396 | Â Â Â Â self.SetSizer(mainSizer) |
---|
1397 | Â Â Â Â self.SetMinSize(self.GetSize()) |
---|
1398 | |
---|
1399 |   def _onClose(self,event): |
---|
1400 | Â Â Â Â self.EndModal(wx.ID_CANCEL) |
---|
1401 | Â |
---|
1402 | ################################################################################ |
---|
1403 | class downdate(wx.Dialog): |
---|
1404 | Â Â '''Dialog to allow a user to select a version of GSAS-II to install |
---|
1405 | Â Â ''' |
---|
1406 |   def __init__(self,parent=None): |
---|
1407 | Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE |Â wx.RESIZE_BORDER |
---|
1408 |     wx.Dialog.__init__(self, parent, wx.ID_ANY, 'Select Version', style=style) |
---|
1409 | Â Â Â Â pnl =Â wx.Panel(self) |
---|
1410 | Â Â Â Â sizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1411 | Â Â Â Â insver =Â GSASIIpath.svnGetRev(local=True) |
---|
1412 | Â Â Â Â curver =Â int(GSASIIpath.svnGetRev(local=False)) |
---|
1413 | Â Â Â Â label =Â wx.StaticText( |
---|
1414 |       pnl, wx.ID_ANY, |
---|
1415 | Â Â Â Â Â Â 'Select a specific GSAS-II version to install' |
---|
1416 | Â Â Â Â Â Â ) |
---|
1417 |     sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) |
---|
1418 | Â Â Â Â sizer1 =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1419 | Â Â Â Â sizer1.Add( |
---|
1420 |       wx.StaticText(pnl, wx.ID_ANY, |
---|
1421 | Â Â Â Â Â Â Â Â Â Â Â Â Â 'Currently installed version: '+str(insver)), |
---|
1422 |       0, wx.ALIGN_CENTRE|wx.ALL, 5) |
---|
1423 | Â Â Â Â sizer.Add(sizer1) |
---|
1424 | Â Â Â Â sizer1 =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1425 | Â Â Â Â sizer1.Add( |
---|
1426 |       wx.StaticText(pnl, wx.ID_ANY, |
---|
1427 | Â Â Â Â Â Â Â Â Â Â Â Â Â 'Select GSAS-II version to install: '), |
---|
1428 |       0, wx.ALIGN_CENTRE|wx.ALL, 5) |
---|
1429 |     self.spin = wx.SpinCtrl(pnl, wx.ID_ANY,size=(150,-1)) |
---|
1430 |     self.spin.SetRange(1, curver) |
---|
1431 | Â Â Â Â self.spin.SetValue(curver) |
---|
1432 |     self.Bind(wx.EVT_SPINCTRL, self._onSpin, self.spin) |
---|
1433 |     self.Bind(wx.EVT_KILL_FOCUS, self._onSpin, self.spin) |
---|
1434 | Â Â Â Â sizer1.Add(self.spin) |
---|
1435 | Â Â Â Â sizer.Add(sizer1) |
---|
1436 | |
---|
1437 |     line = wx.StaticLine(pnl,-1, size=(-1,3), style=wx.LI_HORIZONTAL) |
---|
1438 |     sizer.Add(line, 0, wx.EXPAND|wx.ALIGN_CENTER|wx.ALL, 10) |
---|
1439 | |
---|
1440 |     self.text = wx.StaticText(pnl, wx.ID_ANY, "") |
---|
1441 |     sizer.Add(self.text, 0, wx.ALIGN_LEFT|wx.EXPAND|wx.ALL, 5) |
---|
1442 | |
---|
1443 |     line = wx.StaticLine(pnl,-1, size=(-1,3), style=wx.LI_HORIZONTAL) |
---|
1444 |     sizer.Add(line, 0, wx.EXPAND|wx.ALIGN_CENTER|wx.ALL, 10) |
---|
1445 | Â Â Â Â sizer.Add( |
---|
1446 | Â Â Â Â Â Â wx.StaticText( |
---|
1447 |         pnl, wx.ID_ANY, |
---|
1448 | Â Â Â Â Â Â Â Â 'If "Install" is pressed, your project will be saved;\n' |
---|
1449 | Â Â Â Â Â Â Â Â 'GSAS-II will exit; The specified version will be loaded\n' |
---|
1450 | Â Â Â Â Â Â Â Â 'and GSAS-II will restart. Press "Cancel" to abort.'), |
---|
1451 |       0, wx.EXPAND|wx.ALL, 10) |
---|
1452 | Â Â Â Â btnsizer =Â wx.StdDialogButtonSizer() |
---|
1453 |     btn = wx.Button(pnl, wx.ID_OK, "Install") |
---|
1454 | Â Â Â Â btn.SetDefault() |
---|
1455 | Â Â Â Â btnsizer.AddButton(btn) |
---|
1456 |     btn = wx.Button(pnl, wx.ID_CANCEL) |
---|
1457 | Â Â Â Â btnsizer.AddButton(btn) |
---|
1458 | Â Â Â Â btnsizer.Realize() |
---|
1459 |     sizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5) |
---|
1460 | Â Â Â Â pnl.SetSizer(sizer) |
---|
1461 | Â Â Â Â sizer.Fit(self) |
---|
1462 | Â Â Â Â self.topsizer=sizer |
---|
1463 | Â Â Â Â self.CenterOnParent() |
---|
1464 | Â Â Â Â self._onSpin(None) |
---|
1465 | |
---|
1466 |   def _onSpin(self,event): |
---|
1467 | Â Â Â Â 'Called to load info about the selected version in the dialog' |
---|
1468 | Â Â Â Â ver =Â self.spin.GetValue() |
---|
1469 | Â Â Â Â d =Â GSASIIpath.svnGetLog(version=ver) |
---|
1470 | Â Â Â Â date =Â d.get('date','?').split('T')[0] |
---|
1471 | Â Â Â Â s =Â '(Version '+str(ver)+' created '+date |
---|
1472 | Â Â Â Â s +=Â ' by '+d.get('author','?')+')' |
---|
1473 | Â Â Â Â msg =Â d.get('msg') |
---|
1474 |     if msg: s += '\n\nComment: '+msg |
---|
1475 | Â Â Â Â self.text.SetLabel(s) |
---|
1476 | Â Â Â Â self.topsizer.Fit(self) |
---|
1477 | |
---|
1478 |   def getVersion(self): |
---|
1479 | Â Â Â Â 'Get the version number in the dialog' |
---|
1480 |     return self.spin.GetValue() |
---|
1481 | |
---|
1482 | ################################################################################ |
---|
1483 | class MyHelp(wx.Menu): |
---|
1484 | Â Â ''' |
---|
1485 | Â Â A class that creates the contents of a help menu. |
---|
1486 | Â Â The menu will start with two entries: |
---|
1487 | |
---|
1488 | Â Â * 'Help on <helpType>': where helpType is a reference to an HTML page to |
---|
1489 | Â Â Â be opened |
---|
1490 | Â Â * About: opens an About dialog using OnHelpAbout. N.B. on the Mac this |
---|
1491 | Â Â Â gets moved to the App menu to be consistent with Apple style. |
---|
1492 | |
---|
1493 | Â Â NOTE: for this to work properly with respect to system menus, the title |
---|
1494 | Â Â for the menu must be &Help, or it will not be processed properly: |
---|
1495 | |
---|
1496 | Â Â :: |
---|
1497 | |
---|
1498 | Â Â Â Â menu.Append(menu=MyHelp(self,...),title="&Help") |
---|
1499 | |
---|
1500 | Â Â ''' |
---|
1501 |   def __init__(self,frame,helpType=None,helpLbl=None,morehelpitems=[],title=''): |
---|
1502 | Â Â Â Â wx.Menu.__init__(self,title) |
---|
1503 | Â Â Â Â self.HelpById =Â {} |
---|
1504 | Â Â Â Â self.frame =Â frame |
---|
1505 |     self.Append(help='', id=wx.ID_ABOUT, kind=wx.ITEM_NORMAL, |
---|
1506 | Â Â Â Â Â Â text='&About GSAS-II') |
---|
1507 |     frame.Bind(wx.EVT_MENU, self.OnHelpAbout, id=wx.ID_ABOUT) |
---|
1508 |     if GSASIIpath.whichsvn(): |
---|
1509 | Â Â Â Â Â Â helpobj =Â self.Append( |
---|
1510 |         help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL, |
---|
1511 | Â Â Â Â Â Â Â Â text='&Check for updates') |
---|
1512 |       frame.Bind(wx.EVT_MENU, self.OnCheckUpdates, helpobj) |
---|
1513 | Â Â Â Â Â Â helpobj =Â self.Append( |
---|
1514 |         help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL, |
---|
1515 | Â Â Â Â Â Â Â Â text='&Regress to an old GSAS-II version') |
---|
1516 |       frame.Bind(wx.EVT_MENU, self.OnSelectVersion, helpobj) |
---|
1517 |     for lbl,indx in morehelpitems: |
---|
1518 | Â Â Â Â Â Â helpobj =Â self.Append(text=lbl, |
---|
1519 |         id=wx.ID_ANY, kind=wx.ITEM_NORMAL) |
---|
1520 |       frame.Bind(wx.EVT_MENU, self.OnHelpById, helpobj) |
---|
1521 | Â Â Â Â Â Â self.HelpById[helpobj.GetId()]Â =Â indx |
---|
1522 | Â Â Â Â # add a help item only when helpType is specified |
---|
1523 |     if helpType is not None: |
---|
1524 | Â Â Â Â Â Â self.AppendSeparator() |
---|
1525 |       if helpLbl is None: helpLbl = helpType |
---|
1526 | Â Â Â Â Â Â helpobj =Â self.Append(text='Help on '+helpLbl, |
---|
1527 |                  id=wx.ID_ANY, kind=wx.ITEM_NORMAL) |
---|
1528 |       frame.Bind(wx.EVT_MENU, self.OnHelpById, helpobj) |
---|
1529 | Â Â Â Â Â Â self.HelpById[helpobj.GetId()]Â =Â helpType |
---|
1530 | Â Â Â Â |
---|
1531 |   def OnHelpById(self,event): |
---|
1532 | Â Â Â Â '''Called when Help on... is pressed in a menu. Brings up |
---|
1533 | Â Â Â Â a web page for documentation. |
---|
1534 | Â Â Â Â ''' |
---|
1535 | Â Â Â Â helpType =Â self.HelpById.get(event.GetId()) |
---|
1536 |     if helpType is None: |
---|
1537 |       print 'Error: help lookup failed!',event.GetEventObject() |
---|
1538 |       print 'id=',event.GetId() |
---|
1539 | Â Â Â Â else: |
---|
1540 |       if helpType == 'Tutorials': |
---|
1541 |         self.frame.Tutorials = True |
---|
1542 | Â Â Â Â Â Â ShowHelp(helpType,self.frame) |
---|
1543 | |
---|
1544 |   def OnHelpAbout(self, event): |
---|
1545 | Â Â Â Â "Display an 'About GSAS-II' box" |
---|
1546 |     global __version__ |
---|
1547 | Â Â Â Â info =Â wx.AboutDialogInfo() |
---|
1548 | Â Â Â Â info.Name =Â 'GSAS-II' |
---|
1549 | Â Â Â Â ver =Â GSASIIpath.svnGetRev() |
---|
1550 |     if ver: |
---|
1551 | Â Â Â Â Â Â info.Version =Â 'Revision '+str(ver)+' (svn), version '+__version__ |
---|
1552 | Â Â Â Â else: |
---|
1553 | Â Â Â Â Â Â info.Version =Â 'Revision '+str(GSASIIpath.GetVersionNumber())+' (.py files), version '+__version__ |
---|
1554 | Â Â Â Â #info.Developers = ['Robert B. Von Dreele','Brian H. Toby'] |
---|
1555 | Â Â Â Â info.Copyright =Â ('(c) 'Â +Â time.strftime('%Y')Â + |
---|
1556 | ''' Argonne National Laboratory |
---|
1557 | This product includes software developed |
---|
1558 | by the UChicago Argonne, LLC, as |
---|
1559 | Operator of Argonne National Laboratory.''') |
---|
1560 | Â Â Â Â info.Description =Â '''General Structure Analysis System-II (GSAS-II) |
---|
1561 | Robert B. Von Dreele and Brian H. Toby |
---|
1562 | |
---|
1563 | Please cite as: |
---|
1564 | B.H. Toby & R.B. Von Dreele, J. Appl. Cryst. 46, 544-549 (2013) ''' |
---|
1565 | |
---|
1566 | Â Â Â Â info.WebSite =Â ("https://subversion.xray.aps.anl.gov/trac/pyGSAS","GSAS-II home page") |
---|
1567 | Â Â Â Â wx.AboutBox(info) |
---|
1568 | |
---|
1569 |   def OnCheckUpdates(self,event): |
---|
1570 | Â Â Â Â '''Check if the GSAS-II repository has an update for the current source files |
---|
1571 | Â Â Â Â and perform that update if requested. |
---|
1572 | Â Â Â Â ''' |
---|
1573 |     if not GSASIIpath.whichsvn(): |
---|
1574 | Â Â Â Â Â Â dlg =Â wx.MessageDialog(self.frame, |
---|
1575 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'No Subversion','Cannot update GSAS-II because subversion (svn) was not found.', |
---|
1576 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.OK) |
---|
1577 | Â Â Â Â Â Â dlg.ShowModal() |
---|
1578 | Â Â Â Â Â Â dlg.Destroy() |
---|
1579 | Â Â Â Â Â Â return |
---|
1580 | Â Â Â Â wx.BeginBusyCursor() |
---|
1581 | Â Â Â Â local =Â GSASIIpath.svnGetRev() |
---|
1582 |     if local is None: |
---|
1583 | Â Â Â Â Â Â wx.EndBusyCursor() |
---|
1584 | Â Â Â Â Â Â dlg =Â wx.MessageDialog(self.frame, |
---|
1585 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Unable to run subversion on the GSAS-II current directory. Is GSAS-II installed correctly?', |
---|
1586 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Subversion error', |
---|
1587 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.OK) |
---|
1588 | Â Â Â Â Â Â dlg.ShowModal() |
---|
1589 | Â Â Â Â Â Â dlg.Destroy() |
---|
1590 | Â Â Â Â Â Â return |
---|
1591 |     print 'Installed GSAS-II version: '+local |
---|
1592 | Â Â Â Â repos =Â GSASIIpath.svnGetRev(local=False) |
---|
1593 | Â Â Â Â wx.EndBusyCursor() |
---|
1594 |     if repos is None: |
---|
1595 | Â Â Â Â Â Â dlg =Â wx.MessageDialog(self.frame, |
---|
1596 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Unable to access the GSAS-II server. Is this computer on the internet?', |
---|
1597 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Server unavailable', |
---|
1598 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.OK) |
---|
1599 | Â Â Â Â Â Â dlg.ShowModal() |
---|
1600 | Â Â Â Â Â Â dlg.Destroy() |
---|
1601 | Â Â Â Â Â Â return |
---|
1602 |     print 'GSAS-II version on server: '+repos |
---|
1603 |     if local == repos: |
---|
1604 | Â Â Â Â Â Â dlg =Â wx.MessageDialog(self.frame, |
---|
1605 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'GSAS-II is up-to-date. Version '+local+' is already loaded.', |
---|
1606 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'GSAS-II Up-to-date', |
---|
1607 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.OK) |
---|
1608 | Â Â Â Â Â Â dlg.ShowModal() |
---|
1609 | Â Â Â Â Â Â dlg.Destroy() |
---|
1610 | Â Â Â Â Â Â return |
---|
1611 | Â Â Â Â mods =Â GSASIIpath.svnFindLocalChanges() |
---|
1612 |     if mods: |
---|
1613 | Â Â Â Â Â Â dlg =Â wx.MessageDialog(self.frame, |
---|
1614 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'You have version '+local+ |
---|
1615 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ' of GSAS-II installed, but the current version is '+repos+ |
---|
1616 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â '. However, '+str(len(mods))+ |
---|
1617 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ' file(s) on your local computer have been modified.' |
---|
1618 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ' Updating will attempt to merge your local changes with ' |
---|
1619 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'the latest GSAS-II version, but if ' |
---|
1620 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'conflicts arise, local changes will be ' |
---|
1621 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'discarded. It is also possible that the ' |
---|
1622 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'local changes my prevent GSAS-II from running. ' |
---|
1623 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Press OK to start an update if this is acceptable:', |
---|
1624 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Local GSAS-II Mods', |
---|
1625 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.OK|wx.CANCEL) |
---|
1626 |       if dlg.ShowModal() != wx.ID_OK: |
---|
1627 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1628 | Â Â Â Â Â Â Â Â return |
---|
1629 | Â Â Â Â Â Â else: |
---|
1630 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1631 | Â Â Â Â else: |
---|
1632 | Â Â Â Â Â Â dlg =Â wx.MessageDialog(self.frame, |
---|
1633 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'You have version '+local+ |
---|
1634 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ' of GSAS-II installed, but the current version is '+repos+ |
---|
1635 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â '. Press OK to start an update:', |
---|
1636 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'GSAS-II Updates', |
---|
1637 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.OK|wx.CANCEL) |
---|
1638 |       if dlg.ShowModal() != wx.ID_OK: |
---|
1639 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1640 | Â Â Â Â Â Â Â Â return |
---|
1641 | Â Â Â Â Â Â dlg.Destroy() |
---|
1642 |     print 'start updates' |
---|
1643 | Â Â Â Â dlg =Â wx.MessageDialog(self.frame, |
---|
1644 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Your project will now be saved, GSAS-II will exit and an update ' |
---|
1645 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'will be performed and GSAS-II will restart. Press Cancel to ' |
---|
1646 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'abort the update', |
---|
1647 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Start update?', |
---|
1648 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.OK|wx.CANCEL) |
---|
1649 |     if dlg.ShowModal() != wx.ID_OK: |
---|
1650 | Â Â Â Â Â Â dlg.Destroy() |
---|
1651 | Â Â Â Â Â Â return |
---|
1652 | Â Â Â Â dlg.Destroy() |
---|
1653 | Â Â Â Â self.frame.OnFileSave(event) |
---|
1654 | Â Â Â Â GSASIIpath.svnUpdateProcess(projectfile=self.frame.GSASprojectfile) |
---|
1655 | Â Â Â Â return |
---|
1656 | |
---|
1657 |   def OnSelectVersion(self,event): |
---|
1658 | Â Â Â Â '''Allow the user to select a specific version of GSAS-II |
---|
1659 | Â Â Â Â ''' |
---|
1660 |     if not GSASIIpath.whichsvn(): |
---|
1661 | Â Â Â Â Â Â dlg =Â wx.MessageDialog(self,'No Subversion','Cannot update GSAS-II because subversion (svn) '+ |
---|
1662 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'was not found.' |
---|
1663 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ,wx.OK) |
---|
1664 | Â Â Â Â Â Â dlg.ShowModal() |
---|
1665 | Â Â Â Â Â Â return |
---|
1666 | Â Â Â Â local =Â GSASIIpath.svnGetRev() |
---|
1667 |     if local is None: |
---|
1668 | Â Â Â Â Â Â dlg =Â wx.MessageDialog(self.frame, |
---|
1669 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Unable to run subversion on the GSAS-II current directory. Is GSAS-II installed correctly?', |
---|
1670 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Subversion error', |
---|
1671 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.OK) |
---|
1672 | Â Â Â Â Â Â dlg.ShowModal() |
---|
1673 | Â Â Â Â Â Â return |
---|
1674 | Â Â Â Â mods =Â GSASIIpath.svnFindLocalChanges() |
---|
1675 |     if mods: |
---|
1676 | Â Â Â Â Â Â dlg =Â wx.MessageDialog(self.frame, |
---|
1677 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'You have version '+local+ |
---|
1678 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ' of GSAS-II installed' |
---|
1679 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â '. However, '+str(len(mods))+ |
---|
1680 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ' file(s) on your local computer have been modified.' |
---|
1681 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ' Downdating will attempt to merge your local changes with ' |
---|
1682 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'the selected GSAS-II version. ' |
---|
1683 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Downdating is not encouraged because ' |
---|
1684 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'if merging is not possible, your local changes will be ' |
---|
1685 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'discarded. It is also possible that the ' |
---|
1686 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'local changes my prevent GSAS-II from running. ' |
---|
1687 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Press OK to continue anyway.', |
---|
1688 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Local GSAS-II Mods', |
---|
1689 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.OK|wx.CANCEL) |
---|
1690 |       if dlg.ShowModal() != wx.ID_OK: |
---|
1691 | Â Â Â Â Â Â Â Â dlg.Destroy() |
---|
1692 | Â Â Â Â Â Â Â Â return |
---|
1693 | Â Â Â Â Â Â dlg.Destroy() |
---|
1694 | Â Â Â Â dlg =Â downdate(parent=self.frame) |
---|
1695 |     if dlg.ShowModal() == wx.ID_OK: |
---|
1696 | Â Â Â Â Â Â ver =Â dlg.getVersion() |
---|
1697 | Â Â Â Â else: |
---|
1698 | Â Â Â Â Â Â dlg.Destroy() |
---|
1699 | Â Â Â Â Â Â return |
---|
1700 | Â Â Â Â dlg.Destroy() |
---|
1701 | Â Â Â Â print('start regress to '+str(ver)) |
---|
1702 | Â Â Â Â GSASIIpath.svnUpdateProcess( |
---|
1703 | Â Â Â Â Â Â projectfile=self.frame.GSASprojectfile, |
---|
1704 | Â Â Â Â Â Â version=str(ver) |
---|
1705 | Â Â Â Â Â Â ) |
---|
1706 | Â Â Â Â self.frame.OnFileSave(event) |
---|
1707 | Â Â Â Â return |
---|
1708 | |
---|
1709 | ################################################################################ |
---|
1710 | class AddHelp(wx.Menu): |
---|
1711 | Â Â '''For the Mac: creates an entry to the help menu of type |
---|
1712 | Â Â 'Help on <helpType>': where helpType is a reference to an HTML page to |
---|
1713 | Â Â be opened. |
---|
1714 | |
---|
1715 | Â Â NOTE: when appending this menu (menu.Append) be sure to set the title to |
---|
1716 | Â Â '&Help' so that wx handles it correctly. |
---|
1717 | Â Â ''' |
---|
1718 |   def __init__(self,frame,helpType,helpLbl=None,title=''): |
---|
1719 | Â Â Â Â wx.Menu.__init__(self,title) |
---|
1720 | Â Â Â Â self.frame =Â frame |
---|
1721 |     if helpLbl is None: helpLbl = helpType |
---|
1722 | Â Â Â Â # add a help item only when helpType is specified |
---|
1723 | Â Â Â Â helpobj =Â self.Append(text='Help on '+helpLbl, |
---|
1724 |                id=wx.ID_ANY, kind=wx.ITEM_NORMAL) |
---|
1725 |     frame.Bind(wx.EVT_MENU, self.OnHelpById, helpobj) |
---|
1726 | Â Â Â Â self.HelpById =Â helpType |
---|
1727 | Â Â Â Â |
---|
1728 |   def OnHelpById(self,event): |
---|
1729 | Â Â Â Â '''Called when Help on... is pressed in a menu. Brings up |
---|
1730 | Â Â Â Â a web page for documentation. |
---|
1731 | Â Â Â Â ''' |
---|
1732 | Â Â Â Â ShowHelp(self.HelpById,self.frame) |
---|
1733 | |
---|
1734 | ################################################################################ |
---|
1735 | class HelpButton(wx.Button): |
---|
1736 | Â Â '''Create a help button that displays help information. |
---|
1737 | Â Â The text is displayed in a modal message window. |
---|
1738 | |
---|
1739 | Â Â TODO: it might be nice if it were non-modal: e.g. it stays around until |
---|
1740 | Â Â the parent is deleted or the user closes it, but this did not work for |
---|
1741 | Â Â me. |
---|
1742 | |
---|
1743 | Â Â :param parent: the panel which will be the parent of the button |
---|
1744 | Â Â :param str msg: the help text to be displayed |
---|
1745 | Â Â ''' |
---|
1746 |   def __init__(self,parent,msg): |
---|
1747 |     if sys.platform == "darwin": |
---|
1748 | Â Â Â Â Â Â wx.Button.__init__(self,parent,wx.ID_HELP) |
---|
1749 | Â Â Â Â else: |
---|
1750 | Â Â Â Â Â Â wx.Button.__init__(self,parent,wx.ID_ANY,'?',style=wx.BU_EXACTFIT) |
---|
1751 | Â Â Â Â self.Bind(wx.EVT_BUTTON,self._onPress) |
---|
1752 | Â Â Â Â self.msg=msg |
---|
1753 | Â Â Â Â self.parent =Â parent |
---|
1754 |   def _onClose(self,event): |
---|
1755 | Â Â Â Â self.dlg.EndModal(wx.ID_CANCEL) |
---|
1756 |   def _onPress(self,event): |
---|
1757 | Â Â Â Â 'Respond to a button press by displaying the requested text' |
---|
1758 | Â Â Â Â #dlg = wx.MessageDialog(self.parent,self.msg,'Help info',wx.OK) |
---|
1759 |     self.dlg = wx.Dialog(self.parent,wx.ID_ANY,'Help information', |
---|
1760 | Â Â Â Â Â Â Â Â Â Â Â Â style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) |
---|
1761 | Â Â Â Â #self.dlg.SetBackgroundColour(wx.WHITE) |
---|
1762 | Â Â Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1763 | Â Â Â Â txt =Â wx.StaticText(self.dlg,wx.ID_ANY,self.msg) |
---|
1764 | Â Â Â Â mainSizer.Add(txt,1,wx.ALL|wx.EXPAND,10) |
---|
1765 | Â Â Â Â txt.SetBackgroundColour(wx.WHITE) |
---|
1766 | |
---|
1767 | Â Â Â Â btnsizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
1768 |     btn = wx.Button(self.dlg, wx.ID_CLOSE) |
---|
1769 | Â Â Â Â btn.Bind(wx.EVT_BUTTON,self._onClose) |
---|
1770 | Â Â Â Â btnsizer.Add(btn) |
---|
1771 |     mainSizer.Add(btnsizer, 0, wx.ALIGN_CENTER|wx.ALL, 5) |
---|
1772 | Â Â Â Â self.dlg.SetSizer(mainSizer) |
---|
1773 | Â Â Â Â mainSizer.Fit(self.dlg) |
---|
1774 | Â Â Â Â self.dlg.ShowModal() |
---|
1775 | Â Â Â Â self.dlg.Destroy() |
---|
1776 | ################################################################################ |
---|
1777 | class MyHtmlPanel(wx.Panel): |
---|
1778 | Â Â '''Defines a panel to display HTML help information, as an alternative to |
---|
1779 | Â Â displaying help information in a web browser. |
---|
1780 | Â Â ''' |
---|
1781 |   def __init__(self, frame, id): |
---|
1782 | Â Â Â Â self.frame =Â frame |
---|
1783 |     wx.Panel.__init__(self, frame, id) |
---|
1784 | Â Â Â Â sizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
1785 |     back = wx.Button(self, -1, "Back") |
---|
1786 |     back.Bind(wx.EVT_BUTTON, self.OnBack) |
---|
1787 |     self.htmlwin = G2HtmlWindow(self, id, size=(750,450)) |
---|
1788 |     sizer.Add(self.htmlwin, 1,wx.EXPAND) |
---|
1789 |     sizer.Add(back, 0, wx.ALIGN_LEFT, 0) |
---|
1790 | Â Â Â Â self.SetSizer(sizer) |
---|
1791 | Â Â Â Â sizer.Fit(frame)Â Â Â Â |
---|
1792 | Â Â Â Â self.Bind(wx.EVT_SIZE,self.OnHelpSize) |
---|
1793 |   def OnHelpSize(self,event):     #does the job but weirdly!! |
---|
1794 | Â Â Â Â anchor =Â self.htmlwin.GetOpenedAnchor() |
---|
1795 |     if anchor:      |
---|
1796 | Â Â Â Â Â Â self.htmlwin.ScrollToAnchor(anchor) |
---|
1797 | Â Â Â Â Â Â wx.CallAfter(self.htmlwin.ScrollToAnchor,anchor) |
---|
1798 | Â Â Â Â Â Â event.Skip() |
---|
1799 |   def OnBack(self, event): |
---|
1800 | Â Â Â Â self.htmlwin.HistoryBack() |
---|
1801 |   def LoadFile(self,file): |
---|
1802 | Â Â Â Â pos =Â file.rfind('#') |
---|
1803 |     if pos != -1: |
---|
1804 | Â Â Â Â Â Â helpfile =Â file[:pos] |
---|
1805 | Â Â Â Â Â Â helpanchor =Â file[pos+1:] |
---|
1806 | Â Â Â Â else: |
---|
1807 | Â Â Â Â Â Â helpfile =Â file |
---|
1808 | Â Â Â Â Â Â helpanchor =Â None |
---|
1809 | Â Â Â Â self.htmlwin.LoadPage(helpfile) |
---|
1810 |     if helpanchor is not None: |
---|
1811 | Â Â Â Â Â Â self.htmlwin.ScrollToAnchor(helpanchor) |
---|
1812 | Â Â Â Â Â Â xs,ys =Â self.htmlwin.GetViewStart() |
---|
1813 | Â Â Â Â Â Â self.htmlwin.Scroll(xs,ys-1) |
---|
1814 | |
---|
1815 | class G2HtmlWindow(wx.html.HtmlWindow): |
---|
1816 | Â Â '''Displays help information in a primitive HTML browser type window |
---|
1817 | Â Â ''' |
---|
1818 |   def __init__(self, parent, *args, **kwargs): |
---|
1819 | Â Â Â Â self.parent =Â parent |
---|
1820 |     wx.html.HtmlWindow.__init__(self, parent, *args, **kwargs) |
---|
1821 |   def LoadPage(self, *args, **kwargs): |
---|
1822 |     wx.html.HtmlWindow.LoadPage(self, *args, **kwargs) |
---|
1823 | Â Â Â Â self.TitlePage() |
---|
1824 |   def OnLinkClicked(self, *args, **kwargs): |
---|
1825 |     wx.html.HtmlWindow.OnLinkClicked(self, *args, **kwargs) |
---|
1826 | Â Â Â Â xs,ys =Â self.GetViewStart() |
---|
1827 | Â Â Â Â self.Scroll(xs,ys-1) |
---|
1828 | Â Â Â Â self.TitlePage() |
---|
1829 |   def HistoryBack(self, *args, **kwargs): |
---|
1830 |     wx.html.HtmlWindow.HistoryBack(self, *args, **kwargs) |
---|
1831 | Â Â Â Â self.TitlePage() |
---|
1832 |   def TitlePage(self): |
---|
1833 | Â Â Â Â self.parent.frame.SetTitle(self.GetOpenedPage()Â +Â ' -- 'Â +Â |
---|
1834 | Â Â Â Â Â Â self.GetOpenedPageTitle()) |
---|
1835 | |
---|
1836 | ################################################################################ |
---|
1837 | class DataFrame(wx.Frame): |
---|
1838 | Â Â '''Create the data item window and all the entries in menus used in |
---|
1839 | Â Â that window. For Linux and windows, the menu entries are created for the |
---|
1840 | Â Â current data item window, but in the Mac the menu is accessed from all |
---|
1841 | Â Â windows. This means that a different menu is posted depending on which |
---|
1842 | Â Â data item is posted. On the Mac, all the menus contain the data tree menu |
---|
1843 | Â Â items, but additional menus are added specific to the data item. |
---|
1844 | |
---|
1845 | Â Â Note that while the menus are created here, |
---|
1846 | Â Â the binding for the menus is done later in various GSASII*GUI modules, |
---|
1847 | Â Â where the functions to be called are defined. |
---|
1848 | Â Â ''' |
---|
1849 |   def Bind(self,eventtype,handler,*args,**kwargs): |
---|
1850 | Â Â Â Â '''Override the Bind() function: on the Mac the binding is to |
---|
1851 | Â Â Â Â the main window, so that menus operate with any window on top. |
---|
1852 | Â Â Â Â For other platforms, either wrap calls that will be logged |
---|
1853 | Â Â Â Â or call the default wx.Frame Bind() to bind to the menu item directly. |
---|
1854 | |
---|
1855 | Â Â Â Â Note that bindings can be made to objects by Id or by direct reference to the |
---|
1856 | Â Â Â Â object. As a convention, when bindings are to objects, they are not logged |
---|
1857 | Â Â Â Â but when bindings are by Id, they are logged. |
---|
1858 | Â Â Â Â ''' |
---|
1859 |     if sys.platform == "darwin": # mac |
---|
1860 | Â Â Â Â Â Â self.G2frame.Bind(eventtype,handler,*args,**kwargs) |
---|
1861 | Â Â Â Â Â Â return |
---|
1862 |     if eventtype == wx.EVT_MENU and 'id' in kwargs: |
---|
1863 | Â Â Â Â Â Â menulabels =Â log.SaveMenuCommand(kwargs['id'],self.G2frame,handler) |
---|
1864 |       if menulabels: |
---|
1865 | Â Â Â Â Â Â Â Â #print 'intercepting bind for',handler,menulabels,kwargs['id'] |
---|
1866 | Â Â Â Â Â Â Â Â wx.Frame.Bind(self,eventtype,self.G2frame.MenuBinding,*args,**kwargs) |
---|
1867 | Â Â Â Â Â Â Â Â return |
---|
1868 | Â Â Â Â Â Â wx.Frame.Bind(self,eventtype,handler,*args,**kwargs)Â Â Â |
---|
1869 | Â Â Â Â |
---|
1870 |   def PrefillDataMenu(self,menu,helpType,helpLbl=None,empty=False): |
---|
1871 | Â Â Â Â '''Create the "standard" part of data frame menus. Note that on Linux and |
---|
1872 | Â Â Â Â Windows nothing happens here. On Mac, this menu duplicates the |
---|
1873 | Â Â Â Â tree menu, but adds an extra help command for the data item and a separator. |
---|
1874 | Â Â Â Â ''' |
---|
1875 | Â Â Â Â self.datamenu =Â menu |
---|
1876 | Â Â Â Â self.G2frame.dataMenuBars.append(menu) |
---|
1877 | Â Â Â Â self.helpType =Â helpType |
---|
1878 | Â Â Â Â self.helpLbl =Â helpLbl |
---|
1879 |     if sys.platform == "darwin": # mac             |
---|
1880 | Â Â Â Â Â Â self.G2frame.FillMainMenu(menu)Â # add the data tree menu items |
---|
1881 |       if not empty: |
---|
1882 | Â Â Â Â Â Â Â Â menu.Append(wx.Menu(title=''),title='|')Â # add a separator |
---|
1883 | Â Â Â Â |
---|
1884 |   def PostfillDataMenu(self,empty=False): |
---|
1885 | Â Â Â Â '''Create the "standard" part of data frame menus. Note that on Linux and |
---|
1886 | Â Â Â Â Windows, this is the standard help Menu. On Mac, this menu duplicates the |
---|
1887 | Â Â Â Â tree menu, but adds an extra help command for the data item and a separator. |
---|
1888 | Â Â Â Â ''' |
---|
1889 | Â Â Â Â menu =Â self.datamenu |
---|
1890 | Â Â Â Â helpType =Â self.helpType |
---|
1891 | Â Â Â Â helpLbl =Â self.helpLbl |
---|
1892 |     if sys.platform == "darwin": # mac |
---|
1893 |       if not empty: |
---|
1894 | Â Â Â Â Â Â Â Â menu.Append(wx.Menu(title=''),title='|')Â # add another separator |
---|
1895 |       menu.Append(AddHelp(self.G2frame,helpType=helpType, helpLbl=helpLbl), |
---|
1896 | Â Â Â Â Â Â Â Â Â Â Â Â title='&Help') |
---|
1897 | Â Â Â Â else:Â # other |
---|
1898 |       menu.Append(menu=MyHelp(self,helpType=helpType, helpLbl=helpLbl), |
---|
1899 | Â Â Â Â Â Â Â Â Â Â Â Â title='&Help') |
---|
1900 | |
---|
1901 |   def _init_menus(self): |
---|
1902 | Â Â Â Â 'define all GSAS-II data frame menus' |
---|
1903 | |
---|
1904 | Â Â Â Â # for use where no menu or data frame help is provided |
---|
1905 | Â Â Â Â self.BlankMenu =Â wx.MenuBar() |
---|
1906 | Â Â Â Â |
---|
1907 | Â Â Â Â # Controls |
---|
1908 | Â Â Â Â self.ControlsMenu =Â wx.MenuBar() |
---|
1909 | Â Â Â Â self.PrefillDataMenu(self.ControlsMenu,helpType='Controls',empty=True) |
---|
1910 | Â Â Â Â self.PostfillDataMenu(empty=True) |
---|
1911 | Â Â Â Â |
---|
1912 | Â Â Â Â # Notebook |
---|
1913 | Â Â Â Â self.DataNotebookMenu =Â wx.MenuBar()Â |
---|
1914 | Â Â Â Â self.PrefillDataMenu(self.DataNotebookMenu,helpType='Notebook',empty=True) |
---|
1915 | Â Â Â Â self.PostfillDataMenu(empty=True) |
---|
1916 | Â Â Â Â |
---|
1917 | Â Â Â Â # Comments |
---|
1918 | Â Â Â Â self.DataCommentsMenu =Â wx.MenuBar() |
---|
1919 | Â Â Â Â self.PrefillDataMenu(self.DataCommentsMenu,helpType='Comments',empty=True) |
---|
1920 | Â Â Â Â self.PostfillDataMenu(empty=True) |
---|
1921 | Â Â Â Â |
---|
1922 | Â Â Â Â # Constraints - something amiss here - get weird wx C++ error after refine! |
---|
1923 | Â Â Â Â self.ConstraintMenu =Â wx.MenuBar() |
---|
1924 | Â Â Â Â self.PrefillDataMenu(self.ConstraintMenu,helpType='Constraints') |
---|
1925 | Â Â Â Â self.ConstraintTab =Â wx.Menu(title='') |
---|
1926 |     self.ConstraintMenu.Append(menu=self.ConstraintTab, title='Select tab') |
---|
1927 |     for id,txt in ( |
---|
1928 | Â Â Â Â Â Â (wxID_CONSPHASE,'Phase'), |
---|
1929 | Â Â Â Â Â Â (wxID_CONSHAP,'Histogram/Phase'), |
---|
1930 | Â Â Â Â Â Â (wxID_CONSHIST,'Histogram'), |
---|
1931 | Â Â Â Â Â Â (wxID_CONSGLOBAL,'Global')): |
---|
1932 | Â Â Â Â Â Â self.ConstraintTab.Append( |
---|
1933 |         id=id, kind=wx.ITEM_NORMAL,text=txt, |
---|
1934 | Â Â Â Â Â Â Â Â help='Select '+txt+' constraint editing tab') |
---|
1935 | Â Â Â Â self.ConstraintEdit =Â wx.Menu(title='') |
---|
1936 |     self.ConstraintMenu.Append(menu=self.ConstraintEdit, title='Edit') |
---|
1937 |     self.ConstraintEdit.Append(id=wxID_HOLDADD, kind=wx.ITEM_NORMAL,text='Add hold', |
---|
1938 | Â Â Â Â Â Â help='Add hold on a parameter value') |
---|
1939 |     self.ConstraintEdit.Append(id=wxID_EQUIVADD, kind=wx.ITEM_NORMAL,text='Add equivalence', |
---|
1940 | Â Â Â Â Â Â help='Add equivalence between parameter values') |
---|
1941 |     self.ConstraintEdit.Append(id=wxID_CONSTRAINTADD, kind=wx.ITEM_NORMAL,text='Add constraint', |
---|
1942 | Â Â Â Â Â Â help='Add constraint on parameter values') |
---|
1943 |     self.ConstraintEdit.Append(id=wxID_FUNCTADD, kind=wx.ITEM_NORMAL,text='Add New Var', |
---|
1944 | Â Â Â Â Â Â help='Add variable composed of existing parameter') |
---|
1945 | Â Â Â Â self.PostfillDataMenu() |
---|
1946 | |
---|
1947 | Â Â Â Â # item = self.ConstraintEdit.Append(id=wx.ID_ANY,kind=wx.ITEM_NORMAL,text='Update GUI') |
---|
1948 | Â Â Â Â # def UpdateGSASIIconstrGUI(event): |
---|
1949 | Â Â Â Â #Â Â Â import GSASIIconstrGUI |
---|
1950 | Â Â Â Â #Â Â Â reload(GSASIIconstrGUI) |
---|
1951 | Â Â Â Â #Â Â Â import GSASIIobj |
---|
1952 | Â Â Â Â #Â Â Â reload(GSASIIobj) |
---|
1953 | Â Â Â Â # self.Bind(wx.EVT_MENU,UpdateGSASIIconstrGUI,id=item.GetId()) |
---|
1954 | |
---|
1955 | Â Â Â Â # Rigid bodies |
---|
1956 | Â Â Â Â self.RigidBodyMenu =Â wx.MenuBar() |
---|
1957 | Â Â Â Â self.PrefillDataMenu(self.RigidBodyMenu,helpType='Rigid bodies') |
---|
1958 | Â Â Â Â self.ResidueRBMenu =Â wx.Menu(title='') |
---|
1959 |     self.ResidueRBMenu.Append(id=wxID_RIGIDBODYIMPORT, kind=wx.ITEM_NORMAL,text='Import XYZ', |
---|
1960 | Â Â Â Â Â Â help='Import rigid body XYZ from file') |
---|
1961 |     self.ResidueRBMenu.Append(id=wxID_RESIDUETORSSEQ, kind=wx.ITEM_NORMAL,text='Define sequence', |
---|
1962 | Â Â Â Â Â Â help='Define torsion sequence') |
---|
1963 |     self.ResidueRBMenu.Append(id=wxID_RIGIDBODYADD, kind=wx.ITEM_NORMAL,text='Import residues', |
---|
1964 | Â Â Â Â Â Â help='Import residue rigid bodies from macro file') |
---|
1965 |     self.RigidBodyMenu.Append(menu=self.ResidueRBMenu, title='Edit Body') |
---|
1966 | Â Â Â Â self.PostfillDataMenu() |
---|
1967 | |
---|
1968 | Â Â Â Â self.VectorBodyMenu =Â wx.MenuBar() |
---|
1969 | Â Â Â Â self.PrefillDataMenu(self.VectorBodyMenu,helpType='Vector rigid bodies') |
---|
1970 | Â Â Â Â self.VectorRBEdit =Â wx.Menu(title='') |
---|
1971 |     self.VectorRBEdit.Append(id=wxID_VECTORBODYADD, kind=wx.ITEM_NORMAL,text='Add rigid body', |
---|
1972 | Â Â Â Â Â Â help='Add vector rigid body') |
---|
1973 |     self.VectorBodyMenu.Append(menu=self.VectorRBEdit, title='Edit Vector Body') |
---|
1974 | Â Â Â Â self.PostfillDataMenu() |
---|
1975 | |
---|
1976 | Â Â Â Â Â Â Â Â Â Â |
---|
1977 | Â Â Â Â # Restraints |
---|
1978 | Â Â Â Â self.RestraintTab =Â wx.Menu(title='') |
---|
1979 | Â Â Â Â self.RestraintEdit =Â wx.Menu(title='') |
---|
1980 |     self.RestraintEdit.Append(id=wxID_RESTSELPHASE, kind=wx.ITEM_NORMAL,text='Select phase', |
---|
1981 | Â Â Â Â Â Â help='Select phase') |
---|
1982 |     self.RestraintEdit.Append(id=wxID_RESTRAINTADD, kind=wx.ITEM_NORMAL,text='Add restraints', |
---|
1983 | Â Â Â Â Â Â help='Add restraints') |
---|
1984 | Â Â Â Â self.RestraintEdit.Enable(wxID_RESTRAINTADD,True)Â Â #gets disabled if macromolecule phase |
---|
1985 |     self.RestraintEdit.Append(id=wxID_AARESTRAINTADD, kind=wx.ITEM_NORMAL,text='Add residue restraints', |
---|
1986 | Â Â Â Â Â Â help='Add residue based restraints for macromolecules from macro file') |
---|
1987 | Â Â Â Â self.RestraintEdit.Enable(wxID_AARESTRAINTADD,False)Â Â #gets enabled if macromolecule phase |
---|
1988 |     self.RestraintEdit.Append(id=wxID_AARESTRAINTPLOT, kind=wx.ITEM_NORMAL,text='Plot residue restraints', |
---|
1989 | Â Â Â Â Â Â help='Plot selected residue based restraints for macromolecules from macro file') |
---|
1990 | Â Â Â Â self.RestraintEdit.Enable(wxID_AARESTRAINTPLOT,False)Â Â #gets enabled if macromolecule phase |
---|
1991 |     self.RestraintEdit.Append(id=wxID_RESRCHANGEVAL, kind=wx.ITEM_NORMAL,text='Change value', |
---|
1992 | Â Â Â Â Â Â help='Change observed value') |
---|
1993 |     self.RestraintEdit.Append(id=wxID_RESTCHANGEESD, kind=wx.ITEM_NORMAL,text='Change esd', |
---|
1994 | Â Â Â Â Â Â help='Change esd in observed value') |
---|
1995 |     self.RestraintEdit.Append(id=wxID_RESTDELETE, kind=wx.ITEM_NORMAL,text='Delete restraints', |
---|
1996 | Â Â Â Â Â Â help='Delete selected restraints') |
---|
1997 | |
---|
1998 | Â Â Â Â self.RestraintMenu =Â wx.MenuBar() |
---|
1999 | Â Â Â Â self.PrefillDataMenu(self.RestraintMenu,helpType='Restraints') |
---|
2000 |     self.RestraintMenu.Append(menu=self.RestraintTab, title='Select tab') |
---|
2001 |     self.RestraintMenu.Append(menu=self.RestraintEdit, title='Edit') |
---|
2002 | Â Â Â Â self.PostfillDataMenu() |
---|
2003 | Â Â Â Â Â Â |
---|
2004 | Â Â Â Â # Sequential results |
---|
2005 | Â Â Â Â self.SequentialMenu =Â wx.MenuBar() |
---|
2006 | Â Â Â Â self.PrefillDataMenu(self.SequentialMenu,helpType='Sequential',helpLbl='Sequential Refinement') |
---|
2007 | Â Â Â Â self.SequentialFile =Â wx.Menu(title='') |
---|
2008 |     self.SequentialMenu.Append(menu=self.SequentialFile, title='Columns') |
---|
2009 |     self.SequentialFile.Append(id=wxID_RENAMESEQSEL, kind=wx.ITEM_NORMAL,text='Rename selected', |
---|
2010 | Â Â Â Â Â Â help='Rename selected sequential refinement columns') |
---|
2011 |     self.SequentialFile.Append(id=wxID_SAVESEQSEL, kind=wx.ITEM_NORMAL,text='Save selected as text', |
---|
2012 | Â Â Â Â Â Â help='Save selected sequential refinement results as a text file') |
---|
2013 |     self.SequentialFile.Append(id=wxID_SAVESEQSELCSV, kind=wx.ITEM_NORMAL,text='Save selected as CSV', |
---|
2014 | Â Â Â Â Â Â help='Save selected sequential refinement results as a CSV spreadsheet file') |
---|
2015 |     self.SequentialFile.Append(id=wxID_PLOTSEQSEL, kind=wx.ITEM_NORMAL,text='Plot selected', |
---|
2016 | Â Â Â Â Â Â help='Plot selected sequential refinement results') |
---|
2017 |     self.SequentialFile.Append(id=wxID_ORGSEQSEL, kind=wx.ITEM_NORMAL,text='Reorganize', |
---|
2018 | Â Â Â Â Â Â help='Reorganize variables where variables change') |
---|
2019 | Â Â Â Â self.SequentialPvars =Â wx.Menu(title='') |
---|
2020 |     self.SequentialMenu.Append(menu=self.SequentialPvars, title='Pseudo Vars') |
---|
2021 | Â Â Â Â self.SequentialPvars.Append( |
---|
2022 |       id=wxADDSEQVAR, kind=wx.ITEM_NORMAL,text='Add', |
---|
2023 | Â Â Â Â Â Â help='Add a new pseudo-variable') |
---|
2024 | Â Â Â Â self.SequentialPvars.Append( |
---|
2025 |       id=wxDELSEQVAR, kind=wx.ITEM_NORMAL,text='Delete', |
---|
2026 | Â Â Â Â Â Â help='Delete an existing pseudo-variable') |
---|
2027 | Â Â Â Â self.SequentialPvars.Append( |
---|
2028 |       id=wxEDITSEQVAR, kind=wx.ITEM_NORMAL,text='Edit', |
---|
2029 | Â Â Â Â Â Â help='Edit an existing pseudo-variable') |
---|
2030 | |
---|
2031 | Â Â Â Â self.SequentialPfit =Â wx.Menu(title='') |
---|
2032 |     self.SequentialMenu.Append(menu=self.SequentialPfit, title='Parametric Fit') |
---|
2033 | Â Â Â Â self.SequentialPfit.Append( |
---|
2034 |       id=wxADDPARFIT, kind=wx.ITEM_NORMAL,text='Add equation', |
---|
2035 | Â Â Â Â Â Â help='Add a new equation to minimize') |
---|
2036 | Â Â Â Â self.SequentialPfit.Append( |
---|
2037 |       id=wxCOPYPARFIT, kind=wx.ITEM_NORMAL,text='Copy equation', |
---|
2038 | Â Â Â Â Â Â help='Copy an equation to minimize - edit it next') |
---|
2039 | Â Â Â Â self.SequentialPfit.Append( |
---|
2040 |       id=wxDELPARFIT, kind=wx.ITEM_NORMAL,text='Delete equation', |
---|
2041 | Â Â Â Â Â Â help='Delete an equation for parametric minimization') |
---|
2042 | Â Â Â Â self.SequentialPfit.Append( |
---|
2043 |       id=wxEDITPARFIT, kind=wx.ITEM_NORMAL,text='Edit equation', |
---|
2044 | Â Â Â Â Â Â help='Edit an existing parametric minimization equation') |
---|
2045 | Â Â Â Â self.SequentialPfit.Append( |
---|
2046 |       id=wxDOPARFIT, kind=wx.ITEM_NORMAL,text='Fit to equation(s)', |
---|
2047 | Â Â Â Â Â Â help='Perform a parametric minimization') |
---|
2048 | Â Â Â Â self.PostfillDataMenu() |
---|
2049 | Â Â Â Â Â Â |
---|
2050 | Â Â Â Â # PWDR & SASD |
---|
2051 | Â Â Â Â self.PWDRMenu =Â wx.MenuBar() |
---|
2052 | Â Â Â Â self.PrefillDataMenu(self.PWDRMenu,helpType='PWDR Analysis',helpLbl='Powder Fit Error Analysis') |
---|
2053 | Â Â Â Â self.ErrorAnal =Â wx.Menu(title='') |
---|
2054 | Â Â Â Â self.PWDRMenu.Append(menu=self.ErrorAnal,title='Commands') |
---|
2055 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWDANALYSIS,kind=wx.ITEM_NORMAL,text='Error Analysis', |
---|
2056 | Â Â Â Â Â Â help='Error analysis on powder pattern') |
---|
2057 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWDCOPY,kind=wx.ITEM_NORMAL,text='Copy params', |
---|
2058 | Â Â Â Â Â Â help='Copy of PWDR parameters') |
---|
2059 | Â Â Â Â self.PostfillDataMenu() |
---|
2060 | Â Â Â Â Â Â |
---|
2061 | Â Â Â Â # HKLF |
---|
2062 | Â Â Â Â self.HKLFMenu =Â wx.MenuBar() |
---|
2063 | Â Â Â Â self.PrefillDataMenu(self.HKLFMenu,helpType='HKLF Analysis',helpLbl='HKLF Fit Error Analysis') |
---|
2064 | Â Â Â Â self.ErrorAnal =Â wx.Menu(title='') |
---|
2065 | Â Â Â Â self.HKLFMenu.Append(menu=self.ErrorAnal,title='Commands') |
---|
2066 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWDANALYSIS,kind=wx.ITEM_NORMAL,text='Error Analysis', |
---|
2067 | Â Â Â Â Â Â help='Error analysis on single crystal data') |
---|
2068 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWD3DHKLPLOT,kind=wx.ITEM_NORMAL,text='Plot 3D HKLs', |
---|
2069 | Â Â Â Â Â Â help='Plot HKLs from single crystal data in 3D') |
---|
2070 | Â Â Â Â self.ErrorAnal.Append(id=wxID_PWDCOPY,kind=wx.ITEM_NORMAL,text='Copy params', |
---|
2071 | Â Â Â Â Â Â help='Copy of HKLF parameters') |
---|
2072 | Â Â Â Â self.PostfillDataMenu() |
---|
2073 | Â Â Â Â Â Â |
---|
2074 | Â Â Â Â # PDR / Limits |
---|
2075 | Â Â Â Â self.LimitMenu =Â wx.MenuBar() |
---|
2076 | Â Â Â Â self.PrefillDataMenu(self.LimitMenu,helpType='Limits') |
---|
2077 | Â Â Â Â self.LimitEdit =Â wx.Menu(title='') |
---|
2078 |     self.LimitMenu.Append(menu=self.LimitEdit, title='Edit') |
---|
2079 |     self.LimitEdit.Append(id=wxID_LIMITCOPY, kind=wx.ITEM_NORMAL,text='Copy', |
---|
2080 | Â Â Â Â Â Â help='Copy limits to other histograms') |
---|
2081 |     self.LimitEdit.Append(id=wxID_ADDEXCLREGION, kind=wx.ITEM_NORMAL,text='Add exclude', |
---|
2082 | Â Â Â Â Â Â help='Add excluded region - select a point on plot; drag to adjust')Â Â Â Â Â Â |
---|
2083 | Â Â Â Â self.PostfillDataMenu() |
---|
2084 | Â Â Â Â Â Â |
---|
2085 | Â Â Â Â # PDR / Background |
---|
2086 | Â Â Â Â self.BackMenu =Â wx.MenuBar() |
---|
2087 | Â Â Â Â self.PrefillDataMenu(self.BackMenu,helpType='Background') |
---|
2088 | Â Â Â Â self.BackEdit =Â wx.Menu(title='') |
---|
2089 |     self.BackMenu.Append(menu=self.BackEdit, title='File') |
---|
2090 |     self.BackEdit.Append(id=wxID_BACKCOPY, kind=wx.ITEM_NORMAL,text='Copy', |
---|
2091 | Â Â Â Â Â Â help='Copy background parameters to other histograms') |
---|
2092 |     self.BackEdit.Append(id=wxID_BACKFLAGCOPY, kind=wx.ITEM_NORMAL,text='Copy flags', |
---|
2093 | Â Â Â Â Â Â help='Copy background refinement flags to other histograms') |
---|
2094 | Â Â Â Â self.PostfillDataMenu() |
---|
2095 | Â Â Â Â Â Â |
---|
2096 | Â Â Â Â # PDR / Instrument Parameters |
---|
2097 | Â Â Â Â self.InstMenu =Â wx.MenuBar() |
---|
2098 | Â Â Â Â self.PrefillDataMenu(self.InstMenu,helpType='Instrument Parameters') |
---|
2099 | Â Â Â Â self.InstEdit =Â wx.Menu(title='') |
---|
2100 |     self.InstMenu.Append(menu=self.InstEdit, title='Operations') |
---|
2101 |     self.InstEdit.Append(help='Calibrate from indexed peaks', |
---|
2102 |       id=wxID_INSTCALIB, kind=wx.ITEM_NORMAL,text='Calibrate')      |
---|
2103 |     self.InstEdit.Append(help='Reset instrument profile parameters to default', |
---|
2104 |       id=wxID_INSTPRMRESET, kind=wx.ITEM_NORMAL,text='Reset profile')      |
---|
2105 |     self.InstEdit.Append(help='Load instrument profile parameters from file', |
---|
2106 |       id=wxID_INSTLOAD, kind=wx.ITEM_NORMAL,text='Load profile...')      |
---|
2107 |     self.InstEdit.Append(help='Save instrument profile parameters to file', |
---|
2108 |       id=wxID_INSTSAVE, kind=wx.ITEM_NORMAL,text='Save profile...')      |
---|
2109 |     self.InstEdit.Append(help='Copy instrument profile parameters to other histograms', |
---|
2110 |       id=wxID_INSTCOPY, kind=wx.ITEM_NORMAL,text='Copy') |
---|
2111 |     self.InstEdit.Append(id=wxID_INSTFLAGCOPY, kind=wx.ITEM_NORMAL,text='Copy flags', |
---|
2112 | Â Â Â Â Â Â help='Copy instrument parameter refinement flags to other histograms') |
---|
2113 | #Â Â Â Â self.InstEdit.Append(help='Change radiation type (Ka12 - synch)', |
---|
2114 | #Â Â Â Â Â Â id=wxID_CHANGEWAVETYPE, kind=wx.ITEM_NORMAL,text='Change radiation') |
---|
2115 |     self.InstEdit.Append(id=wxID_INST1VAL, kind=wx.ITEM_NORMAL,text='Set one value', |
---|
2116 | Â Â Â Â Â Â help='Set one instrument parameter value across multiple histograms') |
---|
2117 | |
---|
2118 | Â Â Â Â self.PostfillDataMenu() |
---|
2119 | Â Â Â Â |
---|
2120 | Â Â Â Â # PDR / Sample Parameters |
---|
2121 | Â Â Â Â self.SampleMenu =Â wx.MenuBar() |
---|
2122 | Â Â Â Â self.PrefillDataMenu(self.SampleMenu,helpType='Sample Parameters') |
---|
2123 | Â Â Â Â self.SampleEdit =Â wx.Menu(title='') |
---|
2124 |     self.SampleMenu.Append(menu=self.SampleEdit, title='Command') |
---|
2125 |     self.SetScale = self.SampleEdit.Append(id=wxID_SETSCALE, kind=wx.ITEM_NORMAL,text='Set scale', |
---|
2126 | Â Â Â Â Â Â help='Set scale by matching to another histogram') |
---|
2127 |     self.SampleEdit.Append(id=wxID_SAMPLELOAD, kind=wx.ITEM_NORMAL,text='Load', |
---|
2128 | Â Â Â Â Â Â help='Load sample parameters from file') |
---|
2129 |     self.SampleEdit.Append(id=wxID_SAMPLESAVE, kind=wx.ITEM_NORMAL,text='Save', |
---|
2130 | Â Â Â Â Â Â help='Save sample parameters to file') |
---|
2131 |     self.SampleEdit.Append(id=wxID_SAMPLECOPY, kind=wx.ITEM_NORMAL,text='Copy', |
---|
2132 | Â Â Â Â Â Â help='Copy refinable and most other sample parameters to other histograms') |
---|
2133 |     self.SampleEdit.Append(id=wxID_SAMPLECOPYSOME, kind=wx.ITEM_NORMAL,text='Copy selected...', |
---|
2134 | Â Â Â Â Â Â help='Copy selected sample parameters to other histograms') |
---|
2135 |     self.SampleEdit.Append(id=wxID_SAMPLEFLAGCOPY, kind=wx.ITEM_NORMAL,text='Copy flags', |
---|
2136 | Â Â Â Â Â Â help='Copy sample parameter refinement flags to other histograms') |
---|
2137 |     self.SampleEdit.Append(id=wxID_SAMPLE1VAL, kind=wx.ITEM_NORMAL,text='Set one value', |
---|
2138 | Â Â Â Â Â Â help='Set one sample parameter value across multiple histograms') |
---|
2139 |     self.SampleEdit.Append(id=wxID_ALLSAMPLELOAD, kind=wx.ITEM_NORMAL,text='Load all', |
---|
2140 | Â Â Â Â Â Â help='Load sample parmameters over multiple histograms') |
---|
2141 | |
---|
2142 | Â Â Â Â self.PostfillDataMenu() |
---|
2143 | Â Â Â Â self.SetScale.Enable(False) |
---|
2144 | |
---|
2145 | Â Â Â Â # PDR / Peak List |
---|
2146 | Â Â Â Â self.PeakMenu =Â wx.MenuBar() |
---|
2147 | Â Â Â Â self.PrefillDataMenu(self.PeakMenu,helpType='Peak List') |
---|
2148 | Â Â Â Â self.PeakEdit =Â wx.Menu(title='') |
---|
2149 |     self.PeakMenu.Append(menu=self.PeakEdit, title='Peak Fitting') |
---|
2150 |     self.AutoSearch = self.PeakEdit.Append(help='Automatic peak search', |
---|
2151 |       id=wxID_AUTOSEARCH, kind=wx.ITEM_NORMAL,text='Auto search') |
---|
2152 |     self.UnDo = self.PeakEdit.Append(help='Undo last least squares refinement', |
---|
2153 |       id=wxID_UNDO, kind=wx.ITEM_NORMAL,text='UnDo') |
---|
2154 |     self.PeakFit = self.PeakEdit.Append(id=wxID_LSQPEAKFIT, kind=wx.ITEM_NORMAL,text='Peakfit', |
---|
2155 | Â Â Â Â Â Â help='Peak fitting'Â ) |
---|
2156 |     self.PFOneCycle = self.PeakEdit.Append(id=wxID_LSQONECYCLE, kind=wx.ITEM_NORMAL,text='Peakfit one cycle', |
---|
2157 | Â Â Â Â Â Â help='One cycle of Peak fitting'Â ) |
---|
2158 |     self.PeakEdit.Append(id=wxID_RESETSIGGAM, kind=wx.ITEM_NORMAL, |
---|
2159 | Â Â Â Â Â Â text='Reset sig and gam',help='Reset sigma and gamma to global fit'Â ) |
---|
2160 |     self.PeakCopy = self.PeakEdit.Append(help='Copy peaks to other histograms', |
---|
2161 |       id=wxID_PEAKSCOPY, kind=wx.ITEM_NORMAL,text='Peak copy') |
---|
2162 |     self.SeqPeakFit = self.PeakEdit.Append(id=wxID_SEQPEAKFIT, kind=wx.ITEM_NORMAL,text='Seq PeakFit', |
---|
2163 | Â Â Â Â Â Â help='Sequential Peak fitting for all histograms'Â ) |
---|
2164 |     self.PeakEdit.Append(id=wxID_CLEARPEAKS, kind=wx.ITEM_NORMAL,text='Clear peaks', |
---|
2165 | Â Â Â Â Â Â help='Clear the peak list'Â ) |
---|
2166 | Â Â Â Â self.PostfillDataMenu() |
---|
2167 | Â Â Â Â self.UnDo.Enable(False) |
---|
2168 | Â Â Â Â self.PeakFit.Enable(False) |
---|
2169 | Â Â Â Â self.PFOneCycle.Enable(False) |
---|
2170 | Â Â Â Â self.AutoSearch.Enable(True) |
---|
2171 | Â Â Â Â |
---|
2172 | Â Â Â Â # PDR / Index Peak List |
---|
2173 | Â Â Â Â self.IndPeaksMenu =Â wx.MenuBar() |
---|
2174 | Â Â Â Â self.PrefillDataMenu(self.IndPeaksMenu,helpType='Index Peak List') |
---|
2175 | Â Â Â Â self.IndPeaksEdit =Â wx.Menu(title='') |
---|
2176 | Â Â Â Â self.IndPeaksMenu.Append(menu=self.IndPeaksEdit,title='Operations') |
---|
2177 |     self.IndPeaksEdit.Append(help='Load/Reload index peaks from peak list',id=wxID_INDXRELOAD, |
---|
2178 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Load/Reload') |
---|
2179 | Â Â Â Â self.PostfillDataMenu() |
---|
2180 | Â Â Â Â |
---|
2181 | Â Â Â Â # PDR / Unit Cells List |
---|
2182 | Â Â Â Â self.IndexMenu =Â wx.MenuBar() |
---|
2183 | Â Â Â Â self.PrefillDataMenu(self.IndexMenu,helpType='Unit Cells List') |
---|
2184 | Â Â Â Â self.IndexEdit =Â wx.Menu(title='') |
---|
2185 |     self.IndexMenu.Append(menu=self.IndexEdit, title='Cell Index/Refine') |
---|
2186 |     self.IndexPeaks = self.IndexEdit.Append(help='', id=wxID_INDEXPEAKS, kind=wx.ITEM_NORMAL, |
---|
2187 | Â Â Â Â Â Â text='Index Cell') |
---|
2188 |     self.CopyCell = self.IndexEdit.Append( id=wxID_COPYCELL, kind=wx.ITEM_NORMAL,text='Copy Cell', |
---|
2189 | Â Â Â Â Â Â help='Copy selected unit cell from indexing to cell refinement fields') |
---|
2190 |     self.RefineCell = self.IndexEdit.Append( id=wxID_REFINECELL, kind=wx.ITEM_NORMAL, |
---|
2191 | Â Â Â Â Â Â text='Refine Cell',help='Refine unit cell parameters from indexed peaks') |
---|
2192 |     self.MakeNewPhase = self.IndexEdit.Append( id=wxID_MAKENEWPHASE, kind=wx.ITEM_NORMAL, |
---|
2193 | Â Â Â Â Â Â text='Make new phase',help='Make new phase from selected unit cell') |
---|
2194 | Â Â Â Â self.PostfillDataMenu() |
---|
2195 | Â Â Â Â self.IndexPeaks.Enable(False) |
---|
2196 | Â Â Â Â self.CopyCell.Enable(False) |
---|
2197 | Â Â Â Â self.RefineCell.Enable(False) |
---|
2198 | Â Â Â Â self.MakeNewPhase.Enable(False) |
---|
2199 | Â Â Â Â |
---|
2200 | Â Â Â Â # PDR / Reflection Lists |
---|
2201 | Â Â Â Â self.ReflMenu =Â wx.MenuBar() |
---|
2202 | Â Â Â Â self.PrefillDataMenu(self.ReflMenu,helpType='Reflection List') |
---|
2203 | Â Â Â Â self.ReflEdit =Â wx.Menu(title='') |
---|
2204 |     self.ReflMenu.Append(menu=self.ReflEdit, title='Reflection List') |
---|
2205 |     self.SelectPhase = self.ReflEdit.Append(help='Select phase for reflection list',id=wxID_SELECTPHASE, |
---|
2206 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Select phase') |
---|
2207 | Â Â Â Â self.ReflEdit.Append(id=wxID_PWDHKLPLOT,kind=wx.ITEM_NORMAL,text='Plot HKLs', |
---|
2208 | Â Â Â Â Â Â help='Plot HKLs from powder pattern') |
---|
2209 | Â Â Â Â self.ReflEdit.Append(id=wxID_PWD3DHKLPLOT,kind=wx.ITEM_NORMAL,text='Plot 3D HKLs', |
---|
2210 | Â Â Â Â Â Â help='Plot HKLs from powder pattern in 3D') |
---|
2211 | Â Â Â Â self.PostfillDataMenu() |
---|
2212 | Â Â Â Â |
---|
2213 | Â Â Â Â # SASD / Instrument Parameters |
---|
2214 | Â Â Â Â self.SASDInstMenu =Â wx.MenuBar() |
---|
2215 | Â Â Â Â self.PrefillDataMenu(self.SASDInstMenu,helpType='Instrument Parameters') |
---|
2216 | Â Â Â Â self.SASDInstEdit =Â wx.Menu(title='') |
---|
2217 |     self.SASDInstMenu.Append(menu=self.SASDInstEdit, title='Operations') |
---|
2218 |     self.InstEdit.Append(help='Reset instrument profile parameters to default', |
---|
2219 |       id=wxID_INSTPRMRESET, kind=wx.ITEM_NORMAL,text='Reset profile') |
---|
2220 |     self.SASDInstEdit.Append(help='Copy instrument profile parameters to other histograms', |
---|
2221 |       id=wxID_INSTCOPY, kind=wx.ITEM_NORMAL,text='Copy') |
---|
2222 | Â Â Â Â self.PostfillDataMenu() |
---|
2223 | Â Â Â Â |
---|
2224 | Â Â Â Â #SASD & REFL/ Substance editor |
---|
2225 | Â Â Â Â self.SubstanceMenu =Â wx.MenuBar() |
---|
2226 | Â Â Â Â self.PrefillDataMenu(self.SubstanceMenu,helpType='Substances') |
---|
2227 | Â Â Â Â self.SubstanceEdit =Â wx.Menu(title='') |
---|
2228 |     self.SubstanceMenu.Append(menu=self.SubstanceEdit, title='Edit') |
---|
2229 |     self.SubstanceEdit.Append(id=wxID_LOADSUBSTANCE, kind=wx.ITEM_NORMAL,text='Load substance', |
---|
2230 | Â Â Â Â Â Â help='Load substance from file') |
---|
2231 |     self.SubstanceEdit.Append(id=wxID_ADDSUBSTANCE, kind=wx.ITEM_NORMAL,text='Add substance', |
---|
2232 | Â Â Â Â Â Â help='Add new substance to list') |
---|
2233 |     self.SubstanceEdit.Append(id=wxID_COPYSUBSTANCE, kind=wx.ITEM_NORMAL,text='Copy substances', |
---|
2234 | Â Â Â Â Â Â help='Copy substances') |
---|
2235 |     self.SubstanceEdit.Append(id=wxID_DELETESUBSTANCE, kind=wx.ITEM_NORMAL,text='Delete substance', |
---|
2236 | Â Â Â Â Â Â help='Delete substance from list')Â Â Â Â Â Â |
---|
2237 |     self.SubstanceEdit.Append(id=wxID_ELEMENTADD, kind=wx.ITEM_NORMAL,text='Add elements', |
---|
2238 | Â Â Â Â Â Â help='Add elements to substance') |
---|
2239 |     self.SubstanceEdit.Append(id=wxID_ELEMENTDELETE, kind=wx.ITEM_NORMAL,text='Delete elements', |
---|
2240 | Â Â Â Â Â Â help='Delete elements from substance') |
---|
2241 | Â Â Â Â self.PostfillDataMenu() |
---|
2242 | Â Â Â Â |
---|
2243 | Â Â Â Â # SASD/ Models |
---|
2244 | Â Â Â Â self.ModelMenu =Â wx.MenuBar() |
---|
2245 | Â Â Â Â self.PrefillDataMenu(self.ModelMenu,helpType='Models') |
---|
2246 | Â Â Â Â self.ModelEdit =Â wx.Menu(title='') |
---|
2247 |     self.ModelMenu.Append(menu=self.ModelEdit, title='Models') |
---|
2248 | Â Â Â Â self.ModelEdit.Append(id=wxID_MODELADD,kind=wx.ITEM_NORMAL,text='Add', |
---|
2249 | Â Â Â Â Â Â help='Add new term to model') |
---|
2250 |     self.ModelEdit.Append(id=wxID_MODELFIT, kind=wx.ITEM_NORMAL,text='Fit', |
---|
2251 | Â Â Â Â Â Â help='Fit model parameters to data') |
---|
2252 |     self.SasdUndo = self.ModelEdit.Append(id=wxID_MODELUNDO, kind=wx.ITEM_NORMAL,text='Undo', |
---|
2253 | Â Â Â Â Â Â help='Undo model fit') |
---|
2254 | Â Â Â Â self.SasdUndo.Enable(False)Â Â Â Â Â Â |
---|
2255 |     self.ModelEdit.Append(id=wxID_MODELFITALL, kind=wx.ITEM_NORMAL,text='Sequential fit', |
---|
2256 | Â Â Â Â Â Â help='Sequential fit of model parameters to all SASD data') |
---|
2257 |     self.ModelEdit.Append(id=wxID_MODELCOPY, kind=wx.ITEM_NORMAL,text='Copy', |
---|
2258 | Â Â Â Â Â Â help='Copy model parameters to other histograms') |
---|
2259 |     self.ModelEdit.Append(id=wxID_MODELCOPYFLAGS, kind=wx.ITEM_NORMAL,text='Copy flags', |
---|
2260 | Â Â Â Â Â Â help='Copy model refinement flags to other histograms') |
---|
2261 | Â Â Â Â self.PostfillDataMenu() |
---|
2262 | Â Â Â Â |
---|
2263 | Â Â Â Â # IMG / Image Controls |
---|
2264 | Â Â Â Â self.ImageMenu =Â wx.MenuBar() |
---|
2265 | Â Â Â Â self.PrefillDataMenu(self.ImageMenu,helpType='Image Controls') |
---|
2266 | Â Â Â Â self.ImageEdit =Â wx.Menu(title='') |
---|
2267 |     self.ImageMenu.Append(menu=self.ImageEdit, title='Operations') |
---|
2268 |     self.ImageEdit.Append(help='Calibrate detector by fitting to calibrant lines', |
---|
2269 |       id=wxID_IMCALIBRATE, kind=wx.ITEM_NORMAL,text='Calibrate') |
---|
2270 |     self.ImageEdit.Append(help='Recalibrate detector by fitting to calibrant lines', |
---|
2271 |       id=wxID_IMRECALIBRATE, kind=wx.ITEM_NORMAL,text='Recalibrate') |
---|
2272 |     self.ImageEdit.Append(help='Clear calibration data points and rings',id=wxID_IMCLEARCALIB, |
---|
2273 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Clear calibration') |
---|
2274 |     self.ImageEdit.Append(help='Integrate selected image',id=wxID_IMINTEGRATE, |
---|
2275 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Integrate') |
---|
2276 | Â Â Â Â self.ImageEdit.Append(help='Integrate all images selected from list',id=wxID_INTEGRATEALL, |
---|
2277 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='Integrate all') |
---|
2278 |     self.ImageEdit.Append(help='Copy image controls to other images', |
---|
2279 |       id=wxID_IMCOPYCONTROLS, kind=wx.ITEM_NORMAL,text='Copy Controls') |
---|
2280 |     self.ImageEdit.Append(help='Save image controls to file', |
---|
2281 |       id=wxID_IMSAVECONTROLS, kind=wx.ITEM_NORMAL,text='Save Controls') |
---|
2282 |     self.ImageEdit.Append(help='Load image controls from file', |
---|
2283 |       id=wxID_IMLOADCONTROLS, kind=wx.ITEM_NORMAL,text='Load Controls') |
---|
2284 | Â Â Â Â self.PostfillDataMenu() |
---|
2285 | Â Â Â Â Â Â |
---|
2286 | Â Â Â Â # IMG / Masks |
---|
2287 | Â Â Â Â self.MaskMenu =Â wx.MenuBar() |
---|
2288 | Â Â Â Â self.PrefillDataMenu(self.MaskMenu,helpType='Image Masks') |
---|
2289 | Â Â Â Â self.MaskEdit =Â wx.Menu(title='') |
---|
2290 |     self.MaskMenu.Append(menu=self.MaskEdit, title='Operations') |
---|
2291 | Â Â Â Â submenu =Â wx.Menu() |
---|
2292 | Â Â Â Â self.MaskEdit.AppendMenu( |
---|
2293 |       wx.ID_ANY,'Create new', submenu, |
---|
2294 | Â Â Â Â Â Â help='' |
---|
2295 | Â Â Â Â Â Â ) |
---|
2296 |     self.MaskEdit.Append(help='Copy mask to other images', |
---|
2297 |       id=wxID_MASKCOPY, kind=wx.ITEM_NORMAL,text='Copy mask') |
---|
2298 |     self.MaskEdit.Append(help='Save mask to file', |
---|
2299 |       id=wxID_MASKSAVE, kind=wx.ITEM_NORMAL,text='Save mask') |
---|
2300 |     self.MaskEdit.Append(help='Load mask from file', |
---|
2301 |       id=wxID_MASKLOAD, kind=wx.ITEM_NORMAL,text='Load mask') |
---|
2302 |     self.MaskEdit.Append(help='Load mask from file; ignore threshold', |
---|
2303 |       id=wxID_MASKLOADNOT, kind=wx.ITEM_NORMAL,text='Load mask w/o threshold') |
---|
2304 |     submenu.Append(help='Create an arc mask with mouse input', |
---|
2305 |       id=wxID_NEWMASKARC, kind=wx.ITEM_NORMAL,text='Arc mask') |
---|
2306 |     submenu.Append(help='Create a frame mask with mouse input', |
---|
2307 |       id=wxID_NEWMASKFRAME, kind=wx.ITEM_NORMAL,text='Frame mask') |
---|
2308 |     submenu.Append(help='Create a polygon mask with mouse input', |
---|
2309 |       id=wxID_NEWMASKPOLY, kind=wx.ITEM_NORMAL,text='Polygon mask') |
---|
2310 |     submenu.Append(help='Create a ring mask with mouse input', |
---|
2311 |       id=wxID_NEWMASKRING, kind=wx.ITEM_NORMAL,text='Ring mask') |
---|
2312 |     submenu.Append(help='Create a spot mask with mouse input', |
---|
2313 |       id=wxID_NEWMASKSPOT, kind=wx.ITEM_NORMAL,text='Spot mask') |
---|
2314 | Â Â Â Â self.PostfillDataMenu() |
---|
2315 | Â Â Â Â Â Â |
---|
2316 | Â Â Â Â # IMG / Stress/Strain |
---|
2317 | Â Â Â Â self.StrStaMenu =Â wx.MenuBar() |
---|
2318 | Â Â Â Â self.PrefillDataMenu(self.StrStaMenu,helpType='Stress/Strain') |
---|
2319 | Â Â Â Â self.StrStaEdit =Â wx.Menu(title='') |
---|
2320 |     self.StrStaMenu.Append(menu=self.StrStaEdit, title='Operations') |
---|
2321 |     self.StrStaEdit.Append(help='Append d-zero for one ring', |
---|
2322 |       id=wxID_APPENDDZERO, kind=wx.ITEM_NORMAL,text='Append d-zero') |
---|
2323 |     self.StrStaEdit.Append(help='Fit stress/strain data', |
---|
2324 |       id=wxID_STRSTAFIT, kind=wx.ITEM_NORMAL,text='Fit stress/strain') |
---|
2325 | Â Â Â Â self.StrStaEdit.Append(help='Update d-zero from ave d-zero', |
---|
2326 |       id=wxID_UPDATEDZERO, kind=wx.ITEM_NORMAL,text='Update d-zero')    |
---|
2327 |     self.StrStaEdit.Append(help='Fit stress/strain data for all images', |
---|
2328 |       id=wxID_STRSTAALLFIT, kind=wx.ITEM_NORMAL,text='All image fit') |
---|
2329 |     self.StrStaEdit.Append(help='Copy stress/strain data to other images', |
---|
2330 |       id=wxID_STRSTACOPY, kind=wx.ITEM_NORMAL,text='Copy stress/strain') |
---|
2331 |     self.StrStaEdit.Append(help='Save stress/strain data to file', |
---|
2332 |       id=wxID_STRSTASAVE, kind=wx.ITEM_NORMAL,text='Save stress/strain') |
---|
2333 |     self.StrStaEdit.Append(help='Load stress/strain data from file', |
---|
2334 |       id=wxID_STRSTALOAD, kind=wx.ITEM_NORMAL,text='Load stress/strain') |
---|
2335 |     self.StrStaEdit.Append(help='Load sample data from file', |
---|
2336 |       id=wxID_STRSTSAMPLE, kind=wx.ITEM_NORMAL,text='Load sample data') |
---|
2337 | Â Â Â Â self.PostfillDataMenu() |
---|
2338 | Â Â Â Â Â Â |
---|
2339 | Â Â Â Â # PDF / PDF Controls |
---|
2340 | Â Â Â Â self.PDFMenu =Â wx.MenuBar() |
---|
2341 | Â Â Â Â self.PrefillDataMenu(self.PDFMenu,helpType='PDF Controls') |
---|
2342 | Â Â Â Â self.PDFEdit =Â wx.Menu(title='') |
---|
2343 |     self.PDFMenu.Append(menu=self.PDFEdit, title='PDF Controls') |
---|
2344 |     self.PDFEdit.Append(help='Add element to sample composition',id=wxID_PDFADDELEMENT, kind=wx.ITEM_NORMAL, |
---|
2345 | Â Â Â Â Â Â text='Add element') |
---|
2346 |     self.PDFEdit.Append(help='Delete element from sample composition',id=wxID_PDFDELELEMENT, kind=wx.ITEM_NORMAL, |
---|
2347 | Â Â Â Â Â Â text='Delete element') |
---|
2348 |     self.PDFEdit.Append(help='Copy PDF controls', id=wxID_PDFCOPYCONTROLS, kind=wx.ITEM_NORMAL, |
---|
2349 | Â Â Â Â Â Â text='Copy controls') |
---|
2350 |     self.PDFEdit.Append(help='Load PDF controls from file',id=wxID_PDFLOADCONTROLS, kind=wx.ITEM_NORMAL, |
---|
2351 | Â Â Â Â Â Â text='Load Controls') |
---|
2352 |     self.PDFEdit.Append(help='Save PDF controls to file', id=wxID_PDFSAVECONTROLS, kind=wx.ITEM_NORMAL, |
---|
2353 | Â Â Â Â Â Â text='Save controls') |
---|
2354 |     self.PDFEdit.Append(help='Compute PDF', id=wxID_PDFCOMPUTE, kind=wx.ITEM_NORMAL, |
---|
2355 | Â Â Â Â Â Â text='Compute PDF') |
---|
2356 |     self.PDFEdit.Append(help='Compute all PDFs', id=wxID_PDFCOMPUTEALL, kind=wx.ITEM_NORMAL, |
---|
2357 | Â Â Â Â Â Â text='Compute all PDFs') |
---|
2358 | Â Â Â Â self.PostfillDataMenu() |
---|
2359 | Â Â Â Â |
---|
2360 | Â Â Â Â # Phase / General tab |
---|
2361 | Â Â Â Â self.DataGeneral =Â wx.MenuBar() |
---|
2362 |     self.PrefillDataMenu(self.DataGeneral,helpType='General', helpLbl='Phase/General') |
---|
2363 | Â Â Â Â self.DataGeneral.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2364 | Â Â Â Â self.GeneralCalc =Â wx.Menu(title='') |
---|
2365 | Â Â Â Â self.DataGeneral.Append(menu=self.GeneralCalc,title='Compute') |
---|
2366 |     self.GeneralCalc.Append(help='Compute Fourier map',id=wxID_FOURCALC, kind=wx.ITEM_NORMAL, |
---|
2367 | Â Â Â Â Â Â text='Fourier map') |
---|
2368 |     self.GeneralCalc.Append(help='Search Fourier map',id=wxID_FOURSEARCH, kind=wx.ITEM_NORMAL, |
---|
2369 | Â Â Â Â Â Â text='Search map') |
---|
2370 |     self.GeneralCalc.Append(help='Run charge flipping',id=wxID_CHARGEFLIP, kind=wx.ITEM_NORMAL, |
---|
2371 | Â Â Â Â Â Â text='Charge flipping') |
---|
2372 |     self.GeneralCalc.Append(help='Run 4D charge flipping',id=wxID_4DCHARGEFLIP, kind=wx.ITEM_NORMAL, |
---|
2373 | Â Â Â Â Â Â text='4D Charge flipping') |
---|
2374 | Â Â Â Â self.GeneralCalc.Enable(wxID_4DCHARGEFLIP,False)Â Â |
---|
2375 |     self.GeneralCalc.Append(help='Clear map',id=wxID_FOURCLEAR, kind=wx.ITEM_NORMAL, |
---|
2376 | Â Â Â Â Â Â text='Clear map') |
---|
2377 |     self.GeneralCalc.Append(help='Run Monte Carlo - Simulated Annealing',id=wxID_SINGLEMCSA, kind=wx.ITEM_NORMAL, |
---|
2378 | Â Â Â Â Â Â text='MC/SA') |
---|
2379 |     self.GeneralCalc.Append(help='Run Monte Carlo - Simulated Annealing on multiprocessors',id=wxID_MULTIMCSA, kind=wx.ITEM_NORMAL, |
---|
2380 | Â Â Â Â Â Â text='Multi MC/SA')Â Â Â Â Â Â #currently not useful |
---|
2381 | Â Â Â Â self.PostfillDataMenu() |
---|
2382 | Â Â Â Â |
---|
2383 | Â Â Â Â # Phase / Data tab |
---|
2384 | Â Â Â Â self.DataMenu =Â wx.MenuBar() |
---|
2385 |     self.PrefillDataMenu(self.DataMenu,helpType='Data', helpLbl='Phase/Data') |
---|
2386 | Â Â Â Â self.DataMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2387 | Â Â Â Â self.DataEdit =Â wx.Menu(title='') |
---|
2388 |     self.DataMenu.Append(menu=self.DataEdit, title='Edit') |
---|
2389 |     self.DataEdit.Append(id=wxID_PWDRADD, kind=wx.ITEM_NORMAL,text='Add powder histograms', |
---|
2390 | Â Â Â Â Â Â help='Select new powder histograms to be used for this phase') |
---|
2391 |     self.DataEdit.Append(id=wxID_HKLFADD, kind=wx.ITEM_NORMAL,text='Add single crystal histograms', |
---|
2392 | Â Â Â Â Â Â help='Select new single crystal histograms to be used for this phase') |
---|
2393 |     self.DataEdit.Append(id=wxID_DATADELETE, kind=wx.ITEM_NORMAL,text='Remove histograms', |
---|
2394 | Â Â Â Â Â Â help='Remove histograms from use for this phase') |
---|
2395 | Â Â Â Â self.PostfillDataMenu() |
---|
2396 | Â Â Â Â Â Â |
---|
2397 | Â Â Â Â # Phase / Atoms tab |
---|
2398 | Â Â Â Â self.AtomsMenu =Â wx.MenuBar() |
---|
2399 | Â Â Â Â self.PrefillDataMenu(self.AtomsMenu,helpType='Atoms') |
---|
2400 | Â Â Â Â self.AtomsMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2401 | Â Â Â Â self.AtomEdit =Â wx.Menu(title='') |
---|
2402 | Â Â Â Â self.AtomCompute =Â wx.Menu(title='') |
---|
2403 |     self.AtomsMenu.Append(menu=self.AtomEdit, title='Edit') |
---|
2404 |     self.AtomsMenu.Append(menu=self.AtomCompute, title='Compute') |
---|
2405 |     self.AtomEdit.Append(id=wxID_ATOMSEDITADD, kind=wx.ITEM_NORMAL,text='Append atom', |
---|
2406 | Â Â Â Â Â Â help='Appended as an H atom') |
---|
2407 |     self.AtomEdit.Append(id=wxID_ATOMSVIEWADD, kind=wx.ITEM_NORMAL,text='Append view point', |
---|
2408 | Â Â Â Â Â Â help='Appended as an H atom') |
---|
2409 |     self.AtomEdit.Append(id=wxID_ATOMSEDITINSERT, kind=wx.ITEM_NORMAL,text='Insert atom', |
---|
2410 | Â Â Â Â Â Â help='Select atom row to insert before; inserted as an H atom') |
---|
2411 |     self.AtomEdit.Append(id=wxID_ATOMVIEWINSERT, kind=wx.ITEM_NORMAL,text='Insert view point', |
---|
2412 | Â Â Â Â Â Â help='Select atom row to insert before; inserted as an H atom') |
---|
2413 |     self.AtomEdit.Append(id=wxID_ATOMMOVE, kind=wx.ITEM_NORMAL,text='Move atom to view point', |
---|
2414 | Â Â Â Â Â Â help='Select single atom to move') |
---|
2415 |     self.AtomEdit.Append(id=wxID_ATOMSEDITDELETE, kind=wx.ITEM_NORMAL,text='Delete atom', |
---|
2416 | Â Â Â Â Â Â help='Select atoms to delete first') |
---|
2417 |     self.AtomEdit.Append(id=wxID_ATOMSREFINE, kind=wx.ITEM_NORMAL,text='Set atom refinement flags', |
---|
2418 | Â Â Â Â Â Â help='Select atoms to refine first') |
---|
2419 |     self.AtomEdit.Append(id=wxID_ATOMSMODIFY, kind=wx.ITEM_NORMAL,text='Modify atom parameters', |
---|
2420 | Â Â Â Â Â Â help='Select atoms to modify first') |
---|
2421 |     self.AtomEdit.Append(id=wxID_ATOMSTRANSFORM, kind=wx.ITEM_NORMAL,text='Transform atoms', |
---|
2422 | Â Â Â Â Â Â help='Select atoms to transform first') |
---|
2423 |     self.AtomEdit.Append(id=wxID_RELOADDRAWATOMS, kind=wx.ITEM_NORMAL,text='Reload draw atoms', |
---|
2424 | Â Â Â Â Â Â help='Reload atom drawing list') |
---|
2425 | Â Â Â Â submenu =Â wx.Menu() |
---|
2426 |     self.AtomEdit.AppendMenu(wx.ID_ANY, 'Reimport atoms', submenu, |
---|
2427 | Â Â Â Â Â Â help='Reimport atoms from file; sequence must match') |
---|
2428 | Â Â Â Â # setup a cascade menu for the formats that have been defined |
---|
2429 | Â Â Â Â self.ReImportMenuId =Â {}Â # points to readers for each menu entry |
---|
2430 |     for reader in self.G2frame.ImportPhaseReaderlist: |
---|
2431 | Â Â Â Â Â Â item =Â submenu.Append( |
---|
2432 | Â Â Â Â Â Â Â Â wx.ID_ANY,help=reader.longFormatName, |
---|
2433 | Â Â Â Â Â Â Â Â kind=wx.ITEM_NORMAL,text='reimport coordinates from '+reader.formatName+' file') |
---|
2434 | Â Â Â Â Â Â self.ReImportMenuId[item.GetId()]Â =Â reader |
---|
2435 | Â Â Â Â item =Â submenu.Append( |
---|
2436 | Â Â Â Â Â Â wx.ID_ANY, |
---|
2437 | Â Â Â Â Â Â help='Reimport coordinates, try to determine format from file', |
---|
2438 | Â Â Â Â Â Â kind=wx.ITEM_NORMAL, |
---|
2439 | Â Â Â Â Â Â text='guess format from file') |
---|
2440 |     self.ReImportMenuId[item.GetId()] = None # try all readers |
---|
2441 | |
---|
2442 |     self.AtomCompute.Append(id=wxID_ATOMSDISAGL, kind=wx.ITEM_NORMAL,text='Show Distances && Angles', |
---|
2443 | Â Â Â Â Â Â help='Compute distances & angles for selected atoms') |
---|
2444 |     self.AtomCompute.Append(id=wxID_ATOMSPDISAGL, kind=wx.ITEM_NORMAL,text='Save Distances && Angles', |
---|
2445 | Â Â Â Â Â Â help='Compute distances & angles for selected atoms') |
---|
2446 | Â Â Â Â self.AtomCompute.ISOcalc =Â self.AtomCompute.Append( |
---|
2447 |       id=wxID_ISODISP, kind=wx.ITEM_NORMAL, |
---|
2448 | Â Â Â Â Â Â text='Compute ISODISTORT mode values', |
---|
2449 | Â Â Â Â Â Â help='Compute values of ISODISTORT modes from atom parameters') |
---|
2450 | Â Â Â Â self.PostfillDataMenu() |
---|
2451 | Â Â Â Â |
---|
2452 | Â Â Â Â # Phase / Imcommensurate "waves" tab |
---|
2453 | Â Â Â Â self.WavesData =Â wx.MenuBar() |
---|
2454 |     self.PrefillDataMenu(self.WavesData,helpType='Wave Data', helpLbl='Imcommensurate wave data') |
---|
2455 | Â Â Â Â self.WavesData.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2456 | Â Â Â Â self.WavesDataCompute =Â wx.Menu(title='') |
---|
2457 | Â Â Â Â self.WavesData.Append(menu=self.WavesDataCompute,title='Compute') |
---|
2458 |     self.WavesDataCompute.Append(id=wxID_4DMAPCOMPUTE, kind=wx.ITEM_NORMAL,text='Compute 4D map', |
---|
2459 | Â Â Â Â Â Â help='Compute 4-dimensional map') |
---|
2460 | Â Â Â Â self.PostfillDataMenu() |
---|
2461 | Â Â Â Â Â Â Â Â Â |
---|
2462 | Â Â Â Â # Phase / Draw Options tab |
---|
2463 | Â Â Â Â self.DataDrawOptions =Â wx.MenuBar() |
---|
2464 |     self.PrefillDataMenu(self.DataDrawOptions,helpType='Draw Options', helpLbl='Phase/Draw Options') |
---|
2465 | Â Â Â Â self.DataDrawOptions.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2466 | Â Â Â Â self.PostfillDataMenu() |
---|
2467 | Â Â Â Â |
---|
2468 | Â Â Â Â # Phase / Draw Atoms tab |
---|
2469 | Â Â Â Â self.DrawAtomsMenu =Â wx.MenuBar() |
---|
2470 | Â Â Â Â self.PrefillDataMenu(self.DrawAtomsMenu,helpType='Draw Atoms') |
---|
2471 | Â Â Â Â self.DrawAtomsMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2472 | Â Â Â Â self.DrawAtomEdit =Â wx.Menu(title='') |
---|
2473 | Â Â Â Â self.DrawAtomCompute =Â wx.Menu(title='') |
---|
2474 | Â Â Â Â self.DrawAtomRestraint =Â wx.Menu(title='') |
---|
2475 | Â Â Â Â self.DrawAtomRigidBody =Â wx.Menu(title='') |
---|
2476 |     self.DrawAtomsMenu.Append(menu=self.DrawAtomEdit, title='Edit') |
---|
2477 | Â Â Â Â self.DrawAtomsMenu.Append(menu=self.DrawAtomCompute,title='Compute') |
---|
2478 |     self.DrawAtomsMenu.Append(menu=self.DrawAtomRestraint, title='Restraints') |
---|
2479 |     self.DrawAtomsMenu.Append(menu=self.DrawAtomRigidBody, title='Rigid body') |
---|
2480 |     self.DrawAtomEdit.Append(id=wxID_DRAWATOMSTYLE, kind=wx.ITEM_NORMAL,text='Atom style', |
---|
2481 | Â Â Â Â Â Â help='Select atoms first') |
---|
2482 |     self.DrawAtomEdit.Append(id=wxID_DRAWATOMLABEL, kind=wx.ITEM_NORMAL,text='Atom label', |
---|
2483 | Â Â Â Â Â Â help='Select atoms first') |
---|
2484 |     self.DrawAtomEdit.Append(id=wxID_DRAWATOMCOLOR, kind=wx.ITEM_NORMAL,text='Atom color', |
---|
2485 | Â Â Â Â Â Â help='Select atoms first') |
---|
2486 |     self.DrawAtomEdit.Append(id=wxID_DRAWATOMRESETCOLOR, kind=wx.ITEM_NORMAL,text='Reset atom colors', |
---|
2487 | Â Â Â Â Â Â help='Resets all atom colors to defaults') |
---|
2488 |     self.DrawAtomEdit.Append(id=wxID_DRAWVIEWPOINT, kind=wx.ITEM_NORMAL,text='View point', |
---|
2489 | Â Â Â Â Â Â help='View point is 1st atom selected') |
---|
2490 |     self.DrawAtomEdit.Append(id=wxID_DRAWADDEQUIV, kind=wx.ITEM_NORMAL,text='Add atoms', |
---|
2491 | Â Â Â Â Â Â help='Add symmetry & cell equivalents to drawing set from selected atoms') |
---|
2492 |     self.DrawAtomEdit.Append(id=wxID_DRAWTRANSFORM, kind=wx.ITEM_NORMAL,text='Transform atoms', |
---|
2493 | Â Â Â Â Â Â help='Transform selected atoms by symmetry & cell translations') |
---|
2494 |     self.DrawAtomEdit.Append(id=wxID_DRAWFILLCOORD, kind=wx.ITEM_NORMAL,text='Fill CN-sphere', |
---|
2495 | Â Â Â Â Â Â help='Fill coordination sphere for selected atoms')Â Â Â Â Â Â |
---|
2496 |     self.DrawAtomEdit.Append(id=wxID_DRAWFILLCELL, kind=wx.ITEM_NORMAL,text='Fill unit cell', |
---|
2497 | Â Â Â Â Â Â help='Fill unit cell with selected atoms') |
---|
2498 |     self.DrawAtomEdit.Append(id=wxID_DRAWDELETE, kind=wx.ITEM_NORMAL,text='Delete atoms', |
---|
2499 | Â Â Â Â Â Â help='Delete atoms from drawing set') |
---|
2500 |     self.DrawAtomCompute.Append(id=wxID_DRAWDISTVP, kind=wx.ITEM_NORMAL,text='View pt. dist.', |
---|
2501 | Â Â Â Â Â Â help='Compute distance of selected atoms from view point')Â Â |
---|
2502 |     self.DrawAtomCompute.Append(id=wxID_DRAWDISAGLTOR, kind=wx.ITEM_NORMAL,text='Dist. Ang. Tors.', |
---|
2503 | Â Â Â Â Â Â help='Compute distance, angle or torsion for 2-4 selected atoms')Â Â |
---|
2504 |     self.DrawAtomCompute.Append(id=wxID_DRAWPLANE, kind=wx.ITEM_NORMAL,text='Best plane', |
---|
2505 | Â Â Â Â Â Â help='Compute best plane for 4+ selected atoms')Â Â |
---|
2506 |     self.DrawAtomRestraint.Append(id=wxID_DRAWRESTRBOND, kind=wx.ITEM_NORMAL,text='Add bond restraint', |
---|
2507 | Â Â Â Â Â Â help='Add bond restraint for selected atoms (2)') |
---|
2508 |     self.DrawAtomRestraint.Append(id=wxID_DRAWRESTRANGLE, kind=wx.ITEM_NORMAL,text='Add angle restraint', |
---|
2509 | Â Â Â Â Â Â help='Add angle restraint for selected atoms (3: one end 1st)') |
---|
2510 |     self.DrawAtomRestraint.Append(id=wxID_DRAWRESTRPLANE, kind=wx.ITEM_NORMAL,text='Add plane restraint', |
---|
2511 | Â Â Â Â Â Â help='Add plane restraint for selected atoms (4+)') |
---|
2512 |     self.DrawAtomRestraint.Append(id=wxID_DRAWRESTRCHIRAL, kind=wx.ITEM_NORMAL,text='Add chiral restraint', |
---|
2513 | Â Â Â Â Â Â help='Add chiral restraint for selected atoms (4: center atom 1st)') |
---|
2514 |     self.DrawAtomRigidBody.Append(id=wxID_DRAWDEFINERB, kind=wx.ITEM_NORMAL,text='Define rigid body', |
---|
2515 | Â Â Â Â Â Â help='Define rigid body with selected atoms') |
---|
2516 | Â Â Â Â self.PostfillDataMenu() |
---|
2517 | |
---|
2518 | Â Â Â Â # Phase / MCSA tab |
---|
2519 | Â Â Â Â self.MCSAMenu =Â wx.MenuBar() |
---|
2520 | Â Â Â Â self.PrefillDataMenu(self.MCSAMenu,helpType='MC/SA') |
---|
2521 | Â Â Â Â self.MCSAMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2522 | Â Â Â Â self.MCSAEdit =Â wx.Menu(title='') |
---|
2523 |     self.MCSAMenu.Append(menu=self.MCSAEdit, title='MC/SA') |
---|
2524 |     self.MCSAEdit.Append(id=wxID_ADDMCSAATOM, kind=wx.ITEM_NORMAL,text='Add atom', |
---|
2525 | Â Â Â Â Â Â help='Add single atom to MC/SA model') |
---|
2526 |     self.MCSAEdit.Append(id=wxID_ADDMCSARB, kind=wx.ITEM_NORMAL,text='Add rigid body', |
---|
2527 | Â Â Â Â Â Â help='Add rigid body to MC/SA model'Â ) |
---|
2528 |     self.MCSAEdit.Append(id=wxID_CLEARMCSARB, kind=wx.ITEM_NORMAL,text='Clear rigid bodies', |
---|
2529 | Â Â Â Â Â Â help='Clear all atoms & rigid bodies from MC/SA model'Â ) |
---|
2530 |     self.MCSAEdit.Append(id=wxID_MOVEMCSA, kind=wx.ITEM_NORMAL,text='Move MC/SA solution', |
---|
2531 | Â Â Â Â Â Â help='Move MC/SA solution to atom list'Â ) |
---|
2532 |     self.MCSAEdit.Append(id=wxID_MCSACLEARRESULTS, kind=wx.ITEM_NORMAL,text='Clear results', |
---|
2533 | Â Â Â Â Â Â help='Clear table of MC/SA results'Â ) |
---|
2534 | Â Â Â Â self.PostfillDataMenu() |
---|
2535 | Â Â Â Â Â Â |
---|
2536 | Â Â Â Â # Phase / Texture tab |
---|
2537 | Â Â Â Â self.TextureMenu =Â wx.MenuBar() |
---|
2538 | Â Â Â Â self.PrefillDataMenu(self.TextureMenu,helpType='Texture') |
---|
2539 | Â Â Â Â self.TextureMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2540 | Â Â Â Â self.TextureEdit =Â wx.Menu(title='') |
---|
2541 |     self.TextureMenu.Append(menu=self.TextureEdit, title='Texture') |
---|
2542 | #Â Â Â Â self.TextureEdit.Append(id=wxID_REFINETEXTURE, kind=wx.ITEM_NORMAL,text='Refine texture', |
---|
2543 | #Â Â Â Â Â Â help='Refine the texture coefficients from sequential Pawley results') |
---|
2544 | # N.B. Binding is now commented out |
---|
2545 |     self.TextureEdit.Append(id=wxID_CLEARTEXTURE, kind=wx.ITEM_NORMAL,text='Clear texture', |
---|
2546 | Â Â Â Â Â Â help='Clear the texture coefficients'Â ) |
---|
2547 | Â Â Â Â self.PostfillDataMenu() |
---|
2548 | Â Â Â Â Â Â |
---|
2549 | Â Â Â Â # Phase / Pawley tab |
---|
2550 | Â Â Â Â self.PawleyMenu =Â wx.MenuBar() |
---|
2551 | Â Â Â Â self.PrefillDataMenu(self.PawleyMenu,helpType='Pawley') |
---|
2552 | Â Â Â Â self.PawleyMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2553 | Â Â Â Â self.PawleyEdit =Â wx.Menu(title='') |
---|
2554 | Â Â Â Â self.PawleyMenu.Append(menu=self.PawleyEdit,title='Operations') |
---|
2555 |     self.PawleyEdit.Append(id=wxID_PAWLEYLOAD, kind=wx.ITEM_NORMAL,text='Pawley create', |
---|
2556 | Â Â Â Â Â Â help='Initialize Pawley reflection list') |
---|
2557 |     self.PawleyEdit.Append(id=wxID_PAWLEYESTIMATE, kind=wx.ITEM_NORMAL,text='Pawley estimate', |
---|
2558 | Â Â Â Â Â Â help='Estimate initial Pawley intensities') |
---|
2559 |     self.PawleyEdit.Append(id=wxID_PAWLEYUPDATE, kind=wx.ITEM_NORMAL,text='Pawley update', |
---|
2560 | Â Â Â Â Â Â help='Update negative Pawley intensities with -0.5*Fobs and turn off refinemnt') |
---|
2561 | Â Â Â Â self.PostfillDataMenu() |
---|
2562 | Â Â Â Â Â Â |
---|
2563 | Â Â Â Â # Phase / Map peaks tab |
---|
2564 | Â Â Â Â self.MapPeaksMenu =Â wx.MenuBar() |
---|
2565 | Â Â Â Â self.PrefillDataMenu(self.MapPeaksMenu,helpType='Map peaks') |
---|
2566 | Â Â Â Â self.MapPeaksMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2567 | Â Â Â Â self.MapPeaksEdit =Â wx.Menu(title='') |
---|
2568 |     self.MapPeaksMenu.Append(menu=self.MapPeaksEdit, title='Map peaks') |
---|
2569 |     self.MapPeaksEdit.Append(id=wxID_PEAKSMOVE, kind=wx.ITEM_NORMAL,text='Move peaks', |
---|
2570 | Â Â Â Â Â Â help='Move selected peaks to atom list') |
---|
2571 |     self.MapPeaksEdit.Append(id=wxID_PEAKSVIEWPT, kind=wx.ITEM_NORMAL,text='View point', |
---|
2572 | Â Â Â Â Â Â help='View point is 1st peak selected') |
---|
2573 |     self.MapPeaksEdit.Append(id=wxID_PEAKSDISTVP, kind=wx.ITEM_NORMAL,text='View pt. dist.', |
---|
2574 | Â Â Â Â Â Â help='Compute distance of selected peaks from view point')Â Â |
---|
2575 |     self.MapPeaksEdit.Append(id=wxID_SHOWBONDS, kind=wx.ITEM_NORMAL,text='Hide bonds', |
---|
2576 | Â Â Â Â Â Â help='Hide or show bonds between peak positions')Â Â |
---|
2577 |     self.MapPeaksEdit.Append(id=wxID_PEAKSDA, kind=wx.ITEM_NORMAL,text='Calc dist/ang', |
---|
2578 | Â Â Â Â Â Â help='Calculate distance or angle for selection') |
---|
2579 |     self.MapPeaksEdit.Append(id=wxID_FINDEQVPEAKS, kind=wx.ITEM_NORMAL,text='Equivalent peaks', |
---|
2580 | Â Â Â Â Â Â help='Find equivalent peaks') |
---|
2581 |     self.MapPeaksEdit.Append(id=wxID_PEAKSUNIQUE, kind=wx.ITEM_NORMAL,text='Unique peaks', |
---|
2582 | Â Â Â Â Â Â help='Select unique set') |
---|
2583 |     self.MapPeaksEdit.Append(id=wxID_PEAKSDELETE, kind=wx.ITEM_NORMAL,text='Delete peaks', |
---|
2584 | Â Â Â Â Â Â help='Delete selected peaks') |
---|
2585 |     self.MapPeaksEdit.Append(id=wxID_PEAKSCLEAR, kind=wx.ITEM_NORMAL,text='Clear peaks', |
---|
2586 | Â Â Â Â Â Â help='Clear the map peak list') |
---|
2587 | Â Â Â Â self.PostfillDataMenu() |
---|
2588 | |
---|
2589 | Â Â Â Â # Phase / Rigid bodies tab |
---|
2590 | Â Â Â Â self.RigidBodiesMenu =Â wx.MenuBar() |
---|
2591 | Â Â Â Â self.PrefillDataMenu(self.RigidBodiesMenu,helpType='Rigid bodies') |
---|
2592 | Â Â Â Â self.RigidBodiesMenu.Append(menu=wx.Menu(title=''),title='Select tab') |
---|
2593 | Â Â Â Â self.RigidBodiesEdit =Â wx.Menu(title='') |
---|
2594 |     self.RigidBodiesMenu.Append(menu=self.RigidBodiesEdit, title='Edit') |
---|
2595 |     self.RigidBodiesEdit.Append(id=wxID_ASSIGNATMS2RB, kind=wx.ITEM_NORMAL,text='Assign atoms to rigid body', |
---|
2596 | Â Â Â Â Â Â help='Select & position rigid body in structure of existing atoms') |
---|
2597 |     self.RigidBodiesEdit.Append(id=wxID_AUTOFINDRESRB, kind=wx.ITEM_NORMAL,text='Auto find residues', |
---|
2598 | Â Â Â Â Â Â help='Auto find of residue RBs in macromolecule') |
---|
2599 |     self.RigidBodiesEdit.Append(id=wxID_COPYRBPARMS, kind=wx.ITEM_NORMAL,text='Copy rigid body parms', |
---|
2600 | Â Â Â Â Â Â help='Copy rigid body location & TLS parameters') |
---|
2601 |     self.RigidBodiesEdit.Append(id=wxID_GLOBALTHERM, kind=wx.ITEM_NORMAL,text='Global thermal motion', |
---|
2602 | Â Â Â Â Â Â help='Global setting of residue thermal motion models') |
---|
2603 |     self.RigidBodiesEdit.Append(id=wxID_GLOBALRESREFINE, kind=wx.ITEM_NORMAL,text='Global residue refine', |
---|
2604 | Â Â Â Â Â Â help='Global setting of residue RB refinement flags') |
---|
2605 |     self.RigidBodiesEdit.Append(id=wxID_RBREMOVEALL, kind=wx.ITEM_NORMAL,text='Remove all rigid bodies', |
---|
2606 | Â Â Â Â Â Â help='Remove all rigid body assignment for atoms') |
---|
2607 | Â Â Â Â self.PostfillDataMenu() |
---|
2608 | Â Â # end of GSAS-II menu definitions |
---|
2609 | Â Â Â Â |
---|
2610 |   def _init_ctrls(self, parent,name=None,size=None,pos=None): |
---|
2611 | Â Â Â Â wx.Frame.__init__( |
---|
2612 | Â Â Â Â Â Â self,parent=parent, |
---|
2613 | Â Â Â Â Â Â #style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX | wx.FRAME_FLOAT_ON_PARENT , |
---|
2614 | Â Â Â Â Â Â style=wx.DEFAULT_FRAME_STYLE ^Â wx.CLOSE_BOX, |
---|
2615 | Â Â Â Â Â Â size=size,pos=pos,title='GSAS-II data display') |
---|
2616 | Â Â Â Â self._init_menus() |
---|
2617 |     if name: |
---|
2618 | Â Â Â Â Â Â self.SetLabel(name) |
---|
2619 | Â Â Â Â self.Show() |
---|
2620 | Â Â Â Â |
---|
2621 |   def __init__(self,parent,frame,data=None,name=None, size=None,pos=None): |
---|
2622 | Â Â Â Â self.G2frame =Â frame |
---|
2623 | Â Â Â Â self._init_ctrls(parent,name,size,pos) |
---|
2624 | Â Â Â Â self.data =Â data |
---|
2625 | Â Â Â Â clientSize =Â wx.ClientDisplayRect() |
---|
2626 | Â Â Â Â Size =Â self.GetSize() |
---|
2627 | Â Â Â Â xPos =Â clientSize[2]-Size[0] |
---|
2628 | Â Â Â Â self.SetPosition(wx.Point(xPos,clientSize[1]+250)) |
---|
2629 | Â Â Â Â self.AtomGrid =Â [] |
---|
2630 | Â Â Â Â self.selectedRow =Â 0 |
---|
2631 | Â Â Â Â |
---|
2632 |   def setSizePosLeft(self,Width): |
---|
2633 | Â Â Â Â clientSize =Â wx.ClientDisplayRect() |
---|
2634 | Â Â Â Â Width[1]Â =Â min(Width[1],clientSize[2]-300) |
---|
2635 | Â Â Â Â Width[0]Â =Â max(Width[0],300) |
---|
2636 | Â Â Â Â self.SetSize(Width) |
---|
2637 | #Â Â Â Â self.SetPosition(wx.Point(clientSize[2]-Width[0],clientSize[1]+250)) |
---|
2638 | Â Â Â Â |
---|
2639 |   def Clear(self): |
---|
2640 | Â Â Â Â self.ClearBackground() |
---|
2641 | Â Â Â Â self.DestroyChildren() |
---|
2642 | Â Â Â Â Â Â Â Â Â Â |
---|
2643 | ################################################################################ |
---|
2644 | #####Â GSNotebook |
---|
2645 | ################################################################################Â Â Â Â Â Â |
---|
2646 | Â Â Â Â |
---|
2647 | class GSNoteBook(wx.aui.AuiNotebook): |
---|
2648 | Â Â '''Notebook used in various locations; implemented with wx.aui extension |
---|
2649 | Â Â ''' |
---|
2650 |   def __init__(self, parent, name='',size = None): |
---|
2651 |     wx.aui.AuiNotebook.__init__(self, parent, -1, |
---|
2652 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â style=wx.aui.AUI_NB_TOP | |
---|
2653 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â wx.aui.AUI_NB_SCROLL_BUTTONS) |
---|
2654 |     if size: self.SetSize(size) |
---|
2655 | Â Â Â Â self.parent =Â parent |
---|
2656 | Â Â Â Â self.PageChangeHandler =Â None |
---|
2657 | Â Â Â Â |
---|
2658 |   def PageChangeEvent(self,event): |
---|
2659 | Â Â Â Â G2frame =Â self.parent.G2frame |
---|
2660 | Â Â Â Â page =Â event.GetSelection() |
---|
2661 |     if self.PageChangeHandler: |
---|
2662 |       if log.LogInfo['Logging']: |
---|
2663 | Â Â Â Â Â Â Â Â log.MakeTabLog( |
---|
2664 | Â Â Â Â Â Â Â Â Â Â G2frame.dataFrame.GetTitle(), |
---|
2665 | Â Â Â Â Â Â Â Â Â Â G2frame.dataDisplay.GetPageText(page) |
---|
2666 | Â Â Â Â Â Â Â Â Â Â ) |
---|
2667 | Â Â Â Â Â Â self.PageChangeHandler(event) |
---|
2668 | Â Â Â Â Â Â |
---|
2669 |   def Bind(self,eventtype,handler,*args,**kwargs): |
---|
2670 | Â Â Â Â '''Override the Bind() function so that page change events can be trapped |
---|
2671 | Â Â Â Â ''' |
---|
2672 |     if eventtype == wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED: |
---|
2673 | Â Â Â Â Â Â self.PageChangeHandler =Â handler |
---|
2674 | Â Â Â Â Â Â wx.aui.AuiNotebook.Bind(self,eventtype,self.PageChangeEvent) |
---|
2675 | Â Â Â Â Â Â return |
---|
2676 | Â Â Â Â wx.aui.AuiNotebook.Bind(self,eventtype,handler,*args,**kwargs) |
---|
2677 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
2678 |   def Clear(self):    |
---|
2679 | Â Â Â Â GSNoteBook.DeleteAllPages(self) |
---|
2680 | Â Â Â Â |
---|
2681 |   def FindPage(self,name): |
---|
2682 | Â Â Â Â numPage =Â self.GetPageCount() |
---|
2683 |     for page in range(numPage): |
---|
2684 |       if self.GetPageText(page) == name: |
---|
2685 |         return page |
---|
2686 | |
---|
2687 |   def ChangeSelection(self,page): |
---|
2688 | Â Â Â Â # in wx.Notebook ChangeSelection is like SetSelection, but it |
---|
2689 | Â Â Â Â # does not invoke the event related to pressing the tab button |
---|
2690 | Â Â Â Â # I don't see a way to do that in aui. |
---|
2691 | Â Â Â Â oldPage =Â self.GetSelection() |
---|
2692 | Â Â Â Â self.SetSelection(page) |
---|
2693 |     return oldPage |
---|
2694 | |
---|
2695 | Â Â # def __getattribute__(self,name): |
---|
2696 | Â Â #Â Â Â '''This method provides a way to print out a message every time |
---|
2697 | Â Â #Â Â Â that a method in a class is called -- to see what all the calls |
---|
2698 | Â Â #Â Â Â might be, or where they might be coming from. |
---|
2699 | Â Â #Â Â Â Cute trick for debugging! |
---|
2700 | Â Â #Â Â Â ''' |
---|
2701 | Â Â #Â Â Â attr = object.__getattribute__(self, name) |
---|
2702 | Â Â #Â Â Â if hasattr(attr, '__call__'): |
---|
2703 | Â Â #Â Â Â Â Â def newfunc(*args, **kwargs): |
---|
2704 | Â Â #Â Â Â Â Â Â Â print('GSauiNoteBook calling %s' %attr.__name__) |
---|
2705 | Â Â #Â Â Â Â Â Â Â result = attr(*args, **kwargs) |
---|
2706 | Â Â #Â Â Â Â Â Â Â return result |
---|
2707 | Â Â #Â Â Â Â Â return newfunc |
---|
2708 | Â Â #Â Â Â else: |
---|
2709 | Â Â #Â Â Â Â Â return attr |
---|
2710 | Â Â Â Â Â Â |
---|
2711 | ################################################################################ |
---|
2712 | #####Â GSGrid |
---|
2713 | ################################################################################Â Â Â Â Â Â |
---|
2714 | Â Â Â Â |
---|
2715 | class GSGrid(wg.Grid): |
---|
2716 | Â Â '''Basic wx.Grid implementation |
---|
2717 | Â Â ''' |
---|
2718 |   def __init__(self, parent, name=''): |
---|
2719 | Â Â Â Â wg.Grid.__init__(self,parent,-1,name=name)Â Â Â Â Â Â Â Â Â Â |
---|
2720 | Â Â Â Â #self.SetSize(parent.GetClientSize()) |
---|
2721 | Â Â Â Â # above removed to speed drawing of initial grid |
---|
2722 | Â Â Â Â # does not appear to be needed |
---|
2723 | Â Â Â Â Â Â |
---|
2724 |   def Clear(self): |
---|
2725 | Â Â Â Â wg.Grid.ClearGrid(self) |
---|
2726 | Â Â Â Â |
---|
2727 |   def SetCellReadOnly(self,r,c,readonly=True): |
---|
2728 | Â Â Â Â self.SetReadOnly(r,c,isReadOnly=readonly) |
---|
2729 | Â Â Â Â |
---|
2730 |   def SetCellStyle(self,r,c,color="white",readonly=True): |
---|
2731 | Â Â Â Â self.SetCellBackgroundColour(r,c,color) |
---|
2732 | Â Â Â Â self.SetReadOnly(r,c,isReadOnly=readonly) |
---|
2733 | Â Â Â Â |
---|
2734 |   def GetSelection(self): |
---|
2735 | Â Â Â Â #this is to satisfy structure drawing stuff in G2plt when focus changes |
---|
2736 |     return None |
---|
2737 | |
---|
2738 |   def InstallGridToolTip(self, rowcolhintcallback, |
---|
2739 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â colLblCallback=None,rowLblCallback=None): |
---|
2740 | Â Â Â Â '''code to display a tooltip for each item on a grid |
---|
2741 | Â Â Â Â from http://wiki.wxpython.org/wxGrid%20ToolTips (buggy!), expanded to |
---|
2742 | Â Â Â Â column and row labels using hints from |
---|
2743 | Â Â Â Â https://groups.google.com/forum/#!topic/wxPython-users/bm8OARRVDCs |
---|
2744 | |
---|
2745 | Â Â Â Â :param function rowcolhintcallback: a routine that returns a text |
---|
2746 | Â Â Â Â Â string depending on the selected row and column, to be used in |
---|
2747 | Â Â Â Â Â explaining grid entries. |
---|
2748 | Â Â Â Â :param function colLblCallback: a routine that returns a text |
---|
2749 | Â Â Â Â Â string depending on the selected column, to be used in |
---|
2750 | Â Â Â Â Â explaining grid columns (if None, the default), column labels |
---|
2751 | Â Â Â Â Â do not get a tooltip. |
---|
2752 | Â Â Â Â :param function rowLblCallback: a routine that returns a text |
---|
2753 | Â Â Â Â Â string depending on the selected row, to be used in |
---|
2754 | Â Â Â Â Â explaining grid rows (if None, the default), row labels |
---|
2755 | Â Â Â Â Â do not get a tooltip. |
---|
2756 | Â Â Â Â ''' |
---|
2757 | Â Â Â Â prev_rowcol =Â [None,None,None] |
---|
2758 |     def OnMouseMotion(event): |
---|
2759 | Â Â Â Â Â Â # event.GetRow() and event.GetCol() would be nice to have here, |
---|
2760 | Â Â Â Â Â Â # but as this is a mouse event, not a grid event, they are not |
---|
2761 | Â Â Â Â Â Â # available and we need to compute them by hand. |
---|
2762 |       x, y = self.CalcUnscrolledPosition(event.GetPosition()) |
---|
2763 | Â Â Â Â Â Â row =Â self.YToRow(y) |
---|
2764 | Â Â Â Â Â Â col =Â self.XToCol(x) |
---|
2765 | Â Â Â Â Â Â hinttext =Â '' |
---|
2766 | Â Â Â Â Â Â win =Â event.GetEventObject() |
---|
2767 |       if [row,col,win] == prev_rowcol: # no change from last position |
---|
2768 | Â Â Â Â Â Â Â Â event.Skip() |
---|
2769 | Â Â Â Â Â Â Â Â return |
---|
2770 |       if win == self.GetGridWindow() and row >= 0 and col >= 0: |
---|
2771 |         hinttext = rowcolhintcallback(row, col) |
---|
2772 |       elif win == self.GetGridColLabelWindow() and col >= 0: |
---|
2773 |         if colLblCallback: hinttext = colLblCallback(col) |
---|
2774 |       elif win == self.GetGridRowLabelWindow() and row >= 0: |
---|
2775 |         if rowLblCallback: hinttext = rowLblCallback(row) |
---|
2776 | Â Â Â Â Â Â else:Â # this should be the upper left corner, which is empty |
---|
2777 | Â Â Â Â Â Â Â Â event.Skip() |
---|
2778 | Â Â Â Â Â Â Â Â return |
---|
2779 |       if hinttext is None: hinttext = '' |
---|
2780 | Â Â Â Â Â Â win.SetToolTipString(hinttext) |
---|
2781 | Â Â Â Â Â Â prev_rowcol[:]Â =Â [row,col,win] |
---|
2782 | Â Â Â Â Â Â event.Skip() |
---|
2783 | |
---|
2784 |     wx.EVT_MOTION(self.GetGridWindow(), OnMouseMotion) |
---|
2785 |     if colLblCallback: wx.EVT_MOTION(self.GetGridColLabelWindow(), OnMouseMotion) |
---|
2786 |     if rowLblCallback: wx.EVT_MOTION(self.GetGridRowLabelWindow(), OnMouseMotion) |
---|
2787 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
2788 | ################################################################################ |
---|
2789 | #####Â Table |
---|
2790 | ################################################################################Â Â Â Â Â Â |
---|
2791 | Â Â Â Â |
---|
2792 | class Table(wg.PyGridTableBase): |
---|
2793 | Â Â '''Basic data table for use with GSgrid |
---|
2794 | Â Â ''' |
---|
2795 |   def __init__(self, data=[], rowLabels=None, colLabels=None, types = None): |
---|
2796 | Â Â Â Â wg.PyGridTableBase.__init__(self) |
---|
2797 | Â Â Â Â self.colLabels =Â colLabels |
---|
2798 | Â Â Â Â self.rowLabels =Â rowLabels |
---|
2799 | Â Â Â Â self.dataTypes =Â types |
---|
2800 | Â Â Â Â self.data =Â data |
---|
2801 | Â Â Â Â |
---|
2802 |   def AppendRows(self, numRows=1): |
---|
2803 | Â Â Â Â self.data.append([]) |
---|
2804 |     return True |
---|
2805 | Â Â Â Â |
---|
2806 |   def CanGetValueAs(self, row, col, typeName): |
---|
2807 |     if self.dataTypes: |
---|
2808 | Â Â Â Â Â Â colType =Â self.dataTypes[col].split(':')[0] |
---|
2809 |       if typeName == colType: |
---|
2810 |         return True |
---|
2811 | Â Â Â Â Â Â else: |
---|
2812 |         return False |
---|
2813 | Â Â Â Â else: |
---|
2814 |       return False |
---|
2815 | |
---|
2816 |   def CanSetValueAs(self, row, col, typeName): |
---|
2817 |     return self.CanGetValueAs(row, col, typeName) |
---|
2818 | |
---|
2819 |   def DeleteRow(self,pos): |
---|
2820 | Â Â Â Â data =Â self.GetData() |
---|
2821 | Â Â Â Â self.SetData([]) |
---|
2822 | Â Â Â Â new =Â [] |
---|
2823 |     for irow,row in enumerate(data): |
---|
2824 |       if irow <> pos: |
---|
2825 | Â Â Â Â Â Â Â Â new.append(row) |
---|
2826 | Â Â Â Â self.SetData(new) |
---|
2827 | Â Â Â Â |
---|
2828 |   def GetColLabelValue(self, col): |
---|
2829 |     if self.colLabels: |
---|
2830 |       return self.colLabels[col] |
---|
2831 | Â Â Â Â Â Â |
---|
2832 |   def GetData(self): |
---|
2833 | Â Â Â Â data =Â [] |
---|
2834 |     for row in range(self.GetNumberRows()): |
---|
2835 | Â Â Â Â Â Â data.append(self.GetRowValues(row)) |
---|
2836 |     return data |
---|
2837 | Â Â Â Â |
---|
2838 |   def GetNumberCols(self): |
---|
2839 | Â Â Â Â try: |
---|
2840 |       return len(self.colLabels) |
---|
2841 |     except TypeError: |
---|
2842 |       return None |
---|
2843 | Â Â Â Â |
---|
2844 |   def GetNumberRows(self): |
---|
2845 |     return len(self.data) |
---|
2846 | Â Â Â Â |
---|
2847 |   def GetRowLabelValue(self, row): |
---|
2848 |     if self.rowLabels: |
---|
2849 |       return self.rowLabels[row] |
---|
2850 | Â Â Â Â |
---|
2851 |   def GetColValues(self, col): |
---|
2852 | Â Â Â Â data =Â [] |
---|
2853 |     for row in range(self.GetNumberRows()): |
---|
2854 |       data.append(self.GetValue(row, col)) |
---|
2855 |     return data |
---|
2856 | Â Â Â Â |
---|
2857 |   def GetRowValues(self, row): |
---|
2858 | Â Â Â Â data =Â [] |
---|
2859 |     for col in range(self.GetNumberCols()): |
---|
2860 |       data.append(self.GetValue(row, col)) |
---|
2861 |     return data |
---|
2862 | Â Â Â Â |
---|
2863 |   def GetTypeName(self, row, col): |
---|
2864 | Â Â Â Â try: |
---|
2865 |       if self.data[row][col] is None: return None |
---|
2866 |       return self.dataTypes[col] |
---|
2867 |     except TypeError: |
---|
2868 |       return None |
---|
2869 | |
---|
2870 |   def GetValue(self, row, col): |
---|
2871 | Â Â Â Â try: |
---|
2872 |       if self.data[row][col] is None: return "" |
---|
2873 |       return self.data[row][col] |
---|
2874 |     except IndexError: |
---|
2875 |       return None |
---|
2876 | Â Â Â Â Â Â |
---|
2877 |   def InsertRows(self, pos, rows): |
---|
2878 |     for row in range(rows): |
---|
2879 | Â Â Â Â Â Â self.data.insert(pos,[]) |
---|
2880 | Â Â Â Â Â Â pos +=Â 1 |
---|
2881 | Â Â Â Â |
---|
2882 |   def IsEmptyCell(self,row,col): |
---|
2883 | Â Â Â Â try: |
---|
2884 |       return not self.data[row][col] |
---|
2885 |     except IndexError: |
---|
2886 |       return True |
---|
2887 | Â Â Â Â |
---|
2888 |   def OnKeyPress(self, event): |
---|
2889 | Â Â Â Â dellist =Â self.GetSelectedRows() |
---|
2890 |     if event.GetKeyCode() == wx.WXK_DELETE and dellist: |
---|
2891 | Â Â Â Â Â Â grid =Â self.GetView() |
---|
2892 |       for i in dellist: grid.DeleteRow(i) |
---|
2893 | Â Â Â Â Â Â Â Â |
---|
2894 |   def SetColLabelValue(self, col, label): |
---|
2895 | Â Â Â Â numcols =Â self.GetNumberCols() |
---|
2896 |     if col > numcols-1: |
---|
2897 | Â Â Â Â Â Â self.colLabels.append(label) |
---|
2898 | Â Â Â Â else: |
---|
2899 | Â Â Â Â Â Â self.colLabels[col]=label |
---|
2900 | Â Â Â Â |
---|
2901 |   def SetData(self,data): |
---|
2902 |     for row in range(len(data)): |
---|
2903 | Â Â Â Â Â Â self.SetRowValues(row,data[row]) |
---|
2904 | Â Â Â Â Â Â Â Â |
---|
2905 |   def SetRowLabelValue(self, row, label): |
---|
2906 | Â Â Â Â self.rowLabels[row]=label |
---|
2907 | Â Â Â Â Â Â |
---|
2908 |   def SetRowValues(self,row,data): |
---|
2909 | Â Â Â Â self.data[row]Â =Â data |
---|
2910 | Â Â Â Â Â Â |
---|
2911 |   def SetValue(self, row, col, value): |
---|
2912 |     def innerSetValue(row, col, value): |
---|
2913 | Â Â Â Â Â Â try: |
---|
2914 | Â Â Â Â Â Â Â Â self.data[row][col]Â =Â value |
---|
2915 |       except TypeError: |
---|
2916 | Â Â Â Â Â Â Â Â return |
---|
2917 |       except IndexError: |
---|
2918 |         print row,col,value |
---|
2919 | Â Â Â Â Â Â Â Â # add a new row |
---|
2920 |         if row > self.GetNumberRows(): |
---|
2921 | Â Â Â Â Â Â Â Â Â Â self.data.append(['']Â *Â self.GetNumberCols()) |
---|
2922 |         elif col > self.GetNumberCols(): |
---|
2923 |           for row in range(self.GetNumberRows): |
---|
2924 | Â Â Â Â Â Â Â Â Â Â Â Â self.data[row].append('') |
---|
2925 |         print self.data |
---|
2926 | Â Â Â Â Â Â Â Â self.data[row][col]Â =Â value |
---|
2927 |     innerSetValue(row, col, value) |
---|
2928 | Â Â Â Â |
---|
2929 | ################################################################################ |
---|
2930 | #### Help |
---|
2931 | ################################################################################ |
---|
2932 | |
---|
2933 | def ShowHelp(helpType,frame): |
---|
2934 | Â Â '''Called to bring up a web page for documentation.''' |
---|
2935 |   global htmlFirstUse |
---|
2936 | Â Â # look up a definition for help info from dict |
---|
2937 | Â Â helplink =Â helpLocDict.get(helpType) |
---|
2938 |   if helplink is None: |
---|
2939 | Â Â Â Â # no defined link to use, create a default based on key |
---|
2940 | Â Â Â Â helplink =Â 'gsasII.html#'+helpType.replace(' ','_') |
---|
2941 | Â Â helplink =Â os.path.join(path2GSAS2,'help',helplink) |
---|
2942 |   if helpMode == 'internal': |
---|
2943 | Â Â Â Â try: |
---|
2944 | Â Â Â Â Â Â htmlPanel.LoadFile(helplink) |
---|
2945 | Â Â Â Â Â Â htmlFrame.Raise() |
---|
2946 | Â Â Â Â except: |
---|
2947 |       htmlFrame = wx.Frame(frame, -1, size=(610, 510)) |
---|
2948 | Â Â Â Â Â Â htmlFrame.Show(True) |
---|
2949 | Â Â Â Â Â Â htmlFrame.SetTitle("HTML Window")Â # N.B. reset later in LoadFile |
---|
2950 | Â Â Â Â Â Â htmlPanel =Â MyHtmlPanel(htmlFrame,-1) |
---|
2951 | Â Â Â Â Â Â htmlPanel.LoadFile(helplink) |
---|
2952 | Â Â else: |
---|
2953 | Â Â Â Â pfx =Â "file://" |
---|
2954 |     if sys.platform.lower().startswith('win'): |
---|
2955 | Â Â Â Â Â Â pfx =Â '' |
---|
2956 |     if htmlFirstUse: |
---|
2957 | Â Â Â Â Â Â webbrowser.open_new(pfx+helplink) |
---|
2958 | Â Â Â Â Â Â htmlFirstUse =Â False |
---|
2959 | Â Â Â Â else: |
---|
2960 |       webbrowser.open(pfx+helplink, new=0, autoraise=True) |
---|
2961 | |
---|
2962 | ################################################################################ |
---|
2963 | #####Â Notebook |
---|
2964 | ################################################################################Â Â Â Â Â Â |
---|
2965 | Â Â Â Â |
---|
2966 | def UpdateNotebook(G2frame,data): |
---|
2967 | Â Â '''Called when the data tree notebook entry is selected. Allows for |
---|
2968 | Â Â editing of the text in that tree entry |
---|
2969 | Â Â ''' |
---|
2970 |   def OnNoteBook(event): |
---|
2971 | Â Â Â Â data =Â G2frame.dataDisplay.GetValue().split('\n') |
---|
2972 | Â Â Â Â G2frame.PatternTree.SetItemPyData(GetPatternTreeItemId(G2frame,G2frame.root,'Notebook'),data) |
---|
2973 |     if 'nt' not in os.name: |
---|
2974 | Â Â Â Â Â Â G2frame.dataDisplay.AppendText('\n') |
---|
2975 | Â Â Â Â Â Â Â Â Â Â |
---|
2976 |   if G2frame.dataDisplay: |
---|
2977 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
2978 | Â Â G2frame.dataFrame.SetLabel('Notebook') |
---|
2979 | Â Â G2frame.dataDisplay =Â wx.TextCtrl(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize(), |
---|
2980 | Â Â Â Â style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER |Â wx.TE_DONTWRAP) |
---|
2981 | Â Â G2frame.dataDisplay.Bind(wx.EVT_TEXT_ENTER,OnNoteBook) |
---|
2982 | Â Â G2frame.dataDisplay.Bind(wx.EVT_KILL_FOCUS,OnNoteBook) |
---|
2983 |   for line in data: |
---|
2984 | Â Â Â Â G2frame.dataDisplay.AppendText(line+"\n") |
---|
2985 | Â Â G2frame.dataDisplay.AppendText('Notebook entry @ '+time.ctime()+"\n") |
---|
2986 | Â Â G2frame.dataFrame.setSizePosLeft([400,250]) |
---|
2987 | Â Â Â Â Â Â |
---|
2988 | ################################################################################ |
---|
2989 | #####Â Controls |
---|
2990 | ################################################################################Â Â Â Â Â Â |
---|
2991 | Â Â Â Â |
---|
2992 | def UpdateControls(G2frame,data): |
---|
2993 | Â Â '''Edit overall GSAS-II controls in main Controls data tree entry |
---|
2994 | Â Â ''' |
---|
2995 | Â Â #patch |
---|
2996 |   if 'deriv type' not in data: |
---|
2997 | Â Â Â Â data =Â {} |
---|
2998 | Â Â Â Â data['deriv type']Â =Â 'analytic Hessian' |
---|
2999 | Â Â Â Â data['min dM/M']Â =Â 0.0001 |
---|
3000 | Â Â Â Â data['shift factor']Â =Â 1. |
---|
3001 | Â Â Â Â data['max cyc']Â =Â 3Â Â Â Â |
---|
3002 | Â Â Â Â data['F**2']Â =Â True |
---|
3003 | Â Â Â Â data['minF/sig']Â =Â 0 |
---|
3004 |   if 'shift factor' not in data: |
---|
3005 | Â Â Â Â data['shift factor']Â =Â 1. |
---|
3006 |   if 'max cyc' not in data: |
---|
3007 | Â Â Â Â data['max cyc']Â =Â 3 |
---|
3008 |   if 'F**2' not in data: |
---|
3009 | Â Â Â Â data['F**2']Â =Â True |
---|
3010 | Â Â Â Â data['minF/sig']Â =Â 0 |
---|
3011 |   if 'Author' not in data: |
---|
3012 | Â Â Â Â data['Author']Â =Â 'no name' |
---|
3013 |   if 'FreePrm1' not in data: |
---|
3014 | Â Â Â Â data['FreePrm1']Â =Â 'Sample humidity (%)' |
---|
3015 |   if 'FreePrm2' not in data: |
---|
3016 | Â Â Â Â data['FreePrm2']Â =Â 'Sample voltage (V)' |
---|
3017 |   if 'FreePrm3' not in data: |
---|
3018 | Â Â Â Â data['FreePrm3']Â =Â 'Applied load (MN)' |
---|
3019 |   if 'Copy2Next' not in data: |
---|
3020 | Â Â Â Â data['Copy2Next']Â =Â False |
---|
3021 |   if 'Reverse Seq' not in data: |
---|
3022 |     data['Reverse Seq'] = False  |
---|
3023 | Â Â Â |
---|
3024 | Â Â |
---|
3025 | Â Â #end patch |
---|
3026 | |
---|
3027 |   def SeqSizer(): |
---|
3028 | Â Â Â Â |
---|
3029 |     def OnSelectData(event): |
---|
3030 | Â Â Â Â Â Â choices =Â GetPatternTreeDataNames(G2frame,['PWDR',]) |
---|
3031 | Â Â Â Â Â Â sel =Â [] |
---|
3032 |       if 'Seq Data' in data: |
---|
3033 |         for item in data['Seq Data']: |
---|
3034 | Â Â Â Â Â Â Â Â Â Â sel.append(choices.index(item)) |
---|
3035 |         sel = [choices.index(item) for item in data['Seq Data']] |
---|
3036 |       dlg = G2MultiChoiceDialog(G2frame.dataFrame, 'Sequential refinement', |
---|
3037 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Select dataset to include', |
---|
3038 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â choices) |
---|
3039 | Â Â Â Â Â Â dlg.SetSelections(sel) |
---|
3040 | Â Â Â Â Â Â names =Â [] |
---|
3041 |       if dlg.ShowModal() == wx.ID_OK: |
---|
3042 |         for sel in dlg.GetSelections(): |
---|
3043 | Â Â Â Â Â Â Â Â Â Â names.append(choices[sel]) |
---|
3044 |         data['Seq Data'] = names        |
---|
3045 | Â Â Â Â Â Â Â Â G2frame.EnableSeqRefineMenu() |
---|
3046 | Â Â Â Â Â Â dlg.Destroy() |
---|
3047 | Â Â Â Â Â Â wx.CallAfter(UpdateControls,G2frame,data) |
---|
3048 | Â Â Â Â Â Â |
---|
3049 |     def OnReverse(event): |
---|
3050 | Â Â Â Â Â Â data['Reverse Seq']Â =Â reverseSel.GetValue() |
---|
3051 | Â Â Â Â Â Â |
---|
3052 |     def OnCopySel(event): |
---|
3053 | Â Â Â Â Â Â data['Copy2Next']Â =Â copySel.GetValue()Â |
---|
3054 | Â Â Â Â Â Â Â Â Â Â |
---|
3055 | Â Â Â Â seqSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
3056 | Â Â Â Â dataSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3057 | Â Â Â Â dataSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Sequential Refinement: '),0,WACV) |
---|
3058 | Â Â Â Â selSeqData =Â wx.Button(G2frame.dataDisplay,-1,label=' Select data') |
---|
3059 | Â Â Â Â selSeqData.Bind(wx.EVT_BUTTON,OnSelectData) |
---|
3060 | Â Â Â Â dataSizer.Add(selSeqData,0,WACV) |
---|
3061 | Â Â Â Â SeqData =Â data.get('Seq Data',[]) |
---|
3062 |     if not SeqData: |
---|
3063 | Â Â Â Â Â Â lbl =Â ' (no powder data selected)' |
---|
3064 | Â Â Â Â else: |
---|
3065 | Â Â Â Â Â Â lbl =Â ' ('+str(len(SeqData))+' dataset(s) selected)' |
---|
3066 | |
---|
3067 | Â Â Â Â dataSizer.Add(wx.StaticText(G2frame.dataDisplay,label=lbl),0,WACV) |
---|
3068 | Â Â Â Â seqSizer.Add(dataSizer,0) |
---|
3069 |     if SeqData: |
---|
3070 | Â Â Â Â Â Â selSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3071 | Â Â Â Â Â Â reverseSel =Â wx.CheckBox(G2frame.dataDisplay,-1,label=' Reverse order?') |
---|
3072 | Â Â Â Â Â Â reverseSel.Bind(wx.EVT_CHECKBOX,OnReverse) |
---|
3073 | Â Â Â Â Â Â reverseSel.SetValue(data['Reverse Seq']) |
---|
3074 | Â Â Â Â Â Â selSizer.Add(reverseSel,0,WACV) |
---|
3075 | Â Â Â Â Â Â copySel =Â wx.CheckBox(G2frame.dataDisplay,-1,label=' Copy results to next histogram?') |
---|
3076 | Â Â Â Â Â Â copySel.Bind(wx.EVT_CHECKBOX,OnCopySel) |
---|
3077 | Â Â Â Â Â Â copySel.SetValue(data['Copy2Next']) |
---|
3078 | Â Â Â Â Â Â selSizer.Add(copySel,0,WACV) |
---|
3079 | Â Â Â Â Â Â seqSizer.Add(selSizer,0) |
---|
3080 |     return seqSizer |
---|
3081 | Â Â Â Â |
---|
3082 |   def LSSizer():    |
---|
3083 | Â Â Â Â |
---|
3084 |     def OnDerivType(event): |
---|
3085 | Â Â Â Â Â Â data['deriv type']Â =Â derivSel.GetValue() |
---|
3086 | Â Â Â Â Â Â derivSel.SetValue(data['deriv type']) |
---|
3087 | Â Â Â Â Â Â wx.CallAfter(UpdateControls,G2frame,data) |
---|
3088 | Â Â Â Â Â Â |
---|
3089 |     def OnConvergence(event): |
---|
3090 | Â Â Â Â Â Â try: |
---|
3091 | Â Â Â Â Â Â Â Â value =Â max(1.e-9,min(1.0,float(Cnvrg.GetValue()))) |
---|
3092 |       except ValueError: |
---|
3093 | Â Â Â Â Â Â Â Â value =Â 0.0001 |
---|
3094 | Â Â Â Â Â Â data['min dM/M']Â =Â value |
---|
3095 | Â Â Â Â Â Â Cnvrg.SetValue('%.2g'%(value)) |
---|
3096 | Â Â Â Â Â Â |
---|
3097 |     def OnMaxCycles(event): |
---|
3098 | Â Â Â Â Â Â data['max cyc']Â =Â int(maxCyc.GetValue()) |
---|
3099 | Â Â Â Â Â Â maxCyc.SetValue(str(data['max cyc'])) |
---|
3100 | Â Â Â Â Â Â Â Â Â Â Â Â |
---|
3101 |     def OnFactor(event): |
---|
3102 | Â Â Â Â Â Â try: |
---|
3103 | Â Â Â Â Â Â Â Â value =Â min(max(float(Factr.GetValue()),0.00001),100.) |
---|
3104 |       except ValueError: |
---|
3105 | Â Â Â Â Â Â Â Â value =Â 1.0 |
---|
3106 | Â Â Â Â Â Â data['shift factor']Â =Â value |
---|
3107 | Â Â Â Â Â Â Factr.SetValue('%.5f'%(value)) |
---|
3108 | Â Â Â Â Â Â |
---|
3109 |     def OnFsqRef(event): |
---|
3110 | Â Â Â Â Â Â data['F**2']Â =Â fsqRef.GetValue() |
---|
3111 | Â Â Â Â |
---|
3112 |     def OnMinSig(event): |
---|
3113 | Â Â Â Â Â Â try: |
---|
3114 | Â Â Â Â Â Â Â Â value =Â min(max(float(minSig.GetValue()),0.),5.) |
---|
3115 |       except ValueError: |
---|
3116 | Â Â Â Â Â Â Â Â value =Â 1.0 |
---|
3117 | Â Â Â Â Â Â data['minF/sig']Â =Â value |
---|
3118 | Â Â Â Â Â Â minSig.SetValue('%.2f'%(value)) |
---|
3119 | |
---|
3120 | Â Â Â Â LSSizer =Â wx.FlexGridSizer(cols=4,vgap=5,hgap=5) |
---|
3121 | Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Refinement derivatives: '),0,WACV) |
---|
3122 | Â Â Â Â Choice=['analytic Jacobian','numeric','analytic Hessian'] |
---|
3123 | Â Â Â Â derivSel =Â wx.ComboBox(parent=G2frame.dataDisplay,value=data['deriv type'],choices=Choice, |
---|
3124 | Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
3125 | Â Â Â Â derivSel.SetValue(data['deriv type']) |
---|
3126 |     derivSel.Bind(wx.EVT_COMBOBOX, OnDerivType) |
---|
3127 | Â Â Â Â Â Â |
---|
3128 | Â Â Â Â LSSizer.Add(derivSel,0,WACV) |
---|
3129 | Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Min delta-M/M: '),0,WACV) |
---|
3130 | Â Â Â Â Cnvrg =Â wx.TextCtrl(G2frame.dataDisplay,-1,value='%.2g'%(data['min dM/M']),style=wx.TE_PROCESS_ENTER) |
---|
3131 | Â Â Â Â Cnvrg.Bind(wx.EVT_TEXT_ENTER,OnConvergence) |
---|
3132 | Â Â Â Â Cnvrg.Bind(wx.EVT_KILL_FOCUS,OnConvergence) |
---|
3133 | Â Â Â Â LSSizer.Add(Cnvrg,0,WACV) |
---|
3134 |     if 'Hessian' in data['deriv type']: |
---|
3135 | Â Â Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Max cycles: '),0,WACV) |
---|
3136 | Â Â Â Â Â Â Choice =Â ['0','1','2','3','5','10','15','20'] |
---|
3137 | Â Â Â Â Â Â maxCyc =Â wx.ComboBox(parent=G2frame.dataDisplay,value=str(data['max cyc']),choices=Choice, |
---|
3138 | Â Â Â Â Â Â Â Â style=wx.CB_READONLY|wx.CB_DROPDOWN) |
---|
3139 | Â Â Â Â Â Â maxCyc.SetValue(str(data['max cyc'])) |
---|
3140 |       maxCyc.Bind(wx.EVT_COMBOBOX, OnMaxCycles) |
---|
3141 | Â Â Â Â Â Â LSSizer.Add(maxCyc,0,WACV) |
---|
3142 | Â Â Â Â else: |
---|
3143 | Â Â Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Initial shift factor: '),0,WACV) |
---|
3144 | Â Â Â Â Â Â Factr =Â wx.TextCtrl(G2frame.dataDisplay,-1,value='%.5f'%(data['shift factor']),style=wx.TE_PROCESS_ENTER) |
---|
3145 | Â Â Â Â Â Â Factr.Bind(wx.EVT_TEXT_ENTER,OnFactor) |
---|
3146 | Â Â Â Â Â Â Factr.Bind(wx.EVT_KILL_FOCUS,OnFactor) |
---|
3147 | Â Â Â Â Â Â LSSizer.Add(Factr,0,WACV) |
---|
3148 |     if G2frame.Sngl: |
---|
3149 | Â Â Â Â Â Â LSSizer.Add((1,0),) |
---|
3150 | Â Â Â Â Â Â LSSizer.Add((1,0),) |
---|
3151 | Â Â Â Â Â Â fsqRef =Â wx.CheckBox(G2frame.dataDisplay,-1,label='Refine HKLF as F^2? ') |
---|
3152 | Â Â Â Â Â Â fsqRef.SetValue(data['F**2']) |
---|
3153 | Â Â Â Â Â Â fsqRef.Bind(wx.EVT_CHECKBOX,OnFsqRef) |
---|
3154 | Â Â Â Â Â Â LSSizer.Add(fsqRef,0,WACV) |
---|
3155 | Â Â Â Â Â Â LSSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,label='Min obs/sig (0-5): '),0,WACV) |
---|
3156 | Â Â Â Â Â Â minSig =Â wx.TextCtrl(G2frame.dataDisplay,-1,value='%.2f'%(data['minF/sig']),style=wx.TE_PROCESS_ENTER) |
---|
3157 | Â Â Â Â Â Â minSig.Bind(wx.EVT_TEXT_ENTER,OnMinSig) |
---|
3158 | Â Â Â Â Â Â minSig.Bind(wx.EVT_KILL_FOCUS,OnMinSig) |
---|
3159 | Â Â Â Â Â Â LSSizer.Add(minSig,0,WACV) |
---|
3160 |     return LSSizer |
---|
3161 | Â Â Â Â |
---|
3162 |   def AuthSizer(): |
---|
3163 | |
---|
3164 |     def OnAuthor(event): |
---|
3165 | Â Â Â Â Â Â data['Author']Â =Â auth.GetValue() |
---|
3166 | |
---|
3167 | Â Â Â Â Author =Â data['Author'] |
---|
3168 | Â Â Â Â authSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
3169 | Â Â Â Â authSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' CIF Author (last, first):'),0,WACV) |
---|
3170 | Â Â Â Â auth =Â wx.TextCtrl(G2frame.dataDisplay,-1,value=Author,style=wx.TE_PROCESS_ENTER) |
---|
3171 | Â Â Â Â auth.Bind(wx.EVT_TEXT_ENTER,OnAuthor) |
---|
3172 | Â Â Â Â auth.Bind(wx.EVT_KILL_FOCUS,OnAuthor) |
---|
3173 | Â Â Â Â authSizer.Add(auth,0,WACV) |
---|
3174 |     return authSizer |
---|
3175 | Â Â Â Â |
---|
3176 | Â Â Â Â |
---|
3177 |   if G2frame.dataDisplay: |
---|
3178 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
3179 |   if not G2frame.dataFrame.GetStatusBar(): |
---|
3180 | Â Â Â Â Status =Â G2frame.dataFrame.CreateStatusBar() |
---|
3181 | Â Â Â Â Status.SetStatusText('') |
---|
3182 | Â Â G2frame.dataFrame.SetLabel('Controls') |
---|
3183 | Â Â G2frame.dataDisplay =Â wx.Panel(G2frame.dataFrame) |
---|
3184 | Â Â SetDataMenuBar(G2frame,G2frame.dataFrame.ControlsMenu) |
---|
3185 | Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
3186 | Â Â mainSizer.Add((5,5),0) |
---|
3187 | Â Â mainSizer.Add(wx.StaticText(G2frame.dataDisplay,label=' Refinement Controls:'),0,WACV)Â Â |
---|
3188 | Â Â mainSizer.Add(LSSizer()) |
---|
3189 | Â Â mainSizer.Add((5,5),0) |
---|
3190 | Â Â mainSizer.Add(SeqSizer()) |
---|
3191 | Â Â mainSizer.Add((5,5),0) |
---|
3192 | Â Â mainSizer.Add(AuthSizer()) |
---|
3193 | Â Â mainSizer.Add((5,5),0) |
---|
3194 | Â Â Â Â |
---|
3195 | Â Â mainSizer.Layout()Â Â |
---|
3196 | Â Â G2frame.dataDisplay.SetSizer(mainSizer) |
---|
3197 | Â Â G2frame.dataDisplay.SetSize(mainSizer.Fit(G2frame.dataFrame)) |
---|
3198 | Â Â G2frame.dataFrame.setSizePosLeft(mainSizer.Fit(G2frame.dataFrame)) |
---|
3199 | Â Â Â |
---|
3200 | ################################################################################ |
---|
3201 | #####Â Comments |
---|
3202 | ################################################################################Â Â Â Â Â Â |
---|
3203 | Â Â Â Â |
---|
3204 | def UpdateComments(G2frame,data):          |
---|
3205 | |
---|
3206 |   if G2frame.dataDisplay: |
---|
3207 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
3208 | Â Â G2frame.dataFrame.SetLabel('Comments') |
---|
3209 | Â Â G2frame.dataDisplay =Â wx.TextCtrl(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize(), |
---|
3210 | Â Â Â Â style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP) |
---|
3211 |   for line in data: |
---|
3212 | Â Â Â Â G2frame.dataDisplay.AppendText(line+'\n') |
---|
3213 | Â Â G2frame.dataFrame.setSizePosLeft([400,250]) |
---|
3214 | Â Â Â Â Â Â |
---|
3215 | ################################################################################ |
---|
3216 | #####Â Display of Sequential Results |
---|
3217 | ################################################################################Â Â Â Â Â Â |
---|
3218 | Â Â Â Â |
---|
3219 | def UpdateSeqResults(G2frame,data,prevSize=None): |
---|
3220 | Â Â """ |
---|
3221 | Â Â Called when the Sequential Results data tree entry is selected |
---|
3222 | Â Â to show results from a sequential refinement. |
---|
3223 | Â Â |
---|
3224 | Â Â :param wx.Frame G2frame: main GSAS-II data tree windows |
---|
3225 | |
---|
3226 | Â Â :param dict data: a dictionary containing the following items:Â |
---|
3227 | |
---|
3228 | Â Â Â Â Â Â * 'histNames' - list of histogram names in order as processed by Sequential Refinement |
---|
3229 | Â Â Â Â Â Â * 'varyList' - list of variables - identical over all refinements in sequence |
---|
3230 | Â Â Â Â Â Â Â note that this is the original list of variables, prior to processing |
---|
3231 | Â Â Â Â Â Â Â constraints. |
---|
3232 | Â Â Â Â Â Â * 'variableLabels' -- a dict of labels to be applied to each parameter |
---|
3233 | Â Â Â Â Â Â Â (this is created as an empty dict if not present in data). |
---|
3234 | Â Â Â Â Â Â * keyed by histName - dictionaries for all data sets processed, which contains: |
---|
3235 | |
---|
3236 | Â Â Â Â Â Â Â * 'variables'- result[0] from leastsq call |
---|
3237 | Â Â Â Â Â Â Â * 'varyList' - list of variables passed to leastsq call (not same as above) |
---|
3238 | Â Â Â Â Â Â Â * 'sig' - esds for variables |
---|
3239 | Â Â Â Â Â Â Â * 'covMatrix' - covariance matrix from individual refinement |
---|
3240 | Â Â Â Â Â Â Â * 'title' - histogram name; same as dict item name |
---|
3241 | Â Â Â Â Â Â Â * 'newAtomDict' - new atom parameters after shifts applied |
---|
3242 | Â Â Â Â Â Â Â * 'newCellDict' - refined cell parameters after shifts to A0-A5 from Dij terms applied' |
---|
3243 | Â Â """ |
---|
3244 | |
---|
3245 |   def GetSampleParms(): |
---|
3246 | Â Â Â Â '''Make a dictionary of the sample parameters are not the same over the |
---|
3247 | Â Â Â Â refinement series. |
---|
3248 | Â Â Â Â ''' |
---|
3249 |     if 'IMG' in histNames[0]: |
---|
3250 | Â Â Â Â Â Â sampleParmDict =Â {'Sample load':[],} |
---|
3251 | Â Â Â Â else: |
---|
3252 | Â Â Â Â Â Â sampleParmDict =Â {'Temperature':[],'Pressure':[],'Time':[], |
---|
3253 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'FreePrm1':[],'FreePrm2':[],'FreePrm3':[],} |
---|
3254 | Â Â Â Â Controls =Â G2frame.PatternTree.GetItemPyData( |
---|
3255 |       GetPatternTreeItemId(G2frame,G2frame.root, 'Controls')) |
---|
3256 | Â Â Â Â sampleParm =Â {} |
---|
3257 |     for name in histNames: |
---|
3258 |       if 'IMG' in name: |
---|
3259 |         for item in sampleParmDict: |
---|
3260 | Â Â Â Â Â Â Â Â Â Â sampleParmDict[item].append(data[name]['parmDict'][item]) |
---|
3261 | Â Â Â Â Â Â else: |
---|
3262 | Â Â Â Â Â Â Â Â Id =Â GetPatternTreeItemId(G2frame,G2frame.root,name) |
---|
3263 | Â Â Â Â Â Â Â Â sampleData =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,Id,'Sample Parameters')) |
---|
3264 |         for item in sampleParmDict: |
---|
3265 | Â Â Â Â Â Â Â Â Â Â sampleParmDict[item].append(sampleData[item]) |
---|
3266 |     for item in sampleParmDict: |
---|
3267 | Â Â Â Â Â Â frstValue =Â sampleParmDict[item][0] |
---|
3268 |       if np.any(np.array(sampleParmDict[item])-frstValue): |
---|
3269 |         if item.startswith('FreePrm'): |
---|
3270 | Â Â Â Â Â Â Â Â Â Â sampleParm[Controls[item]]Â =Â sampleParmDict[item] |
---|
3271 | Â Â Â Â Â Â Â Â else: |
---|
3272 | Â Â Â Â Â Â Â Â Â Â sampleParm[item]Â =Â sampleParmDict[item] |
---|
3273 |     return sampleParm |
---|
3274 | |
---|
3275 |   def GetColumnInfo(col): |
---|
3276 | Â Â Â Â '''returns column label, lists of values and errors (or None) for each column in the table |
---|
3277 | Â Â Â Â for plotting. The column label is reformatted from Unicode to MatPlotLib encoding |
---|
3278 | Â Â Â Â ''' |
---|
3279 | Â Â Â Â colName =Â G2frame.SeqTable.GetColLabelValue(col) |
---|
3280 | Â Â Â Â plotName =Â variableLabels.get(colName,colName) |
---|
3281 | Â Â Â Â plotName =Â plotSpCharFix(plotName) |
---|
3282 |     return plotName,colList[col],colSigs[col] |
---|
3283 | Â Â Â Â Â Â |
---|
3284 |   def PlotSelect(event): |
---|
3285 | Â Â Â Â 'Plots a row (covariance) or column on double-click' |
---|
3286 | Â Â Â Â cols =Â G2frame.dataDisplay.GetSelectedCols() |
---|
3287 | Â Â Â Â rows =Â G2frame.dataDisplay.GetSelectedRows() |
---|
3288 |     if cols: |
---|
3289 | Â Â Â Â Â Â G2plt.PlotSelectedSequence(G2frame,cols,GetColumnInfo,SelectXaxis) |
---|
3290 |     elif rows: |
---|
3291 | Â Â Â Â Â Â name =Â histNames[rows[0]]Â Â Â Â #only does 1st one selected |
---|
3292 | Â Â Â Â Â Â G2plt.PlotCovariance(G2frame,data[name]) |
---|
3293 | Â Â Â Â else: |
---|
3294 | Â Â Â Â Â Â G2frame.ErrorDialog( |
---|
3295 | Â Â Â Â Â Â Â Â 'Select row or columns', |
---|
3296 | Â Â Â Â Â Â Â Â 'Nothing selected in table. Click on column or row label(s) to plot. N.B. Grid selection can be a bit funky.' |
---|
3297 | Â Â Â Â Â Â Â Â ) |
---|
3298 | Â Â Â Â Â Â |
---|
3299 |   def OnPlotSelSeq(event): |
---|
3300 | Â Â Â Â 'plot the selected columns or row from menu command' |
---|
3301 | Â Â Â Â cols =Â sorted(G2frame.dataDisplay.GetSelectedCols())Â # ignore selection order |
---|
3302 | Â Â Â Â rows =Â G2frame.dataDisplay.GetSelectedRows() |
---|
3303 |     if cols: |
---|
3304 | Â Â Â Â Â Â G2plt.PlotSelectedSequence(G2frame,cols,GetColumnInfo,SelectXaxis) |
---|
3305 |     elif rows: |
---|
3306 | Â Â Â Â Â Â name =Â histNames[rows[0]]Â Â Â Â #only does 1st one selected |
---|
3307 | Â Â Â Â Â Â G2plt.PlotCovariance(G2frame,data[name]) |
---|
3308 | Â Â Â Â else: |
---|
3309 | Â Â Â Â Â Â G2frame.ErrorDialog( |
---|
3310 | Â Â Â Â Â Â Â Â 'Select columns', |
---|
3311 | Â Â Â Â Â Â Â Â 'No columns or rows selected in table. Click on row or column labels to select fields for plotting.' |
---|
3312 | Â Â Â Â Â Â Â Â ) |
---|
3313 | Â Â Â Â Â Â Â Â |
---|
3314 |   def OnRenameSelSeq(event): |
---|
3315 | Â Â Â Â cols =Â sorted(G2frame.dataDisplay.GetSelectedCols())Â # ignore selection order |
---|
3316 |     colNames = [G2frame.SeqTable.GetColLabelValue(c) for c in cols] |
---|
3317 | Â Â Â Â newNames =Â colNames[:] |
---|
3318 |     for i,name in enumerate(colNames): |
---|
3319 |       if name in variableLabels: |
---|
3320 | Â Â Â Â Â Â Â Â newNames[i]Â =Â variableLabels[name] |
---|
3321 |     if not cols: |
---|
3322 | Â Â Â Â Â Â G2frame.ErrorDialog('Select columns', |
---|
3323 | Â Â Â Â Â Â Â Â 'No columns selected in table. Click on column labels to select fields for rename.') |
---|
3324 | Â Â Â Â Â Â return |
---|
3325 | Â Â Â Â dlg =Â MultiStringDialog(G2frame.dataDisplay,'Set column names',colNames,newNames) |
---|
3326 |     if dlg.Show(): |
---|
3327 | Â Â Â Â Â Â newNames =Â dlg.GetValues()Â Â Â Â Â Â |
---|
3328 | Â Â Â Â Â Â variableLabels.update(dict(zip(colNames,newNames))) |
---|
3329 | Â Â Â Â data['variableLabels']Â =Â variableLabels |
---|
3330 | Â Â Â Â dlg.Destroy() |
---|
3331 | Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3332 | Â Â Â Â G2plt.PlotSelectedSequence(G2frame,cols,GetColumnInfo,SelectXaxis) |
---|
3333 | Â Â Â Â Â Â |
---|
3334 |   def OnReOrgSelSeq(event): |
---|
3335 | Â Â Â Â 'Reorder the columns' |
---|
3336 | Â Â Â Â G2G.GetItemOrder(G2frame,VaryListChanges,vallookup,posdict)Â Â |
---|
3337 | Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3338 | |
---|
3339 |   def OnSaveSelSeqCSV(event): |
---|
3340 | Â Â Â Â 'export the selected columns to a .csv file from menu command' |
---|
3341 | Â Â Â Â OnSaveSelSeq(event,csv=True) |
---|
3342 | Â Â Â Â |
---|
3343 |   def OnSaveSelSeq(event,csv=False): |
---|
3344 | Â Â Â Â 'export the selected columns to a .txt file from menu command' |
---|
3345 |     def WriteCSV(): |
---|
3346 |       def WriteList(headerItems): |
---|
3347 | Â Â Â Â Â Â Â Â line =Â '' |
---|
3348 |         for lbl in headerItems: |
---|
3349 |           if line: line += ',' |
---|
3350 | Â Â Â Â Â Â Â Â Â Â line +=Â '"'+lbl+'"' |
---|
3351 |         return line |
---|
3352 | Â Â Â Â Â Â head =Â ['name'] |
---|
3353 |       for col in cols: |
---|
3354 | Â Â Â Â Â Â Â Â item =Â G2frame.SeqTable.GetColLabelValue(col) |
---|
3355 |         if col in havesig: |
---|
3356 | Â Â Â Â Â Â Â Â Â Â head +=Â [item,'esd-'+item] |
---|
3357 | Â Â Â Â Â Â Â Â else: |
---|
3358 | Â Â Â Â Â Â Â Â Â Â head +=Â [item] |
---|
3359 | Â Â Â Â Â Â SeqFile.write(WriteList(head)+'\n') |
---|
3360 |       for row,name in enumerate(saveNames): |
---|
3361 | Â Â Â Â Â Â Â Â line =Â '"'+saveNames[row]+'"' |
---|
3362 |         for col in cols: |
---|
3363 |           if col in havesig: |
---|
3364 | Â Â Â Â Â Â Â Â Â Â Â Â line +=Â ','+str(saveData[col][row])+','+str(saveSigs[col][row]) |
---|
3365 | Â Â Â Â Â Â Â Â Â Â else: |
---|
3366 | Â Â Â Â Â Â Â Â Â Â Â Â line +=Â ','+str(saveData[col][row]) |
---|
3367 | Â Â Â Â Â Â Â Â SeqFile.write(line+'\n') |
---|
3368 |     def WriteSeq(): |
---|
3369 | Â Â Â Â Â Â lenName =Â len(saveNames[0]) |
---|
3370 |       line = ' %s '%('name'.center(lenName)) |
---|
3371 |       for col in cols: |
---|
3372 | Â Â Â Â Â Â Â Â item =Â G2frame.SeqTable.GetColLabelValue(col) |
---|
3373 |         if col in havesig: |
---|
3374 |           line += ' %12s %12s '%(item.center(12),'esd'.center(12)) |
---|
3375 | Â Â Â Â Â Â Â Â else: |
---|
3376 |           line += ' %12s '%(item.center(12)) |
---|
3377 | Â Â Â Â Â Â SeqFile.write(line+'\n') |
---|
3378 |       for row,name in enumerate(saveNames): |
---|
3379 | Â Â Â Â Â Â Â Â line =Â " '%s' "%(saveNames[row]) |
---|
3380 |         for col in cols: |
---|
3381 |           if col in havesig: |
---|
3382 |             line += ' %12.6f %12.6f '%(saveData[col][row],saveSigs[col][row]) |
---|
3383 | Â Â Â Â Â Â Â Â Â Â else: |
---|
3384 |             line += ' %12.6f '%saveData[col][row] |
---|
3385 | Â Â Â Â Â Â Â Â SeqFile.write(line+'\n') |
---|
3386 | |
---|
3387 | Â Â Â Â # start of OnSaveSelSeq code |
---|
3388 | Â Â Â Â cols =Â sorted(G2frame.dataDisplay.GetSelectedCols())Â # ignore selection order |
---|
3389 | Â Â Â Â nrows =Â G2frame.SeqTable.GetNumberRows() |
---|
3390 |     if not cols: |
---|
3391 | Â Â Â Â Â Â G2frame.ErrorDialog('Select columns', |
---|
3392 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'No columns selected in table. Click on column labels to select fields for output.') |
---|
3393 | Â Â Â Â Â Â return |
---|
3394 |     saveNames = [G2frame.SeqTable.GetRowLabelValue(r) for r in range(nrows)] |
---|
3395 | Â Â Â Â saveData =Â {} |
---|
3396 | Â Â Â Â saveSigs =Â {} |
---|
3397 | Â Â Â Â havesig =Â [] |
---|
3398 |     for col in cols: |
---|
3399 | Â Â Â Â Â Â name,vals,sigs =Â GetColumnInfo(col) |
---|
3400 | Â Â Â Â Â Â saveData[col]Â =Â vals |
---|
3401 |       if sigs: |
---|
3402 | Â Â Â Â Â Â Â Â havesig.append(col) |
---|
3403 | Â Â Â Â Â Â Â Â saveSigs[col]Â =Â sigs |
---|
3404 |     if csv: |
---|
3405 | Â Â Â Â Â Â wild =Â 'CSV output file (*.csv)|*.csv' |
---|
3406 | Â Â Â Â else: |
---|
3407 | Â Â Â Â Â Â wild =Â 'Text output file (*.txt)|*.txt' |
---|
3408 | Â Â Â Â dlg =Â wx.FileDialog( |
---|
3409 | Â Â Â Â Â Â G2frame, |
---|
3410 |       'Choose text output file for your selection', '.', '', |
---|
3411 | Â Â Â Â Â Â wild,wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) |
---|
3412 | Â Â Â Â try: |
---|
3413 |       if dlg.ShowModal() == wx.ID_OK: |
---|
3414 | Â Â Â Â Â Â Â Â SeqTextFile =Â dlg.GetPath() |
---|
3415 | Â Â Â Â Â Â Â Â SeqTextFile =Â G2IO.FileDlgFixExt(dlg,SeqTextFile)Â |
---|
3416 | Â Â Â Â Â Â Â Â SeqFile =Â open(SeqTextFile,'w') |
---|
3417 |         if csv: |
---|
3418 | Â Â Â Â Â Â Â Â Â Â WriteCSV() |
---|
3419 | Â Â Â Â Â Â Â Â else: |
---|
3420 | Â Â Â Â Â Â Â Â Â Â WriteSeq() |
---|
3421 | Â Â Â Â Â Â Â Â SeqFile.close() |
---|
3422 | Â Â Â Â finally: |
---|
3423 | Â Â Â Â Â Â dlg.Destroy() |
---|
3424 | Â Â Â Â Â Â Â Â |
---|
3425 |   def striphist(var,insChar=''): |
---|
3426 | Â Â Â Â 'strip a histogram number from a var name' |
---|
3427 | Â Â Â Â sv =Â var.split(':') |
---|
3428 |     if len(sv) <= 1: return var |
---|
3429 | Â Â Â Â sv[1]Â =Â insChar |
---|
3430 |     return ':'.join(sv) |
---|
3431 | Â Â Â Â |
---|
3432 |   def plotSpCharFix(lbl): |
---|
3433 | Â Â Â Â 'Change selected unicode characters to their matplotlib equivalent' |
---|
3434 |     for u,p in [ |
---|
3435 | Â Â Â Â Â Â (u'\u03B1',r'$\alpha$'), |
---|
3436 | Â Â Â Â Â Â (u'\u03B2',r'$\beta$'), |
---|
3437 | Â Â Â Â Â Â (u'\u03B3',r'$\gamma$'), |
---|
3438 | Â Â Â Â Â Â (u'\u0394\u03C7',r'$\Delta\chi$'), |
---|
3439 | Â Â Â Â Â Â ]: |
---|
3440 | Â Â Â Â Â Â lbl =Â lbl.replace(u,p) |
---|
3441 |     return lbl |
---|
3442 | Â Â |
---|
3443 |   def SelectXaxis(): |
---|
3444 | Â Â Â Â 'returns a selected column number (or None) as the X-axis selection' |
---|
3445 | Â Â Â Â ncols =Â G2frame.SeqTable.GetNumberCols() |
---|
3446 |     colNames = [G2frame.SeqTable.GetColLabelValue(r) for r in range(ncols)] |
---|
3447 | Â Â Â Â dlg =Â G2SingleChoiceDialog( |
---|
3448 | Â Â Â Â Â Â G2frame.dataDisplay, |
---|
3449 | Â Â Â Â Â Â 'Select x-axis parameter for plot or Cancel for sequence number', |
---|
3450 | Â Â Â Â Â Â 'Select X-axis', |
---|
3451 | Â Â Â Â Â Â colNames) |
---|
3452 | Â Â Â Â try: |
---|
3453 |       if dlg.ShowModal() == wx.ID_OK: |
---|
3454 | Â Â Â Â Â Â Â Â col =Â dlg.GetSelection() |
---|
3455 | Â Â Â Â Â Â else: |
---|
3456 | Â Â Â Â Â Â Â Â col =Â None |
---|
3457 | Â Â Â Â finally: |
---|
3458 | Â Â Â Â Â Â dlg.Destroy() |
---|
3459 |     return col |
---|
3460 | Â Â |
---|
3461 |   def EnablePseudoVarMenus(): |
---|
3462 | Â Â Â Â 'Enables or disables the PseudoVar menu items that require existing defs' |
---|
3463 |     if Controls['SeqPseudoVars']: |
---|
3464 | Â Â Â Â Â Â val =Â True |
---|
3465 | Â Â Â Â else: |
---|
3466 | Â Â Â Â Â Â val =Â False |
---|
3467 | Â Â Â Â G2frame.dataFrame.SequentialPvars.Enable(wxDELSEQVAR,val) |
---|
3468 | Â Â Â Â G2frame.dataFrame.SequentialPvars.Enable(wxEDITSEQVAR,val) |
---|
3469 | |
---|
3470 |   def DelPseudoVar(event): |
---|
3471 | Â Â Â Â 'Ask the user to select a pseudo var expression to delete' |
---|
3472 | Â Â Â Â choices =Â Controls['SeqPseudoVars'].keys() |
---|
3473 | Â Â Â Â selected =Â ItemSelector( |
---|
3474 | Â Â Â Â Â Â choices,G2frame.dataFrame, |
---|
3475 | Â Â Â Â Â Â multiple=True, |
---|
3476 | Â Â Â Â Â Â title='Select expressions to remove', |
---|
3477 | Â Â Â Â Â Â header='Delete expression') |
---|
3478 |     if selected is None: return |
---|
3479 |     for item in selected: |
---|
3480 |       del Controls['SeqPseudoVars'][choices[item]] |
---|
3481 |     if selected: |
---|
3482 | Â Â Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3483 | |
---|
3484 |   def EditPseudoVar(event): |
---|
3485 | Â Â Â Â 'Edit an existing pseudo var expression' |
---|
3486 | Â Â Â Â choices =Â Controls['SeqPseudoVars'].keys() |
---|
3487 |     if len(choices) == 1: |
---|
3488 | Â Â Â Â Â Â selected =Â 0 |
---|
3489 | Â Â Â Â else: |
---|
3490 | Â Â Â Â Â Â selected =Â ItemSelector( |
---|
3491 | Â Â Â Â Â Â Â Â choices,G2frame.dataFrame, |
---|
3492 | Â Â Â Â Â Â Â Â multiple=False, |
---|
3493 | Â Â Â Â Â Â Â Â title='Select an expression to edit', |
---|
3494 | Â Â Â Â Â Â Â Â header='Edit expression') |
---|
3495 |     if selected is not None: |
---|
3496 | Â Â Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3497 | Â Â Â Â Â Â Â Â G2frame.dataDisplay,PSvarDict, |
---|
3498 | Â Â Â Â Â Â Â Â Controls['SeqPseudoVars'][choices[selected]], |
---|
3499 | Â Â Â Â Â Â Â Â header="Edit the PseudoVar expression", |
---|
3500 | Â Â Â Â Â Â Â Â VarLabel="PseudoVar #"+str(selected+1), |
---|
3501 | Â Â Â Â Â Â Â Â fit=False) |
---|
3502 | Â Â Â Â Â Â newobj =Â dlg.Show(True) |
---|
3503 |       if newobj: |
---|
3504 | Â Â Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(newobj) |
---|
3505 |         del Controls['SeqPseudoVars'][choices[selected]] |
---|
3506 | Â Â Â Â Â Â Â Â Controls['SeqPseudoVars'][calcobj.eObj.expression]Â =Â newobj |
---|
3507 | Â Â Â Â Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3508 | Â Â Â Â |
---|
3509 |   def AddNewPseudoVar(event): |
---|
3510 | Â Â Â Â 'Create a new pseudo var expression' |
---|
3511 | Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3512 | Â Â Â Â Â Â G2frame.dataDisplay,PSvarDict, |
---|
3513 | Â Â Â Â Â Â header='Enter an expression for a PseudoVar here', |
---|
3514 | Â Â Â Â Â Â VarLabel =Â "New PseudoVar", |
---|
3515 | Â Â Â Â Â Â fit=False) |
---|
3516 | Â Â Â Â obj =Â dlg.Show(True) |
---|
3517 | Â Â Â Â dlg.Destroy() |
---|
3518 |     if obj: |
---|
3519 | Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(obj) |
---|
3520 | Â Â Â Â Â Â Controls['SeqPseudoVars'][calcobj.eObj.expression]Â =Â obj |
---|
3521 | Â Â Â Â Â Â UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize())Â # redisplay variables |
---|
3522 | |
---|
3523 |   def UpdateParmDict(parmDict): |
---|
3524 | Â Â Â Â '''generate the atom positions and the direct & reciprocal cell values, |
---|
3525 | Â Â Â Â because they might be needed to evaluate the pseudovar |
---|
3526 | Â Â Â Â ''' |
---|
3527 | Â Â Â Â Ddict =Â dict(zip(['D11','D22','D33','D12','D13','D23'], |
---|
3528 |              ['A'+str(i) for i in range(6)]) |
---|
3529 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3530 | Â Â Â Â delList =Â [] |
---|
3531 | Â Â Â Â phaselist =Â [] |
---|
3532 |     for item in parmDict: |
---|
3533 |       if ':' not in item: continue |
---|
3534 | Â Â Â Â Â Â key =Â item.split(':') |
---|
3535 |       if len(key) < 3: continue |
---|
3536 | Â Â Â Â Â Â # remove the dA[xyz] terms, they would only bring confusion |
---|
3537 |       if key[2].startswith('dA'): |
---|
3538 | Â Â Â Â Â Â Â Â delList.append(item) |
---|
3539 | Â Â Â Â Â Â # compute and update the corrected reciprocal cell terms using the Dij values |
---|
3540 |       elif key[2] in Ddict: |
---|
3541 |         if key[0] not in phaselist: phaselist.append(key[0]) |
---|
3542 | Â Â Â Â Â Â Â Â akey =Â key[0]+'::'+Ddict[key[2]] |
---|
3543 | Â Â Â Â Â Â Â Â parmDict[akey]Â -=Â parmDict[item] |
---|
3544 | Â Â Â Â Â Â Â Â delList.append(item) |
---|
3545 |     for item in delList: |
---|
3546 |       del parmDict[item]        |
---|
3547 |     for i in phaselist: |
---|
3548 | Â Â Â Â Â Â pId =Â int(i) |
---|
3549 | Â Â Â Â Â Â # apply cell symmetry |
---|
3550 | Â Â Â Â Â Â A,zeros =Â G2stIO.cellFill(str(pId)+'::',SGdata[pId],parmDict,zeroDict[pId]) |
---|
3551 | Â Â Â Â Â Â # convert to direct cell & add the unique terms to the dictionary |
---|
3552 |       for i,val in enumerate(G2lat.A2cell(A)): |
---|
3553 |         if i in uniqCellIndx[pId]: |
---|
3554 | Â Â Â Â Â Â Â Â Â Â lbl =Â str(pId)+'::'+cellUlbl[i] |
---|
3555 | Â Â Â Â Â Â Â Â Â Â parmDict[lbl]Â =Â val |
---|
3556 | Â Â Â Â Â Â lbl =Â str(pId)+'::'+'vol' |
---|
3557 | Â Â Â Â Â Â parmDict[lbl]Â =Â G2lat.calc_V(A) |
---|
3558 |     return parmDict |
---|
3559 | |
---|
3560 |   def EvalPSvarDeriv(calcobj,parmDict,sampleDict,var,ESD): |
---|
3561 | Â Â Â Â '''Evaluate an expression derivative with respect to a |
---|
3562 | Â Â Â Â GSAS-II variable name. |
---|
3563 | |
---|
3564 | Â Â Â Â Note this likely could be faster if the loop over calcobjs were done |
---|
3565 | Â Â Â Â inside after the Dict was created. |
---|
3566 | Â Â Â Â ''' |
---|
3567 | Â Â Â Â step =Â ESD/10 |
---|
3568 | Â Â Â Â Ddict =Â dict(zip(['D11','D22','D33','D12','D13','D23'], |
---|
3569 |              ['A'+str(i) for i in range(6)]) |
---|
3570 | Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3571 | Â Â Â Â results =Â [] |
---|
3572 | Â Â Â Â phaselist =Â [] |
---|
3573 | Â Â Â Â VparmDict =Â sampleDict.copy() |
---|
3574 |     for incr in step,-step: |
---|
3575 | Â Â Â Â Â Â VparmDict.update(parmDict.copy())Â Â Â Â Â Â |
---|
3576 | Â Â Â Â Â Â # as saved, the parmDict has updated 'A[xyz]' values, but 'dA[xyz]' |
---|
3577 | Â Â Â Â Â Â # values are not zeroed: fix that! |
---|
3578 |       VparmDict.update({item:0.0 for item in parmDict if 'dA' in item}) |
---|
3579 | Â Â Â Â Â Â VparmDict[var]Â +=Â incr |
---|
3580 | Â Â Â Â Â Â G2mv.Dict2Map(VparmDict,[])Â # apply constraints |
---|
3581 | Â Â Â Â Â Â # generate the atom positions and the direct & reciprocal cell values now, because they might |
---|
3582 | Â Â Â Â Â Â # needed to evaluate the pseudovar |
---|
3583 |       for item in VparmDict: |
---|
3584 |         if item in sampleDict: |
---|
3585 |           continue |
---|
3586 |         if ':' not in item: continue |
---|
3587 | Â Â Â Â Â Â Â Â key =Â item.split(':') |
---|
3588 |         if len(key) < 3: continue |
---|
3589 | Â Â Â Â Â Â Â Â # apply any new shifts to atom positions |
---|
3590 |         if key[2].startswith('dA'): |
---|
3591 | Â Â Â Â Â Â Â Â Â Â VparmDict[''.join(item.split('d'))]Â +=Â VparmDict[item] |
---|
3592 | Â Â Â Â Â Â Â Â Â Â VparmDict[item]Â =Â 0.0 |
---|
3593 | Â Â Â Â Â Â Â Â # compute and update the corrected reciprocal cell terms using the Dij values |
---|
3594 |         if key[2] in Ddict: |
---|
3595 |           if key[0] not in phaselist: phaselist.append(key[0]) |
---|
3596 | Â Â Â Â Â Â Â Â Â Â akey =Â key[0]+'::'+Ddict[key[2]] |
---|
3597 | Â Â Â Â Â Â Â Â Â Â VparmDict[akey]Â -=Â VparmDict[item] |
---|
3598 |       for i in phaselist: |
---|
3599 | Â Â Â Â Â Â Â Â pId =Â int(i) |
---|
3600 | Â Â Â Â Â Â Â Â # apply cell symmetry |
---|
3601 | Â Â Â Â Â Â Â Â A,zeros =Â G2stIO.cellFill(str(pId)+'::',SGdata[pId],VparmDict,zeroDict[pId]) |
---|
3602 | Â Â Â Â Â Â Â Â # convert to direct cell & add the unique terms to the dictionary |
---|
3603 |         for i,val in enumerate(G2lat.A2cell(A)): |
---|
3604 |           if i in uniqCellIndx[pId]: |
---|
3605 | Â Â Â Â Â Â Â Â Â Â Â Â lbl =Â str(pId)+'::'+cellUlbl[i] |
---|
3606 | Â Â Â Â Â Â Â Â Â Â Â Â VparmDict[lbl]Â =Â val |
---|
3607 | Â Â Â Â Â Â Â Â lbl =Â str(pId)+'::'+'vol' |
---|
3608 | Â Â Â Â Â Â Â Â VparmDict[lbl]Â =Â G2lat.calc_V(A) |
---|
3609 | Â Â Â Â Â Â # dict should be fully updated, use it & calculate |
---|
3610 | Â Â Â Â Â Â calcobj.SetupCalc(VparmDict) |
---|
3611 | Â Â Â Â Â Â results.append(calcobj.EvalExpression()) |
---|
3612 |     return (results[0] - results[1]) / (2.*step) |
---|
3613 | Â Â Â Â |
---|
3614 |   def EnableParFitEqMenus(): |
---|
3615 | Â Â Â Â 'Enables or disables the Parametric Fit menu items that require existing defs' |
---|
3616 |     if Controls['SeqParFitEqList']: |
---|
3617 | Â Â Â Â Â Â val =Â True |
---|
3618 | Â Â Â Â else: |
---|
3619 | Â Â Â Â Â Â val =Â False |
---|
3620 | Â Â Â Â G2frame.dataFrame.SequentialPfit.Enable(wxDELPARFIT,val) |
---|
3621 | Â Â Â Â G2frame.dataFrame.SequentialPfit.Enable(wxEDITPARFIT,val) |
---|
3622 | Â Â Â Â G2frame.dataFrame.SequentialPfit.Enable(wxDOPARFIT,val) |
---|
3623 | |
---|
3624 |   def ParEqEval(Values,calcObjList,varyList): |
---|
3625 | Â Â Â Â '''Evaluate the parametric expression(s) |
---|
3626 | Â Â Â Â :param list Values: a list of values for each variable parameter |
---|
3627 | Â Â Â Â :param list calcObjList: a list of :class:`GSASIIobj.ExpressionCalcObj` |
---|
3628 | Â Â Â Â Â expression objects to evaluate |
---|
3629 | Â Â Â Â :param list varyList: a list of variable names for each value in Values |
---|
3630 | Â Â Â Â ''' |
---|
3631 | Â Â Â Â result =Â [] |
---|
3632 |     for calcobj in calcObjList: |
---|
3633 | Â Â Â Â Â Â calcobj.UpdateVars(varyList,Values) |
---|
3634 | Â Â Â Â Â Â result.append((calcobj.depVal-calcobj.EvalExpression())/calcobj.depSig) |
---|
3635 |     return result |
---|
3636 | |
---|
3637 |   def DoParEqFit(event,eqObj=None): |
---|
3638 | Â Â Â Â 'Parametric fit minimizer' |
---|
3639 | Â Â Â Â varyValueDict =Â {}Â # dict of variables and their initial values |
---|
3640 | Â Â Â Â calcObjList =Â []Â # expression objects, ready to go for each data point |
---|
3641 |     if eqObj is not None: |
---|
3642 | Â Â Â Â Â Â eqObjList =Â [eqObj,] |
---|
3643 | Â Â Â Â else: |
---|
3644 | Â Â Â Â Â Â eqObjList =Â Controls['SeqParFitEqList'] |
---|
3645 | Â Â Â Â UseFlags =Â G2frame.SeqTable.GetColValues(0)Â Â Â Â Â |
---|
3646 |     for obj in eqObjList: |
---|
3647 | Â Â Â Â Â Â expr =Â obj.expression |
---|
3648 | Â Â Â Â Â Â # assemble refined vars for this equation |
---|
3649 |       varyValueDict.update({var:val for var,val in obj.GetVariedVarVal()}) |
---|
3650 | Â Â Â Â Â Â # lookup dependent var position |
---|
3651 | Â Â Â Â Â Â depVar =Â obj.GetDepVar() |
---|
3652 |       if depVar in colLabels: |
---|
3653 | Â Â Â Â Â Â Â Â indx =Â colLabels.index(depVar) |
---|
3654 | Â Â Â Â Â Â else: |
---|
3655 |         raise Exception('Dependent variable '+depVar+' not found') |
---|
3656 | Â Â Â Â Â Â # assemble a list of the independent variables |
---|
3657 | Â Â Â Â Â Â indepVars =Â obj.GetIndependentVars() |
---|
3658 | Â Â Â Â Â Â # loop over each datapoint |
---|
3659 |       for j,row in enumerate(zip(*colList)): |
---|
3660 |         if not UseFlags[j]: continue |
---|
3661 | Â Â Â Â Â Â Â Â # assemble equations to fit |
---|
3662 | Â Â Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(obj) |
---|
3663 | Â Â Â Â Â Â Â Â # prepare a dict of needed independent vars for this expression |
---|
3664 |         indepVarDict = {var:row[i] for i,var in enumerate(colLabels) if var in indepVars} |
---|
3665 | Â Â Â Â Â Â Â Â calcobj.SetupCalc(indepVarDict)Â Â Â Â Â Â Â Â |
---|
3666 | Â Â Â Â Â Â Â Â # values and sigs for current value of dependent var |
---|
3667 | Â Â Â Â Â Â Â Â calcobj.depVal =Â row[indx] |
---|
3668 | Â Â Â Â Â Â Â Â calcobj.depSig =Â colSigs[indx][j] |
---|
3669 | Â Â Â Â Â Â Â Â calcObjList.append(calcobj) |
---|
3670 | Â Â Â Â # varied parameters |
---|
3671 | Â Â Â Â varyList =Â varyValueDict.keys() |
---|
3672 |     values = varyValues = [varyValueDict[key] for key in varyList] |
---|
3673 |     if not varyList: |
---|
3674 |       print 'no variables to refine!' |
---|
3675 | Â Â Â Â Â Â return |
---|
3676 | Â Â Â Â try: |
---|
3677 |       result = so.leastsq(ParEqEval,varyValues,full_output=True,  #ftol=Ftol, |
---|
3678 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â args=(calcObjList,varyList) |
---|
3679 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
---|
3680 | Â Â Â Â Â Â values =Â result[0] |
---|
3681 | Â Â Â Â Â Â covar =Â result[1] |
---|
3682 |       if covar is None: |
---|
3683 |         raise Exception |
---|
3684 | Â Â Â Â Â Â esdDict =Â {} |
---|
3685 |       for i,avar in enumerate(varyList): |
---|
3686 | Â Â Â Â Â Â Â Â esdDict[avar]Â =Â np.sqrt(covar[i,i]) |
---|
3687 | Â Â Â Â except: |
---|
3688 | Â Â Â Â Â Â print('====> Fit failed') |
---|
3689 | Â Â Â Â Â Â return |
---|
3690 | Â Â Â Â print('==== Fit Results ====') |
---|
3691 |     for obj in eqObjList: |
---|
3692 | Â Â Â Â Â Â obj.UpdateVariedVars(varyList,values) |
---|
3693 | Â Â Â Â Â Â ind =Â 'Â Â Â ' |
---|
3694 | Â Â Â Â Â Â print('Â '+obj.GetDepVar()+' = '+obj.expression) |
---|
3695 |       for var in obj.assgnVars: |
---|
3696 | Â Â Â Â Â Â Â Â print(ind+var+' = '+obj.assgnVars[var]) |
---|
3697 |       for var in obj.freeVars: |
---|
3698 | Â Â Â Â Â Â Â Â avar =Â "::"+obj.freeVars[var][0] |
---|
3699 | Â Â Â Â Â Â Â Â val =Â obj.freeVars[var][1] |
---|
3700 |         if obj.freeVars[var][2]: |
---|
3701 | Â Â Â Â Â Â Â Â Â Â print(ind+var+' = '+avar +Â " = "Â +Â G2mth.ValEsd(val,esdDict[avar])) |
---|
3702 | Â Â Â Â Â Â Â Â else: |
---|
3703 | Â Â Â Â Â Â Â Â Â Â print(ind+var+' = '+avar +Â " ="Â +Â G2mth.ValEsd(val,0)) |
---|
3704 | Â Â Â Â # create a plot for each parametric variable |
---|
3705 |     for fitnum,obj in enumerate(eqObjList): |
---|
3706 | Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(obj) |
---|
3707 | Â Â Â Â Â Â # lookup dependent var position |
---|
3708 | Â Â Â Â Â Â indx =Â colLabels.index(obj.GetDepVar()) |
---|
3709 | Â Â Â Â Â Â # assemble a list of the independent variables |
---|
3710 | Â Â Â Â Â Â indepVars =Â obj.GetIndependentVars()Â Â Â Â Â Â |
---|
3711 | Â Â Â Â Â Â # loop over each datapoint |
---|
3712 | Â Â Â Â Â Â fitvals =Â [] |
---|
3713 |       for j,row in enumerate(zip(*colList)): |
---|
3714 | Â Â Â Â Â Â Â Â calcobj.SetupCalc( |
---|
3715 |           {var:row[i] for i,var in enumerate(colLabels) if var in indepVars} |
---|
3716 | Â Â Â Â Â Â Â Â Â Â ) |
---|
3717 | Â Â Â Â Â Â Â Â fitvals.append(calcobj.EvalExpression()) |
---|
3718 | Â Â Â Â Â Â G2plt.PlotSelectedSequence( |
---|
3719 | Â Â Â Â Â Â Â Â G2frame,[indx],GetColumnInfo,SelectXaxis, |
---|
3720 | Â Â Â Â Â Â Â Â fitnum,fitvals) |
---|
3721 | |
---|
3722 |   def SingleParEqFit(eqObj): |
---|
3723 | Â Â Â Â DoParEqFit(None,eqObj) |
---|
3724 | |
---|
3725 |   def DelParFitEq(event): |
---|
3726 | Â Â Â Â 'Ask the user to select function to delete' |
---|
3727 |     txtlst = [obj.GetDepVar()+' = '+obj.expression for obj in Controls['SeqParFitEqList']] |
---|
3728 | Â Â Â Â selected =Â ItemSelector( |
---|
3729 | Â Â Â Â Â Â txtlst,G2frame.dataFrame, |
---|
3730 | Â Â Â Â Â Â multiple=True, |
---|
3731 | Â Â Â Â Â Â title='Select a parametric equation(s) to remove', |
---|
3732 | Â Â Â Â Â Â header='Delete equation') |
---|
3733 |     if selected is None: return |
---|
3734 |     Controls['SeqParFitEqList'] = [obj for i,obj in enumerate(Controls['SeqParFitEqList']) if i not in selected] |
---|
3735 | Â Â Â Â EnableParFitEqMenus() |
---|
3736 |     if Controls['SeqParFitEqList']: DoParEqFit(event) |
---|
3737 | Â Â Â Â |
---|
3738 |   def EditParFitEq(event): |
---|
3739 | Â Â Â Â 'Edit an existing parametric equation' |
---|
3740 |     txtlst = [obj.GetDepVar()+' = '+obj.expression for obj in Controls['SeqParFitEqList']] |
---|
3741 |     if len(txtlst) == 1: |
---|
3742 | Â Â Â Â Â Â selected =Â 0 |
---|
3743 | Â Â Â Â else: |
---|
3744 | Â Â Â Â Â Â selected =Â ItemSelector( |
---|
3745 | Â Â Â Â Â Â Â Â txtlst,G2frame.dataFrame, |
---|
3746 | Â Â Â Â Â Â Â Â multiple=False, |
---|
3747 | Â Â Â Â Â Â Â Â title='Select a parametric equation to edit', |
---|
3748 | Â Â Â Â Â Â Â Â header='Edit equation') |
---|
3749 |     if selected is not None: |
---|
3750 | Â Â Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3751 | Â Â Â Â Â Â Â Â G2frame.dataDisplay,indepVarDict, |
---|
3752 | Â Â Â Â Â Â Â Â Controls['SeqParFitEqList'][selected], |
---|
3753 | Â Â Â Â Â Â Â Â depVarDict=depVarDict, |
---|
3754 | Â Â Â Â Â Â Â Â header="Edit the formula for this minimization function", |
---|
3755 | Â Â Â Â Â Â Â Â ExtraButton=['Fit',SingleParEqFit]) |
---|
3756 | Â Â Â Â Â Â newobj =Â dlg.Show(True) |
---|
3757 |       if newobj: |
---|
3758 | Â Â Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(newobj) |
---|
3759 | Â Â Â Â Â Â Â Â Controls['SeqParFitEqList'][selected]Â =Â newobj |
---|
3760 | Â Â Â Â Â Â Â Â EnableParFitEqMenus() |
---|
3761 |       if Controls['SeqParFitEqList']: DoParEqFit(event) |
---|
3762 | |
---|
3763 |   def AddNewParFitEq(event): |
---|
3764 | Â Â Â Â 'Create a new parametric equation to be fit to sequential results' |
---|
3765 | |
---|
3766 | Â Â Â Â # compile the variable names used in previous freevars to avoid accidental name collisions |
---|
3767 | Â Â Â Â usedvarlist =Â [] |
---|
3768 |     for obj in Controls['SeqParFitEqList']: |
---|
3769 |       for var in obj.freeVars: |
---|
3770 |         if obj.freeVars[var][0] not in usedvarlist: usedvarlist.append(obj.freeVars[var][0]) |
---|
3771 | |
---|
3772 | Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3773 | Â Â Â Â Â Â G2frame.dataDisplay,indepVarDict, |
---|
3774 | Â Â Â Â Â Â depVarDict=depVarDict, |
---|
3775 | Â Â Â Â Â Â header='Define an equation to minimize in the parametric fit', |
---|
3776 | Â Â Â Â Â Â ExtraButton=['Fit',SingleParEqFit], |
---|
3777 | Â Â Â Â Â Â usedVars=usedvarlist) |
---|
3778 | Â Â Â Â obj =Â dlg.Show(True) |
---|
3779 | Â Â Â Â dlg.Destroy() |
---|
3780 |     if obj: |
---|
3781 | Â Â Â Â Â Â Controls['SeqParFitEqList'].append(obj) |
---|
3782 | Â Â Â Â Â Â EnableParFitEqMenus() |
---|
3783 |       if Controls['SeqParFitEqList']: DoParEqFit(event) |
---|
3784 | Â Â Â Â Â Â Â Â |
---|
3785 |   def CopyParFitEq(event): |
---|
3786 | Â Â Â Â 'Copy an existing parametric equation to be fit to sequential results' |
---|
3787 | Â Â Â Â # compile the variable names used in previous freevars to avoid accidental name collisions |
---|
3788 | Â Â Â Â usedvarlist =Â [] |
---|
3789 |     for obj in Controls['SeqParFitEqList']: |
---|
3790 |       for var in obj.freeVars: |
---|
3791 |         if obj.freeVars[var][0] not in usedvarlist: usedvarlist.append(obj.freeVars[var][0]) |
---|
3792 |     txtlst = [obj.GetDepVar()+' = '+obj.expression for obj in Controls['SeqParFitEqList']] |
---|
3793 |     if len(txtlst) == 1: |
---|
3794 | Â Â Â Â Â Â selected =Â 0 |
---|
3795 | Â Â Â Â else: |
---|
3796 | Â Â Â Â Â Â selected =Â ItemSelector( |
---|
3797 | Â Â Â Â Â Â Â Â txtlst,G2frame.dataFrame, |
---|
3798 | Â Â Â Â Â Â Â Â multiple=False, |
---|
3799 | Â Â Â Â Â Â Â Â title='Select a parametric equation to copy', |
---|
3800 | Â Â Â Â Â Â Â Â header='Copy equation') |
---|
3801 |     if selected is not None: |
---|
3802 | Â Â Â Â Â Â newEqn =Â copy.deepcopy(Controls['SeqParFitEqList'][selected]) |
---|
3803 |       for var in newEqn.freeVars: |
---|
3804 | Â Â Â Â Â Â Â Â newEqn.freeVars[var][0]Â =Â G2obj.MakeUniqueLabel(newEqn.freeVars[var][0],usedvarlist) |
---|
3805 | Â Â Â Â Â Â dlg =Â G2exG.ExpressionDialog( |
---|
3806 | Â Â Â Â Â Â Â Â G2frame.dataDisplay,indepVarDict, |
---|
3807 | Â Â Â Â Â Â Â Â newEqn, |
---|
3808 | Â Â Â Â Â Â Â Â depVarDict=depVarDict, |
---|
3809 | Â Â Â Â Â Â Â Â header="Edit the formula for this minimization function", |
---|
3810 | Â Â Â Â Â Â Â Â ExtraButton=['Fit',SingleParEqFit]) |
---|
3811 | Â Â Â Â Â Â newobj =Â dlg.Show(True) |
---|
3812 |       if newobj: |
---|
3813 | Â Â Â Â Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(newobj) |
---|
3814 | Â Â Â Â Â Â Â Â Controls['SeqParFitEqList'].append(newobj) |
---|
3815 | Â Â Â Â Â Â Â Â EnableParFitEqMenus() |
---|
3816 |       if Controls['SeqParFitEqList']: DoParEqFit(event) |
---|
3817 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
3818 |   def GridSetToolTip(row,col): |
---|
3819 | Â Â Â Â '''Routine to show standard uncertainties for each element in table |
---|
3820 | Â Â Â Â as a tooltip |
---|
3821 | Â Â Â Â ''' |
---|
3822 |     if colSigs[col]: |
---|
3823 |       return u'\u03c3 = '+str(colSigs[col][row]) |
---|
3824 |     return '' |
---|
3825 | Â Â Â Â |
---|
3826 |   def GridColLblToolTip(col): |
---|
3827 | Â Â Â Â '''Define a tooltip for a column. This will be the user-entered value |
---|
3828 | Â Â Â Â (from data['variableLabels']) or the default name |
---|
3829 | Â Â Â Â ''' |
---|
3830 |     if col < 0 or col > len(colLabels): |
---|
3831 |       print 'Illegal column #',col |
---|
3832 | Â Â Â Â Â Â return |
---|
3833 | Â Â Â Â var =Â colLabels[col] |
---|
3834 |     return variableLabels.get(var,G2obj.fmtVarDescr(var)) |
---|
3835 | Â Â Â Â |
---|
3836 |   def SetLabelString(event): |
---|
3837 | Â Â Â Â '''Define or edit the label for a column in the table, to be used |
---|
3838 | Â Â Â Â as a tooltip and for plotting |
---|
3839 | Â Â Â Â ''' |
---|
3840 | Â Â Â Â col =Â event.GetCol() |
---|
3841 |     if col < 0 or col > len(colLabels): |
---|
3842 | Â Â Â Â Â Â return |
---|
3843 | Â Â Â Â var =Â colLabels[col] |
---|
3844 | Â Â Â Â lbl =Â variableLabels.get(var,G2obj.fmtVarDescr(var)) |
---|
3845 | Â Â Â Â dlg =Â SingleStringDialog(G2frame.dataFrame,'Set variable label', |
---|
3846 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Set a new name for variable '+var,lbl,size=(400,-1)) |
---|
3847 |     if dlg.Show(): |
---|
3848 | Â Â Â Â Â Â variableLabels[var]Â =Â dlg.GetValue() |
---|
3849 | Â Â Â Â dlg.Destroy() |
---|
3850 | Â Â Â Â |
---|
3851 | Â Â #def GridRowLblToolTip(row): return 'Row ='+str(row) |
---|
3852 | Â Â |
---|
3853 | Â Â # lookup table for unique cell parameters by symmetry |
---|
3854 | Â Â cellGUIlist =Â [ |
---|
3855 | Â Â Â Â [['m3','m3m'],(0,)], |
---|
3856 | Â Â Â Â [['3R','3mR'],(0,3)], |
---|
3857 | Â Â Â Â [['3','3m1','31m','6/m','6/mmm','4/m','4/mmm'],(0,2)], |
---|
3858 | Â Â Â Â [['mmm'],(0,1,2)], |
---|
3859 | Â Â Â Â [['2/m'+'a'],(0,1,2,3)], |
---|
3860 | Â Â Â Â [['2/m'+'b'],(0,1,2,4)], |
---|
3861 | Â Â Â Â [['2/m'+'c'],(0,1,2,5)], |
---|
3862 | Â Â Â Â [['-1'],(0,1,2,3,4,5)], |
---|
3863 | Â Â Â Â ] |
---|
3864 | Â Â # cell labels |
---|
3865 | Â Â cellUlbl =Â ('a','b','c',u'\u03B1',u'\u03B2',u'\u03B3')Â # unicode a,b,c,alpha,beta,gamma |
---|
3866 | |
---|
3867 | Â Â #====================================================================== |
---|
3868 | Â Â # start processing sequential results here (UpdateSeqResults) |
---|
3869 | Â Â #====================================================================== |
---|
3870 |   if not data: |
---|
3871 |     print 'No sequential refinement results' |
---|
3872 | Â Â Â Â return |
---|
3873 | Â Â variableLabels =Â data.get('variableLabels',{}) |
---|
3874 | Â Â data['variableLabels']Â =Â variableLabels |
---|
3875 | Â Â Histograms,Phases =Â G2frame.GetUsedHistogramsAndPhasesfromTree() |
---|
3876 | Â Â Controls =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,G2frame.root,'Controls')) |
---|
3877 | Â Â # create a place to store Pseudo Vars & Parametric Fit functions, if not present |
---|
3878 |   if 'SeqPseudoVars' not in Controls: Controls['SeqPseudoVars'] = {} |
---|
3879 |   if 'SeqParFitEqList' not in Controls: Controls['SeqParFitEqList'] = [] |
---|
3880 | Â Â histNames =Â data['histNames'] |
---|
3881 |   if G2frame.dataDisplay: |
---|
3882 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
3883 |   if not G2frame.dataFrame.GetStatusBar(): |
---|
3884 | Â Â Â Â Status =Â G2frame.dataFrame.CreateStatusBar() |
---|
3885 | Â Â Â Â Status.SetStatusText("Select column to export; Double click on column to plot data; on row for Covariance") |
---|
3886 | Â Â sampleParms =Â GetSampleParms() |
---|
3887 | |
---|
3888 | Â Â # make dict of varied atom coords keyed by absolute position |
---|
3889 | Â Â newAtomDict =Â data[histNames[0]].get('newAtomDict',{})Â # dict with atom positions; relative & absolute |
---|
3890 | Â Â # Possible error: the next might need to be data[histNames[0]]['varyList'] |
---|
3891 | Â Â # error will arise if there constraints on coordinates? |
---|
3892 |   atomLookup = {newAtomDict[item][0]:item for item in newAtomDict if item in data['varyList']} |
---|
3893 | Â Â |
---|
3894 | Â Â # make dict of varied cell parameters equivalents |
---|
3895 | Â Â ESDlookup =Â {}Â # provides the Dij term for each Ak term (where terms are refined) |
---|
3896 | Â Â Dlookup =Â {}Â # provides the Ak term for each Dij term (where terms are refined) |
---|
3897 | Â Â # N.B. These Dij vars are missing a histogram # |
---|
3898 | Â Â newCellDict =Â data[histNames[0]].get('newCellDict',{}) |
---|
3899 |   for item in newCellDict: |
---|
3900 |     if item in data['varyList']: |
---|
3901 | Â Â Â Â Â Â ESDlookup[newCellDict[item][0]]Â =Â item |
---|
3902 | Â Â Â Â Â Â Dlookup[item]Â =Â newCellDict[item][0] |
---|
3903 | Â Â # add coordinate equivalents to lookup table |
---|
3904 |   for parm in atomLookup: |
---|
3905 | Â Â Â Â Dlookup[atomLookup[parm]]Â =Â parm |
---|
3906 | Â Â Â Â ESDlookup[parm]Â =Â atomLookup[parm] |
---|
3907 | |
---|
3908 | Â Â # get unit cell & symmetry for all phases & initial stuff for later use |
---|
3909 | Â Â RecpCellTerms =Â {} |
---|
3910 | Â Â SGdata =Â {} |
---|
3911 | Â Â uniqCellIndx =Â {} |
---|
3912 | Â Â initialCell =Â {} |
---|
3913 | Â Â RcellLbls =Â {} |
---|
3914 | Â Â zeroDict =Â {} |
---|
3915 | Â Â Rcelldict =Â {} |
---|
3916 |   for phase in Phases: |
---|
3917 | Â Â Â Â phasedict =Â Phases[phase] |
---|
3918 | Â Â Â Â pId =Â phasedict['pId'] |
---|
3919 | Â Â Â Â pfx =Â str(pId)+'::'Â # prefix for A values from phase |
---|
3920 |     RcellLbls[pId] = [pfx+'A'+str(i) for i in range(6)] |
---|
3921 | Â Â Â Â RecpCellTerms[pId]Â =Â G2lat.cell2A(phasedict['General']['Cell'][1:7]) |
---|
3922 | Â Â Â Â zeroDict[pId]Â =Â dict(zip(RcellLbls[pId],6*[0.,])) |
---|
3923 | Â Â Â Â SGdata[pId]Â =Â phasedict['General']['SGData'] |
---|
3924 |     Rcelldict.update({lbl:val for lbl,val in zip(RcellLbls[pId],RecpCellTerms[pId])}) |
---|
3925 | Â Â Â Â laue =Â SGdata[pId]['SGLaue'] |
---|
3926 |     if laue == '2/m': |
---|
3927 | Â Â Â Â Â Â laue +=Â SGdata[pId]['SGUniq'] |
---|
3928 |     for symlist,celllist in cellGUIlist: |
---|
3929 |       if laue in symlist: |
---|
3930 | Â Â Â Â Â Â Â Â uniqCellIndx[pId]Â =Â celllist |
---|
3931 | Â Â Â Â Â Â Â Â break |
---|
3932 | Â Â Â Â else:Â # should not happen |
---|
3933 | Â Â Â Â Â Â uniqCellIndx[pId]Â =Â range(6) |
---|
3934 |     for i in uniqCellIndx[pId]: |
---|
3935 | Â Â Â Â Â Â initialCell[str(pId)+'::A'+str(i)]Â =Â RecpCellTerms[pId][i] |
---|
3936 | |
---|
3937 | Â Â SetDataMenuBar(G2frame,G2frame.dataFrame.SequentialMenu) |
---|
3938 | Â Â G2frame.dataFrame.SetLabel('Sequential refinement results') |
---|
3939 |   if not G2frame.dataFrame.GetStatusBar(): |
---|
3940 | Â Â Â Â Status =Â G2frame.dataFrame.CreateStatusBar() |
---|
3941 | Â Â Â Â Status.SetStatusText('') |
---|
3942 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnRenameSelSeq, id=wxID_RENAMESEQSEL) |
---|
3943 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveSelSeq, id=wxID_SAVESEQSEL) |
---|
3944 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveSelSeqCSV, id=wxID_SAVESEQSELCSV) |
---|
3945 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnPlotSelSeq, id=wxID_PLOTSEQSEL) |
---|
3946 |   G2frame.dataFrame.Bind(wx.EVT_MENU, OnReOrgSelSeq, id=wxID_ORGSEQSEL) |
---|
3947 |   G2frame.dataFrame.Bind(wx.EVT_MENU, AddNewPseudoVar, id=wxADDSEQVAR) |
---|
3948 |   G2frame.dataFrame.Bind(wx.EVT_MENU, DelPseudoVar, id=wxDELSEQVAR) |
---|
3949 |   G2frame.dataFrame.Bind(wx.EVT_MENU, EditPseudoVar, id=wxEDITSEQVAR) |
---|
3950 |   G2frame.dataFrame.Bind(wx.EVT_MENU, AddNewParFitEq, id=wxADDPARFIT) |
---|
3951 |   G2frame.dataFrame.Bind(wx.EVT_MENU, CopyParFitEq, id=wxCOPYPARFIT) |
---|
3952 |   G2frame.dataFrame.Bind(wx.EVT_MENU, DelParFitEq, id=wxDELPARFIT) |
---|
3953 |   G2frame.dataFrame.Bind(wx.EVT_MENU, EditParFitEq, id=wxEDITPARFIT) |
---|
3954 |   G2frame.dataFrame.Bind(wx.EVT_MENU, DoParEqFit, id=wxDOPARFIT) |
---|
3955 | Â Â EnablePseudoVarMenus() |
---|
3956 | Â Â EnableParFitEqMenus() |
---|
3957 | |
---|
3958 | Â Â # scan for locations where the variables change |
---|
3959 | Â Â VaryListChanges =Â []Â # histograms where there is a change |
---|
3960 | Â Â prevVaryList =Â [] |
---|
3961 | Â Â combinedVaryList =Â [] |
---|
3962 | Â Â firstValueList =Â [] |
---|
3963 | Â Â vallookup =Â {} |
---|
3964 | Â Â posdict =Â {} |
---|
3965 |   for i,name in enumerate(histNames): |
---|
3966 |     if i == 0 or prevVaryList != sorted(data[name]['varyList']): |
---|
3967 | Â Â Â Â Â Â # add variables to list as they appear |
---|
3968 |       for j,var in enumerate(data[name]['varyList']): |
---|
3969 |         if var in combinedVaryList: continue |
---|
3970 | Â Â Â Â Â Â Â Â combinedVaryList.append(data[name]['varyList'][j]) |
---|
3971 | Â Â Â Â Â Â Â Â firstValueList.append(data[name]['variables'][j]) |
---|
3972 | Â Â Â Â Â Â vallookup[name]Â =Â dict(zip(data[name]['varyList'],data[name]['variables'])) |
---|
3973 | Â Â Â Â Â Â posdict[name]Â =Â {} |
---|
3974 |       for lbl in data[name]['varyList']: |
---|
3975 |         posdict[name][combinedVaryList.index(lbl)] = lbl      |
---|
3976 | Â Â Â Â Â Â prevVaryList =Â sorted(data[name]['varyList']) |
---|
3977 | Â Â Â Â Â Â VaryListChanges.append(name) |
---|
3978 |   if len(VaryListChanges) > 1: |
---|
3979 | Â Â Â Â G2frame.dataFrame.SequentialFile.Enable(wxID_ORGSEQSEL,True) |
---|
3980 | Â Â else: |
---|
3981 | Â Â Â Â G2frame.dataFrame.SequentialFile.Enable(wxID_ORGSEQSEL,False) |
---|
3982 | Â Â #----------------------------------------------------------------------------------- |
---|
3983 | Â Â # build up the data table by columns ----------------------------------------------- |
---|
3984 | Â Â nRows =Â len(histNames) |
---|
3985 | Â Â colList =Â [nRows*[True]] |
---|
3986 | Â Â colSigs =Â [None] |
---|
3987 | Â Â colLabels =Â ['Use'] |
---|
3988 | Â Â Types =Â [wg.GRID_VALUE_BOOL] |
---|
3989 | Â Â # start with Rwp values |
---|
3990 |   if 'IMG ' not in histNames[0][:4]: |
---|
3991 |     colList += [[data[name]['Rvals']['Rwp'] for name in histNames]] |
---|
3992 | Â Â Â Â colSigs +=Â [None] |
---|
3993 | Â Â Â Â colLabels +=Â ['Rwp'] |
---|
3994 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT+':10,3',] |
---|
3995 | Â Â # add % change in Chi^2 in last cycle |
---|
3996 |   if histNames[0][:4] not in ['SASD','IMG '] and Controls['ShowCell']: |
---|
3997 |     colList += [[100.*data[name]['Rvals'].get('DelChi2',-1) for name in histNames]] |
---|
3998 | Â Â Â Â colSigs +=Â [None] |
---|
3999 | Â Â Â Â colLabels +=Â [u'\u0394\u03C7\u00B2Â (%)'] |
---|
4000 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT,] |
---|
4001 | Â Â deltaChiCol =Â len(colLabels)-1 |
---|
4002 | Â Â # add changing sample parameters to table |
---|
4003 |   for key in sampleParms: |
---|
4004 | Â Â Â Â colList +=Â [sampleParms[key]] |
---|
4005 | Â Â Â Â colSigs +=Â [None] |
---|
4006 | Â Â Â Â colLabels +=Â [key] |
---|
4007 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT,] |
---|
4008 | Â Â sampleDict =Â {} |
---|
4009 |   for i,name in enumerate(histNames): |
---|
4010 |     sampleDict[name] = dict(zip(sampleParms.keys(),[sampleParms[key][i] for key in sampleParms.keys()])) |
---|
4011 | Â Â # add unique cell parameters TODO: review this where the cell symmetry changes (when possible) |
---|
4012 |   if Controls.get('ShowCell',False): |
---|
4013 |     for pId in sorted(RecpCellTerms): |
---|
4014 | Â Â Â Â Â Â pfx =Â str(pId)+'::'Â # prefix for A values from phase |
---|
4015 | Â Â Â Â Â Â cells =Â [] |
---|
4016 | Â Â Â Â Â Â cellESDs =Â [] |
---|
4017 |       colLabels += [pfx+cellUlbl[i] for i in uniqCellIndx[pId]] |
---|
4018 | Â Â Â Â Â Â colLabels +=Â [pfx+'Vol'] |
---|
4019 | Â Â Â Â Â Â Types +=Â (1+len(uniqCellIndx[pId]))*[wg.GRID_VALUE_FLOAT,] |
---|
4020 |       for name in histNames: |
---|
4021 | Â Â Â Â Â Â Â Â covData =Â { |
---|
4022 |           'varyList': [Dlookup.get(striphist(v),v) for v in data[name]['varyList']], |
---|
4023 | Â Â Â Â Â Â Â Â Â Â 'covMatrix':Â data[name]['covMatrix'] |
---|
4024 | Â Â Â Â Â Â Â Â Â Â } |
---|
4025 | Â Â Â Â Â Â Â Â A =Â RecpCellTerms[pId][:]Â # make copy of starting A values |
---|
4026 | Â Â Â Â Â Â Â Â # update with refined values |
---|
4027 |         for i in range(6): |
---|
4028 | Â Â Â Â Â Â Â Â Â Â var =Â str(pId)+'::A'+str(i) |
---|
4029 |           if var in ESDlookup: |
---|
4030 | Â Â Â Â Â Â Â Â Â Â Â Â val =Â data[name]['newCellDict'][ESDlookup[var]][1]Â # get refined value |
---|
4031 | Â Â Â Â Â Â Â Â Â Â Â Â A[i]Â =Â val # override with updated value |
---|
4032 | Â Â Â Â Â Â Â Â # apply symmetry |
---|
4033 |         Albls = [pfx+'A'+str(i) for i in range(6)] |
---|
4034 | Â Â Â Â Â Â Â Â cellDict =Â dict(zip(Albls,A)) |
---|
4035 | Â Â Â Â Â Â Â Â A,zeros =Â G2stIO.cellFill(pfx,SGdata[pId],cellDict,zeroDict[pId]) |
---|
4036 | Â Â Â Â Â Â Â Â # convert to direct cell & add only unique values to table |
---|
4037 | Â Â Â Â Â Â Â Â c =Â G2lat.A2cell(A) |
---|
4038 | Â Â Â Â Â Â Â Â vol =Â G2lat.calc_V(A) |
---|
4039 | Â Â Â Â Â Â Â Â cE =Â G2stIO.getCellEsd(pfx,SGdata[pId],A,covData) |
---|
4040 |         cells += [[c[i] for i in uniqCellIndx[pId]]+[vol]] |
---|
4041 |         cellESDs += [[cE[i] for i in uniqCellIndx[pId]]+[cE[-1]]] |
---|
4042 | Â Â Â Â Â Â colList +=Â zip(*cells) |
---|
4043 | Â Â Â Â Â Â colSigs +=Â zip(*cellESDs) |
---|
4044 | Â Â # sort out the variables in their selected order |
---|
4045 | Â Â varcols =Â 0 |
---|
4046 |   for d in posdict.itervalues(): |
---|
4047 | Â Â Â Â varcols =Â max(varcols,max(d.keys())+1) |
---|
4048 | Â Â # get labels for each column |
---|
4049 |   for i in range(varcols): |
---|
4050 | Â Â Â Â lbl =Â '' |
---|
4051 |     for h in VaryListChanges: |
---|
4052 |       if posdict[h].get(i): |
---|
4053 |         if posdict[h].get(i) in lbl: continue |
---|
4054 |         if lbl != "": lbl += '/' |
---|
4055 | Â Â Â Â Â Â Â Â lbl +=Â posdict[h].get(i) |
---|
4056 | Â Â Â Â colLabels.append(lbl) |
---|
4057 | Â Â Types +=Â varcols*[wg.GRID_VALUE_FLOAT] |
---|
4058 | Â Â vals =Â [] |
---|
4059 | Â Â esds =Â [] |
---|
4060 |   varsellist = None    # will be a list of variable names in the order they are selected to appear |
---|
4061 | Â Â # tabulate values for each hist, leaving None for blank columns |
---|
4062 |   for name in histNames: |
---|
4063 |     if name in posdict: |
---|
4064 |       varsellist = [posdict[name].get(i) for i in range(varcols)] |
---|
4065 |       sellist = [data[name]['varyList'].index(v) if v is not None else None for v in varsellist] |
---|
4066 |     if not varsellist: raise Exception() |
---|
4067 |     vals.append([data[name]['variables'][s] if s is not None else None for s in sellist]) |
---|
4068 |     esds.append([data[name]['sig'][s] if s is not None else None for s in sellist]) |
---|
4069 | Â Â colList +=Â zip(*vals) |
---|
4070 | Â Â colSigs +=Â zip(*esds) |
---|
4071 | Â Â # add the variables that were refined; change from rows to columns |
---|
4072 | Â Â #colList += zip(*[data[name]['variables'] for name in histNames]) |
---|
4073 | Â Â #colLabels += data[histNames[0]]['varyList'] |
---|
4074 | Â Â #Types += len(data[histNames[0]]['varyList'])*[wg.GRID_VALUE_FLOAT] |
---|
4075 | Â Â #colSigs += zip(*[data[name]['sig'] for name in histNames]) |
---|
4076 | |
---|
4077 | Â Â # for var in combinedVaryList: |
---|
4078 | Â Â #Â Â Â colLabels += [var] |
---|
4079 | Â Â #Â Â Â Types += [wg.GRID_VALUE_FLOAT] |
---|
4080 | Â Â #Â Â Â vals = [] |
---|
4081 | Â Â #Â Â Â sigs = [] |
---|
4082 | Â Â #Â Â Â for name in histNames: |
---|
4083 | Â Â #Â Â Â Â Â try: |
---|
4084 | Â Â #Â Â Â Â Â Â Â i = data[name]['varyList'].index(var) |
---|
4085 | Â Â #Â Â Â Â Â Â Â vals.append(data[name]['variables'][i]) |
---|
4086 | Â Â #Â Â Â Â Â Â Â sigs.append(data[name]['sig'][i]) |
---|
4087 | Â Â #Â Â Â Â Â except ValueError: # var not in list |
---|
4088 | Â Â #Â Â Â Â Â Â Â vals.append(None) |
---|
4089 | Â Â #Â Â Â Â Â Â Â sigs.append(None) |
---|
4090 | Â Â #Â Â Â colList += [vals] |
---|
4091 | Â Â #Â Â Â colSigs += [sigs] |
---|
4092 | Â Â Â Â Â Â Â Â |
---|
4093 | Â Â # tabulate constrained variables, removing histogram numbers if needed |
---|
4094 | Â Â # from parameter label |
---|
4095 | Â Â depValDict =Â {} |
---|
4096 | Â Â depSigDict =Â {} |
---|
4097 |   for name in histNames: |
---|
4098 |     for var in data[name].get('depParmDict',{}): |
---|
4099 | Â Â Â Â Â Â val,sig =Â data[name]['depParmDict'][var] |
---|
4100 | Â Â Â Â Â Â svar =Â striphist(var,'*') |
---|
4101 |       if svar not in depValDict: |
---|
4102 | Â Â Â Â Â Â Â Â depValDict[svar]Â =Â [val] |
---|
4103 | Â Â Â Â Â Â Â Â depSigDict[svar]Â =Â [sig] |
---|
4104 | Â Â Â Â Â Â else: |
---|
4105 | Â Â Â Â Â Â Â Â depValDict[svar].append(val) |
---|
4106 | Â Â Â Â Â Â Â Â depSigDict[svar].append(sig) |
---|
4107 | Â Â # add the dependent constrained variables to the table |
---|
4108 |   for var in sorted(depValDict): |
---|
4109 |     if len(depValDict[var]) != len(histNames): continue |
---|
4110 | Â Â Â Â colLabels.append(var) |
---|
4111 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT,] |
---|
4112 | Â Â Â Â colSigs +=Â [depSigDict[var]] |
---|
4113 | Â Â Â Â colList +=Â [depValDict[var]] |
---|
4114 | |
---|
4115 | Â Â # add atom parameters to table |
---|
4116 | Â Â colLabels +=Â atomLookup.keys() |
---|
4117 | Â Â Types +=Â len(atomLookup)*[wg.GRID_VALUE_FLOAT] |
---|
4118 |   for parm in sorted(atomLookup): |
---|
4119 |     colList += [[data[name]['newAtomDict'][atomLookup[parm]][1] for name in histNames]] |
---|
4120 |     if atomLookup[parm] in data[histNames[0]]['varyList']: |
---|
4121 | Â Â Â Â Â Â col =Â data[histNames[0]]['varyList'].index(atomLookup[parm]) |
---|
4122 |       colSigs += [[data[name]['sig'][col] for name in histNames]] |
---|
4123 | Â Â Â Â else: |
---|
4124 | Â Â Â Â Â Â colSigs +=Â [None]Â # should not happen |
---|
4125 | Â Â # evaluate Pseudovars, their ESDs and add them to grid |
---|
4126 |   for expr in Controls['SeqPseudoVars']: |
---|
4127 | Â Â Â Â obj =Â Controls['SeqPseudoVars'][expr] |
---|
4128 | Â Â Â Â calcobj =Â G2obj.ExpressionCalcObj(obj) |
---|
4129 | Â Â Â Â valList =Â [] |
---|
4130 | Â Â Â Â esdList =Â [] |
---|
4131 |     for seqnum,name in enumerate(histNames): |
---|
4132 | Â Â Â Â Â Â sigs =Â data[name]['sig'] |
---|
4133 | Â Â Â Â Â Â G2mv.InitVars() |
---|
4134 | Â Â Â Â Â Â parmDict =Â data[name].get('parmDict') |
---|
4135 | Â Â Â Â Â Â badVary =Â data[name].get('badVary',[]) |
---|
4136 | Â Â Â Â Â Â constraintInfo =Â data[name].get('constraintInfo',[[],[],{},[],seqnum]) |
---|
4137 | Â Â Â Â Â Â groups,parmlist,constrDict,fixedList,ihst =Â constraintInfo |
---|
4138 | Â Â Â Â Â Â varyList =Â data[name]['varyList'] |
---|
4139 | Â Â Â Â Â Â parmDict =Â data[name]['parmDict'] |
---|
4140 | Â Â Â Â Â Â G2mv.GenerateConstraints(groups,parmlist,varyList,constrDict,fixedList,parmDict,SeqHist=ihst) |
---|
4141 | Â Â Â Â Â Â derivs =Â np.array( |
---|
4142 | Â Â Â Â Â Â Â Â [EvalPSvarDeriv(calcobj,parmDict.copy(),sampleDict[name],var,ESD) |
---|
4143 |          for var,ESD in zip(varyList,sigs)] |
---|
4144 | Â Â Â Â Â Â Â Â ) |
---|
4145 | Â Â Â Â Â Â esdList.append(np.sqrt( |
---|
4146 | Â Â Â Â Â Â Â Â np.inner(derivs,np.inner(data[name]['covMatrix'],derivs.T)) |
---|
4147 | Â Â Â Â Â Â Â Â )) |
---|
4148 | Â Â Â Â Â Â PSvarDict =Â parmDict.copy() |
---|
4149 | Â Â Â Â Â Â PSvarDict.update(sampleDict[name]) |
---|
4150 | Â Â Â Â Â Â UpdateParmDict(PSvarDict) |
---|
4151 | Â Â Â Â Â Â calcobj.UpdateDict(PSvarDict) |
---|
4152 | Â Â Â Â Â Â valList.append(calcobj.EvalExpression()) |
---|
4153 |     if not esdList: |
---|
4154 | Â Â Â Â Â Â esdList =Â None |
---|
4155 | Â Â Â Â colList +=Â [valList] |
---|
4156 | Â Â Â Â colSigs +=Â [esdList] |
---|
4157 | Â Â Â Â colLabels +=Â [expr] |
---|
4158 | Â Â Â Â Types +=Â [wg.GRID_VALUE_FLOAT,] |
---|
4159 | Â Â #---- table build done ------------------------------------------------------------- |
---|
4160 | |
---|
4161 | Â Â # Make dict needed for creating & editing pseudovars (PSvarDict). |
---|
4162 | Â Â name =Â histNames[0] |
---|
4163 | Â Â parmDict =Â data[name].get('parmDict') |
---|
4164 | Â Â PSvarDict =Â parmDict.copy() |
---|
4165 | Â Â PSvarDict.update(sampleParms) |
---|
4166 | Â Â UpdateParmDict(PSvarDict) |
---|
4167 | Â Â # Also dicts of dependent (depVarDict) & independent vars (indepVarDict) |
---|
4168 | Â Â # for Parametric fitting from the data table |
---|
4169 | Â Â parmDict =Â dict(zip(colLabels,zip(*colList)[0]))Â # scratch dict w/all values in table |
---|
4170 | Â Â parmDict.update( |
---|
4171 |     {var:val for var,val in data[name].get('newCellDict',{}).values()} # add varied reciprocal cell terms |
---|
4172 | Â Â ) |
---|
4173 | Â Â name =Â histNames[0] |
---|
4174 | Â Â |
---|
4175 | Â Â indepVarDict =Â {Â Â Â #Â values in table w/o ESDs |
---|
4176 |     var:colList[i][0] for i,var in enumerate(colLabels) if colSigs[i] is None |
---|
4177 | Â Â Â Â } |
---|
4178 | Â Â # make dict of dependent vars (w/ESDs) that are not converted (Dij to Ak or dAx to Ax) |
---|
4179 | Â Â depVarDict =Â { |
---|
4180 |     var:colList[i][0] for i,var in enumerate(colLabels) |
---|
4181 |     if colSigs[i] is not None and striphist(var) not in Dlookup |
---|
4182 | Â Â Â Â } |
---|
4183 | Â Â # add recip cell coeff. values |
---|
4184 |   depVarDict.update({var:val for var,val in data[name].get('newCellDict',{}).values()}) |
---|
4185 | Â Â |
---|
4186 | Â Â G2frame.dataDisplay =Â GSGrid(parent=G2frame.dataFrame) |
---|
4187 | Â Â G2frame.SeqTable =Â Table( |
---|
4188 |     [list(c) for c in zip(*colList)],   # convert from columns to rows |
---|
4189 | Â Â Â Â colLabels=colLabels,rowLabels=histNames,types=Types) |
---|
4190 |   G2frame.dataDisplay.SetTable(G2frame.SeqTable, True) |
---|
4191 | Â Â #G2frame.dataDisplay.EnableEditing(False) |
---|
4192 | Â Â # make all but first column read-only |
---|
4193 |   for c in range(1,len(colLabels)): |
---|
4194 |     for r in range(nRows): |
---|
4195 | Â Â Â Â Â Â G2frame.dataDisplay.SetCellReadOnly(r,c) |
---|
4196 |   G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, PlotSelect) |
---|
4197 |   G2frame.dataDisplay.Bind(wg.EVT_GRID_LABEL_RIGHT_CLICK, SetLabelString) |
---|
4198 | Â Â G2frame.dataDisplay.SetRowLabelSize(8*len(histNames[0]))Â Â Â Â #pretty arbitrary 8 |
---|
4199 | Â Â G2frame.dataDisplay.SetMargins(0,0) |
---|
4200 | Â Â G2frame.dataDisplay.AutoSizeColumns(True) |
---|
4201 |   if prevSize: |
---|
4202 | Â Â Â Â G2frame.dataDisplay.SetSize(prevSize) |
---|
4203 | Â Â else: |
---|
4204 | Â Â Â Â G2frame.dataFrame.setSizePosLeft([700,350]) |
---|
4205 | Â Â # highlight unconverged shifts |
---|
4206 |   if histNames[0][:4] not in ['SASD','IMG ']: |
---|
4207 |     for row,name in enumerate(histNames): |
---|
4208 | Â Â Â Â Â Â deltaChi =Â G2frame.SeqTable.GetValue(row,deltaChiCol) |
---|
4209 |       if deltaChi > 10.: |
---|
4210 | Â Â Â Â Â Â Â Â G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Colour(255,0,0)) |
---|
4211 |       elif deltaChi > 1.0: |
---|
4212 | Â Â Â Â Â Â Â Â G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Colour(255,255,0)) |
---|
4213 | Â Â G2frame.dataDisplay.InstallGridToolTip(GridSetToolTip,GridColLblToolTip) |
---|
4214 | Â Â G2frame.dataDisplay.SendSizeEvent()Â # resize needed on mac |
---|
4215 | Â Â G2frame.dataDisplay.Refresh()Â # shows colored text on mac |
---|
4216 | Â Â |
---|
4217 | ################################################################################ |
---|
4218 | #####Â Main PWDR panel |
---|
4219 | ################################################################################Â Â Â Â Â Â |
---|
4220 | Â Â Â Â |
---|
4221 | def UpdatePWHKPlot(G2frame,kind,item): |
---|
4222 | Â Â '''Called when the histogram main tree entry is called. Displays the |
---|
4223 | Â Â histogram weight factor, refinement statistics for the histogram |
---|
4224 | Â Â and the range of data for a simulation. |
---|
4225 | |
---|
4226 | Â Â Also invokes a plot of the histogram. |
---|
4227 | Â Â ''' |
---|
4228 |   def onEditSimRange(event): |
---|
4229 | Â Â Â Â 'Edit simulation range' |
---|
4230 | Â Â Â Â inp =Â [ |
---|
4231 | Â Â Â Â Â Â min(data[1][0]), |
---|
4232 | Â Â Â Â Â Â max(data[1][0]), |
---|
4233 | Â Â Â Â Â Â None |
---|
4234 | Â Â Â Â Â Â ] |
---|
4235 | Â Â Â Â inp[2]Â =Â (inp[1]Â -Â inp[0])/(len(data[1][0])-1.) |
---|
4236 |     names = ('start angle', 'end angle', 'step size') |
---|
4237 | Â Â Â Â dictlst =Â [inp]Â *Â len(inp) |
---|
4238 | Â Â Â Â elemlst =Â range(len(inp)) |
---|
4239 | Â Â Â Â dlg =Â G2G.ScrolledMultiEditor( |
---|
4240 |       G2frame,[inp] * len(inp), range(len(inp)), names, |
---|
4241 | Â Â Â Â Â Â header='Edit simulation range', |
---|
4242 | Â Â Â Â Â Â minvals=(0.001,0.001,0.0001), |
---|
4243 | Â Â Â Â Â Â maxvals=(180.,180.,.1), |
---|
4244 | Â Â Â Â Â Â ) |
---|
4245 | Â Â Â Â dlg.CenterOnParent() |
---|
4246 | Â Â Â Â val =Â dlg.ShowModal() |
---|
4247 | Â Â Â Â dlg.Destroy() |
---|
4248 |     if val != wx.ID_OK: return |
---|
4249 |     if inp[0] > inp[1]: |
---|
4250 | Â Â Â Â Â Â end,start,step =Â inp |
---|
4251 | Â Â Â Â else:Â Â Â Â Â Â Â Â |
---|
4252 | Â Â Â Â Â Â start,end,step =Â inp |
---|
4253 | Â Â Â Â step =Â abs(step) |
---|
4254 | Â Â Â Â N =Â int((end-start)/step)+1 |
---|
4255 | Â Â Â Â newdata =Â np.linspace(start,end,N,True) |
---|
4256 |     if len(newdata) < 2: return # too small a range - reject |
---|
4257 | Â Â Â Â data[1]Â =Â [newdata,np.zeros_like(newdata),np.ones_like(newdata), |
---|
4258 | Â Â Â Â Â Â np.zeros_like(newdata),np.zeros_like(newdata),np.zeros_like(newdata)] |
---|
4259 | Â Â Â Â Tmin =Â newdata[0] |
---|
4260 | Â Â Â Â Tmax =Â newdata[-1] |
---|
4261 | Â Â Â Â G2frame.PatternTree.SetItemPyData(GetPatternTreeItemId(G2frame,item,'Limits'), |
---|
4262 | Â Â Â Â Â Â [(Tmin,Tmax),[Tmin,Tmax]]) |
---|
4263 | Â Â Â Â UpdatePWHKPlot(G2frame,kind,item)Â # redisplay data screen |
---|
4264 | |
---|
4265 |   def OnPlot3DHKL(event): |
---|
4266 | Â Â Â Â refList =Â data[1]['RefList'] |
---|
4267 | Â Â Â Â FoMax =Â np.max(refList.T[8+Super]) |
---|
4268 | Â Â Â Â Hmin =Â np.array([int(np.min(refList.T[0])),int(np.min(refList.T[1])),int(np.min(refList.T[2]))]) |
---|
4269 | Â Â Â Â Hmax =Â np.array([int(np.max(refList.T[0])),int(np.max(refList.T[1])),int(np.max(refList.T[2]))]) |
---|
4270 | Â Â Â Â Vpoint =Â [int(np.mean(refList.T[0])),int(np.mean(refList.T[1])),int(np.mean(refList.T[2]))] |
---|
4271 | Â Â Â Â controls =Â {'Type'Â :Â 'Fosq','Iscale'Â :Â False,'HKLmax'Â :Â Hmax,'HKLmin'Â :Â Hmin, |
---|
4272 | Â Â Â Â Â Â 'FoMax'Â :Â FoMax,'Scale'Â :Â 1.0,'Drawing':{'viewPoint':[Vpoint,[]],'default':Vpoint[:], |
---|
4273 | Â Â Â Â Â Â 'backColor':[0,0,0],'depthFog':False,'Zclip':10.0,'cameraPos':10.,'Zstep':0.05, |
---|
4274 | Â Â Â Â Â Â 'Scale':1.0,'oldxy':[],'viewDir':[1,0,0]},'Super':Super,'SuperVec':SuperVec} |
---|
4275 | Â Â Â Â G2plt.Plot3DSngl(G2frame,newPlot=True,Data=controls,hklRef=refList,Title=phaseName) |
---|
4276 | Â Â Â Â |
---|
4277 |   def OnErrorAnalysis(event): |
---|
4278 | Â Â Â Â G2plt.PlotDeltSig(G2frame,kind) |
---|
4279 | Â Â Â Â |
---|
4280 |   def OnWtFactor(event): |
---|
4281 | Â Â Â Â try: |
---|
4282 | Â Â Â Â Â Â val =Â float(wtval.GetValue()) |
---|
4283 |     except ValueError: |
---|
4284 | Â Â Â Â Â Â val =Â data[0]['wtFactor'] |
---|
4285 | Â Â Â Â data[0]['wtFactor']Â =Â val |
---|
4286 | Â Â Â Â wtval.SetValue('%.3f'%(val)) |
---|
4287 | |
---|
4288 |   def onCopySelectedItems(event): |
---|
4289 | Â Â Â Â '''Respond to menu item to copy multiple sections from a histogram. |
---|
4290 | Â Â Â Â Need this here to pass on the G2frame object. |
---|
4291 | Â Â Â Â ''' |
---|
4292 | Â Â Â Â G2pdG.CopySelectedHistItems(G2frame) |
---|
4293 | Â Â Â Â Â Â |
---|
4294 | Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4295 | #patches |
---|
4296 |   if 'wtFactor' not in data[0]: |
---|
4297 | Â Â Â Â data[0]Â =Â {'wtFactor':1.0} |
---|
4298 | Â Â #if isinstance(data[1],list) and kind == 'HKLF': |
---|
4299 |   if 'list' in str(type(data[1])) and kind == 'HKLF': |
---|
4300 | Â Â Â Â RefData =Â {'RefList':[],'FF':[]} |
---|
4301 |     for ref in data[1]: |
---|
4302 | Â Â Â Â Â Â RefData['RefList'].append(ref[:11]+[ref[13],]) |
---|
4303 | Â Â Â Â Â Â RefData['FF'].append(ref[14]) |
---|
4304 | Â Â Â Â data[1]Â =Â RefData |
---|
4305 | Â Â Â Â G2frame.PatternTree.SetItemPyData(item,data) |
---|
4306 | #end patches |
---|
4307 |   if G2frame.dataDisplay: |
---|
4308 | Â Â Â Â G2frame.dataDisplay.Destroy() |
---|
4309 |   if kind in ['PWDR','SASD']: |
---|
4310 | Â Â Â Â SetDataMenuBar(G2frame,G2frame.dataFrame.PWDRMenu) |
---|
4311 |     G2frame.dataFrame.Bind(wx.EVT_MENU, OnErrorAnalysis, id=wxID_PWDANALYSIS) |
---|
4312 |     G2frame.dataFrame.Bind(wx.EVT_MENU, onCopySelectedItems, id=wxID_PWDCOPY) |
---|
4313 |   elif kind in ['HKLF',]: |
---|
4314 | Â Â Â Â SetDataMenuBar(G2frame,G2frame.dataFrame.HKLFMenu) |
---|
4315 | #Â Â Â Â G2frame.dataFrame.Bind(wx.EVT_MENU, OnErrorAnalysis, id=wxID_PWDANALYSIS) |
---|
4316 |     G2frame.dataFrame.Bind(wx.EVT_MENU, OnPlot3DHKL, id=wxID_PWD3DHKLPLOT) |
---|
4317 | #Â Â Â Â G2frame.dataFrame.Bind(wx.EVT_MENU, onCopySelectedItems, id=wxID_PWDCOPY) |
---|
4318 | Â Â G2frame.dataDisplay =Â wx.Panel(G2frame.dataFrame) |
---|
4319 | Â Â |
---|
4320 | Â Â mainSizer =Â wx.BoxSizer(wx.VERTICAL) |
---|
4321 | Â Â mainSizer.Add((5,5),) |
---|
4322 | Â Â wtSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
4323 | Â Â wtSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' Weight factor: '),0,WACV) |
---|
4324 | Â Â wtval =Â wx.TextCtrl(G2frame.dataDisplay,-1,'%.3f'%(data[0]['wtFactor']),style=wx.TE_PROCESS_ENTER) |
---|
4325 | Â Â wtval.Bind(wx.EVT_TEXT_ENTER,OnWtFactor) |
---|
4326 | Â Â wtval.Bind(wx.EVT_KILL_FOCUS,OnWtFactor) |
---|
4327 | Â Â wtSizer.Add(wtval,0,WACV) |
---|
4328 | Â Â mainSizer.Add(wtSizer) |
---|
4329 |   if data[0].get('Dummy'): |
---|
4330 | Â Â Â Â simSizer =Â wx.BoxSizer(wx.HORIZONTAL) |
---|
4331 | Â Â Â Â Tmin =Â min(data[1][0]) |
---|
4332 | Â Â Â Â Tmax =Â max(data[1][0]) |
---|
4333 | Â Â Â Â num =Â len(data[1][0]) |
---|
4334 | Â Â Â Â step =Â (Tmax -Â Tmin)/(num-1) |
---|
4335 | Â Â Â Â t =Â u'2\u03b8'Â # 2theta |
---|
4336 | Â Â Â Â lbl =Â u'Simulation range: {:.2f}Â to {:.2f}Â {:s}\nwith {:.4f}Â steps ({:d}Â points)' |
---|
4337 | Â Â Â Â lbl +=Â u'\n(Edit range resets observed intensities).' |
---|
4338 | Â Â Â Â lbl =Â lbl.format(Tmin,Tmax,t,step,num) |
---|
4339 | Â Â Â Â simSizer.Add(wx.StaticText(G2frame.dataDisplay,wx.ID_ANY,lbl), |
---|
4340 | Â Â Â Â Â Â Â Â Â Â 0,WACV) |
---|
4341 | Â Â Â Â but =Â wx.Button(G2frame.dataDisplay,wx.ID_ANY,"Edit range") |
---|
4342 | Â Â Â Â but.Bind(wx.EVT_BUTTON,onEditSimRange) |
---|
4343 | Â Â Â Â simSizer.Add(but,0,WACV) |
---|
4344 | Â Â Â Â mainSizer.Add(simSizer) |
---|
4345 |   if 'Nobs' in data[0]: |
---|
4346 | Â Â Â Â mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1, |
---|
4347 |       ' Data residual wR: %.3f%% on %d observations'%(data[0]['wR'],data[0]['Nobs']))) |
---|
4348 |     for value in data[0]: |
---|
4349 |       if 'Nref' in value: |
---|
4350 | Â Â Â Â Â Â Â Â mainSizer.Add((5,5),) |
---|
4351 | Â Â Â Â Â Â Â Â pfx =Â value.split('Nref')[0] |
---|
4352 | Â Â Â Â Â Â Â Â name =Â data[0].get(pfx.split(':')[0]+'::Name','?') |
---|
4353 | Â Â Â Â Â Â Â Â mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' For phase '+name+':')) |
---|
4354 | Â Â Â Â Â Â Â Â mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1, |
---|
4355 |           u' Unweighted phase residuals RF\u00b2: %.3f%%, RF: %.3f%% on %d reflections '% \ |
---|
4356 | Â Â Â Â Â Â Â Â Â Â (data[0][pfx+'Rf^2'],data[0][pfx+'Rf'],data[0][value]))) |
---|
4357 | Â Â mainSizer.Add((5,5),) |
---|
4358 | Â Â mainSizer.Layout()Â Â |
---|
4359 | Â Â G2frame.dataDisplay.SetSizer(mainSizer) |
---|
4360 | Â Â Size =Â mainSizer.Fit(G2frame.dataFrame) |
---|
4361 | Â Â Size[1]Â +=Â 10 |
---|
4362 | Â Â G2frame.dataFrame.setSizePosLeft(Size) |
---|
4363 | Â Â G2frame.PatternTree.SetItemPyData(item,data) |
---|
4364 |   if kind in ['PWDR','SASD']: |
---|
4365 | Â Â Â Â G2plt.PlotPatterns(G2frame,plotType=kind,newPlot=True) |
---|
4366 |   elif kind == 'HKLF': |
---|
4367 | Â Â Â Â Name =Â G2frame.PatternTree.GetItemText(item) |
---|
4368 | Â Â Â Â phaseName =Â G2pdG.IsHistogramInAnyPhase(G2frame,Name) |
---|
4369 |     if phaseName: |
---|
4370 | Â Â Â Â Â Â pId =Â GetPatternTreeItemId(G2frame,G2frame.root,'Phases') |
---|
4371 | Â Â Â Â Â Â phaseId =Â GetPatternTreeItemId(G2frame,pId,phaseName) |
---|
4372 | Â Â Â Â Â Â General =Â G2frame.PatternTree.GetItemPyData(phaseId)['General'] |
---|
4373 | Â Â Â Â Â Â Super =Â General.get('Super',0) |
---|
4374 | Â Â Â Â Â Â SuperVec =Â General.get('SuperVec',[]) |
---|
4375 | Â Â Â Â else: |
---|
4376 | Â Â Â Â Â Â Super =Â 0 |
---|
4377 | Â Â Â Â Â Â SuperVec =Â []Â Â Â Â |
---|
4378 | Â Â Â Â refList =Â data[1]['RefList'] |
---|
4379 | Â Â Â Â FoMax =Â np.max(refList.T[5+data[1].get('Super',0)]) |
---|
4380 |     controls = {'Type' : 'Fo','ifFc' : True,   |
---|
4381 | Â Â Â Â Â Â 'HKLmax'Â :Â [int(np.max(refList.T[0])),int(np.max(refList.T[1])),int(np.max(refList.T[2]))], |
---|
4382 | Â Â Â Â Â Â 'HKLmin'Â :Â [int(np.min(refList.T[0])),int(np.min(refList.T[1])),int(np.min(refList.T[2]))], |
---|
4383 | Â Â Â Â Â Â 'FoMax'Â :Â FoMax,'Zone'Â :Â '001','Layer'Â :Â 0,'Scale'Â :Â 1.0,'Super':Super,'SuperVec':SuperVec} |
---|
4384 | Â Â Â Â G2plt.PlotSngl(G2frame,newPlot=True,Data=controls,hklRef=refList) |
---|
4385 | Â Â Â Â Â Â Â Â Â |
---|
4386 | ################################################################################ |
---|
4387 | #####Â Pattern tree routines |
---|
4388 | ################################################################################Â Â Â Â Â Â |
---|
4389 | Â Â Â Â |
---|
4390 | def GetPatternTreeDataNames(G2frame,dataTypes): |
---|
4391 | Â Â '''Needs a doc string |
---|
4392 | Â Â ''' |
---|
4393 | Â Â names =Â [] |
---|
4394 |   item, cookie = G2frame.PatternTree.GetFirstChild(G2frame.root)    |
---|
4395 |   while item: |
---|
4396 | Â Â Â Â name =Â G2frame.PatternTree.GetItemText(item) |
---|
4397 |     if name[:4] in dataTypes: |
---|
4398 | Â Â Â Â Â Â names.append(name) |
---|
4399 |     item, cookie = G2frame.PatternTree.GetNextChild(G2frame.root, cookie) |
---|
4400 |   return names |
---|
4401 | Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
4402 | def GetPatternTreeItemId(G2frame, parentId, itemText): |
---|
4403 | Â Â '''Needs a doc string |
---|
4404 | Â Â ''' |
---|
4405 |   item, cookie = G2frame.PatternTree.GetFirstChild(parentId) |
---|
4406 |   while item: |
---|
4407 |     if G2frame.PatternTree.GetItemText(item) == itemText: |
---|
4408 |       return item |
---|
4409 |     item, cookie = G2frame.PatternTree.GetNextChild(parentId, cookie) |
---|
4410 |   return 0        |
---|
4411 | |
---|
4412 | def MovePatternTreeToGrid(G2frame,item): |
---|
4413 | Â Â '''Called from GSASII.OnPatternTreeSelChanged when a item is selected on the tree |
---|
4414 | Â Â ''' |
---|
4415 | Â Â |
---|
4416 | #Â Â print G2frame.PatternTree.GetItemText(item) |
---|
4417 | Â Â |
---|
4418 |   oldPage = None # will be set later if already on a Phase item |
---|
4419 |   if G2frame.dataFrame: |
---|
4420 | Â Â Â Â SetDataMenuBar(G2frame) |
---|
4421 |     if G2frame.dataFrame.GetLabel() == 'Comments': |
---|
4422 | Â Â Â Â Â Â try: |
---|
4423 | Â Â Â Â Â Â Â Â data =Â [G2frame.dataDisplay.GetValue()] |
---|
4424 | Â Â Â Â Â Â Â Â G2frame.dataDisplay.Clear()Â |
---|
4425 |         Id = GetPatternTreeItemId(G2frame,G2frame.root, 'Comments') |
---|
4426 |         if Id: G2frame.PatternTree.SetItemPyData(Id,data) |
---|
4427 | Â Â Â Â Â Â except:Â Â Â #clumsy but avoids dead window problem when opening another project |
---|
4428 | Â Â Â Â Â Â Â Â pass |
---|
4429 |     elif G2frame.dataFrame.GetLabel() == 'Notebook': |
---|
4430 | Â Â Â Â Â Â try: |
---|
4431 | Â Â Â Â Â Â Â Â data =Â [G2frame.dataDisplay.GetValue()] |
---|
4432 | Â Â Â Â Â Â Â Â G2frame.dataDisplay.Clear()Â |
---|
4433 |         Id = GetPatternTreeItemId(G2frame,G2frame.root, 'Notebook') |
---|
4434 |         if Id: G2frame.PatternTree.SetItemPyData(Id,data) |
---|
4435 | Â Â Â Â Â Â except:Â Â Â #clumsy but avoids dead window problem when opening another project |
---|
4436 | Â Â Â Â Â Â Â Â pass |
---|
4437 |     elif 'Phase Data for' in G2frame.dataFrame.GetLabel(): |
---|
4438 |       if G2frame.dataDisplay: |
---|
4439 | Â Â Â Â Â Â Â Â oldPage =Â G2frame.dataDisplay.GetSelection() |
---|
4440 | Â Â Â Â G2frame.dataFrame.Clear() |
---|
4441 | Â Â Â Â G2frame.dataFrame.SetLabel('') |
---|
4442 | Â Â else: |
---|
4443 | Â Â Â Â #create the frame for the data item window |
---|
4444 | Â Â Â Â G2frame.dataFrame =Â DataFrame(parent=G2frame.mainPanel,frame=G2frame) |
---|
4445 | Â Â Â Â G2frame.dataFrame.PhaseUserSize =Â None |
---|
4446 | Â Â Â Â |
---|
4447 | Â Â G2frame.dataFrame.Raise()Â Â Â Â Â Â |
---|
4448 | Â Â G2frame.PickId =Â 0 |
---|
4449 | Â Â parentID =Â G2frame.root |
---|
4450 | Â Â #for i in G2frame.ExportPattern: i.Enable(False) |
---|
4451 | Â Â defWid =Â [250,150] |
---|
4452 |   if item != G2frame.root: |
---|
4453 | Â Â Â Â parentID =Â G2frame.PatternTree.GetItemParent(item) |
---|
4454 |   if G2frame.PatternTree.GetItemParent(item) == G2frame.root: |
---|
4455 | Â Â Â Â G2frame.PatternId =Â item |
---|
4456 | Â Â Â Â G2frame.PickId =Â item |
---|
4457 |     if G2frame.PatternTree.GetItemText(item) == 'Notebook': |
---|
4458 | Â Â Â Â Â Â SetDataMenuBar(G2frame,G2frame.dataFrame.DataNotebookMenu) |
---|
4459 | Â Â Â Â Â Â G2frame.PatternId =Â 0 |
---|
4460 | Â Â Â Â Â Â #for i in G2frame.ExportPattern: i.Enable(False) |
---|
4461 | Â Â Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4462 | Â Â Â Â Â Â UpdateNotebook(G2frame,data) |
---|
4463 |     elif G2frame.PatternTree.GetItemText(item) == 'Controls': |
---|
4464 | Â Â Â Â Â Â G2frame.PatternId =Â 0 |
---|
4465 | Â Â Â Â Â Â #for i in G2frame.ExportPattern: i.Enable(False) |
---|
4466 | Â Â Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4467 |       if not data:      #fill in defaults |
---|
4468 | Â Â Â Â Â Â Â Â data =Â copy.copy(G2obj.DefaultControls)Â Â #least squares controls |
---|
4469 | Â Â Â Â Â Â Â Â G2frame.PatternTree.SetItemPyData(item,data)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â |
---|
4470 |       for i in G2frame.Refine: i.Enable(True) |
---|
4471 | Â Â Â Â Â Â G2frame.EnableSeqRefineMenu() |
---|
4472 | Â Â Â Â Â Â UpdateControls(G2frame,data) |
---|
4473 |     elif G2frame.PatternTree.GetItemText(item) == 'Sequential results': |
---|
4474 | Â Â Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4475 | Â Â Â Â Â Â UpdateSeqResults(G2frame,data) |
---|
4476 |     elif G2frame.PatternTree.GetItemText(item) == 'Covariance': |
---|
4477 | Â Â Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4478 | Â Â Â Â Â Â G2frame.dataFrame.setSizePosLeft(defWid) |
---|
4479 | Â Â Â Â Â Â text =Â '' |
---|
4480 |       if 'Rvals' in data: |
---|
4481 | Â Â Â Â Â Â Â Â Nvars =Â len(data['varyList']) |
---|
4482 | Â Â Â Â Â Â Â Â Rvals =Â data['Rvals'] |
---|
4483 |         text = '\nFinal residuals: \nwR = %.3f%% \nchi**2 = %.1f \nGOF = %.2f'%(Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']) |
---|
4484 |         text += '\nNobs = %d \nNvals = %d'%(Rvals['Nobs'],Nvars) |
---|
4485 |         if 'lamMax' in Rvals: |
---|
4486 | Â Â Â Â Â Â Â Â Â Â text +=Â '\nlog10 MaxLambda = %.1f'%(np.log10(Rvals['lamMax'])) |
---|
4487 | Â Â Â Â Â Â wx.TextCtrl(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize(), |
---|
4488 | Â Â Â Â Â Â Â Â value='See plot window for covariance display'+text,style=wx.TE_MULTILINE) |
---|
4489 | Â Â Â Â Â Â G2plt.PlotCovariance(G2frame,data) |
---|
4490 |     elif G2frame.PatternTree.GetItemText(item) == 'Constraints': |
---|
4491 | Â Â Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4492 | Â Â Â Â Â Â G2cnstG.UpdateConstraints(G2frame,data) |
---|
4493 |     elif G2frame.PatternTree.GetItemText(item) == 'Rigid bodies': |
---|
4494 | Â Â Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4495 | Â Â Â Â Â Â G2cnstG.UpdateRigidBodies(G2frame,data) |
---|
4496 |     elif G2frame.PatternTree.GetItemText(item) == 'Restraints': |
---|
4497 | Â Â Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4498 | Â Â Â Â Â Â Phases =Â G2frame.GetPhaseData() |
---|
4499 | Â Â Â Â Â Â phase =Â '' |
---|
4500 | Â Â Â Â Â Â phaseName =Â '' |
---|
4501 |       if Phases: |
---|
4502 | Â Â Â Â Â Â Â Â phaseName =Â Phases.keys()[0] |
---|
4503 | Â Â Â Â Â Â G2frame.dataFrame.setSizePosLeft(defWid) |
---|
4504 | Â Â Â Â Â Â G2restG.UpdateRestraints(G2frame,data,Phases,phaseName) |
---|
4505 |     elif 'IMG' in G2frame.PatternTree.GetItemText(item): |
---|
4506 | Â Â Â Â Â Â G2frame.Image =Â item |
---|
4507 | Â Â Â Â Â Â G2frame.dataFrame.SetTitle('Image Data') |
---|
4508 | Â Â Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(Â \ |
---|
4509 | Â Â Â Â Â Â Â Â G2frame,item,'Image Controls')) |
---|
4510 | Â Â Â Â Â Â G2imG.UpdateImageData(G2frame,data) |
---|
4511 | Â Â Â Â Â Â G2plt.PlotImage(G2frame,newPlot=True) |
---|
4512 |     elif 'PKS' in G2frame.PatternTree.GetItemText(item): |
---|
4513 | Â Â Â Â Â Â G2plt.PlotPowderLines(G2frame) |
---|
4514 |     elif 'PWDR' in G2frame.PatternTree.GetItemText(item): |
---|
4515 | Â Â Â Â Â Â #for i in G2frame.ExportPattern: i.Enable(True) |
---|
4516 |       if G2frame.EnablePlot: |
---|
4517 | Â Â Â Â Â Â Â Â UpdatePWHKPlot(G2frame,'PWDR',item) |
---|
4518 |     elif 'SASD' in G2frame.PatternTree.GetItemText(item): |
---|
4519 | Â Â Â Â Â Â #for i in G2frame.ExportPattern: i.Enable(True) |
---|
4520 |       if G2frame.EnablePlot: |
---|
4521 | Â Â Â Â Â Â Â Â UpdatePWHKPlot(G2frame,'SASD',item) |
---|
4522 |     elif 'HKLF' in G2frame.PatternTree.GetItemText(item): |
---|
4523 | Â Â Â Â Â Â G2frame.Sngl =Â True |
---|
4524 | Â Â Â Â Â Â UpdatePWHKPlot(G2frame,'HKLF',item) |
---|
4525 |     elif 'PDF' in G2frame.PatternTree.GetItemText(item): |
---|
4526 | Â Â Â Â Â Â G2frame.PatternId =Â item |
---|
4527 |       for i in G2frame.ExportPDF: i.Enable(True) |
---|
4528 | Â Â Â Â Â Â G2plt.PlotISFG(G2frame,type='S(Q)') |
---|
4529 |     elif G2frame.PatternTree.GetItemText(item) == 'Phases': |
---|
4530 | Â Â Â Â Â Â G2frame.dataFrame.setSizePosLeft(defWid) |
---|
4531 | Â Â Â Â Â Â wx.TextCtrl(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize(), |
---|
4532 | Â Â Â Â Â Â Â Â value='Select one phase to see its parameters')Â Â Â Â Â Â |
---|
4533 |   elif 'I(Q)' in G2frame.PatternTree.GetItemText(item): |
---|
4534 | Â Â Â Â G2frame.PickId =Â item |
---|
4535 | Â Â Â Â G2frame.PatternId =Â G2frame.PatternTree.GetItemParent(item) |
---|
4536 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,G2frame.PatternId,'PDF Controls')) |
---|
4537 | Â Â Â Â G2pdG.UpdatePDFGrid(G2frame,data) |
---|
4538 | Â Â Â Â G2plt.PlotISFG(G2frame,type='I(Q)',newPlot=True) |
---|
4539 |   elif 'S(Q)' in G2frame.PatternTree.GetItemText(item): |
---|
4540 | Â Â Â Â G2frame.PickId =Â item |
---|
4541 | Â Â Â Â G2frame.PatternId =Â G2frame.PatternTree.GetItemParent(item) |
---|
4542 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,G2frame.PatternId,'PDF Controls')) |
---|
4543 | Â Â Â Â G2pdG.UpdatePDFGrid(G2frame,data) |
---|
4544 | Â Â Â Â G2plt.PlotISFG(G2frame,type='S(Q)',newPlot=True) |
---|
4545 |   elif 'F(Q)' in G2frame.PatternTree.GetItemText(item): |
---|
4546 | Â Â Â Â G2frame.PickId =Â item |
---|
4547 | Â Â Â Â G2frame.PatternId =Â G2frame.PatternTree.GetItemParent(item) |
---|
4548 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,G2frame.PatternId,'PDF Controls')) |
---|
4549 | Â Â Â Â G2pdG.UpdatePDFGrid(G2frame,data) |
---|
4550 | Â Â Â Â G2plt.PlotISFG(G2frame,type='F(Q)',newPlot=True) |
---|
4551 |   elif 'G(R)' in G2frame.PatternTree.GetItemText(item): |
---|
4552 | Â Â Â Â G2frame.PickId =Â item |
---|
4553 | Â Â Â Â G2frame.PatternId =Â G2frame.PatternTree.GetItemParent(item) |
---|
4554 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(GetPatternTreeItemId(G2frame,G2frame.PatternId,'PDF Controls')) |
---|
4555 | Â Â Â Â G2pdG.UpdatePDFGrid(G2frame,data) |
---|
4556 | Â Â Â Â G2plt.PlotISFG(G2frame,type='G(R)',newPlot=True)Â Â Â Â Â Â |
---|
4557 |   elif G2frame.PatternTree.GetItemText(parentID) == 'Phases': |
---|
4558 | Â Â Â Â G2frame.PickId =Â item |
---|
4559 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4560 | Â Â Â Â G2phG.UpdatePhaseData(G2frame,item,data,oldPage) |
---|
4561 |   elif G2frame.PatternTree.GetItemText(item) == 'Comments': |
---|
4562 | Â Â Â Â SetDataMenuBar(G2frame,G2frame.dataFrame.DataCommentsMenu) |
---|
4563 | Â Â Â Â G2frame.PatternId =Â G2frame.PatternTree.GetItemParent(item) |
---|
4564 | Â Â Â Â G2frame.PickId =Â item |
---|
4565 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4566 | Â Â Â Â UpdateComments(G2frame,data) |
---|
4567 |   elif G2frame.PatternTree.GetItemText(item) == 'Image Controls': |
---|
4568 | Â Â Â Â G2frame.dataFrame.SetTitle('Image Controls') |
---|
4569 | Â Â Â Â G2frame.PickId =Â item |
---|
4570 | Â Â Â Â G2frame.Image =Â G2frame.PatternTree.GetItemParent(item) |
---|
4571 | Â Â Â Â masks =Â G2frame.PatternTree.GetItemPyData( |
---|
4572 |       GetPatternTreeItemId(G2frame,G2frame.Image, 'Masks')) |
---|
4573 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4574 | Â Â Â Â G2imG.UpdateImageControls(G2frame,data,masks) |
---|
4575 | Â Â Â Â G2plt.PlotImage(G2frame) |
---|
4576 |   elif G2frame.PatternTree.GetItemText(item) == 'Masks': |
---|
4577 | Â Â Â Â G2frame.dataFrame.SetTitle('Masks') |
---|
4578 | Â Â Â Â G2frame.PickId =Â item |
---|
4579 | Â Â Â Â G2frame.Image =Â G2frame.PatternTree.GetItemParent(item) |
---|
4580 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4581 | Â Â Â Â G2imG.UpdateMasks(G2frame,data) |
---|
4582 | Â Â Â Â G2plt.PlotImage(G2frame) |
---|
4583 |   elif G2frame.PatternTree.GetItemText(item) == 'Stress/Strain': |
---|
4584 | Â Â Â Â G2frame.dataFrame.SetTitle('Stress/Strain') |
---|
4585 | Â Â Â Â G2frame.PickId =Â item |
---|
4586 | Â Â Â Â G2frame.Image =Â G2frame.PatternTree.GetItemParent(item) |
---|
4587 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4588 | Â Â Â Â G2plt.PlotImage(G2frame) |
---|
4589 | Â Â Â Â G2plt.PlotStrain(G2frame,data,newPlot=True) |
---|
4590 | Â Â Â Â G2imG.UpdateStressStrain(G2frame,data) |
---|
4591 |   elif G2frame.PatternTree.GetItemText(item) == 'PDF Controls': |
---|
4592 | Â Â Â Â G2frame.PatternId =Â G2frame.PatternTree.GetItemParent(item) |
---|
4593 |     for i in G2frame.ExportPDF: i.Enable(True) |
---|
4594 | Â Â Â Â G2frame.PickId =Â item |
---|
4595 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4596 | Â Â Â Â G2pdG.UpdatePDFGrid(G2frame,data) |
---|
4597 | Â Â Â Â G2plt.PlotISFG(G2frame,type='I(Q)') |
---|
4598 | Â Â Â Â G2plt.PlotISFG(G2frame,type='S(Q)') |
---|
4599 | Â Â Â Â G2plt.PlotISFG(G2frame,type='F(Q)') |
---|
4600 | Â Â Â Â G2plt.PlotISFG(G2frame,type='G(R)') |
---|
4601 |   elif G2frame.PatternTree.GetItemText(item) == 'Peak List': |
---|
4602 | Â Â Â Â G2frame.PatternId =Â G2frame.PatternTree.GetItemParent(item) |
---|
4603 |     for i in G2frame.ExportPeakList: i.Enable(True) |
---|
4604 | Â Â Â Â G2frame.PickId =Â item |
---|
4605 | Â Â Â Â data =Â G2frame.PatternTree.GetItemPyData(item) |
---|
4606 | #patch |
---|
4607 |     if 'list' in str(type(data)): |
---|
4608 | Â Â Â Â Â Â data =Â {'peaks':data,'sigDict':{}} |
---|
4609 | Â Â Â Â Â Â G2frame.PatternTree.SetItemPyData(item,data) |
---|
4610 | #end patch |
---|
4611 | Â Â Â Â G2pdG.UpdatePeakGrid(G2frame,data) |
---|
4612 | Â Â Â Â G2plt.PlotPatterns(G2frame) |
---|
4613 |   elif G2frame.PatternTree.GetItemText(item) == 'Background': |
---|
4614 | Â Â Â Â G2frame.PatternId =Â G2frame.PatternTree.GetItemParent(item) |
---|
4615 | Â |
---|