Exemplo n.º 1
0
            def setup(self, idx):
                simplify_mask, simplify_label, mask_method = self.params[idx]
                self.parent.parameters.do_simplify = simplify_mask
                self.parent.parameters.simplify_tolerance = 1.0

                m = self.layer.simplifyMethod()
                m.setSimplifyHints(
                    QgsVectorSimplifyMethod.SimplifyHints(
                        1 if simplify_label else 0))
                self.layer.setSimplifyMethod(m)

                self.parent.mask_method = mask_method
Exemplo n.º 2
0
    def apply(self):
        # get data before closing
        self.update_parameters_from_ui(self.parameters)

        # update labeling from parameters
        self.ui.layer_list.update_labeling_from_list()

        if self.parameters.polygon_mask_method == 0:
            # test if some limited layers have simplification turned on
            limited = self.ui.layer_list.get_limited_layers()
            slayers = []
            for name, layer in QgsProject.instance().mapLayers().items():
                if not isinstance(layer, QgsVectorLayer):
                    continue
                if (
                    layer.id() in limited
                    and int(layer.simplifyMethod().simplifyHints()) > 0
                ):
                    # simplification is enabled
                    slayers.append(layer)

            if len(slayers) > 0:
                r = QMessageBox.question(
                    None,
                    self.tr("Warning"),
                    self.tr(
                        "Some layer have rendering simplification turned on, \
                    which is not compatible with the labeling filtering you choose. \
                    Force simplification disabling ?"
                    ),
                    buttons=QMessageBox.Yes | QMessageBox.No,
                )

                if r == QMessageBox.Yes:
                    for l in slayers:
                        m = layer.simplifyMethod()
                        m.setSimplifyHints(QgsVectorSimplifyMethod.SimplifyHints(0))
                        layer.setSimplifyMethod(m)