This repository was archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGSASIIphsGUI.py
More file actions
16862 lines (15924 loc) · 820 KB
/
GSASIIphsGUI.py
File metadata and controls
16862 lines (15924 loc) · 820 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
#GSASII - phase data display routines
#========== SVN repository information ###################
# $Date: 2024-02-05 15:49:09 -0600 (Mon, 05 Feb 2024) $
# $Author: toby $
# $Revision: 5722 $
# $URL: https://subversion.xray.aps.anl.gov/pyGSAS/trunk/GSASIIphsGUI.py $
# $Id: GSASIIphsGUI.py 5722 2024-02-05 21:49:09Z toby $
#========== SVN repository information ###################
'''
Main routine here is :func:`UpdatePhaseData`, which displays the phase information
(called from :func:`GSASIIdataGUI:SelectDataTreeItem`).
Other top-level routines are:
:func:`GetSpGrpfromUser` (called locally only);
:func:`FindBondsDraw` and :func:`FindBondsDrawCell` (called locally and in GSASIIplot);
:func:`SetPhaseWindow` (called locally and in GSASIIddataGUI and GSASIIrestrGUI, multiple locations)
to control scrolling.
Routines for Phase dataframes follow.
'''
from __future__ import division, print_function
import platform
import os
import wx
import wx.grid as wg
import wx.lib.scrolledpanel as wxscroll
import matplotlib as mpl
#import math
import copy
import time
import sys
import random as ran
import subprocess as subp
import distutils.file_util as disfile
import scipy.optimize as so
import GSASIIpath
GSASIIpath.SetVersionNumber("$Revision: 5722 $")
import GSASIIlattice as G2lat
import GSASIIspc as G2spc
import GSASIIElem as G2elem
import GSASIIElemGUI as G2elemGUI
import GSASIIddataGUI as G2ddG
import GSASIIplot as G2plt
# if GSASIIpath.GetConfigValue('debug'):
# print('Debug reloading',G2plt)
# import imp
# imp.reload(G2plt)
import GSASIIdataGUI as G2gd
import GSASIIIO as G2IO
import GSASIIstrMain as G2stMn
import GSASIIstrIO as G2stIO
import GSASIImath as G2mth
import GSASIIpwd as G2pwd
import GSASIIobj as G2obj
import GSASIIctrlGUI as G2G
import GSASIIfiles as G2fl
import GSASIIconstrGUI as G2cnstG
import numpy as np
import numpy.linalg as nl
import numpy.ma as ma
import atmdata
import ISODISTORT as ISO
try:
wx.NewIdRef
wx.NewId = wx.NewIdRef
except AttributeError:
pass
try:
VERY_LIGHT_GREY = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
WHITE = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)
BLACK = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT)
RED = wx.Colour(255,0,0)
WACV = wx.ALIGN_CENTER_VERTICAL
except:
pass
mapDefault = G2elem.mapDefault
TabSelectionIdDict = {}
# trig functions in degrees
sind = lambda x: np.sin(x*np.pi/180.)
tand = lambda x: np.tan(x*np.pi/180.)
cosd = lambda x: np.cos(x*np.pi/180.)
asind = lambda x: 180.*np.arcsin(x)/np.pi
acosd = lambda x: 180.*np.arccos(x)/np.pi
atan2d = lambda x,y: 180.*np.arctan2(y,x)/np.pi
is_exe = lambda fpath: os.path.isfile(fpath) and os.access(fpath, os.X_OK)
sqt2 = np.sqrt(2.)
sqt3 = np.sqrt(3.)
# previous rigid body selections
prevResId = None
prevVecId = None
prevSpnId = None
if '2' in platform.python_version_tuple()[0]:
GkDelta = unichr(0x0394)
Angstr = unichr(0x00c5)
else:
GkDelta = chr(0x0394)
Angstr = chr(0x00c5)
RMCmisc = {}
#### phase class definitions ################################################################################
class SymOpDialog(wx.Dialog):
'''Class to select a symmetry operator
'''
def __init__(self,parent,SGData,New=True,ForceUnit=False):
wx.Dialog.__init__(self,parent,-1,'Select symmetry operator',
pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
panel = wx.Panel(self)
self.SGData = SGData
self.New = New
self.Force = ForceUnit
self.OpSelected = [0,0,0,[0,0,0],False,False]
mainSizer = wx.BoxSizer(wx.VERTICAL)
if ForceUnit:
choice = ['No','Yes']
self.force = wx.RadioBox(panel,-1,'Force to unit cell?',choices=choice)
self.force.Bind(wx.EVT_RADIOBOX, self.OnOpSelect)
mainSizer.Add(self.force,0,wx.TOP,5)
# if SGData['SGInv']:
choice = ['No','Yes']
self.inv = wx.RadioBox(panel,-1,'Choose inversion?',choices=choice)
self.inv.Bind(wx.EVT_RADIOBOX, self.OnOpSelect)
mainSizer.Add(self.inv,0)
if SGData['SGLatt'] != 'P':
LattOp = G2spc.Latt2text(SGData['SGCen']).split(';')
self.latt = wx.RadioBox(panel,-1,'Choose cell centering?',choices=LattOp)
self.latt.Bind(wx.EVT_RADIOBOX, self.OnOpSelect)
mainSizer.Add(self.latt,0)
if SGData['SGLaue'] in ['-1','2/m','mmm','4/m','4/mmm']:
Ncol = 2
else:
Ncol = 3
OpList = []
for Opr in SGData['SGOps']:
OpList.append(G2spc.MT2text(Opr))
self.oprs = wx.RadioBox(panel,-1,'Choose space group operator?',choices=OpList,
majorDimension=Ncol)
self.oprs.Bind(wx.EVT_RADIOBOX, self.OnOpSelect)
mainSizer.Add(self.oprs,0,wx.BOTTOM,5)
mainSizer.Add(wx.StaticText(panel,-1," Choose unit cell?"),0)
cellSizer = wx.BoxSizer(wx.HORIZONTAL)
cellName = ['X','Y','Z']
self.cell = []
for i in range(3):
self.cell.append(wx.SpinCtrl(panel,-1,cellName[i],size=wx.Size(50,20)))
self.cell[-1].SetRange(-3,3)
self.cell[-1].SetValue(0)
self.cell[-1].Bind(wx.EVT_SPINCTRL, self.OnOpSelect)
cellSizer.Add(self.cell[-1],0)
mainSizer.Add(cellSizer,0,wx.BOTTOM,5)
if self.New:
choice = ['No','Yes']
self.new = wx.RadioBox(panel,-1,'Generate new positions?',choices=choice)
self.new.Bind(wx.EVT_RADIOBOX, self.OnOpSelect)
mainSizer.Add(self.new,0)
OkBtn = wx.Button(panel,-1,"Ok")
OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
cancelBtn = wx.Button(panel,-1,"Cancel")
cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add((20,20),1)
btnSizer.Add(OkBtn)
btnSizer.Add((20,20),1)
btnSizer.Add(cancelBtn)
btnSizer.Add((20,20),1)
mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
panel.SetSizer(mainSizer)
panel.Fit()
self.Fit()
def OnOpSelect(self,event):
self.OpSelected[0] = self.inv.GetSelection()
if self.SGData['SGLatt'] != 'P':
self.OpSelected[1] = self.latt.GetSelection()
self.OpSelected[2] = self.oprs.GetSelection()
for i in range(3):
self.OpSelected[3][i] = float(self.cell[i].GetValue())
if self.New:
self.OpSelected[4] = self.new.GetSelection()
if self.Force:
self.OpSelected[5] = self.force.GetSelection()
def GetSelection(self):
return self.OpSelected
def OnOk(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_OK)
def OnCancel(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_CANCEL)
#==============================================================================
class SphereEnclosure(wx.Dialog):
''' Add atoms within sphere of enclosure to drawing
:param wx.Frame parent: reference to parent frame (or None)
:param general: general data (includes drawing data)
:param atoms: drawing atoms data
:param indx: list of selected atoms (may be empty)
'''
def __init__(self,parent,general,drawing,indx):
wx.Dialog.__init__(self,parent,wx.ID_ANY,'Supply sphere info',
pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!
self.General = general
self.Drawing = drawing
self.indx = indx
self.Sphere = [3.0,]
self.centers = []
self.atomTypes = [[item,False] for item in self.General['AtomTypes']]
self.CenterOnParent()
self.Draw()
def Draw(self):
def OnAtomType(event):
Obj = event.GetEventObject()
Id = Ind[Obj.GetId()]
self.atomTypes[Id][1] = Obj.GetValue()
self.panel.Destroy()
self.panel = wx.Panel(self)
mainSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(wx.StaticText(self.panel,label=' Sphere of enclosure controls:'),0)
topSizer = wx.BoxSizer(wx.HORIZONTAL)
atoms = []
if len(self.indx):
topSizer.Add(wx.StaticText(self.panel,label=' Sphere centered at atoms: '),0,WACV)
cx,ct,cs = self.Drawing['atomPtrs'][:3]
for Id in self.indx:
if Id < len(self.Drawing['Atoms']):
atom = self.Drawing['Atoms'][Id]
self.centers.append(atom[cx:cx+3])
atoms.append('%s(%s)'%(atom[ct-1],atom[cs-1]))
else:
self.centers.append(list(self.Drawing['viewPoint'][0]))
atoms.append('View point')
topSizer.Add(wx.ComboBox(self.panel,choices=atoms,value=atoms[0],
style=wx.CB_READONLY|wx.CB_DROPDOWN),0,WACV)
else:
topSizer.Add(wx.StaticText(self.panel,label=' Sphere centered at drawing view point'),0,WACV)
self.centers.append(self.Drawing['viewPoint'][0])
mainSizer.Add(topSizer,0)
sphereSizer = wx.BoxSizer(wx.HORIZONTAL)
sphereSizer.Add(wx.StaticText(self.panel,label=' Sphere radius: '),0,WACV)
radius = G2G.ValidatedTxtCtrl(self.panel,self.Sphere,0,nDig=(10,3),size=(65,25))
sphereSizer.Add(radius,0,WACV)
mainSizer.Add(sphereSizer,0)
mainSizer.Add(wx.StaticText(self.panel,label=' Target selected atoms:'),0)
atSizer = wx.BoxSizer(wx.HORIZONTAL)
Ind = {}
for i,item in enumerate(self.atomTypes):
atm = wx.CheckBox(self.panel,label=item[0])
atm.SetValue(item[1])
atm.Bind(wx.EVT_CHECKBOX, OnAtomType)
Ind[atm.GetId()] = i
atSizer.Add(atm,0,WACV)
mainSizer.Add(atSizer,0)
OkBtn = wx.Button(self.panel,-1,"Ok")
OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
cancelBtn = wx.Button(self.panel,-1,"Cancel")
cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add((20,20),1)
btnSizer.Add(OkBtn)
btnSizer.Add((20,20),1)
btnSizer.Add(cancelBtn)
btnSizer.Add((20,20),1)
mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
self.panel.SetSizer(mainSizer)
self.panel.Fit()
self.Fit()
def GetSelection(self):
used = []
for atm in self.atomTypes:
if atm[1]:
used.append(str(atm[0]))
return self.centers,self.Sphere[0],used
def OnOk(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_OK)
def OnCancel(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_CANCEL)
#==============================================================================
class TransformDialog(wx.Dialog):
''' Phase transformation X' = M*(X-U)+V
:param wx.Frame parent: reference to parent frame (or None)
:param phase: parent phase data
#NB: commonNames & commonTrans defined in GSASIIdataGUI = G2gd
'''
def __init__(self,parent,phase,Trans=np.eye(3),Uvec=np.zeros(3),Vvec=np.zeros(3),ifMag=False,BNSlatt=''):
wx.Dialog.__init__(self,parent,wx.ID_ANY,'Setup phase transformation',
pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!
self.Phase = copy.deepcopy(phase) #will be a new phase!
# self.Super = phase['General']['Super']
# if self.Super:
# self.Trans = np.eye(4)
# self.Vec = np.zeros(4)
# else:
self.Trans = Trans
self.Uvec = Uvec
self.Vvec = Vvec
self.oldSpGrp = copy.deepcopy(phase['General']['SGData']['SpGrp'])
self.oldSGdata = copy.deepcopy(phase['General']['SGData'])
self.newSpGrp = self.Phase['General']['SGData']['SpGrp']
self.SGData = G2spc.SpcGroup(self.newSpGrp)[1]
self.oldCell = copy.deepcopy(phase['General']['Cell'][1:8])
self.newCell = self.Phase['General']['Cell'][1:8]
self.Common = 'abc'
self.ifMag = ifMag
if ifMag:
self.BNSlatt = BNSlatt
self.ifConstr = False
self.Mtrans = False
self.kvec = [0.,0.,0.]
self.Draw()
self.CenterOnParent()
def Draw(self):
def OnCommon(event):
Obj = event.GetEventObject()
self.Common = Obj.GetValue()
self.Mtrans = False
if '*' in self.Common:
A,B = G2lat.cell2AB(self.oldCell[:6])
self.newCell[2:5] = [A[2,2],90.,90.]
a,b = G2lat.cell2AB(self.newCell[:6])
self.Trans = np.inner(a,B) #correct!
self.ifConstr = False
self.newSpGrp = 'P 1'
SGErr,SGData = G2spc.SpcGroup(self.newSpGrp)
self.Phase['General']['SGData'] = SGData
else:
if self.Common == G2gd.commonNames[-1]: #change setting
self.Vvec = G2spc.spg2origins[self.oldSpGrp]
self.newSpGrp = self.oldSpGrp
else:
self.Trans = G2gd.commonTrans[self.Common]
if 'R' == self.Common[-1]:
self.newSpGrp += ' r'
SGErr,SGData = G2spc.SpcGroup(self.newSpGrp)
self.Phase['General']['SGData'] = SGData
SGTxt.SetLabel(self.newSpGrp)
OnTest(event)
def OnSpaceGroup(event):
event.Skip()
SpcGp = GetSpGrpfromUser(self.panel,self.newSpGrp)
if SpcGp == self.newSpGrp or SpcGp is None: #didn't change it!
return
# try a lookup on the user-supplied name
SpGrpNorm = G2spc.StandardizeSpcName(SpcGp)
if SpGrpNorm:
SGErr,self.SGData = G2spc.SpcGroup(SpGrpNorm)
else:
SGErr,self.SGData = G2spc.SpcGroup(SpcGp)
if SGErr:
text = [G2spc.SGErrors(SGErr)+'\nSpace Group set to previous']
SGTxt.SetLabel(self.newSpGrp)
msg = 'Space Group Error'
Text = '\n'.join(text)
wx.MessageBox(Text,caption=msg,style=wx.ICON_EXCLAMATION)
else:
text,table = G2spc.SGPrint(self.SGData)
self.Phase['General']['SGData'] = self.SGData
self.newSpGrp = SpcGp
SGTxt.SetLabel(self.Phase['General']['SGData']['SpGrp'])
msg = 'Space Group Information'
G2G.SGMessageBox(self.panel,msg,text,table).Show()
if self.ifMag:
self.BNSlatt = self.SGData['SGLatt']
G2spc.SetMagnetic(self.SGData)
if self.Phase['General']['Type'] == 'magnetic':
Nops = len(self.SGData['SGOps'])*len(self.SGData['SGCen'])
if self.SGData['SGInv']:
Nops *= 2
self.SGData['SpnFlp'] = Nops*[1,]
del self.oldSGdata['MAXMAGN']
wx.CallAfter(self.Draw)
def OnShowOps(event):
text,table = G2spc.SGPrint(self.SGData,AddInv=True)
if self.ifMag:
msg = 'Magnetic space group information'
OprNames,SpnFlp = G2spc.GenMagOps(self.SGData)
text[0] = ' Magnetic Space Group: '+self.SGData['MagSpGrp']
text[3] = ' The magnetic lattice point group is '+self.SGData['MagPtGp']
G2G.SGMagSpinBox(self.panel,msg,text,table,self.SGData['SGCen'],OprNames,
self.SGData['SpnFlp'],False).Show()
else:
msg = 'Space group information'
G2G.SGMessageBox(self.panel,msg,text,table).Show()
def OnTest(event):
if not self.TestMat():
return
if self.Mtrans:
self.newCell = G2lat.TransformCell(self.oldCell[:6],self.Trans.T)
else:
self.newCell = G2lat.TransformCell(self.oldCell[:6],self.Trans)
wx.CallAfter(self.Draw)
def OnMag(event):
self.ifMag = True
self.BNSlatt = self.SGData['SGLatt']
G2spc.SetMagnetic(self.SGData)
wx.CallAfter(self.Draw)
def OnConstr(event):
self.ifConstr = constr.GetValue()
def OnBNSlatt(event):
Obj = event.GetEventObject()
self.BNSlatt = Obj.GetValue()
if self.BNSlatt == self.SGData['SGLatt']:
return
GenSym,GenFlg,BNSsym = G2spc.GetGenSym(self.SGData)
self.SGData['BNSlattsym'] = [self.BNSlatt,BNSsym[self.BNSlatt]]
self.SGData['SGSpin'] = [1,]*len(self.SGData['SGSpin'])
wx.CallAfter(self.Draw)
def OnMtrans(event):
Obj = event.GetEventObject()
self.Mtrans = Obj.GetValue()
def OnSpinOp(event):
Obj = event.GetEventObject()
isym = Indx[Obj.GetId()]+1
spCode = {'red':-1,'black':1}
self.SGData['SGSpin'][isym] = spCode[Obj.GetValue()]
G2spc.CheckSpin(isym,self.SGData)
G2spc.SetMagnetic(self.SGData)
wx.CallAfter(self.Draw)
self.panel.Destroy()
self.panel = wx.Panel(self)
mainSizer = wx.BoxSizer(wx.VERTICAL)
if self.ifMag:
if self.BNSlatt != self.SGData['SGLatt']:
GenSym,GenFlg,BNSsym = G2spc.GetGenSym(self.SGData)
self.SGData['BNSlattsym'] = [self.BNSlatt,BNSsym[self.BNSlatt]]
else:
mag = wx.Button(self.panel,label='Make new phase magnetic?')
mag.Bind(wx.EVT_BUTTON,OnMag)
mainSizer.Add(mag,0)
MatSizer = wx.BoxSizer(wx.HORIZONTAL)
transSizer = wx.BoxSizer(wx.VERTICAL)
transSizer.Add((5,5),0)
transSizer.Add(wx.StaticText(self.panel,label=
" Cell transformation via g'=gM; g=metric tensor \n XYZ transformation via M*(X-U)+V = X'; M* = inv(M)"))
# if self.Super:
# Trmat = wx.FlexGridSizer(4,4,0,0)
# else:
commonSizer = wx.BoxSizer(wx.HORIZONTAL)
commonSizer.Add(wx.StaticText(self.panel,label=' Common transformations: '),0,WACV)
if self.oldSpGrp not in G2spc.spg2origins:
common = wx.ComboBox(self.panel,value=self.Common,choices=G2gd.commonNames[:-1],
style=wx.CB_READONLY|wx.CB_DROPDOWN)
else:
common = wx.ComboBox(self.panel,value=self.Common,choices=G2gd.commonNames,
style=wx.CB_READONLY|wx.CB_DROPDOWN)
common.Bind(wx.EVT_COMBOBOX,OnCommon)
commonSizer.Add(common,0,WACV)
transSizer.Add(commonSizer)
transSizer.Add(G2G.XformMatrix(self.panel,self.Trans,self.Uvec,self.Vvec))
MatSizer.Add((10,0),0)
MatSizer.Add(transSizer)
mainSizer.Add(MatSizer)
if self.ifMag:
MagSizer = wx.BoxSizer(wx.HORIZONTAL)
if not self.oldSGdata.get('MAXMAGN',[]):
Mtrans = wx.CheckBox(self.panel,label=' Use matrix transform?')
Mtrans.SetValue(self.Mtrans)
Mtrans.Bind(wx.EVT_CHECKBOX,OnMtrans)
MagSizer.Add(Mtrans,0,WACV)
mainSizer.Add(MagSizer,0)
mainSizer.Add(wx.StaticText(self.panel,label=' Old lattice parameters:'),0)
mainSizer.Add(wx.StaticText(self.panel,label=
' a = %.5f b = %.5f c = %.5f'%(self.oldCell[0],self.oldCell[1],self.oldCell[2])),0)
mainSizer.Add(wx.StaticText(self.panel,label=' alpha = %.3f beta = %.3f gamma = %.3f'%
(self.oldCell[3],self.oldCell[4],self.oldCell[5])),0)
mainSizer.Add(wx.StaticText(self.panel,label=' volume = %.3f'%(self.oldCell[6])),0)
mainSizer.Add(wx.StaticText(self.panel,label=' New lattice parameters:'),0)
mainSizer.Add(wx.StaticText(self.panel,label=
' a = %.5f b = %.5f c = %.5f'%(self.newCell[0],self.newCell[1],self.newCell[2])),0)
mainSizer.Add(wx.StaticText(self.panel,label=' alpha = %.3f beta = %.3f gamma = %.3f'%
(self.newCell[3],self.newCell[4],self.newCell[5])),0)
mainSizer.Add(wx.StaticText(self.panel,label=' volume = %.3f'%(self.newCell[6])),0)
sgSizer = wx.BoxSizer(wx.HORIZONTAL)
sgSizer.Add(wx.StaticText(self.panel,label=' Target space group: '),0,WACV)
SGTxt = wx.Button(self.panel,wx.ID_ANY,self.newSpGrp,size=(100,-1))
SGTxt.Bind(wx.EVT_BUTTON,OnSpaceGroup)
sgSizer.Add(SGTxt,0,WACV)
showOps = wx.Button(self.panel,label=' Show operators?')
showOps.Bind(wx.EVT_BUTTON,OnShowOps)
sgSizer.Add(showOps,0,WACV)
mainSizer.Add(sgSizer,0)
if 'magnetic' not in self.Phase['General']['Type']:
if self.ifMag:
Indx = {}
GenSym,GenFlg,BNSsym = G2spc.GetGenSym(self.SGData)
BNSizer = wx.BoxSizer(wx.HORIZONTAL)
BNSizer.Add(wx.StaticText(self.panel,label=' Select BNS lattice:'),0,WACV)
BNSkeys = [self.SGData['SGLatt'],]+list(BNSsym.keys())
BNSkeys.sort()
try: #this is an ugly kluge - bug in wx.ComboBox
if self.BNSlatt[2] in ['a','b','c']:
BNSkeys.reverse()
except:
pass
BNS = wx.ComboBox(self.panel,choices=BNSkeys,style=wx.CB_READONLY|wx.CB_DROPDOWN)
BNS.SetValue(self.BNSlatt)
BNS.Bind(wx.EVT_COMBOBOX,OnBNSlatt)
BNSizer.Add(BNS,0,WACV)
spinColor = ['black','red']
spCode = {-1:'red',1:'black'}
for isym,sym in enumerate(GenSym[1:]):
BNSizer.Add(wx.StaticText(self.panel,label=' %s: '%(sym.strip())),0,WACV)
spinOp = wx.ComboBox(self.panel,value=spCode[self.SGData['SGSpin'][isym+1]],choices=spinColor,
style=wx.CB_READONLY|wx.CB_DROPDOWN)
Indx[spinOp.GetId()] = isym
spinOp.Bind(wx.EVT_COMBOBOX,OnSpinOp)
BNSizer.Add(spinOp,0,WACV)
OprNames,SpnFlp = G2spc.GenMagOps(self.SGData)
self.SGData['SpnFlp'] = SpnFlp
mainSizer.Add(BNSizer,0)
mainSizer.Add(wx.StaticText(self.panel,label=' Magnetic Space Group: '+self.SGData['MagSpGrp']),0)
if self.ifMag:
mainSizer.Add(wx.StaticText(self.panel, \
label=' NB: Nonmagnetic atoms will be deleted from new phase'),0)
constr = wx.CheckBox(self.panel,label=' Make constraints between phases?')
constr.SetValue(self.ifConstr)
constr.Bind(wx.EVT_CHECKBOX,OnConstr)
mainSizer.Add(constr,0)
TestBtn = wx.Button(self.panel,-1,"Test")
TestBtn.Bind(wx.EVT_BUTTON, OnTest)
OkBtn = wx.Button(self.panel,-1,"Ok")
OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
cancelBtn = wx.Button(self.panel,-1,"Cancel")
cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add((20,20),1)
btnSizer.Add(TestBtn)
btnSizer.Add((20,20),1)
btnSizer.Add(OkBtn)
btnSizer.Add((20,20),1)
btnSizer.Add(cancelBtn)
btnSizer.Add((20,20),1)
mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
self.panel.SetSizer(mainSizer)
self.panel.Fit()
self.Fit()
def TestMat(self):
VC = nl.det(self.Trans)
if VC < 0.:
wx.MessageBox('Warning - left handed transformation',caption='Transformation matrix check',
style=wx.ICON_EXCLAMATION)
return True
try:
nl.inv(self.Trans)
except nl.LinAlgError:
wx.MessageBox('ERROR - bad transformation matrix',caption='Transformation matrix check',
style=wx.ICON_ERROR)
return False
return True
def GetSelection(self):
self.Phase['General']['SGData'] = self.SGData
if self.ifMag:
self.Phase['General']['Name'] += ' mag: '
else:
self.Phase['General']['Name'] += ' %s'%(self.Common)
if not self.TestMat():
return None
if self.Mtrans:
self.Phase['General']['Cell'][1:] = G2lat.TransformCell(self.oldCell[:6],self.Trans.T)
return self.Phase,self.Trans.T,self.Uvec,self.Vvec,self.ifMag,self.ifConstr,self.Common
else:
self.Phase['General']['Cell'][1:] = G2lat.TransformCell(self.oldCell[:6],self.Trans)
return self.Phase,self.Trans,self.Uvec,self.Vvec,self.ifMag,self.ifConstr,self.Common
def OnOk(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_OK)
def OnCancel(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_CANCEL)
#==============================================================================
class UseMagAtomDialog(wx.Dialog):
'''Get user selected magnetic atoms after cell transformation
'''
def __init__(self,parent,Name,Atoms,atCodes,atMxyz,ifMag=True,ifOK=False,ifDelete=False):
title = 'Subgroup atom list'
if ifMag:
title = 'Magnetic atom selection'
wx.Dialog.__init__(self,parent,wx.ID_ANY,title,
pos=wx.DefaultPosition,size=(450,275),
style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
self.panel = wxscroll.ScrolledPanel(self) #just a dummy - gets destroyed in Draw!
# self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!
self.Name = Name
self.Atoms = Atoms
self.atCodes = atCodes
self.atMxyz = atMxyz
self.ifMag = ifMag
self.ifOK = ifOK
self.ifDelete = ifDelete
self.Use = len(self.Atoms)*[True,]
self.Draw()
def Draw(self):
def OnUseChk(event):
Obj = event.GetEventObject()
iuse = Indx[Obj.GetId()]
self.Use[iuse] = not self.Use[iuse]
Obj.SetValue(self.Use[iuse])
self.panel.Destroy()
self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE)
Indx = {}
Mstr = [' Mx',' My',' Mz']
Xstr = ['X','Y','Z']
mainSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(wx.StaticText(self.panel,label='For: %s'%self.Name),0)
if self.ifMag:
mainSizer.Add(wx.StaticText(self.panel,label=' Name, x, y, z, allowed moments, mag. site sym:'),0)
else:
mainSizer.Add(wx.StaticText(self.panel,label=' Name, x, y, z, allowed xyz, site sym:'),0)
atmSizer = wx.FlexGridSizer(0,2,5,5)
for iuse,[use,atom,mxyz] in enumerate(zip(self.Use,self.Atoms,self.atMxyz)):
mstr = [' ---',' ---',' ---']
for i,mx in enumerate(mxyz[1]):
if mx:
if self.ifMag:
mstr[i] = Mstr[i]
else:
mstr[i] = Xstr[i]
if self.ifMag:
useChk = wx.CheckBox(self.panel,label='Use?')
Indx[useChk.GetId()] = iuse
useChk.SetValue(use)
useChk.Bind(wx.EVT_CHECKBOX, OnUseChk)
atmSizer.Add(useChk,0,WACV)
else:
atmSizer.Add((2,2),0)
text = ' %5s %10.5f %10.5f %10.5f (%s,%s,%s) %s '%(atom[0],atom[3],atom[4],atom[5],mstr[0],mstr[1],mstr[2],mxyz[0])
atmSizer.Add(wx.StaticText(self.panel,label=text),0,WACV)
mainSizer.Add(atmSizer)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
if self.ifOK:
OKBtn = wx.Button(self.panel,-1,"OK")
OKBtn.Bind(wx.EVT_BUTTON, self.OnNo)
btnSizer.Add(OKBtn)
else:
YesBtn = wx.Button(self.panel,-1,"Yes")
YesBtn.Bind(wx.EVT_BUTTON, self.OnYes)
NoBtn = wx.Button(self.panel,-1,"No")
NoBtn.Bind(wx.EVT_BUTTON, self.OnNo)
btnSizer.Add((20,20),1)
btnSizer.Add(YesBtn)
btnSizer.Add((20,20),1)
btnSizer.Add(NoBtn)
if self.ifDelete:
DeleteBtn = wx.Button(self.panel,-1,"Delete")
DeleteBtn.Bind(wx.EVT_BUTTON, self.OnDelete)
btnSizer.Add((20,20),1)
btnSizer.Add(DeleteBtn)
btnSizer.Add((20,20),1)
mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
self.panel.SetSizer(mainSizer)
size = np.array(self.GetSize())
self.panel.SetupScrolling()
self.panel.SetAutoLayout(1)
size = [size[0]-5,size[1]-20] #this fiddling is needed for older wx!
self.panel.SetSize(size)
def GetSelection(self):
useAtoms = []
useatCodes = []
for use,atom,code in zip(self.Use,self.Atoms,self.atCodes):
if use:
useAtoms.append(atom)
useatCodes.append(code)
return useAtoms,useatCodes
def OnYes(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_YES)
def OnNo(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_NO)
def OnDelete(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_DELETE)
#==============================================================================
class RotationDialog(wx.Dialog):
''' Get Rotate & translate matrix & vector - currently not used
needs rethinking - possible use to rotate a group of atoms about some
vector/origin + translation
'''
def __init__(self,parent):
wx.Dialog.__init__(self,parent,wx.ID_ANY,'Atom group rotation/translation',
pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!
self.Trans = np.eye(3)
self.Vec = np.zeros(3)
self.rotAngle = 0.
self.rotVec = np.array([0.,0.,1.])
self.Expand = ''
self.Draw()
def Draw(self):
def OnExpand(event):
self.Expand = expand.GetValue()
def OnRotAngle(event):
event.Skip()
self.rotAngle = float(rotangle.GetValue())
rotangle.SetValue('%5.3f'%(self.rotAngle))
Q = G2mth.AVdeg2Q(self.rotAngle,self.rotVec)
self.Trans = G2mth.Q2Mat(Q)
self.Draw()
def OnRotVec(event):
event.Skip()
vals = rotvec.GetValue()
vals = vals.split()
self.rotVec = np.array([float(val) for val in vals])
rotvec.SetValue('%5.3f %5.3f %5.3f'%(self.rotVec[0],self.rotVec[1],self.rotVec[2]))
Q = G2mth.AVdeg2Q(self.rotAngle,self.rotVec)
self.Trans = G2mth.Q2Mat(Q)
self.Draw()
self.panel.Destroy()
self.panel = wx.Panel(self)
mainSizer = wx.BoxSizer(wx.VERTICAL)
MatSizer = wx.BoxSizer(wx.HORIZONTAL)
transSizer = wx.BoxSizer(wx.VERTICAL)
transSizer.Add(wx.StaticText(self.panel,label=" XYZ Transformation matrix && vector: "+ \
"\n B*M*A*(X-V)+V = X'\n A,B: Cartesian transformation matrices"))
Trmat = wx.FlexGridSizer(3,5,0,0)
for iy,line in enumerate(self.Trans):
for ix,val in enumerate(line):
item = G2G.ValidatedTxtCtrl(self.panel,self.Trans[iy],ix,nDig=(10,3),size=(65,25))
Trmat.Add(item)
Trmat.Add((25,0),0)
vec = G2G.ValidatedTxtCtrl(self.panel,self.Vec,iy,nDig=(10,3),size=(65,25))
Trmat.Add(vec)
transSizer.Add(Trmat)
MatSizer.Add((10,0),0)
MatSizer.Add(transSizer)
mainSizer.Add(MatSizer)
rotationBox = wx.BoxSizer(wx.HORIZONTAL)
rotationBox.Add(wx.StaticText(self.panel,label=' Rotation angle: '),0,WACV)
# Zstep = G2G.ValidatedTxtCtrl(drawOptions,drawingData,'Zstep',nDig=(10,2),xmin=0.01,xmax=4.0)
rotangle = wx.TextCtrl(self.panel,value='%5.3f'%(self.rotAngle),
size=(50,25),style=wx.TE_PROCESS_ENTER)
rotangle.Bind(wx.EVT_TEXT_ENTER,OnRotAngle)
rotangle.Bind(wx.EVT_KILL_FOCUS,OnRotAngle)
rotationBox.Add(rotangle,0,WACV)
rotationBox.Add(wx.StaticText(self.panel,label=' about vector: '),0,WACV)
# Zstep = G2G.ValidatedTxtCtrl(drawOptions,drawingData,'Zstep',nDig=(10,2),xmin=0.01,xmax=4.0)
rotvec = wx.TextCtrl(self.panel,value='%5.3f %5.3f %5.3f'%(self.rotVec[0],self.rotVec[1],self.rotVec[2]),
size=(100,25),style=wx.TE_PROCESS_ENTER)
rotvec.Bind(wx.EVT_TEXT_ENTER,OnRotVec)
rotvec.Bind(wx.EVT_KILL_FOCUS,OnRotVec)
rotationBox.Add(rotvec,0,WACV)
mainSizer.Add(rotationBox,0)
expandChoice = ['','xy','xz','yz','xyz']
expandBox = wx.BoxSizer(wx.HORIZONTAL)
expandBox.Add(wx.StaticText(self.panel,label=' Expand -1 to +1 on: '),0,WACV)
expand = wx.ComboBox(self.panel,value=self.Expand,choices=expandChoice,
style=wx.CB_READONLY|wx.CB_DROPDOWN)
expand.Bind(wx.EVT_COMBOBOX,OnExpand)
expandBox.Add(expand,0,WACV)
expandBox.Add(wx.StaticText(self.panel,label=' and find unique atoms '),0,WACV)
mainSizer.Add(expandBox)
OkBtn = wx.Button(self.panel,-1,"Ok")
OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
cancelBtn = wx.Button(self.panel,-1,"Cancel")
cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add((20,20),1)
btnSizer.Add(OkBtn)
btnSizer.Add((20,20),1)
btnSizer.Add(cancelBtn)
btnSizer.Add((20,20),1)
mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
self.panel.SetSizer(mainSizer)
self.panel.Fit()
self.Fit()
def GetSelection(self):
return self.Trans,self.Vec,self.Expand
def OnOk(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_OK)
def OnCancel(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_CANCEL)
#==============================================================================
class DIFFaXcontrols(wx.Dialog):
''' Solicit items needed to prepare DIFFaX control.dif file
'''
def __init__(self,parent,ctrls,parms=None):
wx.Dialog.__init__(self,parent,wx.ID_ANY,'DIFFaX controls',
pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw!
self.ctrls = ctrls
self.calcType = 'powder pattern'
self.plane = 'h0l'
self.planeChoice = ['h0l','0kl','hhl','h-hl',]
self.lmax = '2'
self.lmaxChoice = [str(i+1) for i in range(6)]
self.Parms = parms
self.Parm = None
if self.Parms != None:
self.Parm = self.Parms[0]
self.parmRange = [0.,1.]
self.parmStep = 2
self.Inst = 'Gaussian'
self.Draw()
def Draw(self):
def OnCalcType(event):
self.calcType = calcType.GetValue()
wx.CallAfter(self.Draw)
def OnPlane(event):
self.plane = plane.GetValue()
def OnMaxL(event):
self.lmax = lmax.GetValue()
def OnParmSel(event):
self.Parm = parmsel.GetValue()
def OnNumStep(event):
self.parmStep = int(numStep.GetValue())
def OnParmRange(event):
event.Skip()
vals = parmrange.GetValue().split()
try:
vals = [float(vals[0]),float(vals[1])]
except ValueError:
vals = self.parmRange
parmrange.SetValue('%.3f %.3f'%(vals[0],vals[1]))
self.parmRange = vals
def OnInstSel(event):
self.Inst = instsel.GetValue()
self.panel.Destroy()
self.panel = wx.Panel(self)
mainSizer = wx.BoxSizer(wx.VERTICAL)
mainSizer.Add(wx.StaticText(self.panel,label=' Controls for DIFFaX'),0)
if self.Parms:
mainSizer.Add(wx.StaticText(self.panel,label=' Sequential powder pattern simulation'),0)
else:
calcChoice = ['powder pattern','selected area']
calcSizer = wx.BoxSizer(wx.HORIZONTAL)
calcSizer.Add(wx.StaticText(self.panel,label=' Select calculation type: '),0,WACV)
calcType = wx.ComboBox(self.panel,value=self.calcType,choices=calcChoice,
style=wx.CB_READONLY|wx.CB_DROPDOWN)
calcType.Bind(wx.EVT_COMBOBOX,OnCalcType)
calcSizer.Add(calcType,0,WACV)
mainSizer.Add(calcSizer)
if self.Parms:
parmSel = wx.BoxSizer(wx.HORIZONTAL)
parmSel.Add(wx.StaticText(self.panel,label=' Select parameter to vary: '),0,WACV)
parmsel = wx.ComboBox(self.panel,value=self.Parm,choices=self.Parms,
style=wx.CB_READONLY|wx.CB_DROPDOWN)
parmsel.Bind(wx.EVT_COMBOBOX,OnParmSel)
parmSel.Add(parmsel,0,WACV)
mainSizer.Add(parmSel)
mainSizer.Add(wx.StaticText(self.panel,label=' Enter parameter range & no. steps: '))
parmRange = wx.BoxSizer(wx.HORIZONTAL)
numChoice = [str(i+1) for i in range(10)]
# Zstep = G2G.ValidatedTxtCtrl(drawOptions,drawingData,'Zstep',nDig=(10,2),xmin=0.01,xmax=4.0)
parmrange = wx.TextCtrl(self.panel,value='%.3f %.3f'%(self.parmRange[0],self.parmRange[1]),
style=wx.TE_PROCESS_ENTER)
parmrange.Bind(wx.EVT_TEXT_ENTER,OnParmRange)
parmrange.Bind(wx.EVT_KILL_FOCUS,OnParmRange)
parmRange.Add(parmrange,0,WACV)
numStep = wx.ComboBox(self.panel,value=str(self.parmStep),choices=numChoice,
style=wx.CB_READONLY|wx.CB_DROPDOWN)
numStep.Bind(wx.EVT_COMBOBOX,OnNumStep)
parmRange.Add(numStep,0,WACV)
mainSizer.Add(parmRange)
if 'selected' in self.calcType:
planeSizer = wx.BoxSizer(wx.HORIZONTAL)
planeSizer.Add(wx.StaticText(self.panel,label=' Select plane: '),0,WACV)
plane = wx.ComboBox(self.panel,value=self.plane,choices=self.planeChoice,
style=wx.CB_READONLY|wx.CB_DROPDOWN)
plane.Bind(wx.EVT_COMBOBOX,OnPlane)
planeSizer.Add(plane,0,WACV)
planeSizer.Add(wx.StaticText(self.panel,label=' Max. l index: '),0,WACV)
lmax = wx.ComboBox(self.panel,value=self.lmax,choices=self.lmaxChoice,
style=wx.CB_READONLY|wx.CB_DROPDOWN)
lmax.Bind(wx.EVT_COMBOBOX,OnMaxL)
planeSizer.Add(lmax,0,WACV)
mainSizer.Add(planeSizer)
else:
instChoice = ['None','Mean Gaussian','Gaussian',]
instSizer = wx.BoxSizer(wx.HORIZONTAL)
instSizer.Add(wx.StaticText(self.panel,label=' Select instrument broadening: '),0,WACV)
instsel = wx.ComboBox(self.panel,value=self.Inst,choices=instChoice,
style=wx.CB_READONLY|wx.CB_DROPDOWN)
instsel.Bind(wx.EVT_COMBOBOX,OnInstSel)
instSizer.Add(instsel,0,WACV)
mainSizer.Add(instSizer)
OkBtn = wx.Button(self.panel,-1,"Ok")
OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
cancelBtn = wx.Button(self.panel,-1,"Cancel")
cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add((20,20),1)
btnSizer.Add(OkBtn)
btnSizer.Add((20,20),1)
btnSizer.Add(cancelBtn)
btnSizer.Add((20,20),1)
mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
self.panel.SetSizer(mainSizer)
self.panel.Fit()
self.Fit()
def GetSelection(self):
if 'powder' in self.calcType:
return 'PWDR',self.Inst,self.Parm,self.parmRange,self.parmStep
elif 'selected' in self.calcType:
return 'SADP',self.plane,self.lmax
def OnOk(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_OK)
def OnCancel(self,event):
parent = self.GetParent()
parent.Raise()
self.EndModal(wx.ID_CANCEL)
#==============================================================================
class AddHatomDialog(wx.Dialog):
'''H atom addition dialog. After :meth:`ShowModal` returns, the results
are found in dict :attr:`self.data`, which is accessed using :meth:`GetData`.