예제 #1
0
파일: view.py 프로젝트: smdabdoub/find
 def selectItemTreeSelection(self, rightClick=False):
     """
     Using the selected tree item, set the corresponding object 
     in the data store as the current selection.
     """
     item = self.getSanitizedItemSelectionData()
     
     if item is not None:
         if item[0] is DATA_SET_ITEM:
             self.applyToSelection(DataStore.selectDataSet, FacsData.selectClustering)
         
         if item[0] is FIGURE_SET_ITEM and not rightClick:
             if item[1] != FigureStore.getSelectedIndex():
                 currFig = FigureStore.getSelectedFigure()
                 newFig = FigureStore.get(item[1])
                 switchFigures(self.Parent.TopLevelParent.facsPlotPanel, currFig, newFig, True)
                 self.Parent.TopLevelParent.selectAxes(newFig.axes)
                 FigureStore.setSelectedFigure(item[1])
예제 #2
0
파일: io.py 프로젝트: smdabdoub/find
def loadState(dir, filename):
    """
    Restore the system state as stored to disk.
    
    @type dir: string
    @param path: The directory under which the the saved system state is stored
    @type filename: str
    @param filename: The name of the saved project file (.find)
    @rtype: tuple
    @return: A list of subplot settings (dicts) retrieved from the file,
             The index of the currently selected subplot,
             The currently selected axes,
             The number of rows and columns in the figure (grid size)
    """
    store = shelve.open(os.path.join(dir, filename))
    #store = dbopen(os.path.join(dir, filename))
    datakeys = store['data']
    
    try:
        bindata = np.load(os.path.join(dir,store['binfile']))
    except IOError:
        bindata = None
    except BadZipfile:
        wx.MessageBox('The file \'%s\' may have become corrupted. Project loading has been cancelled' % store['binfile'],
                      'Data Loading Error',
                      wx.OK|wx.ICON_ERROR)
        raise ProjectLoadingError('BadZipfile: %s' % os.path.join(dir,store['binfile']))
    
    # Parse data sets
    for dID in datakeys:
        dStr = 'data-%s' % dID
        dsett = store[dStr]
        ann = dsett['annotations'] if 'annotations' in dsett else {}
        ana = dsett['analysis'] if 'analysis' in dsett else {}
        fdata = FacsData(dsett['filename'], dsett['labels'], bindata[dStr], 
                         annotations=ann, analysis=ana,
                         parent=dsett['parent'])
        fdata.displayname = dsett['displayname']
        fdata.ID = dsett['ID']
        fdata.children = dsett['children']
        fdata.selDims = dsett['selDims']
        fdata.nodeExpanded = dsett['nodeExpanded']
        # Parse clusterings
        for cID in dsett['clustering']:
            cStr = 'clust-%i-%i' % (dID, cID)
            csett = store[cStr]
            clusterIDs = bindata[cStr]
            fdata.addClustering(csett['method'], clusterIDs, csett['opts'], cID)
            fdata.clusteringSelDims[cID] = csett['clusteringSelDims']
            fdata.infoExpanded[cID] = csett['infoExpanded']
        
        DataStore.add(fdata)
        
    DataStore.selectDataSet(store['current-data'])

    # Figures
    if 'figures' in store:
        for fStr in store['figures']:
            fDict = store[fStr]
            splots = []
            for pStr in fDict['subplots']:
                splots.append(store[pStr])
            fDict['subplots'] = splots
            f = Figure()
            f.load(fDict)
            FigureStore.add(f)
            
    # handle older save files w/o Figure support
    else:
        # load the saved subplots into a new 'Default' Figure
        plots = []
        for pStr in store['plots']:
            plots.append(store[pStr])
        defFig = Figure('Default', plots, store['current-subplot'], store['grid'], store['selected-axes'])
        FigureStore.add(defFig)

        
    if 'current-figure' in store:
        FigureStore.setSelectedFigure(store['current-figure'])
    else:
        FigureStore.setSelectedFigure(0)