Changeset 1579
- Timestamp:
- Nov 21, 2014 3:31:56 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimgGUI.py
r1577 r1579 1030 1030 Obj = event.GetEventObject() 1031 1031 Obj.SetToolTipString('Drag this mask on 2D Powder Image with mouse to change ') 1032 1033 def OnThreshold(event): 1034 try: 1035 lower = max(int(lowerThreshold.GetValue()),thresh[0][0]) 1036 except ValueError: 1037 lower = thresh[0][0] 1038 try: 1039 upper = min(int(upperThreshold.GetValue()),thresh[0][1]) 1040 except ValueError: 1041 upper = thresh[0][1] 1042 data['Thresholds'][1] = [lower,upper] 1043 lowerThreshold.SetValue("%8d" % (lower)) 1044 upperThreshold.SetValue("%8d" % (upper)) 1045 G2plt.PlotExposedImage(G2frame,event=event) 1046 1047 def OnSpotDiameter(event): 1032 1033 def Replot(*args,**kwargs): 1034 print 'Replot' 1035 G2plt.PlotExposedImage(G2frame) 1036 1037 def onDeleteMask(event): 1048 1038 Obj = event.GetEventObject() 1049 try: 1050 diameter = min(100.,max(0.1,float(Obj.GetValue()))) 1051 except ValueError: 1052 diameter = 1.0 1053 Obj.SetValue("%.2f"%(diameter)) 1054 data['Points'][spotIds.index(Obj.GetId())][2] = diameter 1055 G2plt.PlotExposedImage(G2frame,event=event) 1056 1057 def OnDeleteSpot(event): 1058 Obj = event.GetEventObject() 1059 del(data['Points'][delSpotId.index(Obj)]) 1039 typ = Obj.locationcode.split('+')[1] 1040 num = int(Obj.locationcode.split('+')[2]) 1041 del(data[typ][num]) 1060 1042 wx.CallAfter(UpdateMasks,G2frame,data) 1061 1043 G2plt.PlotExposedImage(G2frame,event=event) 1062 1063 def OnRingThickness(event): 1064 Obj = event.GetEventObject() 1065 try: 1066 thick = min(1.0,max(0.001,float(Obj.GetValue()))) 1067 except ValueError: 1068 thick = 0.1 1069 Obj.SetValue("%.3f"%(thick)) 1070 data['Rings'][ringIds.index(Obj.GetId())][1] = thick 1071 G2plt.PlotExposedImage(G2frame,event=event) 1072 1073 def OnDeleteRing(event): 1074 Obj = event.GetEventObject() 1075 del(data['Rings'][delRingId.index(Obj)]) 1076 wx.CallAfter(UpdateMasks,G2frame,data) 1077 G2plt.PlotExposedImage(G2frame,event=event) 1078 1079 def OnArcThickness(event): 1080 Obj = event.GetEventObject() 1081 try: 1082 thick = min(20.0,max(0.001,float(Obj.GetValue()))) 1083 except ValueError: 1084 thick = 0.1 1085 Obj.SetValue("%.3f"%(thick)) 1086 data['Arcs'][arcIds.index(Obj.GetId())][2] = thick 1087 G2plt.PlotExposedImage(G2frame,event=event) 1088 1089 def OnDeleteArc(event): 1090 Obj = event.GetEventObject() 1091 del(data['Arcs'][delArcId.index(Obj)]) 1092 wx.CallAfter(UpdateMasks,G2frame,data) 1093 G2plt.PlotExposedImage(G2frame,event=event) 1094 1095 def OnDeletePoly(event): 1096 Obj = event.GetEventObject() 1097 del(data['Polygons'][delPolyId.index(Obj)]) 1098 wx.CallAfter(UpdateMasks,G2frame,data) 1099 G2plt.PlotExposedImage(G2frame,event=event) 1100 1101 def OnDeleteFrame(event): 1044 1045 def onDeleteFrame(event): 1102 1046 data['Frames'] = [] 1103 1047 wx.CallAfter(UpdateMasks,G2frame,data) … … 1209 1153 G2frame.MaskKey = 'f' 1210 1154 G2plt.OnStartMask(G2frame) 1211 1155 1156 startScroll = None 1212 1157 if G2frame.dataDisplay: 1158 startScroll = G2frame.dataDisplay.GetScrollPos(wx.VERTICAL) # save scroll position 1213 1159 G2frame.dataDisplay.Destroy() 1214 1160 G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.MaskMenu) … … 1240 1186 1241 1187 thresh = data['Thresholds'] #min/max intensity range 1242 spots = data['Points'] #x,y,radius in mm1243 rings = data['Rings'] #radius, thickness1244 polygons = data['Polygons'] #3+ x,y pairs1188 Spots = data['Points'] #x,y,radius in mm 1189 Rings = data['Rings'] #radius, thickness 1190 Polygons = data['Polygons'] #3+ x,y pairs 1245 1191 if 'Frames' not in data: 1246 1192 data['Frames'] = [] 1247 1193 frame = data['Frames'] #3+ x,y pairs 1248 arcs = data['Arcs'] #radius, start/end azimuth, thickness1194 Arcs = data['Arcs'] #radius, start/end azimuth, thickness 1249 1195 1250 1196 littleSizer = wx.FlexGridSizer(0,3,0,5) 1251 1197 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Lower/Upper limits '),0,WACV) 1252 Text = wx.TextCtrl(G2frame.dataDisplay,value= ("%8d" % (thresh[0][0])),style=wx.TE_READONLY)1198 Text = wx.TextCtrl(G2frame.dataDisplay,value=str(thresh[0][0]),style=wx.TE_READONLY) 1253 1199 littleSizer.Add(Text,0,WACV) 1254 1200 Text.SetBackgroundColour(VERY_LIGHT_GREY) 1255 Text = wx.TextCtrl(G2frame.dataDisplay,value= ("%8d" % (thresh[0][1])),style=wx.TE_READONLY)1201 Text = wx.TextCtrl(G2frame.dataDisplay,value=str(thresh[0][1]),style=wx.TE_READONLY) 1256 1202 littleSizer.Add(Text,0,WACV) 1257 1203 Text.SetBackgroundColour(VERY_LIGHT_GREY) 1258 1204 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Lower/Upper thresholds '),0,WACV) 1259 lowerThreshold = wx.TextCtrl(parent=G2frame.dataDisplay, 1260 value=("%8d" % (thresh[1][0])),style=wx.TE_PROCESS_ENTER) 1261 lowerThreshold.Bind(wx.EVT_TEXT_ENTER,OnThreshold) 1262 lowerThreshold.Bind(wx.EVT_KILL_FOCUS,OnThreshold) 1205 lowerThreshold = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,loc=thresh[1],key=0, 1206 min=thresh[0][0],OnLeave=Replot,typeHint=int) 1263 1207 littleSizer.Add(lowerThreshold,0,WACV) 1264 upperThreshold = wx.TextCtrl(parent=G2frame.dataDisplay, 1265 value=("%8d" % (thresh[1][1])),style=wx.TE_PROCESS_ENTER) 1266 upperThreshold.Bind(wx.EVT_TEXT_ENTER,OnThreshold) 1267 upperThreshold.Bind(wx.EVT_KILL_FOCUS,OnThreshold) 1208 upperThreshold = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,loc=thresh[1],key=1, 1209 max=thresh[0][1],OnLeave=Replot,typeHint=int) 1268 1210 littleSizer.Add(upperThreshold,0,WACV) 1269 1211 mainSizer.Add(littleSizer,0,) 1270 spotIds = [] 1271 delSpotId = [] 1272 if spots: 1212 if Spots: 1273 1213 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Spot masks') 1274 1214 lbl.SetBackgroundColour(wx.Colour(200,200,210)) … … 1278 1218 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' diameter, mm'),0,WACV) 1279 1219 littleSizer.Add((5,0),0) 1280 for spot in spots:1281 if spot:1282 x,y,d = spot1220 for i in range(len(Spots)): 1221 if Spots[i]: 1222 x,y,d = Spots[i] 1283 1223 spotText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.2f,%.2f" % (x,y)), 1284 1224 style=wx.TE_READONLY) … … 1286 1226 littleSizer.Add(spotText,0,WACV) 1287 1227 spotText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1288 spotDiameter = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.2f" % (d)),1289 style=wx.TE_PROCESS_ENTER)1228 spotDiameter = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,loc=Spots[i],key=2, 1229 max=100.,OnLeave=Replot,nDig=[8,2]) 1290 1230 littleSizer.Add(spotDiameter,0,WACV) 1291 spotDiameter.Bind(wx.EVT_TEXT_ENTER,OnSpotDiameter) 1292 spotDiameter.Bind(wx.EVT_KILL_FOCUS,OnSpotDiameter) 1293 spotIds.append(spotDiameter.GetId()) 1294 spotDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?') 1295 spotDelete.Bind(wx.EVT_CHECKBOX,OnDeleteSpot) 1296 delSpotId.append(spotDelete) 1231 spotDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1232 locationcode='Delete+Points+'+str(i), 1233 handler=onDeleteMask) 1297 1234 littleSizer.Add(spotDelete,0,WACV) 1298 1235 mainSizer.Add(littleSizer,0,) 1299 ringIds = [] 1300 delRingId = [] 1301 if rings: 1236 if Rings: 1302 1237 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Ring masks') 1303 1238 lbl.SetBackgroundColour(wx.Colour(200,200,210)) … … 1307 1242 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' thickness, deg'),0,WACV) 1308 1243 littleSizer.Add((5,0),0) 1309 for ring in rings: 1310 if ring: 1311 tth,thick = ring 1312 ringText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (tth)), 1244 for i in range(len(Rings)): 1245 if Rings[i]: 1246 ringText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (Rings[i][0])), 1313 1247 style=wx.TE_READONLY) 1314 1248 ringText.SetBackgroundColour(VERY_LIGHT_GREY) 1315 1249 ringText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1316 1250 littleSizer.Add(ringText,0,WACV) 1317 ringThick = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (thick)),1318 style=wx.TE_PROCESS_ENTER)1251 ringThick = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,loc=Rings[i],key=1, 1252 min=0.001,max=1.,OnLeave=Replot,nDig=[8,3]) 1319 1253 littleSizer.Add(ringThick,0,WACV) 1320 ringThick.Bind(wx.EVT_TEXT_ENTER,OnRingThickness) 1321 ringThick.Bind(wx.EVT_KILL_FOCUS,OnRingThickness) 1322 ringIds.append(ringThick.GetId()) 1323 ringDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?') 1324 ringDelete.Bind(wx.EVT_CHECKBOX,OnDeleteRing) 1325 delRingId.append(ringDelete) 1254 ringDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1255 locationcode='Delete+Rings+'+str(i), 1256 handler=onDeleteMask) 1326 1257 littleSizer.Add(ringDelete,0,WACV) 1327 1258 mainSizer.Add(littleSizer,0,) 1328 arcIds = [] 1329 delArcId = [] 1330 if arcs: 1259 if Arcs: 1331 1260 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Arc masks') 1332 1261 lbl.SetBackgroundColour(wx.Colour(200,200,210)) … … 1337 1266 littleSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' thickness, deg'),0,WACV) 1338 1267 littleSizer.Add((5,0),0) 1339 for arc in arcs:1340 if arc:1341 tth,azimuth,thick = arc1268 for i in range(len(Arcs)): 1269 if Arcs[i]: 1270 tth,azimuth,thick = Arcs[i] 1342 1271 arcText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (tth)), 1343 1272 style=wx.TE_READONLY) … … 1350 1279 azmText.Bind(wx.EVT_ENTER_WINDOW,OnTextMsg) 1351 1280 littleSizer.Add(azmText,0,WACV) 1352 arcThick = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.3f" % (thick)),1353 style=wx.TE_PROCESS_ENTER)1281 arcThick = G2gd.ValidatedTxtCtrl(G2frame.dataDisplay,loc=Arcs[i],key=2, 1282 min=0.001,max=20.,OnLeave=Replot,nDig=[8,3]) 1354 1283 littleSizer.Add(arcThick,0,WACV) 1355 arcThick.Bind(wx.EVT_TEXT_ENTER,OnArcThickness) 1356 arcThick.Bind(wx.EVT_KILL_FOCUS,OnArcThickness) 1357 arcIds.append(arcThick.GetId()) 1358 arcDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?') 1359 arcDelete.Bind(wx.EVT_CHECKBOX,OnDeleteArc) 1360 delArcId.append(arcDelete) 1284 arcDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1285 locationcode='Delete+Arcs+'+str(i), 1286 handler=onDeleteMask) 1361 1287 littleSizer.Add(arcDelete,0,WACV) 1362 1288 mainSizer.Add(littleSizer,0,) 1363 polyIds = [] 1364 delPolyId = [] 1365 delFrameId = [] 1366 if polygons: 1367 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Polygon masks (on plot RB vertex drag to move,\nLB vertex drag to insert)') 1289 if Polygons: 1290 lbl = wx.StaticText(parent=G2frame.dataDisplay, 1291 label=' Polygon masks (on plot RB vertex drag to move,\nLB vertex drag to insert)') 1368 1292 lbl.SetBackgroundColour(wx.Colour(200,200,210)) 1369 1293 mainSizer.Add(lbl,0,wx.EXPAND|wx.ALIGN_CENTER,0) 1370 1294 littleSizer = wx.FlexGridSizer(0,2,0,5) 1371 for polygon in polygons:1372 if polygon:1295 for i in range(len(Polygons)): 1296 if Polygons[i]: 1373 1297 polyList = [] 1374 for x,y in polygon:1298 for x,y in Polygons[i]: 1375 1299 polyList.append("%.2f, %.2f"%(x,y)) 1376 1300 polyText = wx.ComboBox(G2frame.dataDisplay,value=polyList[0],choices=polyList,style=wx.CB_READONLY) 1377 1301 littleSizer.Add(polyText,0,WACV) 1378 polyDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?')1379 polyDelete.Bind(wx.EVT_CHECKBOX,OnDeletePoly)1380 delPolyId.append(polyDelete)1302 polyDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1303 locationcode='Delete+Polygons+'+str(i), 1304 handler=onDeleteMask) 1381 1305 littleSizer.Add(polyDelete,0,WACV) 1382 1306 mainSizer.Add(littleSizer,0,) 1383 1307 if frame: 1384 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Frame mask (on plot RB vertex drag to move,\nLB vertex drag to insert)') 1308 lbl = wx.StaticText(parent=G2frame.dataDisplay, 1309 label=' Frame mask (on plot RB vertex drag to move,\nLB vertex drag to insert)') 1385 1310 lbl.SetBackgroundColour(wx.Colour(200,200,210)) 1386 1311 mainSizer.Add(lbl,0,wx.EXPAND|wx.ALIGN_CENTER,0) … … 1391 1316 frameText = wx.ComboBox(G2frame.dataDisplay,value=frameList[0],choices=frameList,style=wx.CB_READONLY) 1392 1317 littleSizer.Add(frameText,0,WACV) 1393 frameDelete = wx.CheckBox(parent=G2frame.dataDisplay,label='delete?')1394 frameDelete.Bind(wx.EVT_CHECKBOX,OnDeleteFrame)1395 delFrameId.append(frameDelete)1318 frameDelete = G2gd.G2LoggedButton(G2frame.dataDisplay,label='delete?', 1319 locationcode='Delete+Frame', 1320 handler=onDeleteFrame) 1396 1321 littleSizer.Add(frameDelete,0,WACV) 1397 1322 mainSizer.Add(littleSizer,0,) 1398 #if (frame or polygons):1399 # mainSizer.Add(wx.StaticText(G2frame.dataDisplay,1400 # label=' For frame and polygons: on plot RB vertex drag to move, LB vertex drag to insert'),0,WACV)1401 1323 mainSizer.Layout() 1402 1324 G2frame.dataDisplay.SetSizer(mainSizer) … … 1408 1330 G2frame.dataDisplay.SetSize(Size) 1409 1331 G2frame.dataFrame.setSizePosLeft(Size) 1332 wx.Yield() 1333 if startScroll: # reset scroll to saved position 1334 G2frame.dataDisplay.Scroll(0,startScroll) # set to saved scroll position 1335 wx.Yield() 1410 1336 1411 1337 ################################################################################ -
trunk/GSASIIplot.py
r1578 r1579 2955 2955 for col in Page.seqYaxisList: 2956 2956 name,Y,sig = Page.seqTableGet(col) 2957 if sig: 2957 # deal with missing (None) values 2958 Xnew = [] 2959 Ynew = [] 2960 Ysnew = [] 2961 for i in range(len(X)): 2962 if X[i] is None or Y[i] is None: continue 2963 Xnew.append(X[i]) 2964 Ynew.append(Y[i]) 2965 Ysnew.append(sig[i]) 2966 if Ysnew: 2958 2967 if G2frame.seqReverse and not G2frame.seqXaxis: 2959 Y = Y[::-1]2960 sig = sig[::-1]2961 Plot.errorbar(X ,Y,yerr=sig,label=name)2968 Ynew = Ynew[::-1] 2969 Ysnew = Ysnew[::-1] 2970 Plot.errorbar(Xnew,Ynew,yerr=Ysnew,label=name) 2962 2971 else: 2963 2972 if G2frame.seqReverse and not G2frame.seqXaxis: 2964 Y = Y[::-1]2965 Plot.plot(X ,Y)2966 Plot.plot(X ,Y,'o',label=name)2967 if Page.fitvals: 2973 Ynew = Ynew[::-1] 2974 Plot.plot(Xnew,Ynew) 2975 Plot.plot(Xnew,Ynew,'o',label=name) 2976 if Page.fitvals: # TODO: deal with fitting of None values 2968 2977 if G2frame.seqReverse and not G2frame.seqXaxis: 2969 2978 Page.fitvals = Page.fitvals[::-1] … … 3322 3331 newPos = np.array([float(newPos[0]),float(newPos[1])]) 3323 3332 for spot in spots: 3324 if np.allclose(np.array([spot[:2]]),newPos):3333 if spot and np.allclose(np.array([spot[:2]]),newPos): 3325 3334 spot[:2] = Xpos,Ypos 3326 3335 G2imG.UpdateMasks(G2frame,Masks)
Note: See TracChangeset
for help on using the changeset viewer.