示例#1
0
 def loadCurrentBlock(self, **kwargs):
     filename = dataManager.config.value("data/init/file", None)
     if filename is not None:
         buttonReply = QMessageBox.question(
             self, 'Hyperclass Initialization', "Load current block?",
             QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
         if buttonReply == QMessageBox.Yes:
             taskRunner.start(
                 Task(f"load dataset", self.openFile, filename, **kwargs))
示例#2
0
 def setTile(self, tile_coords: Tuple[int], **kwargs):
     current_tile_coords = dataManager.config.value("tile/indices", None)
     if current_tile_coords is None or current_tile_coords != tile_coords:
         print(f"Setting tile indices = {tile_coords}")
         dataManager.config.setValue("tile/indices", tile_coords)
         filename = dataManager.config.value("data/init/file", None)
         if filename is not None:
             taskRunner.start(
                 Task(f"Load New Tile", self.openFile, filename, **kwargs))
         self.update_tile_load_menu.emit()
示例#3
0
 def selectFile(self, *args, **kwargs):
     data_dir = dataManager.config.value('data/dir')
     dialog = QFileDialog(self, "Select File", data_dir)
     dialog.setFileMode(QFileDialog.AnyFile)
     dialog.setViewMode(QFileDialog.Detail)
     if (dialog.exec()):
         fileNames = dialog.selectedFiles()
         taskRunner.start(
             Task(f"load dataset", self.openFile, fileNames[0], **kwargs))
     dialog.close()
示例#4
0
 def runLoadDataset(self, dsid: str, **kwargs):
     load_dataset_in_background = True
     if load_dataset_in_background:
         taskRunner.start(
             Task(f"Load Dataset {dsid}", self.loadDataset, dsid, **kwargs))
     else:
         dset = self.loadDataset(dsid, **kwargs)
         event = dict(event='task',
                      type='result',
                      label='load dataset',
                      result=dset)
         self.submitEvent(event, EventMode.Gui)
示例#5
0
 def processEvent(self, event: Dict):
     if event.get('event') == 'gui':
         if event.get('type') == 'update':
             self.refresh_points(**event)
             self.refresh_images(**event)
             print("GUI UPDATE")
             self.update()
             self.repaint()
         if event.get('type') == 'reload':
             filename = dataManager.config.value("data/init/file", None)
             if filename is not None:
                 taskRunner.start(
                     Task(f"load dataset",
                          self.openFile,
                          filename,
                          reset=True))
示例#6
0
    def __init__(self, nodes_data: xa.DataArray, **kwargs):
        QObject.__init__(self)
        self.nodes: xa.DataArray = None
        self.nnd: NNDescent = None
        self.I: np.ndarray = None
        self.D: np.ndarray = None
        self.P: np.ndarray = None
        self.C: np.ndarray = None
        self.reset = True

        background = kwargs.get('background', False)
        if background:
            self.init_task = Task(f"Compute NN graph", self.setNodeData,
                                  nodes_data, **kwargs)
            taskRunner.start(self.init_task)
        else:
            self.setNodeData(nodes_data, **kwargs)
示例#7
0
 def submitEvent(self, event: Dict, mode: EventMode):
     from hyperclass.data.events import dataEventHandler
     from hyperclass.gui.tasks import taskRunner, Task
     try:
         dataEventHandler.reset(event)
     except:
         pass
     if mode == EventMode.Gui:
         self.process_event.emit(event)
     else:
         for client in self._clients:
             if mode == EventMode.Foreground:
                 client.processEvent(event)
             elif mode == EventMode.Background:
                 print(
                     f"\n****  CLASS {self.__class__.__name__}: submit background event {event}"
                 )
                 task_label = ".".join([
                     event.get(id, "") for id in ['event', 'type', 'label']
                 ])
                 task = Task(task_label, client.processEvent, event)
                 taskRunner.start(task)
示例#8
0
 def runSetTile(self, coords, **kwargs):
     taskRunner.start(Task("Loading tile", self.setTile, coords, **kwargs))
示例#9
0
 def runSetBlock(self, coords, **kwargs):
     taskRunner.start(Task("Loading block", self.setBlock, coords,
                           **kwargs))
示例#10
0
 def run_task(self, executable: Callable, messsage: str, *args, **kwargs ):
     task = Task( messsage, executable, *args, **kwargs )
     taskRunner.start( task )