Changeset 2215 for trunk/GSASII.py


Ignore:
Timestamp:
Apr 15, 2016 1:17:34 PM (6 years ago)
Author:
toby
Message:

load images to tree as read in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2214 r2215  
    339339   
    340340    def OnImportGeneric(self,reader,readerlist,label,multiple=False,
    341                         usedRanIdList=[],Preview=True):
     341                        usedRanIdList=[],Preview=True,
     342                        load2Tree=False):
    342343        '''Used for all imports, including Phases, datasets, images...
    343344
     
    380381        :param bool Preview: indicates if a preview of the file should
    381382          be shown. Default is True, but set to False for image files
    382           which are all binary.
     383          which are all binary.
     384
     385        :param bool load2Tree: indicates if the file should be loaded
     386          into the data tree immediately (used for images only)
    383387
    384388        :returns: a list of reader objects (rd_list) that were able
     
    518522                    if flag: # this read succeeded
    519523                        rd.readfilename = filename
    520                         rd_list.append(copy.deepcopy(rd)) # save the result before it is written over
     524                        if load2Tree:
     525                            if rd.repeatcount == 1 and not rd.repeat: # skip image number if only one in set
     526                                rd.Data['ImageTag'] = None
     527                            else:
     528                                rd.Data['ImageTag'] = rd.repeatcount
     529                            G2IO.LoadImage2Tree(rd.readfilename,self,rd.Comments,rd.Data,rd.Npix,rd.Image)
     530                            rd_list.append(True) # save a stub the result before it is written over
     531                            del rd.Image
     532                        else:                                                   
     533                            rd_list.append(copy.deepcopy(rd)) # save the result before it is written over
    521534                        if rd.repeat:
    522535                            repeat = True
     
    751764        A reader object is filled each time an image is read.
    752765        '''
     766        self.CheckNotebook()
    753767        # look up which format was requested
    754768        reqrdr = self.ImportMenuId.get(event.GetId())
    755         rdlist = self.OnImportGeneric(reqrdr,self.ImportImageReaderlist,
    756             'image',multiple=True,Preview=False)
    757         if not rdlist: return
    758         first = True
    759         for rd in rdlist:
    760             if first:
    761                 first = False
    762                 self.CheckNotebook()
    763             if rd.repeatcount == 1 and not rd.repeat: # skip image number if only one in set
    764                 rd.Data['ImageTag'] = None
    765             else:
    766                 rd.Data['ImageTag'] = rd.repeatcount
    767             G2IO.LoadImage2Tree(rd.readfilename,self,rd.Comments,rd.Data,rd.Npix,rd.Image)
    768         self.PatternTree.SelectItem(G2gd.GetPatternTreeItemId(self,self.Image,'Image Controls'))             #show last image to have beeen read
     769        rdlist = self.OnImportGeneric(reqrdr,
     770                    self.ImportImageReaderlist,
     771                    'image',multiple=True,Preview=False,
     772                    load2Tree=True)
     773        if rdlist:
     774            self.PatternTree.SelectItem(G2gd.GetPatternTreeItemId(self,self.Image,'Image Controls'))             #show last image to have beeen read
    769775                   
    770776    def _Add_ImportMenu_Sfact(self,parent):
     
    22672273            style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX)
    22682274        self.G2plotNB = G2plt.G2PlotNoteBook(plotFrame)
     2275        #self.G2plotNB = G2plt.G2PlotNoteBook(plotFrame,G2frame=self)
    22692276        plotFrame.Show()
    22702277       
     
    25082515    def OnImageRead(self,event):
    25092516        '''Called to read in an image in any known format. *** Depreciated. ***
    2510         Note: When removed, G2IO.ReadLoadImage can also be removed
    25112517        '''
    25122518        G2G.G2MessageBox(self,'Please use the Import/Image/... menu item rather than this','depreciating menu item')
    2513         self.CheckNotebook()
    2514         dlg = wx.FileDialog(
    2515             self, 'Choose image files', '.', '',
    2516             'Any supported image file (*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.stl;*.G2img;*.png)|'
    2517             '*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.stl;*.G2img;*.png;*.zip|'
    2518             'European detector file (*.edf)|*.edf|'
    2519             'Any detector tif (*.tif;*.tiff)|*.tif;*.tiff|'
    2520             'MAR file (*.mar*)|*.mar*|'
    2521             'GE Image (*.ge*;*.avg;*.sum)|*.ge*;*.avg;*.sum|'
    2522             'ADSC Image (*.img)|*.img|'
    2523             'Rigaku R-Axis IV (*.stl)|*.stl|'
    2524             'GSAS-II Image (*.G2img)|*.G2img|'
    2525             'Portable Network Graphics image (*.png)|*.png|'
    2526             'Zip archive (*.zip)|*.zip|'
    2527             'All files (*.*)|*.*',
    2528             wx.OPEN | wx.MULTIPLE)
    2529         try:
    2530             if dlg.ShowModal() == wx.ID_OK:
    2531                 imagefiles = dlg.GetPaths()
    2532                 imagefiles.sort()
    2533                 for imagefile in imagefiles:
    2534                     G2IO.ReadLoadImage(imagefile,self)
    2535                 os.chdir(dlg.GetDirectory())           # to get Mac/Linux to change directory!
    2536                 self.PatternTree.SelectItem(G2gd.GetPatternTreeItemId(self,self.Image,'Image Controls'))             #show last image to be read
    2537         finally:
    2538             path = dlg.GetDirectory()           # to get Mac/Linux to change directory!
    2539             os.chdir(path)
    2540             dlg.Destroy()
    25412519
    25422520    def CheckNotebook(self):
Note: See TracChangeset for help on using the changeset viewer.