Changeset 225


Ignore:
Timestamp:
Jan 6, 2011 1:23:52 PM (13 years ago)
Author:
vondreele
Message:

fixes to window positioning around task bar

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r193 r225  
    203203        wx.Frame.__init__(self, name='GSASII', parent=parent,
    204204            size=wx.Size(300, 250),style=wx.DEFAULT_FRAME_STYLE, title='GSAS-II data tree')
    205         screenSize = wx.DisplaySize()
     205        clientSize = wx.ClientDisplayRect()
    206206        Size = self.GetSize()
    207         xPos = screenSize[0]-Size[0]
    208         self.SetPosition(wx.Point(xPos,0))
     207        xPos = clientSize[2]-Size[0]
     208        self.SetPosition(wx.Point(xPos,clientSize[1]))
    209209        self._init_utils()
    210210        self.SetMenuBar(self.GSASIIMenu)
     
    410410                imagefiles.sort()
    411411                for imagefile in imagefiles:
    412                     Comments,Data,Size,Image = G2IO.GetImageData(imagefile)
     412                    Comments,Data,Size,Image = G2IO.GetImageData(self,imagefile)
    413413                    if Comments:
    414414                        Id = self.PatternTree.AppendItem(parent=self.root,text='IMG '+ospath.basename(imagefile))
     
    450450                        self.PickId = Id
    451451                        self.Image = Id
    452                 self.PatternTree.SelectItem(Id)             #show last one
    453                 self.PatternTree.Expand(Id)
     452                self.PatternTree.SelectItem(G2gd.GetPatternTreeItemId(self,Id,'Image Controls'))             #show last one
    454453        finally:
    455454            dlg.Destroy()
  • trunk/GSASIIIO.py

    r223 r225  
    406406    return [np.array(x),np.array(y),np.array(w),np.zeros(N),np.zeros(N),np.zeros(N)]
    407407   
    408 def GetImageData(imagefile,imageOnly=False):
     408def CheckImageFile(self,imagefile):
     409    if not ospath.exists(imagefile):
     410        dlg = wx.FileDialog(self, 'Bad image file name; choose name', '.', '',\
     411        'MAR345 (*.mar3450;*.mar2300)|*.mar3450;*.mar2300|ADSC Image (*.img)\
     412        |*.img|Detector tif (*.tif;*.tiff)|*.tif;*.tiff|GE Image sum (*.sum)\
     413        |*.sum|GE Image avg (*.avg)|*.avg|GE Image raw (*)|*|All files (*.*)|*.*',wx.OPEN)
     414        if self.dirname:
     415            dlg.SetDirectory(self.dirname)
     416        try:
     417            dlg.SetFilename(ospath.split(imagefile)[1])
     418            if dlg.ShowModal() == wx.ID_OK:
     419                self.dirname = dlg.GetDirectory()
     420                imagefile = dlg.GetPath()
     421            else:
     422                imagefile = False
     423        finally:
     424            dlg.Destroy()
     425    return imagefile
     426       
     427def GetImageData(self,imagefile,imageOnly=False):       
    409428    ext = ospath.splitext(imagefile)[1]
    410429    Comments = []
     
    575594   
    576595def GetTifData(filename,imageOnly=False):
    577     # only works for APS Perkin-Elmer detector data files in "TIFF" format that are readable by Fit2D
     596    # only works for APS Perkin-Elmer or MAR detector data files in "TIFF" format that are readable by Fit2D
    578597    import struct as st
    579598    import array as ar
     
    595614        lines = ['not a detector tiff file',]
    596615        return lines,0,0
    597     size,Ityp = st.unpack('<ii',File.read(8))
     616    origSize,Ityp = st.unpack('<ii',File.read(8))
    598617    File.seek(30)
    599     size = st.unpack('<i',File.read(4))[0]
     618    finalSize = st.unpack('<i',File.read(4))[0]
     619    if finalSize:
     620        sizeScale = origSize/finalSize
     621    else:
     622        sizeScale = 1
     623        finalSize = origSize
    600624    if Ityp == 0:
    601625        tifType = 'Pilatus'
    602         pixy = (172,172)
     626        pixy = (172*sizeScale,172*sizeScale)
    603627        pos = 4096
    604628        if not imageOnly:
     
    606630    elif Ityp == 1:
    607631        tifType = 'PE'
    608         pixy = (200,200)
     632        pixy = (200*sizeScale,200*sizeScale)
    609633        pos = 8
    610634        if not imageOnly:
     
    612636    elif Ityp == 3328:
    613637        tifType = 'MAR'
    614         pixy = (79,79)
     638        pixy = (79*sizeScale,79*sizeScale)
    615639        pos = 4096
    616640        if not imageOnly:
     
    619643        lines = 'unknown tif type'
    620644        return lines,0,0
    621     image = np.zeros(shape=(size,size),dtype=np.int32)
     645    image = np.zeros(shape=(finalSize,finalSize),dtype=np.int32)
    622646    row = 0
    623     while row < size:
     647    while row < finalSize:
    624648        File.seek(pos)
    625649        if 'PE' in tifType:
    626650            if dataType == 5:
    627                 line = ar.array('f',File.read(4*size))
     651                line = ar.array('f',File.read(4*finalSize))
    628652            else:
    629                 line = ar.array('l',File.read(4*size))
    630             pos += 4*size
     653                line = ar.array('l',File.read(4*finalSize))
     654            pos += 4*finalSize
    631655        elif 'MAR' in tifType:
    632             line = ar.array('H',File.read(2*size))
    633             pos += 2*size
     656            line = ar.array('H',File.read(2*finalSize))
     657            pos += 2*finalSize
    634658        image[row] = np.asarray(line)
    635659        row += 1
     
    639663        return image
    640664    else:
    641         return head,data,size,image
     665        return head,data,finalSize,image
    642666   
    643667def ProjFileOpen(self):
  • trunk/GSASIIgrid.py

    r195 r225  
    245245        self._init_ctrls(parent,name,size,pos)
    246246        self.data = data
    247         self.screenSize = wx.DisplaySize()
     247        clientSize = wx.ClientDisplayRect()
    248248        Size = self.GetSize()
    249         xPos = self.screenSize[0]-Size[0]
    250         self.SetPosition(wx.Point(xPos,250))
     249        xPos = clientSize[2]-Size[0]
     250        self.SetPosition(wx.Point(xPos,clientSize[1]+250))
    251251        self.dirname = ''
    252252        self.AtomGrid = []
     
    254254       
    255255    def setSizePosLeft(self,Width):
    256         screenSize = wx.DisplaySize()
    257         Width[1] = min(Width[1],screenSize[1]-300)
     256        clientSize = wx.ClientDisplayRect()
     257        Width[1] = min(Width[1],clientSize[2]-300)
    258258        self.SetSize(Width)
    259         self.SetPosition(wx.Point(screenSize[0]-Width[0],250))
     259        self.SetPosition(wx.Point(clientSize[2]-Width[0],clientSize[1]+250))
    260260       
    261261    def Clear(self):
  • trunk/GSASIIplot.py

    r197 r225  
    10191019        Page.canvas.mpl_connect('pick_event', OnImPick)
    10201020        Page.canvas.mpl_connect('button_release_event', OnImRelease)
     1021        xylim = []
    10211022    if not event:                       #event from GUI TextCtrl - don't want focus to change to plot!!!
    10221023        Page.SetFocus()
     
    10241025    size,imagefile = self.PatternTree.GetItemPyData(self.Image)
    10251026    if imagefile != self.oldImagefile:
    1026         self.ImageZ = G2IO.GetImageData(imagefile,imageOnly=True)
     1027        imagefile = G2IO.CheckImageFile(self,imagefile)
     1028        if not imagefile:
     1029            self.G2plotNB.Delete('2D Powder Image')
     1030            return
     1031        self.PatternTree.SetItemPyData(self.Image,[size,imagefile])
     1032        self.ImageZ = G2IO.GetImageData(self,imagefile,imageOnly=True)
    10271033        self.oldImagefile = imagefile
    10281034    Data = self.PatternTree.GetItemPyData(
     
    11331139        Plot.set_xlim(xlim)
    11341140        Plot.set_ylim(ylim)
    1135         if not newPlot:
     1141        if not newPlot and xylim:
    11361142            Page.toolbar.push_current()
    11371143            Plot.set_xlim(xylim[0])
Note: See TracChangeset for help on using the changeset viewer.