Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    def _active_feature_changed(self):
        """
        Triggered when the active feature is changed
        """
        if self._block_feature_changes:
            return

        selected_index = self.feature_model.index(
            self.feature_combo.currentIndex(), 0)
        if selected_index.isValid():
            feature = self.feature_model.data(selected_index,
                                              FeatureModel.FEATURE_ROLE)
            changed = self.vertex_model.feature is None or feature is None or self.vertex_model.feature.id(
            ) != feature.id()
            self.vertex_model.set_feature(feature)

            if feature is not None:
                self.label_part_count.setText(
                    str(feature.geometry().constGet().numGeometries(
                    ) if feature.geometry().isMultipart() else 1))
                self.label_vertex_count.setText(
                    str(feature.geometry().constGet().nCoordinates()))
                self.label_geometry_type.setText(
                    QgsWkbTypes.translatedDisplayString(
                        feature.geometry().wkbType()))
                self.button_zoom.setEnabled(True)
            else:
                self.label_geometry_type.clear()
                self.label_part_count.clear()
                self.label_vertex_count.clear()
                self.button_zoom.setEnabled(False)

            if changed and feature is not None and SettingsRegistry.flash_feature(
            ):
                self.map_canvas.flashGeometries([feature.geometry()],
                                                self.layer.crs())

        else:
            self.vertex_model.set_feature(None)
            self.label_geometry_type.clear()
            self.label_part_count.clear()
            self.label_vertex_count.clear()
            self.button_zoom.setEnabled(False)

        self._vertex_selection_changed()
Exemplo n.º 3
0
    def _zoom_to_feature(self):
        """
        Zooms to the extent of the selected feature
        """
        selected_index = self.feature_model.index(
            self.feature_combo.currentIndex(), 0)
        if selected_index.isValid():
            feature = self.feature_model.data(selected_index,
                                              FeatureModel.FEATURE_ROLE)

            ct = QgsCoordinateTransform(
                self.layer.crs(),
                self.map_canvas.mapSettings().destinationCrs(),
                QgsProject.instance())
            try:
                bounds = ct.transformBoundingBox(
                    feature.geometry().boundingBox())
                self.map_canvas.zoomToFeatureExtent(bounds)
                if SettingsRegistry.flash_feature():
                    self.map_canvas.flashGeometries([feature.geometry()],
                                                    self.layer.crs())
            except QgsCsException:
                pass