def rect(self): return QRectF(self.pos(), QSizeF(*self.size()))
def patchRectF(self, blockNum, overlap=0): startx, endx, starty, endy = self.getPatchBounds(blockNum, overlap) return QRectF(QPointF(startx, starty), QPointF(endx, endy))
def patchRectF(self, blockNum, overlap=0): startx, endx, starty, endy = self.getPatchBounds(blockNum, overlap) return QRectF(QPointF(startx, starty), QPointF(endx, endy)) def getPatchesForRect(self, startx, starty, endx, endy): sx = int(numpy.floor(1.0 * startx / self._blockSize)) ex = int(numpy.ceil(1.0 * endx / self._blockSize)) sy = int(numpy.floor(1.0 * starty / self._blockSize)) ey = int(numpy.ceil(1.0 * endy / self._blockSize)) # Clip to rect bounds sx = max(sx, 0) sy = max(sy, 0) ex = min(ex, self._cX) ey = min(ey, self._cY) nums = [] for y in range(sy, ey): nums += range(y * self._cX + sx, y * self._cX + ex) return nums if __name__ == "__main__": pa = PatchAccessor(1000, 1000, 100) assert pa.patchCount == 100 assert pa.patchRectF(0) == QRectF(0, 0, 100, 100) assert pa.patchRectF(1) == QRectF(100, 0, 100, 100) assert pa.getPatchesForRect(50, 50, 150, 150) == [0, 1, 10, 11]
def _onSizeChanged(self): self._cache = _TilesCache(self._current_stack_id, self._sims, maxstacks=self._cache_size) self.sceneRectChanged.emit(QRectF())
def update_data(self, attr_x, attr_y): self.shown_x = attr_x self.shown_y = attr_y self.remove_legend() if self.scatterplot_item: self.plot_widget.removeItem(self.scatterplot_item) if self.scatterplot_item_sel: self.plot_widget.removeItem(self.scatterplot_item_sel) for label in self.labels: self.plot_widget.removeItem(label) self.labels = [] self.set_axis_title("bottom", "") self.set_axis_title("left", "") if self.scaled_data is None or not len(self.scaled_data): self.valid_data = None self.n_points = 0 return index_x = self.attribute_name_index[attr_x] index_y = self.attribute_name_index[attr_y] self.valid_data = self.get_valid_list([index_x, index_y]) x_data, y_data = self.get_xy_data_positions(attr_x, attr_y, self.valid_data) x_data = x_data[self.valid_data] y_data = y_data[self.valid_data] self.n_points = len(x_data) for axis, name, index in (("bottom", attr_x, index_x), ("left", attr_y, index_y)): self.set_axis_title(axis, name) var = self.data_domain[index] if var.is_discrete: self.set_labels(axis, get_variable_values_sorted(var)) else: self.set_labels(axis, None) color_data, brush_data = self.compute_colors() color_data_sel, brush_data_sel = self.compute_colors_sel() size_data = self.compute_sizes() shape_data = self.compute_symbols() self.scatterplot_item = ScatterPlotItem(x=x_data, y=y_data, data=np.arange(self.n_points), symbol=shape_data, size=size_data, pen=color_data, brush=brush_data) self.scatterplot_item_sel = ScatterPlotItem( x=x_data, y=y_data, data=np.arange(self.n_points), symbol=shape_data, size=size_data + SELECTION_WIDTH, pen=color_data_sel, brush=brush_data_sel) self.plot_widget.addItem(self.scatterplot_item) self.plot_widget.addItem(self.scatterplot_item_sel) self.scatterplot_item.selected_points = [] self.scatterplot_item.sigClicked.connect(self.select_by_click) self.update_labels() self.make_legend() self.view_box.init_history() self.plot_widget.replot() min_x, max_x = np.nanmin(x_data), np.nanmax(x_data) min_y, max_y = np.nanmin(y_data), np.nanmax(y_data) self.view_box.setRange(QRectF(min_x, min_y, max_x - min_x, max_y - min_y), padding=0.025) self.view_box.tag_history()
def boundingRect(self): return QRectF()