Changeset 749
- Timestamp:
- Sep 4, 2012 1:34:01 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r748 r749 1354 1354 if 'Atoms' in data['Drawing']: 1355 1355 DrawAtomsDeleteByIDs(IDs) 1356 FillAtomsGrid()1356 wx.CallAfter(FillAtomsGrid) 1357 1357 G2plt.PlotStructure(G2frame,data) 1358 1358 SetupGeneral() -
trunk/GSASIIplot.py
r748 r749 2360 2360 Draw() #make sure plot is fresh!! 2361 2361 mode = cb.GetValue() 2362 Fname = os.path.joint(Mydir,generalData['Name']+'.'+mode) 2363 size = Page.canvas.GetSize() 2364 glPixelStorei(GL_UNPACK_ALIGNMENT, 1) 2365 if mode in ['jpeg',]: 2366 Pix = glReadPixels(0,0,size[0],size[1],GL_RGBA, GL_UNSIGNED_BYTE) 2367 im = Image.new("RGBA", (size[0],size[1])) 2362 if mode in ['jpeg','bmp','tiff',]: 2363 Fname = os.path.joint(Mydir,generalData['Name']+'.'+mode) 2364 size = Page.canvas.GetSize() 2365 glPixelStorei(GL_UNPACK_ALIGNMENT, 1) 2366 if mode in ['jpeg',]: 2367 Pix = glReadPixels(0,0,size[0],size[1],GL_RGBA, GL_UNSIGNED_BYTE) 2368 im = Image.new("RGBA", (size[0],size[1])) 2369 else: 2370 Pix = glReadPixels(0,0,size[0],size[1],GL_RGB, GL_UNSIGNED_BYTE) 2371 im = Image.new("RGB", (size[0],size[1])) 2372 im.fromstring(Pix) 2373 im.save(Fname,mode) 2374 cb.SetValue(' save as/key:') 2375 G2frame.G2plotNB.status.SetStatusText('Drawing saved to: '+Fname,1) 2368 2376 else: 2369 Pix = glReadPixels(0,0,size[0],size[1],GL_RGB, GL_UNSIGNED_BYTE) 2370 im = Image.new("RGB", (size[0],size[1])) 2371 im.fromstring(Pix) 2372 im.save(Fname,mode) 2373 cb.SetValue(' Save as:') 2374 G2frame.G2plotNB.status.SetStatusText('Drawing saved to: '+Fname,1) 2375 2377 event.key = cb.GetValue()[0] 2378 cb.SetValue(' save as/key:') 2379 wx.CallAfter(OnKey,event) 2380 2381 def OnKey(event): #on key UP!! 2382 Draw() #make sure plot is fresh!! 2383 try: 2384 keyCode = event.GetKeyCode() 2385 if keyCode > 255: 2386 keyCode = 0 2387 key = chr(keyCode) 2388 except AttributeError: #if from OnKeyBox above 2389 key = str(event.key).upper() 2390 indx = drawingData['selectedAtoms'] 2391 if key in ['C']: 2392 drawingData['viewPoint'] = [[.5,.5,.5],[0,0]] 2393 drawingData['Rotation'] = [0.0,0.0,0.0,[]] 2394 SetViewPointText(drawingData['viewPoint'][0]) 2395 elif key in ['N']: 2396 drawAtoms = drawingData['Atoms'] 2397 pI = drawingData['viewPoint'][1] 2398 if indx: 2399 pI[0] = indx[pI[1]] 2400 Tx,Ty,Tz = drawAtoms[pI[0]][cx:cx+3] 2401 pI[1] += 1 2402 if pI[1] >= len(indx): 2403 pI[1] = 0 2404 else: 2405 Tx,Ty,Tz = drawAtoms[pI[0]][cx:cx+3] 2406 pI[0] += 1 2407 if pI[0] >= len(drawAtoms): 2408 pI[0] = 0 2409 drawingData['viewPoint'] = [[Tx,Ty,Tz],pI] 2410 SetViewPointText(drawingData['viewPoint'][0]) 2411 G2frame.G2plotNB.status.SetStatusText('View point at atom '+drawAtoms[pI[0]][ct-1]+str(pI),1) 2412 2413 elif key in ['P']: 2414 drawAtoms = drawingData['Atoms'] 2415 pI = drawingData['viewPoint'][1] 2416 if indx: 2417 pI[0] = indx[pI[1]] 2418 Tx,Ty,Tz = drawAtoms[pI[0]][cx:cx+3] 2419 pI[1] -= 1 2420 if pI[1] < 0: 2421 pI[1] = len(indx)-1 2422 else: 2423 Tx,Ty,Tz = drawAtoms[pI[0]][cx:cx+3] 2424 pI[0] -= 1 2425 if pI[0] < 0: 2426 pI[0] = len(drawAtoms)-1 2427 drawingData['viewPoint'] = [[Tx,Ty,Tz],pI] 2428 SetViewPointText(drawingData['viewPoint'][0]) 2429 G2frame.G2plotNB.status.SetStatusText('View point at atom '+drawAtoms[pI[0]][ct-1]+str(pI),1) 2430 elif key in ['U','D','L','R'] and mapData['Flip'] == True: 2431 dirDict = {'U':[0,-1],'D':[0,1],'L':[-1,0],'R':[1,0]} 2432 SetMapRoll(dirDict[key]) 2433 SetPeakRoll(dirDict[key]) 2434 Draw() 2435 2376 2436 def GetTruePosition(xy,Add=False): 2377 2437 View = glGetIntegerv(GL_VIEWPORT) … … 2508 2568 return Ind 2509 2569 2510 def OnKey(event): #on key UP!!2511 keyCode = event.GetKeyCode()2512 if keyCode > 255:2513 keyCode = 02514 key,xyz = chr(keyCode),event.GetPosition()2515 indx = drawingData['selectedAtoms']2516 if key in ['C']:2517 drawingData['viewPoint'] = [[.5,.5,.5],[0,0]]2518 drawingData['Rotation'] = [0.0,0.0,0.0,[]]2519 SetViewPointText(drawingData['viewPoint'][0])2520 elif key in ['N']:2521 drawAtoms = drawingData['Atoms']2522 pI = drawingData['viewPoint'][1]2523 if indx:2524 pI[0] = indx[pI[1]]2525 Tx,Ty,Tz = drawAtoms[pI[0]][cx:cx+3]2526 pI[1] += 12527 if pI[1] >= len(indx):2528 pI[1] = 02529 else:2530 Tx,Ty,Tz = drawAtoms[pI[0]][cx:cx+3]2531 pI[0] += 12532 if pI[0] >= len(drawAtoms):2533 pI[0] = 02534 drawingData['viewPoint'] = [[Tx,Ty,Tz],pI]2535 SetViewPointText(drawingData['viewPoint'][0])2536 G2frame.G2plotNB.status.SetStatusText('View point at atom '+drawAtoms[pI[0]][ct-1]+str(pI),1)2537 2538 elif key in ['P']:2539 drawAtoms = drawingData['Atoms']2540 pI = drawingData['viewPoint'][1]2541 if indx:2542 pI[0] = indx[pI[1]]2543 Tx,Ty,Tz = drawAtoms[pI[0]][cx:cx+3]2544 pI[1] -= 12545 if pI[1] < 0:2546 pI[1] = len(indx)-12547 else:2548 Tx,Ty,Tz = drawAtoms[pI[0]][cx:cx+3]2549 pI[0] -= 12550 if pI[0] < 0:2551 pI[0] = len(drawAtoms)-12552 drawingData['viewPoint'] = [[Tx,Ty,Tz],pI]2553 SetViewPointText(drawingData['viewPoint'][0])2554 G2frame.G2plotNB.status.SetStatusText('View point at atom '+drawAtoms[pI[0]][ct-1]+str(pI),1)2555 elif key in ['U','D','L','R'] and mapData['Flip'] == True:2556 dirDict = {'U':[0,1],'D':[0,-1],'L':[-1,0],'R':[1,0]}2557 SetMapRoll(dirDict[key])2558 Draw()2559 2560 2570 def SetBackground(): 2561 2571 R,G,B,A = Page.camera['backColor'] … … 2572 2582 glLightfv(GL_LIGHT0,GL_DIFFUSE,[1,1,1,1]) 2573 2583 2574 def SetMapRoll(newxy): 2575 global sumroll 2584 def GetRoll(newxy,rho): 2576 2585 anglex,angley,anglez,oldxy = drawingData['Rotation'] 2577 2586 Rx = G2lat.rotdMat(anglex,0) … … 2580 2589 dxy = np.inner(Bmat,np.inner(Rz,np.inner(Ry,np.inner(Rx,newxy+[0,])))) 2581 2590 dxy *= np.array([-1,-1,1]) 2582 rho = mapData['rho']2583 2591 dxy = np.array(dxy*rho.shape) 2584 2592 roll = np.where(dxy>0.5,1,np.where(dxy<-.5,-1,0)) 2593 return roll 2594 2595 def SetMapRoll(newxy): 2596 global sumroll 2597 rho = mapData['rho'] 2598 roll = GetRoll(newxy,rho) 2585 2599 sumroll += roll 2586 2600 mapData['rho'] = np.roll(np.roll(np.roll(rho,roll[0],axis=0),roll[1],axis=1),roll[2],axis=2) … … 2588 2602 drawingData['Rotation'][3] = list(newxy) 2589 2603 2604 def SetPeakRoll(newxy): 2605 rho = mapData['rho'] 2606 roll = GetRoll(newxy,rho) 2607 steps = 1./np.array(rho.shape) 2608 dxy = roll*steps 2609 for peak in mapPeaks: 2610 peak[1:4] += dxy 2611 peak[1:4] %= 1. 2612 2590 2613 def SetTranslation(newxy): 2591 2614 Tx,Ty,Tz = drawingData['viewPoint'][0] … … 2648 2671 for line,color in zip(uEdges,uColors)[:3]: 2649 2672 glColor3ubv(color) 2650 glVertex3fv( line[0])2651 glVertex3fv(line[1] )2673 glVertex3fv(-line[1]/2.) 2674 glVertex3fv(line[1]/2.) 2652 2675 glEnd() 2653 2676 glPopMatrix() … … 2981 3004 altDown = False 2982 3005 Page.SetFocus() 2983 cb = wx.ComboBox(G2frame.G2plotNB.status,style=wx.CB_DROPDOWN|wx.CB_READONLY, 2984 choices=(' save as:','jpeg','tiff','bmp')) 3006 if mapData['Flip']: 3007 choice = [' save as/key:','jpeg','tiff','bmp','c: center on 1/2,1/2,1/2','n: next','p: previous'] 3008 else: 3009 choice = [' save as/key:','jpeg','tiff','bmp','u: roll up','d: roll down','l: roll left','r: roll right'] 3010 cb = wx.ComboBox(G2frame.G2plotNB.status,style=wx.CB_DROPDOWN|wx.CB_READONLY,choices=choice) 2985 3011 cb.Bind(wx.EVT_COMBOBOX, OnKeyBox) 2986 cb.SetValue(' save as :')3012 cb.SetValue(' save as/key:') 2987 3013 Page.canvas.Bind(wx.EVT_MOUSEWHEEL, OnMouseWheel) 2988 3014 Page.canvas.Bind(wx.EVT_LEFT_DOWN, OnMouseDown)
Note: See TracChangeset
for help on using the changeset viewer.