예제 #1
0
파일: view.py 프로젝트: smdabdoub/find
 def renameItem(self):
     """
     Give a new display name to the currently selected data item
     """
     item = self.getSanitizedItemSelectionData()
     if item is None:
         return
     
     if (item[0] is DATA_SET_ITEM):
         data = DataStore.get(item[1])
         dlg = EditNameDialog(self.Parent, data.displayname)
         if dlg.ShowModal() == wx.ID_OK:
             data.displayname = dlg.Text
         dlg.Destroy()
             
     if (item[0] is FIGURE_SET_ITEM):
         figure = FigureStore.get(item[1])
         dlg = EditNameDialog(self.Parent, figure.name)
         if dlg.ShowModal() == wx.ID_OK:
             figure.name = dlg.Text
         dlg.Destroy()
         
     item = self.tree.GetSelection()
     item.SetText(dlg.Text)
     self.tree.RefreshSelected()
     item.SetHilight(False)
     item.SetHilight(True)
예제 #2
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])
예제 #3
0
파일: find.py 프로젝트: smdabdoub/find
    def OnLoadState(self, event):
        from data.io import loadState
        
        if len(DataStore.getData()) > 0:
            dlgWarn = wx.MessageDialog(self, 'This action may overwrite currently loaded datasets and/or plots.\n\nContinue anyway?', 'Warning', 
                                   wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING)
            if dlgWarn.ShowModal() == wx.ID_NO:
                dlgWarn.Destroy()
                return
            dlgWarn.Destroy()

        formats = "FIND Project File (*.find)|*.find"
        dlg = wx.FileDialog(self, "Select saved project", self.dirname, "", formats, wx.FD_OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            try:
                loadState(dlg.Directory, dlg.Filename)
            except error.ProjectLoadingError:
                return
            # Load all Figures with Subplot instances from the stored dicts
            for fID in FigureStore.getFigures():
                fig = FigureStore.get(fID)
                splots = []
                for plot in fig.subplots:
                    s = dv.Subplot()
                    s.load(plot)
                    s.parent = self.facsPlotPanel.figure
                    splots.append(s)
                fig.subplots = splots
            
            currFigure = FigureStore.getSelectedFigure()
            self.facsPlotPanel.subplots = currFigure.subplots
            self.facsPlotPanel.SelectedSubplotIndex = currFigure.selectedSubplot
            self.facsPlotPanel.updateAxes(currFigure.axes, False)
            self.facsPlotPanel.updateSubplotGrid(currFigure.grid[0], currFigure.grid[1], True)
            self.chkLinked.Value = self.facsPlotPanel.CurrentSubplotLinked
            labels = DataStore.getCurrentDataSet().labels if DataStore.getCurrentDataSet() is not None else []
            self.updateAxesList(labels, currFigure.axes)
            self.treeCtrlPanel.updateTree()
            self.statusbar.SetStatusText("Project loaded from %s" % dlg.Path, 0)
        
        dlg.Destroy()
예제 #4
0
파일: io.py 프로젝트: smdabdoub/find
def saveState(dir, filename):
    """
    Save a representation of the system state: All the loaded data sets, 
    their clusterings, any transformations or analyses (future), 
    and all plots.
    
    The state is saved in JSON format based on a dict of the following form:
    
    data: list of IDs
    binfile: the filename of the binary file used to store all the actual data
    data-dID: dict of settings belonging to a FacsData instance
    clust-dID-cID: a dict of attributes belonging to a clustering
    figures: list of figureID strings
    fig-ID: A dict for each figure keyed on the ID. The subplot attribute here 
          is replaced with a list of fig-ID-p-ID strings for locating subplot dicts
    fig-ID-p-ID: A dict for each subplot in each figure keyed on fig ID and plot ID.
    current-data: data ID
    current-figure: figure ID
    """ 
    store = shelve.open(os.path.join(dir, filename))
    #store = dbopen(os.path.join(dir, filename), 'c', format='csv')
    # The actual numeric data will be stored in a separate binary file using
    # the numpy savez() method allowing for efficient storage/retrieval of data
    binfile = '%s.npz' % filename
    bindata = {}
    
    store['data'] = DataStore.getData().keys()
    store['binfile'] = binfile
    for dID in DataStore.getData():
        fdata = DataStore.get(dID)
        dStr = 'data-%i' % dID
        dfname = fdata.filename if (fdata.filename is not '') else binfile
        bindata[dStr] = fdata.data
        store[dStr] = {'filename':     dfname,
                       'displayname':  fdata.displayname, 
                       'labels':       fdata.labels, 
                       'annotations':  fdata.annotations, 
                       'analysis':     fdata.analysis, 
                       'ID':           fdata.ID,
                       'parent':       fdata.parent,
                       'children':     fdata.children,
                       'selDims':      fdata.selDims,
                       'clustering':   fdata.clustering.keys(),
                       'nodeExpanded': fdata.nodeExpanded,
                       'selectedClustering': fdata.selectedClustering}
        # clusterings
        for cID in fdata.clustering:
            cStr = 'clust-%i-%i' % (dID, cID)
            csett = {'method':            fdata.methodIDs[cID],
                     'opts':              fdata.clusteringOpts[cID],
                     'clusteringSelDims': fdata.clusteringSelDims[cID],
                     'infoExpanded':      fdata.infoExpanded[cID]}
            store[cStr] = csett
            bindata[cStr] = fdata.clustering[cID]
    
    
    # figures
    sfigs = []
    for figID in FigureStore.getFigures():
        fig = FigureStore.get(figID)
        fStr = 'fig-%i' % figID
        d = dict(fig.__dict__)
        splots = packSubplots(store, figID, fig.subplots)
        d['subplots'] = splots
        store[fStr] = d
        sfigs.append(fStr)        
        
    store['figures'] = list(sfigs)

    # other
    store['current-data'] = DataStore.getCurrentIndex()
    store['current-figure'] = FigureStore.getSelectedIndex()
    
    # write out settings data
    store.close()
    # write out numeric data to binary file
    np.savez(os.path.join(dir, binfile), **bindata)