Changeset 173


Ignore:
Timestamp:
Nov 16, 2010 10:06:23 AM (12 years ago)
Author:
vondreele
Message:

fix atom selection clearing
fix contour plotting

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r167 r173  
    12021202       
    12031203        FindBonds()
     1204        drawAtoms.ClearSelection()
    12041205        G2plt.PlotStructure(self,data)
    12051206
     
    12231224            dlg.Destroy()
    12241225            FindBonds()
     1226            drawAtoms.ClearSelection()
    12251227            G2plt.PlotStructure(self,data)
    12261228
     
    12421244                    drawAtoms.SetCellValue(r,cs+1,parms)
    12431245            dlg.Destroy()
     1246            drawAtoms.ClearSelection()
    12441247            G2plt.PlotStructure(self,data)
    12451248           
     
    12741277                    drawAtoms.SetAttr(r,cs+2,attr)
    12751278                    data['Drawing']['Atoms'][r][cs+2] = color
     1279            drawAtoms.ClearSelection()
    12761280            dlg.Destroy()
    12771281           
     
    12841288            atom[cs+2] = list(generalData['Color'][atNum])
    12851289        UpdateDrawAtoms()
     1290        drawAtoms.ClearSelection()
    12861291        G2plt.PlotStructure(self,data)       
    12871292       
     
    13431348                dlg.Destroy()
    13441349            UpdateDrawAtoms()
     1350            drawAtoms.ClearSelection()
    13451351            G2plt.PlotStructure(self,data)
    13461352           
     
    13861392                dlg.Destroy()
    13871393            UpdateDrawAtoms()
     1394            drawAtoms.ClearSelection()
    13881395            G2plt.PlotStructure(self,data)
    13891396           
     
    14281435            data['Drawing']['Atoms'] = atomData
    14291436            UpdateDrawAtoms()
     1437            drawAtoms.ClearSelection()
    14301438            G2plt.PlotStructure(self,data)
    14311439           
     
    14791487                                atomData.append(atom[:])               
    14801488                data['Drawing']['Atoms'] = atomData
    1481                
    14821489            UpdateDrawAtoms()
     1490            drawAtoms.ClearSelection()
    14831491            G2plt.PlotStructure(self,data)
    14841492           
     
    15721580                del atomData[ind]
    15731581            UpdateDrawAtoms()
     1582            drawAtoms.ClearSelection()
    15741583            G2plt.PlotStructure(self,data)
    15751584        event.StopPropagation()
     
    16201629        def OnCameraPos(event):
    16211630            drawingData['cameraPos'] = cameraPos.GetValue()
    1622             cameraPosTxt.SetLabel('Camera Position: '+'%.2f'%(drawingData['cameraPos']))
     1631            cameraPosTxt.SetLabel('Camera Distance: '+'%.2f'%(drawingData['cameraPos']))
    16231632            ZclipTxt.SetLabel('Z clipping: '+'%.2fA'%(drawingData['Zclip']*drawingData['cameraPos']/100.))
    16241633            G2plt.PlotStructure(self,data)
     
    16941703
    16951704        cameraPosTxt = wx.StaticText(dataDisplay,-1,
    1696             'Camera Position: '+'%.2f'%(drawingData['cameraPos']),name='cameraPos')
     1705            'Camera Distance: '+'%.2f'%(drawingData['cameraPos']),name='cameraPos')
    16971706        slideSizer.Add(cameraPosTxt,0,wx.ALIGN_CENTER_VERTICAL)
    16981707        cameraPos = wx.Slider(dataDisplay,style=wx.SL_HORIZONTAL,value=drawingData['cameraPos'],name='cameraSlider')
  • trunk/GSASIIplot.py

    r172 r173  
    287287       
    288288    def OnPlotKeyPress(event):
     289        newPlot = False
    289290        if event.key == 'w':
    290291            if self.Weight:
     
    304305                self.Offset -= 1.
    305306        elif event.key == 'c':
     307            newPlot = True
    306308            if self.Contour:
    307309                self.Contour = False
    308310            else:
    309311                self.Contour = True
     312                self.SinglePlot = False
     313                self.Offset = 0
    310314        elif event.key == 's':
    311315            if self.SinglePlot:
     
    314318                self.SinglePlot = True
    315319           
    316         PlotPatterns(self)
     320        PlotPatterns(self,newPlot=newPlot)
    317321       
    318322    def OnKeyBox(event):
     
    423427            item, cookie = self.PatternTree.GetNextChild(self.root, cookie)               
    424428    Ymax = 1.0
     429    lenX = 0
    425430    HKL = np.array(self.HKL)
    426431    for Pattern in PlotList:
     
    443448            LimitId = G2gd.GetPatternTreeItemId(self,PatternId, 'Limits')
    444449        X = xye[0]
     450        if not lenX:
     451            lenX = len(X)
    445452        Y = xye[1]+offset*N
    446453        if LimitId:
     
    449456            Lines.append(Plot.axvline(limits[1][1],color='r',dashes=(5,5),picker=3.))                   
    450457        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)
    456464        else:
    457465            if ifpicked:
     
    490498        Plot.imshow(ContourZ,cmap=acolor,vmin=0,vmax=Ymax*self.Cmax,interpolation='nearest',
    491499            extent=[ContourX[0],ContourX[-1],ContourY[0],ContourY[-1]],aspect='auto')
    492         newPlot = True
    493500    else:
    494501        self.Lines = Lines
     
    11341141def PlotStructure(self,data):
    11351142    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)
    11361147    Mydir = generalData['Mydir']
    11371148    atomData = data['Atoms']
     
    11761187        Model = glGetDoublev(GL_MODELVIEW_MATRIX)
    11771188        Zmax = 1.
    1178         ClearSelectedAtoms()
    11791189        for i,atom in enumerate(drawAtoms):
    11801190            x,y,z = atom[cx:cx+3]
     
    11841194                Zmax = Z
    11851195                SetSelectedAtoms(i)
    1186        
     1196                   
    11871197    def OnMouseDown(event):
    11881198        xy = event.GetPosition()
     
    11951205    def OnMouseMove(event):
    11961206        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():
    12001212                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():
    12031218            if event.LeftIsDown():
    12041219                SetRotation(newxy)
     
    12311246        if self.dataDisplay.GetPageText(page) == 'Draw Atoms':
    12321247            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
    12331250                   
    12341251    def SetSelectedAtoms(ind):
     
    12361253        if self.dataDisplay.GetPageText(page) == 'Draw Atoms':
    12371254            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
    12381260                 
    12391261    def GetSelectedAtoms():
     
    12421264        if self.dataDisplay.GetPageText(page) == 'Draw Atoms':
    12431265            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
    12441268        return Ind
    12451269                                       
     
    12521276        if key in ['c','C']:
    12531277            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]]
    12551279            drawingData['Rotation'] = [0.0,0.0,0.0,[]]
    12561280            SetViewPointText(drawingData['viewPoint'][0])
     
    13201344       
    13211345    def SetTestPos(newxy):
    1322         Tx,Ty,Tz = drawingData['testPos']
     1346        Tx,Ty,Tz = drawingData['testPos'][0]
    13231347        anglex,angley,anglez,oldxy = drawingData['Rotation']
    13241348        Rx = G2lat.rotdMat(anglex,0)
     
    13311355        Tz += dxy[2]*0.001
    13321356        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
    13341390                             
    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.001
    1345         Ty -= dxy[1]*0.001
    1346         Tz += dxy[2]*0.001
    1347 #        drawingData['Rotation'][3] = newxy
    1348 #        drawingData['testPos'] =  Tx,Ty,Tz
    1349 
    13501391    def SetRotation(newxy):       
    13511392        anglex,angley,anglez,oldxy = drawingData['Rotation']
     
    14941535        import numpy.linalg as nl
    14951536        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)           
    15011537        VS = np.array(Page.canvas.GetSize())
    15021538        aspect = float(VS[0])/float(VS[1])
     
    15271563        glMatrixMode(GL_MODELVIEW)
    15281564        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)
    15371565        glRotate(anglez,0,0,1)
    15381566        glRotate(anglex,cosd(anglez),-sind(anglez),0)
     
    15431571            RenderBox()
    15441572        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)           
    15461582            RenderUnitVectors(x,y,z)
    15471583        Backbone = []
     
    16731709    Page.canvas.Bind(wx.EVT_SIZE, OnSize)
    16741710    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 - inverse
    1677     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)
    16791711    Page.camera['position'] = drawingData['cameraPos']
    16801712    Page.camera['viewPoint'] = np.inner(Amat,drawingData['viewPoint'][0])
Note: See TracChangeset for help on using the changeset viewer.