Changeset 173
- Timestamp:
- Nov 16, 2010 10:06:23 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r167 r173 1202 1202 1203 1203 FindBonds() 1204 drawAtoms.ClearSelection() 1204 1205 G2plt.PlotStructure(self,data) 1205 1206 … … 1223 1224 dlg.Destroy() 1224 1225 FindBonds() 1226 drawAtoms.ClearSelection() 1225 1227 G2plt.PlotStructure(self,data) 1226 1228 … … 1242 1244 drawAtoms.SetCellValue(r,cs+1,parms) 1243 1245 dlg.Destroy() 1246 drawAtoms.ClearSelection() 1244 1247 G2plt.PlotStructure(self,data) 1245 1248 … … 1274 1277 drawAtoms.SetAttr(r,cs+2,attr) 1275 1278 data['Drawing']['Atoms'][r][cs+2] = color 1279 drawAtoms.ClearSelection() 1276 1280 dlg.Destroy() 1277 1281 … … 1284 1288 atom[cs+2] = list(generalData['Color'][atNum]) 1285 1289 UpdateDrawAtoms() 1290 drawAtoms.ClearSelection() 1286 1291 G2plt.PlotStructure(self,data) 1287 1292 … … 1343 1348 dlg.Destroy() 1344 1349 UpdateDrawAtoms() 1350 drawAtoms.ClearSelection() 1345 1351 G2plt.PlotStructure(self,data) 1346 1352 … … 1386 1392 dlg.Destroy() 1387 1393 UpdateDrawAtoms() 1394 drawAtoms.ClearSelection() 1388 1395 G2plt.PlotStructure(self,data) 1389 1396 … … 1428 1435 data['Drawing']['Atoms'] = atomData 1429 1436 UpdateDrawAtoms() 1437 drawAtoms.ClearSelection() 1430 1438 G2plt.PlotStructure(self,data) 1431 1439 … … 1479 1487 atomData.append(atom[:]) 1480 1488 data['Drawing']['Atoms'] = atomData 1481 1482 1489 UpdateDrawAtoms() 1490 drawAtoms.ClearSelection() 1483 1491 G2plt.PlotStructure(self,data) 1484 1492 … … 1572 1580 del atomData[ind] 1573 1581 UpdateDrawAtoms() 1582 drawAtoms.ClearSelection() 1574 1583 G2plt.PlotStructure(self,data) 1575 1584 event.StopPropagation() … … 1620 1629 def OnCameraPos(event): 1621 1630 drawingData['cameraPos'] = cameraPos.GetValue() 1622 cameraPosTxt.SetLabel('Camera Position: '+'%.2f'%(drawingData['cameraPos']))1631 cameraPosTxt.SetLabel('Camera Distance: '+'%.2f'%(drawingData['cameraPos'])) 1623 1632 ZclipTxt.SetLabel('Z clipping: '+'%.2fA'%(drawingData['Zclip']*drawingData['cameraPos']/100.)) 1624 1633 G2plt.PlotStructure(self,data) … … 1694 1703 1695 1704 cameraPosTxt = wx.StaticText(dataDisplay,-1, 1696 'Camera Position: '+'%.2f'%(drawingData['cameraPos']),name='cameraPos')1705 'Camera Distance: '+'%.2f'%(drawingData['cameraPos']),name='cameraPos') 1697 1706 slideSizer.Add(cameraPosTxt,0,wx.ALIGN_CENTER_VERTICAL) 1698 1707 cameraPos = wx.Slider(dataDisplay,style=wx.SL_HORIZONTAL,value=drawingData['cameraPos'],name='cameraSlider') -
trunk/GSASIIplot.py
r172 r173 287 287 288 288 def OnPlotKeyPress(event): 289 newPlot = False 289 290 if event.key == 'w': 290 291 if self.Weight: … … 304 305 self.Offset -= 1. 305 306 elif event.key == 'c': 307 newPlot = True 306 308 if self.Contour: 307 309 self.Contour = False 308 310 else: 309 311 self.Contour = True 312 self.SinglePlot = False 313 self.Offset = 0 310 314 elif event.key == 's': 311 315 if self.SinglePlot: … … 314 318 self.SinglePlot = True 315 319 316 PlotPatterns(self )320 PlotPatterns(self,newPlot=newPlot) 317 321 318 322 def OnKeyBox(event): … … 423 427 item, cookie = self.PatternTree.GetNextChild(self.root, cookie) 424 428 Ymax = 1.0 429 lenX = 0 425 430 HKL = np.array(self.HKL) 426 431 for Pattern in PlotList: … … 443 448 LimitId = G2gd.GetPatternTreeItemId(self,PatternId, 'Limits') 444 449 X = xye[0] 450 if not lenX: 451 lenX = len(X) 445 452 Y = xye[1]+offset*N 446 453 if LimitId: … … 449 456 Lines.append(Plot.axvline(limits[1][1],color='r',dashes=(5,5),picker=3.)) 450 457 if self.Contour: 451 ContourY.append(N) 452 ContourZ.append(Y) 453 ContourX = X 454 Nseq += 1 455 Plot.set_ylabel('Data sequence',fontsize=12) 458 if lenX == len(X): 459 ContourY.append(N) 460 ContourZ.append(Y) 461 ContourX = X 462 Nseq += 1 463 Plot.set_ylabel('Data sequence',fontsize=12) 456 464 else: 457 465 if ifpicked: … … 490 498 Plot.imshow(ContourZ,cmap=acolor,vmin=0,vmax=Ymax*self.Cmax,interpolation='nearest', 491 499 extent=[ContourX[0],ContourX[-1],ContourY[0],ContourY[-1]],aspect='auto') 492 newPlot = True493 500 else: 494 501 self.Lines = Lines … … 1134 1141 def PlotStructure(self,data): 1135 1142 generalData = data['General'] 1143 cell = generalData['Cell'][1:7] 1144 Amat,Bmat = G2lat.cell2AB(cell) #Amat - crystal to cartesian, Bmat - inverse 1145 A4mat = np.concatenate((np.concatenate((Amat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0) 1146 B4mat = np.concatenate((np.concatenate((Bmat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0) 1136 1147 Mydir = generalData['Mydir'] 1137 1148 atomData = data['Atoms'] … … 1176 1187 Model = glGetDoublev(GL_MODELVIEW_MATRIX) 1177 1188 Zmax = 1. 1178 ClearSelectedAtoms()1179 1189 for i,atom in enumerate(drawAtoms): 1180 1190 x,y,z = atom[cx:cx+3] … … 1184 1194 Zmax = Z 1185 1195 SetSelectedAtoms(i) 1186 1196 1187 1197 def OnMouseDown(event): 1188 1198 xy = event.GetPosition() … … 1195 1205 def OnMouseMove(event): 1196 1206 newxy = event.GetPosition() 1197 if event.AltDown() and drawingData['showABC']: 1198 if event.RightIsDown(): 1199 altDown = True 1207 if event.ControlDown() and drawingData['showABC']: 1208 if event.LeftIsDown(): 1209 ctrlDown = True 1210 SetTestRot(newxy) 1211 elif event.RightIsDown(): 1200 1212 SetTestPos(newxy) 1201 if event.Dragging() and not event.AltDown(): 1202 altDown = False 1213 elif event.MiddleIsDown(): 1214 SetTestRotZ(newxy) 1215 1216 1217 if event.Dragging() and not event.ControlDown(): 1203 1218 if event.LeftIsDown(): 1204 1219 SetRotation(newxy) … … 1231 1246 if self.dataDisplay.GetPageText(page) == 'Draw Atoms': 1232 1247 self.dataDisplay.GetPage(page).ClearSelection() #this is the Atoms grid in Draw Atoms 1248 elif self.dataDisplay.GetPageText(page) == 'Atoms': 1249 self.dataDisplay.GetPage(page).ClearSelection() #this is the Atoms grid in Atoms 1233 1250 1234 1251 def SetSelectedAtoms(ind): … … 1236 1253 if self.dataDisplay.GetPageText(page) == 'Draw Atoms': 1237 1254 self.dataDisplay.GetPage(page).SelectRow(ind) #this is the Atoms grid in Draw Atoms 1255 elif self.dataDisplay.GetPageText(page) == 'Atoms': 1256 Id = drawAtoms[ind][-2] 1257 for i,atom in enumerate(atomData): 1258 if atom[-1] == Id: 1259 self.dataDisplay.GetPage(page).SelectRow(i) #this is the Atoms grid in Atoms 1238 1260 1239 1261 def GetSelectedAtoms(): … … 1242 1264 if self.dataDisplay.GetPageText(page) == 'Draw Atoms': 1243 1265 Ind = self.dataDisplay.GetPage(page).GetSelectedRows() #this is the Atoms grid in Draw Atoms 1266 elif self.dataDisplay.GetPageText(page) == 'Atoms': 1267 Ind = self.dataDisplay.GetPage(page).GetSelectedRows() #this is the Atoms grid in Atoms 1244 1268 return Ind 1245 1269 … … 1252 1276 if key in ['c','C']: 1253 1277 drawingData['viewPoint'] = [[.5,.5,.5],[0,0]] 1254 drawingData['testPos'] = [ -.1,-.1,-.1]1278 drawingData['testPos'] = [[-.1,-.1,-.1],[0.0,0.0,0.0],[0,0]] 1255 1279 drawingData['Rotation'] = [0.0,0.0,0.0,[]] 1256 1280 SetViewPointText(drawingData['viewPoint'][0]) … … 1320 1344 1321 1345 def SetTestPos(newxy): 1322 Tx,Ty,Tz = drawingData['testPos'] 1346 Tx,Ty,Tz = drawingData['testPos'][0] 1323 1347 anglex,angley,anglez,oldxy = drawingData['Rotation'] 1324 1348 Rx = G2lat.rotdMat(anglex,0) … … 1331 1355 Tz += dxy[2]*0.001 1332 1356 drawingData['Rotation'][3] = newxy 1333 drawingData['testPos'] = Tx,Ty,Tz 1357 drawingData['testPos'][0] = Tx,Ty,Tz 1358 1359 def SetTestRot(newxy): 1360 Txyz = np.array(drawingData['testPos'][0]) 1361 oldxy = drawingData['testPos'][2] 1362 Ax,Ay,Az = drawingData['testPos'][1] 1363 Vxyz = np.array(drawingData['viewPoint'][0]) 1364 Dxyz = np.inner(Amat,Txyz-Vxyz) 1365 dxy = list(newxy-oldxy)+[0,] 1366 Ax += dxy[1]*0.01 1367 Ay += dxy[0]*0.01 1368 Rx = G2lat.rotdMat(Ax,0) 1369 Ry = G2lat.rotdMat(Ay,1) 1370 Dxyz = np.inner(Ry,np.inner(Rx,Dxyz)) 1371 Dxyz = np.inner(Bmat,Dxyz)+Vxyz 1372 drawingData['testPos'][1] = [Ax,Ay,Az] 1373 drawingData['testPos'][2] = newxy 1374 drawingData['testPos'][0] = Dxyz 1375 1376 def SetTestRotZ(newxy): 1377 Txyz = np.array(drawingData['testPos'][0]) 1378 oldxy = drawingData['testPos'][2] 1379 Ax,Ay,Az = drawingData['testPos'][1] 1380 Vxyz = np.array(drawingData['viewPoint'][0]) 1381 Dxyz = np.inner(Amat,Txyz-Vxyz) 1382 dxy = list(newxy-oldxy)+[0,] 1383 Az += (dxy[0]+dxy[1])*.01 1384 Rz = G2lat.rotdMat(Az,2) 1385 Dxyz = np.inner(Rz,Dxyz) 1386 Dxyz = np.inner(Bmat,Dxyz)+Vxyz 1387 drawingData['testPos'][1] = [Ax,Ay,Az] 1388 drawingData['testPos'][2] = newxy 1389 drawingData['testPos'][0] = Dxyz 1334 1390 1335 def SetNewPos(newxy):1336 1337 Tx,Ty,Tz = drawingData['testPos']1338 anglex,angley,anglez,oldxy = drawingData['Rotation']1339 Rx = G2lat.rotdMat(anglex,0)1340 Ry = G2lat.rotdMat(angley,1)1341 Rz = G2lat.rotdMat(anglez,2)1342 dxy = list(newxy-oldxy)+[0,]1343 dxy = np.inner(Rz,np.inner(Ry,np.inner(Rx,dxy)))1344 Tx += dxy[0]*0.0011345 Ty -= dxy[1]*0.0011346 Tz += dxy[2]*0.0011347 # drawingData['Rotation'][3] = newxy1348 # drawingData['testPos'] = Tx,Ty,Tz1349 1350 1391 def SetRotation(newxy): 1351 1392 anglex,angley,anglez,oldxy = drawingData['Rotation'] … … 1494 1535 import numpy.linalg as nl 1495 1536 Ind = GetSelectedAtoms() 1496 x,y,z = drawingData['testPos']1497 if altDown:1498 self.G2plotNB.status.SetStatusText('moving test point %.4f,%.4f,%.4f'%(x,y,z),1)1499 else:1500 self.G2plotNB.status.SetStatusText('test point %.4f,%.4f,%.4f'%(x,y,z),1)1501 1537 VS = np.array(Page.canvas.GetSize()) 1502 1538 aspect = float(VS[0])/float(VS[1]) … … 1527 1563 glMatrixMode(GL_MODELVIEW) 1528 1564 glLoadIdentity() 1529 # Mz = G2lat.rotdMat4(anglez,2)1530 # My = G2lat.rotdMat4(angley,1)1531 # Mx = G2lat.rotdMat4(anglex,0)1532 # Myz = np.inner(Mz,My)1533 # Mxyz = np.inner(Myz,Mx)1534 # glMultMatrixf(Mz)1535 # glMultMatrixf(My)1536 # glMultMatrixf(Mx)1537 1565 glRotate(anglez,0,0,1) 1538 1566 glRotate(anglex,cosd(anglez),-sind(anglez),0) … … 1543 1571 RenderBox() 1544 1572 if drawingData['showABC']: 1545 x,y,z = drawingData['testPos'] 1573 # try: #temporary fix - not needed further? 1574 # x,y,z = drawingData['testPos'][0] 1575 # except TypeError: 1576 # x,y,z = drawingData['testPos'] 1577 x,y,z = drawingData['testPos'][0] 1578 if altDown: 1579 self.G2plotNB.status.SetStatusText('moving test point %.4f,%.4f,%.4f'%(x,y,z),1) 1580 else: 1581 self.G2plotNB.status.SetStatusText('test point %.4f,%.4f,%.4f'%(x,y,z),1) 1546 1582 RenderUnitVectors(x,y,z) 1547 1583 Backbone = [] … … 1673 1709 Page.canvas.Bind(wx.EVT_SIZE, OnSize) 1674 1710 Page.canvas.Bind(wx.EVT_SET_FOCUS, OnFocus) 1675 cell = generalData['Cell'][1:7]1676 Amat,Bmat = G2lat.cell2AB(cell) #Amat - crystal to cartesian, Bmat - inverse1677 A4mat = np.concatenate((np.concatenate((Amat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)1678 B4mat = np.concatenate((np.concatenate((Bmat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)1679 1711 Page.camera['position'] = drawingData['cameraPos'] 1680 1712 Page.camera['viewPoint'] = np.inner(Amat,drawingData['viewPoint'][0])
Note: See TracChangeset
for help on using the changeset viewer.