Changeset 1128
- Timestamp:
- Oct 29, 2013 12:03:49 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r1125 r1128 1408 1408 self.Sngl = 0 1409 1409 self.ifGetRing = False 1410 self.setPoly = False 1411 self.setFrame = False 1412 self.setSpot = False 1413 self.setArc = False 1414 self.setRing = False 1410 self.MaskKey = '' #trigger for making image masks 1415 1411 arg = sys.argv 1416 1412 if len(arg) > 1: -
trunk/GSASIIgrid.py
r1127 r1128 95 95 ] = [wx.NewId() for item in range(8)] 96 96 97 [ wxID_MASKCOPY, wxID_MASKSAVE, wxID_MASKLOAD, 97 [ wxID_MASKCOPY, wxID_MASKSAVE, wxID_MASKLOAD,wxID_NEWMASKSPOT,wxID_NEWMASKARC,wxID_NEWMASKRING, 98 98 wxID_NEWMASKFRAME, wxID_NEWMASKPOLY, 99 ] = [wx.NewId() for item in range( 5)]99 ] = [wx.NewId() for item in range(8)] 100 100 101 101 … … 2214 2214 self.MaskEdit.Append(help='Load mask from file', 2215 2215 id=wxID_MASKLOAD, kind=wx.ITEM_NORMAL,text='Load mask') 2216 submenu.Append(help='Create a Frame mask with mouse input', 2216 submenu.Append(help='Create an arc mask with mouse input', 2217 id=wxID_NEWMASKARC, kind=wx.ITEM_NORMAL,text='Arc mask') 2218 submenu.Append(help='Create a frame mask with mouse input', 2217 2219 id=wxID_NEWMASKFRAME, kind=wx.ITEM_NORMAL,text='Frame mask') 2218 2220 submenu.Append(help='Create a polygon mask with mouse input', 2219 2221 id=wxID_NEWMASKPOLY, kind=wx.ITEM_NORMAL,text='Polygon mask') 2222 submenu.Append(help='Create a ring mask with mouse input', 2223 id=wxID_NEWMASKRING, kind=wx.ITEM_NORMAL,text='Ring mask') 2224 submenu.Append(help='Create a spot mask with mouse input', 2225 id=wxID_NEWMASKSPOT, kind=wx.ITEM_NORMAL,text='Spot mask') 2220 2226 self.PostfillDataMenu() 2221 2227 -
trunk/GSASIIimgGUI.py
r1124 r1128 990 990 finally: 991 991 dlg.Destroy() 992 993 def OnNewSpotMask(event): 994 'Start a new spot mask' 995 G2frame.MaskKey = 's' 996 G2plt.OnStartMask(G2frame) 997 998 def OnNewArcMask(event): 999 'Start a new arc mask' 1000 G2frame.MaskKey = 'a' 1001 G2plt.OnStartMask(G2frame) 1002 1003 def OnNewRingMask(event): 1004 'Start a new ring mask' 1005 G2frame.MaskKey = 'r' 1006 G2plt.OnStartMask(G2frame) 1007 1008 def OnNewPolyMask(event): 1009 'Start a new polygon mask' 1010 G2frame.MaskKey = 'p' 1011 G2plt.OnStartMask(G2frame) 1012 992 1013 def OnNewFrameMask(event): 993 1014 'Start a new Frame mask' 994 G2plt.OnStartMask(G2frame,'f') 995 def OnNewPolyMask(event): 996 'Start a new polygon mask' 997 G2plt.OnStartMask(G2frame,'p') 998 1015 G2frame.MaskKey = 'f' 1016 G2plt.OnStartMask(G2frame) 1017 999 1018 if G2frame.dataDisplay: 1000 1019 G2frame.dataDisplay.Destroy() … … 1003 1022 G2frame.dataFrame.Bind(wx.EVT_MENU, OnLoadMask, id=G2gd.wxID_MASKLOAD) 1004 1023 G2frame.dataFrame.Bind(wx.EVT_MENU, OnSaveMask, id=G2gd.wxID_MASKSAVE) 1024 G2frame.dataFrame.Bind(wx.EVT_MENU, OnNewSpotMask, id=G2gd.wxID_NEWMASKSPOT) 1025 G2frame.dataFrame.Bind(wx.EVT_MENU, OnNewArcMask, id=G2gd.wxID_NEWMASKARC) 1026 G2frame.dataFrame.Bind(wx.EVT_MENU, OnNewRingMask, id=G2gd.wxID_NEWMASKRING) 1027 G2frame.dataFrame.Bind(wx.EVT_MENU, OnNewPolyMask, id=G2gd.wxID_NEWMASKPOLY) 1005 1028 G2frame.dataFrame.Bind(wx.EVT_MENU, OnNewFrameMask, id=G2gd.wxID_NEWMASKFRAME) 1006 G2frame.dataFrame.Bind(wx.EVT_MENU, OnNewPolyMask, id=G2gd.wxID_NEWMASKPOLY)1007 1029 if not G2frame.dataFrame.GetStatusBar(): 1008 1030 Status = G2frame.dataFrame.CreateStatusBar() 1009 if G2frame.setFrame: 1010 G2frame.dataFrame.GetStatusBar().SetStatusText("Adding frame mask") 1011 elif G2frame.setPoly: 1012 G2frame.dataFrame.GetStatusBar().SetStatusText("Adding polygon mask") 1031 if G2frame.MaskKey == 'f': 1032 G2frame.dataFrame.GetStatusBar().SetStatusText('Frame mask active - LB pick next point, RB close polygon') 1033 elif G2frame.MaskKey == 'p': 1034 G2frame.dataFrame.GetStatusBar().SetStatusText('Polygon mask active - LB pick next point, RB close polygon') 1035 elif G2frame.MaskKey == 's': 1036 G2frame.dataFrame.GetStatusBar().SetStatusText('Spot mask active - LB pick spot location') 1037 elif G2frame.MaskKey == 'a': 1038 G2frame.dataFrame.GetStatusBar().SetStatusText('Arc mask active - LB pick arc location') 1039 elif G2frame.MaskKey == 'r': 1040 G2frame.dataFrame.GetStatusBar().SetStatusText('Ring mask active - LB pick ring location') 1013 1041 else: 1014 1042 G2frame.dataFrame.GetStatusBar().SetStatusText("To add mask: On 2D Powder Image, key a:arc, r:ring, s:spot, p:polygon, f:frame") … … 1061 1089 wx.ALIGN_CENTER_VERTICAL) 1062 1090 littleSizer.Add((5,0),0) 1063 for x,y,d in spots: 1064 spotText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.2f,%.2f" % (x,y)), 1065 style=wx.TE_READONLY) 1066 spotText.SetBackgroundColour(VERY_LIGHT_GREY) 1067 littleSizer.Add(spotText,0,wx.ALIGN_CENTER_VERTICAL) 1068 spotText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1069 spotDiameter = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.2f" % (d)), 1070 style=wx.TE_PROCESS_ENTER) 1071 littleSizer.Add(spotDiameter,0,wx.ALIGN_CENTER_VERTICAL) 1072 spotDiameter.Bind(wx.EVT_TEXT_ENTER,OnSpotDiameter) 1073 spotDiameter.Bind(wx.EVT_KILL_FOCUS,OnSpotDiameter) 1074 spotIds.append(spotDiameter.GetId()) 1075 spotDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?') 1076 spotDelete.Bind(wx.EVT_CHECKBOX,OnDeleteSpot) 1077 delSpotId.append(spotDelete) 1078 littleSizer.Add(spotDelete,0,wx.ALIGN_CENTER_VERTICAL) 1091 for spot in spots: 1092 if spot: 1093 x,y,d = spot 1094 spotText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.2f,%.2f" % (x,y)), 1095 style=wx.TE_READONLY) 1096 spotText.SetBackgroundColour(VERY_LIGHT_GREY) 1097 littleSizer.Add(spotText,0,wx.ALIGN_CENTER_VERTICAL) 1098 spotText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1099 spotDiameter = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.2f" % (d)), 1100 style=wx.TE_PROCESS_ENTER) 1101 littleSizer.Add(spotDiameter,0,wx.ALIGN_CENTER_VERTICAL) 1102 spotDiameter.Bind(wx.EVT_TEXT_ENTER,OnSpotDiameter) 1103 spotDiameter.Bind(wx.EVT_KILL_FOCUS,OnSpotDiameter) 1104 spotIds.append(spotDiameter.GetId()) 1105 spotDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?') 1106 spotDelete.Bind(wx.EVT_CHECKBOX,OnDeleteSpot) 1107 delSpotId.append(spotDelete) 1108 littleSizer.Add(spotDelete,0,wx.ALIGN_CENTER_VERTICAL) 1079 1109 mainSizer.Add(littleSizer,0,) 1080 1110 ringIds = [] … … 1091 1121 wx.ALIGN_CENTER_VERTICAL) 1092 1122 littleSizer.Add((5,0),0) 1093 for tth,thick in rings: 1094 ringText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (tth)), 1095 style=wx.TE_READONLY) 1096 ringText.SetBackgroundColour(VERY_LIGHT_GREY) 1097 ringText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1098 littleSizer.Add(ringText,0,wx.ALIGN_CENTER_VERTICAL) 1099 ringThick = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (thick)), 1100 style=wx.TE_PROCESS_ENTER) 1101 littleSizer.Add(ringThick,0,wx.ALIGN_CENTER_VERTICAL) 1102 ringThick.Bind(wx.EVT_TEXT_ENTER,OnRingThickness) 1103 ringThick.Bind(wx.EVT_KILL_FOCUS,OnRingThickness) 1104 ringIds.append(ringThick.GetId()) 1105 ringDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?') 1106 ringDelete.Bind(wx.EVT_CHECKBOX,OnDeleteRing) 1107 delRingId.append(ringDelete) 1108 littleSizer.Add(ringDelete,0,wx.ALIGN_CENTER_VERTICAL) 1123 for ring in rings: 1124 if ring: 1125 tth,thick = ring 1126 ringText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (tth)), 1127 style=wx.TE_READONLY) 1128 ringText.SetBackgroundColour(VERY_LIGHT_GREY) 1129 ringText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1130 littleSizer.Add(ringText,0,wx.ALIGN_CENTER_VERTICAL) 1131 ringThick = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (thick)), 1132 style=wx.TE_PROCESS_ENTER) 1133 littleSizer.Add(ringThick,0,wx.ALIGN_CENTER_VERTICAL) 1134 ringThick.Bind(wx.EVT_TEXT_ENTER,OnRingThickness) 1135 ringThick.Bind(wx.EVT_KILL_FOCUS,OnRingThickness) 1136 ringIds.append(ringThick.GetId()) 1137 ringDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?') 1138 ringDelete.Bind(wx.EVT_CHECKBOX,OnDeleteRing) 1139 delRingId.append(ringDelete) 1140 littleSizer.Add(ringDelete,0,wx.ALIGN_CENTER_VERTICAL) 1109 1141 mainSizer.Add(littleSizer,0,) 1110 1142 arcIds = [] … … 1124 1156 wx.ALIGN_CENTER_VERTICAL) 1125 1157 littleSizer.Add((5,0),0) 1126 for tth,azimuth,thick in arcs: 1127 arcText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (tth)), 1128 style=wx.TE_READONLY) 1129 arcText.SetBackgroundColour(VERY_LIGHT_GREY) 1130 arcText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1131 littleSizer.Add(arcText,0,wx.ALIGN_CENTER_VERTICAL) 1132 azmText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%d,%d" % (azimuth[0],azimuth[1])), 1133 style=wx.TE_READONLY) 1134 azmText.SetBackgroundColour(VERY_LIGHT_GREY) 1135 azmText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1136 littleSizer.Add(azmText,0,wx.ALIGN_CENTER_VERTICAL) 1137 arcThick = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (thick)), 1138 style=wx.TE_PROCESS_ENTER) 1139 littleSizer.Add(arcThick,0,wx.ALIGN_CENTER_VERTICAL) 1140 arcThick.Bind(wx.EVT_TEXT_ENTER,OnArcThickness) 1141 arcThick.Bind(wx.EVT_KILL_FOCUS,OnArcThickness) 1142 arcIds.append(arcThick.GetId()) 1143 arcDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?') 1144 arcDelete.Bind(wx.EVT_CHECKBOX,OnDeleteArc) 1145 delArcId.append(arcDelete) 1146 littleSizer.Add(arcDelete,0,wx.ALIGN_CENTER_VERTICAL) 1158 for arc in arcs: 1159 if arc: 1160 tth,azimuth,thick = arc 1161 arcText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (tth)), 1162 style=wx.TE_READONLY) 1163 arcText.SetBackgroundColour(VERY_LIGHT_GREY) 1164 arcText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1165 littleSizer.Add(arcText,0,wx.ALIGN_CENTER_VERTICAL) 1166 azmText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%d,%d" % (azimuth[0],azimuth[1])), 1167 style=wx.TE_READONLY) 1168 azmText.SetBackgroundColour(VERY_LIGHT_GREY) 1169 azmText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1170 littleSizer.Add(azmText,0,wx.ALIGN_CENTER_VERTICAL) 1171 arcThick = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (thick)), 1172 style=wx.TE_PROCESS_ENTER) 1173 littleSizer.Add(arcThick,0,wx.ALIGN_CENTER_VERTICAL) 1174 arcThick.Bind(wx.EVT_TEXT_ENTER,OnArcThickness) 1175 arcThick.Bind(wx.EVT_KILL_FOCUS,OnArcThickness) 1176 arcIds.append(arcThick.GetId()) 1177 arcDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?') 1178 arcDelete.Bind(wx.EVT_CHECKBOX,OnDeleteArc) 1179 delArcId.append(arcDelete) 1180 littleSizer.Add(arcDelete,0,wx.ALIGN_CENTER_VERTICAL) 1147 1181 mainSizer.Add(littleSizer,0,) 1148 1182 polyIds = [] -
trunk/GSASIIobj.py
r1127 r1128 148 148 \ F000N neutron F(000) intensity (float) 149 149 \ Mydir directory of current .gpx file (str) 150 \ MCSA controls ?151 \ Cell List with 7items: cell refinement flag (bool)150 \ MCSA controls Monte Carlo-Simulated Annealing controls (dict) 151 \ Cell List with 8 items: cell refinement flag (bool) 152 152 a, b, c, (Angstrom, float) 153 153 alpha, beta & gamma (degrees, float) 154 \ Type for now 'nuclear' (str) 154 volume (A^3, float) 155 \ Type 'nuclear' or 'macromolecular' for now (str) 155 156 \ Map dict of map parameters 156 157 \ SH Texture dict of spherical harmonic preferred orientation … … 164 165 \ Pawley neg wt Restraint value for negative Pawley intensities 165 166 (float) 166 \ Flip Charge flip controls dict? 167 \ Data plot type ? 167 \ Flip dict of Charge flip controls 168 \ Data plot type data plot type ('Mustrain', 'Size' or 169 'Preferred orientation') for powder data (str) 168 170 \ Mass Mass of unit cell contents in g/mol 169 171 \ POhkl March-Dollase preferred orientation direction 170 \ Z ?171 \ vdWRadii ?172 \ Z dict of atomic numbers for each atom type 173 \ vdWRadii dict of van der Waals radii for each atom type 172 174 \ Color Colors for atoms (list of (r,b,g) triplets) 173 175 \ AtomTypes List of atom types … … 198 200 \ ballScale Size of spheres in ball-and-stick display (float) 199 201 \ bondList dict with bonds 200 \ contourLevel ?(float)202 \ contourLevel map contour level in e/A^3 (float) 201 203 \ showABC Flag to show view point triplet (bool). True=show. 202 204 \ viewDir cartesian viewing direction (np.array with three … … 210 212 \ sizeH Size ratio for H atoms (float) 211 213 \ bondRadius Size of binds in A (float) 212 \ atomPtrs ?(list)214 \ atomPtrs positions of x, type, site sym, ADP flag in Draw Atoms (list) 213 215 \ viewPoint list of lists. First item in list is [x,y,z] 214 216 in fractional coordinates for the center of 215 the plot. Second item ?. 217 the plot. Second item list of previous & current 218 atom number viewed (may be [0,0]) 216 219 \ showHydrogen Flag to control plotting of H atoms. 217 220 \ unitCellBox Flag to control display of the unit cell. … … 227 230 are located that are within r(Ra+Rb) and (Ra+Rb)/r 228 231 where Ra and Rb are the atomic radii. 229 \ oldxy ?(list with two floats)232 \ oldxy previous view point (list with two floats) 230 233 \ cameraPos Viewing position in A for plot (float) 231 \ depthFog ?(bool)234 \ depthFog True if use depthFog on plot - set currently as False (bool) 232 235 RBModels \ Rigid body assignments (note Rigid body definitions 233 236 are stored in their own main top-level tree entry.) … … 238 241 parameters for items such as scale factors, 239 242 size and strain parameters. (dict) 240 MCSA \ Monte-Carlo simulated annealing parameters 243 MCSA \ Monte-Carlo simulated annealing parameters (dict) 244 \ 241 245 ========== =============== ==================================================== 242 246 … … 304 308 ``phasedict['Atoms']``. Also needed to read atom information 305 309 are four pointers, ``cx,ct,cs,cia = phasedict['General']['AtomPtrs']``, 306 which define locations in the atom record, as shown below. 310 which define locations in the atom record, as shown below. Items shown are 311 always present; additional ones for macromolecular phases are marked 'mm' 307 312 308 313 .. tabularcolumns:: |l|p{4.5in}| … … 313 318 cx,cx+1,cx+2 the x,y and z coordinates 314 319 cx+3 fractional occupancy (also cs-1) 320 ct-4 (mm) residue number (str) 321 ct-3 (mm) residue name (e.g. ALA) (str) 322 ct-2 (mm) chain label (str) 315 323 ct-1 atom label 316 324 ct atom type -
trunk/GSASIIplot.py
r1124 r1128 2083 2083 PlotIntegration(G2frame,newPlot,event) 2084 2084 2085 def OnStartMask(G2frame ,eventkey):2085 def OnStartMask(G2frame): 2086 2086 '''Initiate the start of a Frame or Polygon map 2087 2087 … … 2092 2092 Masks = G2frame.PatternTree.GetItemPyData( 2093 2093 G2gd.GetPatternTreeItemId(G2frame,G2frame.Image, 'Masks')) 2094 if eventkey == 'f': 2095 G2frame.setFrame = True 2094 if G2frame.MaskKey == 'f': 2096 2095 Masks['Frames'] = [] 2097 G2frame.G2plotNB.status.SetFields(['','Frame mask active - LB pick next point, RB close polygon']) 2098 elif eventkey == 'p': 2099 G2frame.setPoly = True 2096 elif G2frame.MaskKey == 'p': 2100 2097 Masks['Polygons'].append([]) 2101 G2frame.G2plotNB.status.SetFields(['','Polygon mask active - LB pick next point, RB close polygon']) 2098 elif G2frame.MaskKey == 's': 2099 Masks['Points'].append([]) 2100 elif G2frame.MaskKey == 'a': 2101 Masks['Arcs'].append([]) 2102 elif G2frame.MaskKey == 'r': 2103 Masks['Rings'].append([]) 2102 2104 G2imG.UpdateMasks(G2frame,Masks) 2103 2105 PlotImage(G2frame,newImage=True) … … 2153 2155 tth,azm,dsp = G2img.GetTthAzmDsp(xpos,ypos,Data) 2154 2156 Q = 2.*math.pi/dsp 2155 if G2frame. setPoly or G2frame.setFrame:2157 if G2frame.MaskKey in ['p','f']: 2156 2158 G2frame.G2plotNB.status.SetFields(['','Polygon/frame mask pick - LB next point, RB close polygon']) 2157 2159 else: … … 2165 2167 return 2166 2168 if PickName == 'Masks': 2167 Xpos = event.xdata 2168 if not Xpos: #got point out of frame 2169 return 2170 Ypos = event.ydata 2171 if event.key == 's': 2172 Masks['Points'].append([Xpos,Ypos,1.]) 2173 elif event.key == 'r': 2174 tth = G2img.GetTth(Xpos,Ypos,Data) 2175 Masks['Rings'].append([tth,0.1]) 2176 elif event.key == 'a': 2177 tth,azm = G2img.GetTthAzm(Xpos,Ypos,Data) 2178 azm = int(azm) 2179 Masks['Arcs'].append([tth,[azm-5,azm+5],0.1]) 2180 elif event.key == 'p': 2181 OnStartMask(G2frame,event.key) 2182 #G2frame.setPoly = True 2183 #Masks['Polygons'].append([]) 2184 #G2frame.G2plotNB.status.SetFields(['','Polygon mask active - LB pick next point, RB close polygon']) 2185 elif event.key == 'f': 2186 OnStartMask(G2frame,event.key) 2187 #G2frame.setFrame = True 2188 #Masks['Frames'] = [] 2189 #G2frame.G2plotNB.status.SetFields(['','Frame mask active - LB pick next point, RB close polygon']) 2190 G2imG.UpdateMasks(G2frame,Masks) 2169 if event.key in ['p','f','s','a','r']: 2170 G2frame.MaskKey = event.key 2171 OnStartMask(G2frame) 2172 2191 2173 elif PickName == 'Image Controls': 2192 2174 if event.key == 'c': … … 2222 2204 if G2frame.PatternTree.GetItemText(G2frame.PickId) not in ['Image Controls','Masks']: 2223 2205 return 2224 if G2frame.setPoly: 2225 polygon = Masks['Polygons'][-1] 2226 xpos,ypos = event.mouseevent.xdata,event.mouseevent.ydata 2227 if xpos and ypos: #point inside image 2228 if len(polygon) > 2 and event.mouseevent.button == 3: 2229 x0,y0 = polygon[0] 2230 polygon.append([x0,y0]) 2231 G2frame.setPoly = False 2232 G2frame.G2plotNB.status.SetFields(['','Polygon closed - RB drag a vertex to change shape']) 2233 else: 2234 G2frame.G2plotNB.status.SetFields(['','New polygon point: %.1f,%.1f'%(xpos,ypos)]) 2235 polygon.append([xpos,ypos]) 2236 G2imG.UpdateMasks(G2frame,Masks) 2237 elif G2frame.setFrame: 2238 frame = Masks['Frames'] 2239 xpos,ypos = event.mouseevent.xdata,event.mouseevent.ydata 2240 if xpos and ypos: #point inside image 2241 if len(frame) > 2 and event.mouseevent.button == 3: 2242 x0,y0 = frame[0] 2243 frame.append([x0,y0]) 2244 G2frame.setFrame = False 2245 G2frame.G2plotNB.status.SetFields(['','Frame closed - RB drag a vertex to change shape']) 2246 else: 2247 G2frame.G2plotNB.status.SetFields(['','New frame point: %.1f,%.1f'%(xpos,ypos)]) 2248 frame.append([xpos,ypos]) 2249 G2imG.UpdateMasks(G2frame,Masks) 2250 else: 2251 if G2frame.itemPicked is not None: return 2252 G2frame.itemPicked = event.artist 2253 G2frame.mousePicked = event.mouseevent 2206 if G2frame.itemPicked is not None: return 2207 G2frame.itemPicked = event.artist 2208 G2frame.mousePicked = event.mouseevent 2254 2209 2255 2210 def OnImRelease(event): … … 2265 2220 pixLimit = Data['pixLimit'] 2266 2221 if G2frame.itemPicked is None and PickName == 'Image Controls' and len(G2frame.ImageZ): 2267 # sizexy = Data['size']2268 2222 Xpos = event.xdata 2269 2223 if not (Xpos and G2frame.ifGetRing): #got point out of frame … … 2294 2248 PlotImage(G2frame,newImage=False) 2295 2249 return 2250 elif G2frame.MaskKey and PickName == 'Masks': 2251 Xpos,Ypos = [event.xdata,event.ydata] 2252 if not Xpos or not Ypos or Page.toolbar._active: #got point out of frame or zoom/pan selected 2253 return 2254 if G2frame.MaskKey == 's' and event.button == 1: 2255 Masks['Points'][-1] = [Xpos,Ypos,1.] 2256 G2frame.MaskKey = '' 2257 elif G2frame.MaskKey == 'r' and event.button == 1: 2258 tth = G2img.GetTth(Xpos,Ypos,Data) 2259 Masks['Rings'][-1] = [tth,0.1] 2260 G2frame.MaskKey = '' 2261 elif G2frame.MaskKey == 'a' and event.button == 1: 2262 tth,azm = G2img.GetTthAzm(Xpos,Ypos,Data) 2263 azm = int(azm) 2264 Masks['Arcs'][-1] = [tth,[azm-5,azm+5],0.1] 2265 G2frame.MaskKey = '' 2266 elif G2frame.MaskKey =='p': 2267 polygon = Masks['Polygons'][-1] 2268 if len(polygon) > 2 and event.mouseevent.button == 3: 2269 x0,y0 = polygon[0] 2270 polygon.append([x0,y0]) 2271 G2frame.MaskKey = '' 2272 G2frame.G2plotNB.status.SetFields(['','Polygon closed - RB drag a vertex to change shape']) 2273 else: 2274 G2frame.G2plotNB.status.SetFields(['','New polygon point: %.1f,%.1f'%(Xpos,Ypos)]) 2275 polygon.append([Xpos,Ypos]) 2276 elif G2frame.MaskKey =='f': 2277 frame = Masks['Frames'] 2278 if len(frame) > 2 and event.mouseevent.button == 3: 2279 x0,y0 = frame[0] 2280 frame.append([x0,y0]) 2281 G2frame.MaskKey = '' 2282 G2frame.G2plotNB.status.SetFields(['','Frame closed - RB drag a vertex to change shape']) 2283 else: 2284 G2frame.G2plotNB.status.SetFields(['','New frame point: %.1f,%.1f'%(Xpos,Ypos)]) 2285 frame.append([Xpos,Ypos]) 2286 G2imG.UpdateMasks(G2frame,Masks) 2287 PlotImage(G2frame,newImage=False) 2296 2288 else: 2297 xpos = event.xdata 2298 if xpos: #avoid out of frame mouse position 2299 ypos = event.ydata 2300 if G2frame.ifGetRing: #delete a calibration ring pick 2301 xypos = [xpos,ypos] 2302 rings = Data['ring'] 2303 for ring in rings: 2304 if np.allclose(ring,xypos,.01,0): 2305 rings.remove(ring) 2306 else: 2307 tth,azm,dsp = G2img.GetTthAzmDsp(xpos,ypos,Data) 2308 itemPicked = str(G2frame.itemPicked) 2309 if 'Line2D' in itemPicked and PickName == 'Image Controls': 2310 if 'line1' in itemPicked: 2311 Data['IOtth'][0] = max(tth,0.001) 2312 elif 'line2' in itemPicked: 2313 Data['IOtth'][1] = tth 2314 elif 'line3' in itemPicked: 2315 Data['LRazimuth'][0] = int(azm) 2316 if Data['fullIntegrate']: 2317 Data['LRazimuth'][1] = Data['LRazimuth'][0]+360 2318 elif 'line4' in itemPicked and not Data['fullIntegrate']: 2319 Data['LRazimuth'][1] = int(azm) 2320 2321 if Data['LRazimuth'][0] > Data['LRazimuth'][1]: 2322 Data['LRazimuth'][0] -= 360 2323 2324 azLim = np.array(Data['LRazimuth']) 2325 if np.any(azLim>360): 2326 azLim -= 360 2327 Data['LRazimuth'] = list(azLim) 2328 2329 if Data['IOtth'][0] > Data['IOtth'][1]: 2330 Data['IOtth'][0],Data['IOtth'][1] = Data['IOtth'][1],Data['IOtth'][0] 2331 2332 G2frame.InnerTth.SetValue("%8.2f" % (Data['IOtth'][0])) 2333 G2frame.OuterTth.SetValue("%8.2f" % (Data['IOtth'][1])) 2334 G2frame.Lazim.SetValue("%6d" % (Data['LRazimuth'][0])) 2335 G2frame.Razim.SetValue("%6d" % (Data['LRazimuth'][1])) 2336 elif 'Circle' in itemPicked and PickName == 'Masks': 2337 spots = Masks['Points'] 2338 newPos = itemPicked.split(')')[0].split('(')[2].split(',') 2339 newPos = np.array([float(newPos[0]),float(newPos[1])]) 2340 for spot in spots: 2341 if np.allclose(np.array([spot[:2]]),newPos): 2342 spot[:2] = xpos,ypos 2343 G2imG.UpdateMasks(G2frame,Masks) 2344 elif 'Line2D' in itemPicked and PickName == 'Masks': 2345 Obj = G2frame.itemPicked.findobj() 2346 rings = Masks['Rings'] 2347 arcs = Masks['Arcs'] 2348 polygons = Masks['Polygons'] 2349 frame = Masks['Frames'] 2350 for ring in G2frame.ringList: 2351 if Obj == ring[0]: 2352 rN = ring[1] 2353 if ring[2] == 'o': 2354 rings[rN][0] = G2img.GetTth(xpos,ypos,Data)-rings[rN][1]/2. 2355 else: 2356 rings[rN][0] = G2img.GetTth(xpos,ypos,Data)+rings[rN][1]/2. 2357 for arc in G2frame.arcList: 2358 if Obj == arc[0]: 2359 aN = arc[1] 2360 if arc[2] == 'o': 2361 arcs[aN][0] = G2img.GetTth(xpos,ypos,Data)-arcs[aN][2]/2 2362 elif arc[2] == 'i': 2363 arcs[aN][0] = G2img.GetTth(xpos,ypos,Data)+arcs[aN][2]/2 2364 elif arc[2] == 'l': 2365 arcs[aN][1][0] = int(G2img.GetAzm(xpos,ypos,Data)) 2366 else: 2367 arcs[aN][1][1] = int(G2img.GetAzm(xpos,ypos,Data)) 2368 for poly in G2frame.polyList: 2369 if Obj == poly[0]: 2370 ind = G2frame.itemPicked.contains(G2frame.mousePicked)[1]['ind'][0] 2371 oldPos = np.array([G2frame.mousePicked.xdata,G2frame.mousePicked.ydata]) 2372 pN = poly[1] 2373 for i,xy in enumerate(polygons[pN]): 2374 if np.allclose(np.array([xy]),oldPos,atol=1.0): 2375 polygons[pN][i] = xpos,ypos 2376 if frame: 2289 Xpos,Ypos = [event.xdata,event.ydata] 2290 if not Xpos or not Ypos or Page.toolbar._active: #got point out of frame or zoom/pan selected 2291 return 2292 if G2frame.ifGetRing: #delete a calibration ring pick 2293 xypos = [Xpos,Ypos] 2294 rings = Data['ring'] 2295 for ring in rings: 2296 if np.allclose(ring,xypos,.01,0): 2297 rings.remove(ring) 2298 else: 2299 tth,azm,dsp = G2img.GetTthAzmDsp(Xpos,Ypos,Data) 2300 itemPicked = str(G2frame.itemPicked) 2301 if 'Line2D' in itemPicked and PickName == 'Image Controls': 2302 if 'line1' in itemPicked: 2303 Data['IOtth'][0] = max(tth,0.001) 2304 elif 'line2' in itemPicked: 2305 Data['IOtth'][1] = tth 2306 elif 'line3' in itemPicked: 2307 Data['LRazimuth'][0] = int(azm) 2308 if Data['fullIntegrate']: 2309 Data['LRazimuth'][1] = Data['LRazimuth'][0]+360 2310 elif 'line4' in itemPicked and not Data['fullIntegrate']: 2311 Data['LRazimuth'][1] = int(azm) 2312 2313 if Data['LRazimuth'][0] > Data['LRazimuth'][1]: 2314 Data['LRazimuth'][0] -= 360 2315 2316 azLim = np.array(Data['LRazimuth']) 2317 if np.any(azLim>360): 2318 azLim -= 360 2319 Data['LRazimuth'] = list(azLim) 2320 2321 if Data['IOtth'][0] > Data['IOtth'][1]: 2322 Data['IOtth'][0],Data['IOtth'][1] = Data['IOtth'][1],Data['IOtth'][0] 2323 2324 G2frame.InnerTth.SetValue("%8.2f" % (Data['IOtth'][0])) 2325 G2frame.OuterTth.SetValue("%8.2f" % (Data['IOtth'][1])) 2326 G2frame.Lazim.SetValue("%6d" % (Data['LRazimuth'][0])) 2327 G2frame.Razim.SetValue("%6d" % (Data['LRazimuth'][1])) 2328 elif 'Circle' in itemPicked and PickName == 'Masks': 2329 spots = Masks['Points'] 2330 newPos = itemPicked.split(')')[0].split('(')[2].split(',') 2331 newPos = np.array([float(newPos[0]),float(newPos[1])]) 2332 for spot in spots: 2333 if np.allclose(np.array([spot[:2]]),newPos): 2334 spot[:2] = Xpos,Ypos 2335 G2imG.UpdateMasks(G2frame,Masks) 2336 elif 'Line2D' in itemPicked and PickName == 'Masks': 2337 Obj = G2frame.itemPicked.findobj() 2338 rings = Masks['Rings'] 2339 arcs = Masks['Arcs'] 2340 polygons = Masks['Polygons'] 2341 frame = Masks['Frames'] 2342 for ring in G2frame.ringList: 2343 if Obj == ring[0]: 2344 rN = ring[1] 2345 if ring[2] == 'o': 2346 rings[rN][0] = G2img.GetTth(Xpos,Ypos,Data)-rings[rN][1]/2. 2347 else: 2348 rings[rN][0] = G2img.GetTth(Xpos,Ypos,Data)+rings[rN][1]/2. 2349 for arc in G2frame.arcList: 2350 if Obj == arc[0]: 2351 aN = arc[1] 2352 if arc[2] == 'o': 2353 arcs[aN][0] = G2img.GetTth(Xpos,Ypos,Data)-arcs[aN][2]/2 2354 elif arc[2] == 'i': 2355 arcs[aN][0] = G2img.GetTth(Xpos,Ypos,Data)+arcs[aN][2]/2 2356 elif arc[2] == 'l': 2357 arcs[aN][1][0] = int(G2img.GetAzm(Xpos,Ypos,Data)) 2358 else: 2359 arcs[aN][1][1] = int(G2img.GetAzm(Xpos,Ypos,Data)) 2360 for poly in G2frame.polyList: 2361 if Obj == poly[0]: 2362 ind = G2frame.itemPicked.contains(G2frame.mousePicked)[1]['ind'][0] 2377 2363 oldPos = np.array([G2frame.mousePicked.xdata,G2frame.mousePicked.ydata]) 2378 for i,xy in enumerate(frame): 2364 pN = poly[1] 2365 for i,xy in enumerate(polygons[pN]): 2379 2366 if np.allclose(np.array([xy]),oldPos,atol=1.0): 2380 frame[i] = xpos,ypos 2381 G2imG.UpdateMasks(G2frame,Masks) 2382 # else: #keep for future debugging 2383 # print str(G2frame.itemPicked),event.xdata,event.ydata,event.button 2384 PlotImage(G2frame,newImage=True) 2367 polygons[pN][i] = Xpos,Ypos 2368 if frame: 2369 oldPos = np.array([G2frame.mousePicked.xdata,G2frame.mousePicked.ydata]) 2370 for i,xy in enumerate(frame): 2371 if np.allclose(np.array([xy]),oldPos,atol=1.0): 2372 frame[i] = Xpos,Ypos 2373 G2imG.UpdateMasks(G2frame,Masks) 2374 # else: #keep for future debugging 2375 # print str(G2frame.itemPicked),event.xdata,event.ydata,event.button 2376 PlotImage(G2frame,newImage=True) 2385 2377 G2frame.itemPicked = None 2386 2378 … … 2417 2409 Page.Choice[1] = 'l: log(I) off' 2418 2410 Page.keyPress = OnImPlotKeyPress 2411 elif G2frame.PatternTree.GetItemText(G2frame.PickId) in ['Masks',]: 2412 Page.Choice = (' key press','s: spot mask','a: arc mask','r: ring mask', 2413 'p: polygon mask','f: frame mask',) 2414 Page.keyPress = OnImPlotKeyPress 2419 2415 except TypeError: 2420 2416 pass … … 2463 2459 Img = Plot.imshow(A,aspect='equal',cmap=acolor, 2464 2460 interpolation='nearest',vmin=Imin,vmax=Imax,extent=[0,Xmax,Ymax,0]) 2465 if G2frame.setPoly or G2frame.setFrame:2466 Img.set_picker(True)2467 2461 2468 2462 Plot.plot(xcent,ycent,'x') … … 2534 2528 Masks['Frames'] = [] 2535 2529 frame = Masks['Frames'] 2536 for x,y,d in spots: 2537 Plot.add_artist(Circle((x,y),radius=d/2,fc='none',ec='r',picker=3)) 2530 for spot in spots: 2531 if spot: 2532 x,y,d = spot 2533 Plot.add_artist(Circle((x,y),radius=d/2,fc='none',ec='r',picker=3)) 2538 2534 G2frame.ringList = [] 2539 for iring,(tth,thick) in enumerate(rings): 2540 wave = Data['wavelength'] 2541 x1,y1 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(tth+thick/2.,wave),Data))),2) 2542 x2,y2 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(tth-thick/2.,wave),Data))),2) 2543 G2frame.ringList.append([Plot.plot(x1,y1,'r',picker=3),iring,'o']) 2544 G2frame.ringList.append([Plot.plot(x2,y2,'r',picker=3),iring,'i']) 2535 for iring,ring in enumerate(rings): 2536 if ring: 2537 tth,thick = ring 2538 wave = Data['wavelength'] 2539 x1,y1 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(tth+thick/2.,wave),Data))),2) 2540 x2,y2 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(tth-thick/2.,wave),Data))),2) 2541 G2frame.ringList.append([Plot.plot(x1,y1,'r',picker=3),iring,'o']) 2542 G2frame.ringList.append([Plot.plot(x2,y2,'r',picker=3),iring,'i']) 2545 2543 G2frame.arcList = [] 2546 for iarc,(tth,azm,thick) in enumerate(arcs): 2547 wave = Data['wavelength'] 2548 x1,y1 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(tth+thick/2.,wave),Data),azm)),2) 2549 x2,y2 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(max(0.01,tth-thick/2.),wave),Data),azm)),2) 2550 G2frame.arcList.append([Plot.plot(x1,y1,'r',picker=3),iarc,'o']) 2551 G2frame.arcList.append([Plot.plot(x2,y2,'r',picker=3),iarc,'i']) 2552 G2frame.arcList.append([Plot.plot([x1[0],x2[0]],[y1[0],y2[0]],'r',picker=3),iarc,'l']) 2553 G2frame.arcList.append([Plot.plot([x1[-1],x2[-1]],[y1[-1],y2[-1]],'r',picker=3),iarc,'u']) 2544 for iarc,arc in enumerate(arcs): 2545 if arc: 2546 tth,azm,thick = arc 2547 wave = Data['wavelength'] 2548 x1,y1 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(tth+thick/2.,wave),Data),azm)),2) 2549 x2,y2 = np.hsplit(np.array(G2img.makeIdealRing(G2img.GetEllipse(Dsp(max(0.01,tth-thick/2.),wave),Data),azm)),2) 2550 G2frame.arcList.append([Plot.plot(x1,y1,'r',picker=3),iarc,'o']) 2551 G2frame.arcList.append([Plot.plot(x2,y2,'r',picker=3),iarc,'i']) 2552 G2frame.arcList.append([Plot.plot([x1[0],x2[0]],[y1[0],y2[0]],'r',picker=3),iarc,'l']) 2553 G2frame.arcList.append([Plot.plot([x1[-1],x2[-1]],[y1[-1],y2[-1]],'r',picker=3),iarc,'u']) 2554 2554 G2frame.polyList = [] 2555 2555 for ipoly,polygon in enumerate(polygons): 2556 x,y = np.hsplit(np.array(polygon),2) 2557 G2frame.polyList.append([Plot.plot(x,y,'r+',picker=10),ipoly]) 2558 Plot.plot(x,y,'r') 2556 if polygon: 2557 x,y = np.hsplit(np.array(polygon),2) 2558 G2frame.polyList.append([Plot.plot(x,y,'r+',picker=10),ipoly]) 2559 Plot.plot(x,y,'r') 2559 2560 G2frame.frameList = [] 2560 2561 if frame:
Note: See TracChangeset
for help on using the changeset viewer.