def set_selected_vertex(self, feature_id: Optional[int], vertex_number: Optional[int]): """ Triggered when the selected vertex is changed """ if self.current_vertex_number == vertex_number and self.current_feature_id == feature_id: return needs_redraw = SettingsRegistry.label_filtering() == SettingsRegistry.LABEL_SELECTED or \ ( SettingsRegistry.label_filtering() == SettingsRegistry.LABEL_ALL and feature_id != self.current_feature_id) self.current_feature_id = feature_id self.current_vertex_number = vertex_number self._remove_current_generator() self._reset_generator(not needs_redraw)
def restore_settings(self): """ Restores saved settings """ current_label_filter = SettingsRegistry.label_filtering() self.filtering_combo.setCurrentIndex(self.filtering_combo.findData(current_label_filter)) self.check_center_on_selection.setChecked(SettingsRegistry.center_on_selected()) self.check_flash_feature.setChecked(SettingsRegistry.flash_feature()) self.check_flash_vertex.setChecked(SettingsRegistry.flash_vertex()) self.point_symbol_button.setSymbol(SettingsRegistry.vertex_symbol()) self.vertex_font_button.setTextFormat(SettingsRegistry.vertex_format()) self.number_format = SettingsRegistry.number_format()
def createRenderer(self) -> QgsSingleSymbolRenderer: # pylint: disable=missing-function-docstring filtering = SettingsRegistry.label_filtering() topological = self.topological and self.layer.selectedFeatureCount( ) == 2 if filtering == SettingsRegistry.LABEL_NONE: return QgsNullSymbolRenderer() if filtering == SettingsRegistry.LABEL_SELECTED: if self.feature_id is None or self.vertex_number is None: # labeling selected vertex only, and no selection => no renderer return QgsNullSymbolRenderer() selection = {self.feature_id} vertex_number = self.vertex_number else: selection = self.layer.selectedFeatureIds() vertex_number = None if topological: request = QgsFeatureRequest().setFilterFids( self.layer.selectedFeatureIds()).setNoAttributes() topological_geometries = { f.id(): f.geometry() for f in self.layer.getFeatures(request) } else: topological_geometries = None layer_source = QgsVectorLayerFeatureSource(self.layer) return VertexHighlighterRenderer( source=layer_source, layer_type=self.layer_type, selection=selection, vertex_number=vertex_number, topological_geometries=topological_geometries, )