Browse Source

tinker, tinker, tinkering

master
Christian Voigt 1 year ago
parent
commit
d56934a6ea
  1. 4
      world_regions_widget/layout_region_label_collection.py
  2. 20
      world_regions_widget/object_region_label.py

4
world_regions_widget/layout_region_label_collection.py

@ -38,10 +38,8 @@ class WorkerUpdateLabelCollection(QThread):
def run(self):
progress_percentage = (100 / self.regions_per_row) / self.regions_per_row
for y in range(0, self.regions_per_row):
self.progress.emit(int((y * (progress_percentage * self.regions_per_row))))
for x in range(0, self.regions_per_row):
self.progress.emit(
int((y * (progress_percentage * self.regions_per_row)) + (x * progress_percentage))
)
self.region_label_helper.region_label_set_raw_data_array.emit(
create_region_string_from_grid_index(x=x + self.offset, y=y + self.offset),
self.blockshaped_map_data[y][x].copy()

20
world_regions_widget/object_region_label.py

@ -109,23 +109,25 @@ class RegionLabel(QLabel):
pixmap.fill(get_color_by_coordinates(self.x, self.y))
self.setPixmap(pixmap)
def set_label_pixmap(self, chunk):
pixmap = QPixmap(self.dimensions)
pixmap.fill(QColor("transparent"))
painter = QPainter(pixmap)
painter.drawPixmap(0, 0, self.dimensions.width(), self.dimensions.height(), QPixmap.fromImage(chunk))
def set_label_pixmap(self, region_string: str, raw_data_array: np.array):
if region_string == self.region_string:
chunk = QImage(raw_data_array, 512, 512, QImage.Format_Grayscale16)
pixmap = QPixmap(self.dimensions)
pixmap.fill(QColor("transparent"))
painter = QPainter(pixmap)
painter.drawPixmap(0, 0, self.dimensions.width(), self.dimensions.height(), QPixmap.fromImage(chunk))
painter.end()
self.setPixmap(pixmap)
painter.end()
self.setPixmap(pixmap)
""" getter + setter"""
def set_raw_data_array(self, region_string: str, raw_data_array: np.array = None) -> None:
if region_string == self.region_string:
self.raw_data_array = raw_data_array
chunk = QImage(self.raw_data_array.copy(), 512, 512, QImage.Format_Grayscale16)
self.set_label_pixmap(chunk)
self.is_region = True
self.set_label_pixmap(region_string, raw_data_array.copy())
def set_adjacent_marked_region_labels(self, adjacent_marked_region_labels) -> None:
self.adjacent_marked_region_labels = adjacent_marked_region_labels

Loading…
Cancel
Save