Browse Source

always wanted to use a property :)

master
Christian Voigt 1 year ago
parent
commit
0c655b5adf
  1. 37
      world_regions_widget/__init__.py
  2. 4
      world_regions_widget/region_label_collection.py

37
world_regions_widget/__init__.py

@ -72,6 +72,10 @@ class WorldRegionsWidget(QScrollArea):
self.init_actions()
self.init_cursors()
@property
def zoom_adjusted_label_size(self):
return self.world_label_zoom_factor * self.world_label_region_size
def init_actions(self):
open_world_file = QAction()
open_world_file.setShortcut(
@ -92,28 +96,25 @@ class WorldRegionsWidget(QScrollArea):
def init_cursors(self):
self.root_dir = os.path.dirname(os.path.abspath(__file__))
cursor_size = QSize(86, 86)
self.cursor_hover_region = QCursor(QPixmap(
os.path.join(self.root_dir, 'cursors/hover_region.png')
).scaled(cursor_size, Qt.KeepAspectRatio), -1, -1)
self.cursor_add_region = QCursor(QPixmap(
os.path.join(self.root_dir, 'cursors/add_region.png')
).scaled(cursor_size, Qt.KeepAspectRatio), -1, -1)
self.cursor_remove_region = QCursor(QPixmap(
os.path.join(self.root_dir, 'cursors/remove_region.png')
).scaled(cursor_size, Qt.KeepAspectRatio), -1, -1)
self.cursor_plot_region = QCursor(QPixmap(
os.path.join(self.root_dir, 'cursors/region_context.png')
).scaled(cursor_size, Qt.KeepAspectRatio), -1, -1)
scale_options = (QSize(86, 86), Qt.KeepAspectRatio)
self.cursor_hover_region = QCursor(
QPixmap(os.path.join(self.root_dir, 'cursors/hover_region.png')).scaled(*scale_options), -1, -1
)
self.cursor_add_region = QCursor(
QPixmap(os.path.join(self.root_dir, 'cursors/add_region.png')).scaled(*scale_options), -1, -1
)
self.cursor_remove_region = QCursor(
QPixmap(os.path.join(self.root_dir, 'cursors/remove_region.png')).scaled(*scale_options), -1, -1
)
self.cursor_plot_region = QCursor(
QPixmap(os.path.join(self.root_dir, 'cursors/region_context.png')).scaled(*scale_options), -1, -1
)
self.setCursor(self.cursor_hover_region)
def set_currently_hovered_label(self, label):
self.currently_hovered_label = label
def get_zoom_adjusted_label_size(self):
return self.world_label_zoom_factor * self.world_label_region_size
def action_zoom_in(self):
self.world_label_zoom_factor += self.min_zoom_factor
if self.world_label_zoom_factor >= self.max_zoom_factor:
@ -121,7 +122,7 @@ class WorldRegionsWidget(QScrollArea):
return
self.region_label_collection.change_label_size(
self.get_zoom_adjusted_label_size()
self.zoom_adjusted_label_size
)
self.adjust_scrollbar_positions()
self.center_mouse_on_hovered_label()
@ -133,7 +134,7 @@ class WorldRegionsWidget(QScrollArea):
return
self.region_label_collection.change_label_size(
self.get_zoom_adjusted_label_size()
self.zoom_adjusted_label_size
)
self.adjust_scrollbar_positions()
self.center_mouse_on_hovered_label()

4
world_regions_widget/region_label_collection.py

@ -19,7 +19,7 @@ class RegionLabelCollection(QGridLayout):
super().__init__()
self.world_regions = world_regions
self.label_collection = {}
self.create_label_collection(self.world_regions.get_zoom_adjusted_label_size())
self.create_label_collection(self.world_regions.zoom_adjusted_label_size)
def set_currently_hovered_label(self, region_label):
self.world_regions.set_currently_hovered_label(region_label)
@ -121,7 +121,7 @@ class RegionLabelCollection(QGridLayout):
return self
def update_label_collection_with_raw_map_data(self, raw_map_data, length, offset=0):
self.clear_viewer_grid().create_label_collection(self.world_regions.get_zoom_adjusted_label_size())
self.clear_viewer_grid().create_label_collection(self.world_regions.zoom_adjusted_label_size)
regions_per_row = int(length / 512)
self.raw_map_data = np.flipud(np.reshape(raw_map_data, (length, length)))

Loading…
Cancel
Save