def mark_selected(self, mask, data): # We now make a subset state. For scatter plots we'll want to use an # ElementSubsetState, while for cubes, we'll need to change to a # MaskSubsetState. subset_state = ElementSubsetState(indices=np.where(mask)[0], data=data) # We now check what the selection mode is, and update the selection as # needed (this is delegated to the correct subset mode). mode = EditSubsetMode() mode.update(self.viewer._data, subset_state, focus_data=data)
def mark_selected(self, mask, visible_data): # We now make a subset state. For scatter plots we'll want to use an # ElementSubsetState, while for cubes, we'll need to change to a # MaskSubsetState. subset_state = ElementSubsetState(np.where(mask)[0]) # We now check what the selection mode is, and update the selection as # needed (this is delegated to the correct subset mode). mode = EditSubsetMode() focus = visible_data[0] if len(visible_data) > 0 else None mode.update(self._data_collection, subset_state, focus_data=focus)
def _broadcast_selection(self): if self.data is not None: model = self.ui.table.selectionModel() self.selected_rows = [ self.model.order[x.row()] for x in model.selectedRows() ] subset_state = ElementSubsetState(self.selected_rows) mode = EditSubsetMode() mode.update(self.data, subset_state, focus_data=self.data)
def finalize_selection(self, clear=True): model = self.ui.table.selectionModel() selected_rows = [self.model.order[x.row()] for x in model.selectedRows()] subset_state = ElementSubsetState(indices=selected_rows, data=self.data) mode = EditSubsetMode() mode.update(self._data, subset_state, focus_data=self.data) if clear: # We block the signals here to make sure that we don't update # the subset again once the selection is cleared. self.ui.table.blockSignals(True) self.ui.table.clearSelection() self.ui.table.blockSignals(False)
def apply_filter(self): selected_rows = self.widget_table.checked subset_state = ElementSubsetState(indices=selected_rows, data=self.layers[0].layer) mode = self.session.edit_subset_mode mode.update(self._data, subset_state, focus_data=self.layers[0].layer)
def receive_message(self, private_key, sender_id, msg_id, mtype, params, extra): logger.info( 'SAMP: received message - sender_id={0} msg_id={1} mtype={2} ' 'params={3} extra={4}'.format(sender_id, msg_id, mtype, params, extra)) if mtype.startswith('table.load'): if self.table_id_exists(params['table-id']): logger.info('SAMP: table with table-id={0} has already ' 'been read in'.format(params['table-id'])) return logger.info('SAMP: loading table with table-id={0}'.format( params['table-id'])) if mtype == 'table.load.votable': data = astropy_tabular_data_votable(params['url']) elif mtype == 'table.load.fits': data = astropy_tabular_data_fits(params['url']) else: logger.info('SAMP: unknown format {0}'.format( mtype.split('.')[-1])) return data.label = params['name'] data.meta['samp-table-id'] = params['table-id'] self.data_collection.append(data) elif mtype.startswith('image.load'): if self.image_id_exists(params['image-id']): logger.info('SAMP: image with image-id={0} has already ' 'been read in'.format(params['image-id'])) return logger.info('SAMP: loading image with image-id={0}'.format( params['image-id'])) if mtype == 'image.load.fits': data = fits_reader(params['url']) else: logger.info('SAMP: unknown format {0}'.format( mtype.split('.')[-1])) return data.label = params['name'] data.meta['samp-image-id'] = params['image-id'] self.data_collection.append(data) elif self.state.highlight_is_selection and mtype == 'table.highlight.row': data = self.data_from_table_id(params['table-id']) len(self.data_collection.subset_groups) subset_state = ElementSubsetState(indices=[params['row']], data=data) mode = EditSubsetMode() mode.update(self.data_collection, subset_state) elif mtype == 'table.select.rowList': data = self.data_from_table_id(params['table-id']) len(self.data_collection.subset_groups) rows = np.asarray(params['row-list'], dtype=int) subset_state = ElementSubsetState(indices=rows, data=data) mode = EditSubsetMode() mode.update(self.data_collection, subset_state) elif mtype == 'samp.hub.event.register' or mtype == 'samp.hub.event.unregister': self.state.on_client_change()