Ejemplo n.º 1
0
    def selection_init(self):

        # Fem que l'eina de selecció estigui activa
        iface.actionSelect().trigger()

        # Listeners d'Events
        iface.mapCanvas().selectionChanged.connect(self.selection_changed)
Ejemplo n.º 2
0
    def __init__(self, edit_dialog):
        """Constructor"""
        ProductionChanges.__init__(self, edit_dialog)
        # set editing to edit polygon
        iface.actionSelect().trigger()
        selecttools = iface.attributesToolBar().findChildren(QToolButton)
        # selection actions
        iface.building_toolbar.addSeparator()
        for sel in selecttools:
            if sel.text() == "Select Feature(s)":
                for a in sel.actions()[0:3]:
                    iface.building_toolbar.addAction(a)
        iface.building_toolbar.show()
        self.msgbox_remove = self.confirmation_dialog_box("remove")

        self.disable_UI_functions()

        if len(self.editing_layer.selectedFeatures()) > 0:
            if self.is_correct_selections():
                self.get_selections()
                self.enable_UI_functions()
                self.populate_edit_comboboxes()
                self.select_comboboxes_value()
            else:
                self.edit_dialog.ids = []
                self.edit_dialog.building_outline_id = None
                self.disable_UI_functions()
Ejemplo n.º 3
0
    def run_delete_action(self):
        self.layer_selector()
        assert self.link_layer != None, "self.link_layer != None"

        if self.delete_link_action.isChecked() == True:
            self.changeTool(self.delete_link_action)
            print("link 삭제 작업이 시작되었습니다.")

            # deselect all
            self.deselectAll()

            # selection 버튼 call
            iface.actionSelect().trigger()
            #link_layer 활성화
            iface.setActiveLayer(self.link_layer)

            # # delete a feature with specified ID
            # layer.deleteFeature(fid)

            # selection 이벤트 함수 연결
            self.link_layer.selectionChanged.connect(self.deleteLink)

        else:
            self.link_layer.selectionChanged.disconnect(self.deleteLink)
            print("link 삭제 작업이 종료되었습니다.")
Ejemplo n.º 4
0
    def run_add_action(self):
        # layer 설정
        self.layer_selector()
        # assert문으로 layer가 설정되었는지 검증
        assert self.node_layer != None, "self.node_layer != None"

        # checked 상태 확인
        # print("self.add_link_action.isChecked()=", self.add_link_action.isChecked())

        # checked 상태이면 node레이어에 selectionChanged 이벤트를 connect
        if self.add_link_action.isChecked() == True:
            # 버튼 change
            self.changeTool(self.add_link_action)
            print("Link 추가 작업이 시작되었습니다.")

            # 기존에 선택됐던 피쳐 선택 취소하기 위해 deselect action trigger
            self.deselectAll()
            # selection 버튼 call
            iface.actionSelect().trigger()
            # node_layer 활성화
            iface.setActiveLayer(self.node_layer)
            # selectionChanged 이벤트함수 연결
            self.node_layer.selectionChanged.connect(self.onNodeSelected)
        # checked 아니면 disconnect
        else:
            self.node_layer.selectionChanged.disconnect(self.onNodeSelected)
            print("Link 추가 작업이 종료되었습니다.")
Ejemplo n.º 5
0
 def edit_reset_clicked(self):
     """When bulk load frame btn_reset_save clicked"""
     self.edit_dialog.ids = []
     self.edit_dialog.building_outline_id = None
     iface.actionSelect().trigger()
     iface.activeLayer().removeSelection()
     # reset and disable comboboxes
     self.edit_dialog.circle_tool = None
     self.disable_UI_functions()
Ejemplo n.º 6
0
 def edit_reset_clicked(self):
     """
         When production frame btn_edit_reset clicked
     """
     self.edit_dialog.ids = []
     self.edit_dialog.building_outline_id = None
     # restart editing
     iface.actionSelect().trigger()
     iface.activeLayer().removeSelection()
     # reset and disable comboboxes
     self.disable_UI_functions()
Ejemplo n.º 7
0
    def selectArea(self):
        for a in iface.attributesToolBar().actions():
            if a.objectName() == 'mActionDeselectAll':
                a.trigger()
                break

        l = self.proj.mapLayersByName('Beräkningsområde')
        if l:
            l = l[0]
            iface.setActiveLayer(l)
            iface.actionSelect().trigger()
Ejemplo n.º 8
0
    def onSelect(self):
        """Select features action."""
        layer = self.getActiveLayer()
        if not layer:
            # disable select button if no layer selected
            self.actionSelect.setEnabled(False)
            return

        if not self.actionDeselect.isEnabled():
            # enable deselect/delete buttons if features selected
            self.actionDeselect.setEnabled(True)
            self.actionDelete.setEnabled(True)
        iface.actionSelect().trigger()
Ejemplo n.º 9
0
    def selectStart(self, comboBox):
        # Start object selection for QGYF
        for a in iface.attributesToolBar().actions():
            if a.objectName() == 'mActionDeselectAll':
                a.trigger()
                break

        iface.actionSelect().trigger()

        def lyr(x):
            return {
                'punkt': 'Punktobjekt',
                'linje': 'Linjeobjekt'
            }.get(x, 'Ytobjekt')

        l = self.proj.mapLayersByName(lyr(comboBox.currentText()))
        if l:
            iface.setActiveLayer(l[0])
Ejemplo n.º 10
0
    def run_status_action(self):
        self.layer_selector()
        assert self.link_layer != None, "self.link_layer != None"

        if self.change_status_action.isChecked() == True:
            self.changeTool(self.change_status_action)
            print("link 작업상태 변경이 시작되었습니다.")
            self.deselectAll()
            iface.actionSelect().trigger()
            iface.setActiveLayer(self.link_layer)

            # selection 이벤트 함수 연결
            self.link_layer.selectionChanged.connect(self.changeStatus)

        else:
            # checked 아니면 disconnect
            self.link_layer.selectionChanged.disconnect(self.changeStatus)
            print("link 작업상태 변경이 종료되었습니다.")
Ejemplo n.º 11
0
    def run_heading_action(self):
        self.layer_selector()
        assert self.node_layer != None, "self.node_layer != None"

        if self.change_heading_action.isChecked() == True:
            self.changeTool(self.change_heading_action)
            print("heading 입력 작업이 시작되었습니다.")
            self.deselectAll()
            iface.actionSelect().trigger()
            iface.setActiveLayer(self.node_layer)

            # selection 이벤트에 함수 연결
            self.node_layer.selectionChanged.connect(self.changeHeading)

        else:
            # checked 아니면 disconnect
            self.node_layer.selectionChanged.disconnect(self.changeHeading)
            print("heading 입력 작업이 종료되었습니다.")
Ejemplo n.º 12
0
    def rb_select_from_layer_clicked(self, checked):
        """PyqtSlot: When the select from layer radio button is clicked"""
        self.l_wrong_projection.setText("")
        if checked:
            self.mcb_selection_layer.showPopup()
            self.mcb_selection_layer.setEnabled(True)
            iface.actionSelect().trigger()
            self.mcb_selection_layer.layerChanged.connect(
                self.mcb_selection_layer_changed)
        else:
            self.mcb_selection_layer.layerChanged.disconnect(
                self.mcb_selection_layer_changed)
            if self.current_layer is not None:
                self.current_layer.removeSelection()
                self.current_layer.selectionChanged.disconnect(
                    self.current_layer_selection_changed)

            self.mcb_selection_layer.setDisabled(True)
            iface.actionAddFeature().trigger()
            self.current_layer = None
            iface.setActiveLayer(self.current_layer)
    def __init__(self,
                 parent=None,
                 manhole_layer=None,
                 pipe_layer=None,
                 measuring_point_layer=None):
        """Constructor."""
        super(BeoordelingstoolDockWidget, self).__init__(parent)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect
        self.setupUi(self)
        self.add_herstelmaatregelen()
        self.tabWidget.currentChanged.connect(self.tab_changed)

        self.manholes = manhole_layer
        self.pipes = pipe_layer
        self.measuring_points = measuring_point_layer

        self.manholes.selectionChanged.connect(self.get_selected_manhole)
        self.pipes.selectionChanged.connect(self.get_selected_pipe)
        self.measuring_points.selectionChanged.connect(
            self.get_selected_measuring_point)

        # Enable the 'Select Feature` tool by default.
        iface.actionSelect().trigger()

        # General tab
        self.set_project_properties()
        self.pushbutton_upload_voortgang_json.clicked.connect(
            self.show_login_dialog_voortgang)
        self.pushbutton_upload_zip_json.clicked.connect(
            self.show_login_dialog_final)

        # Manholes tab
        self.selected_manhole_id = 0
        self.pushbutton_save_attribute_manholes.clicked.connect(
            self.save_beoordeling_putten)

        # Pipes tab
        self.selected_pipe_id = 0
        self.pushbutton_save_attribute_pipes.clicked.connect(
            self.save_beoordeling_leidingen)
        self.pushbutton_pipe_to_measuring_point.clicked.connect(
            self.show_measuring_point)

        # Measuring points tab
        self.selected_measuring_point_id = 0
        self.pushbutton_save_attribute_measuring_points.clicked.connect(
            self.save_beoordeling_measuring_points)
        self.pushbutton_measuring_points_previous.clicked.connect(
            self.show_previous_measuring_point)
        self.pushbutton_measuring_point_to_pipe.clicked.connect(self.show_pipe)
        self.pushbutton_measuring_points_next.clicked.connect(
            self.show_next_measuring_point)

        self.selected_measuring_points_ids = []
        self.measure_point_marker = QgsVertexMarker(iface.mapCanvas())
        self.measure_point_marker.setColor(Qt.blue)
        self.disable_next_measuring_point_button()
        self.disable_previous_measuring_point_button()
Ejemplo n.º 14
0
    def confirmarCortes(self):  #Aqui cehcamos que los cortes esten en orden

        #cuentaCortes = 0
        rango = len(self.eventos.relaciones) - 1
        #for i in range(0, rango):
        #    geom = self.eventos.relaciones[i].geom
        #    if geom != None:
        #        cuentaCortes += 1
        #Obtenemos la cantidad de corte
        #print('cuentaCortes ', cuentaCortes)
        geoTemp = QgsGeometry.fromWkt(self.geomEnDivision.asWkt())
        cuentaSalida = self.subdividirPredio(
            geoTemp, True
        ) - 1  #Aqui enviamos una geomtria temporal, para ven en cuantos cortes quedara

        if cuentaSalida >= 2:

            listaNoTocar = []
            capaPredios = QgsProject.instance().mapLayer(
                self.ACA.obtenerIdCapa('predios.geom'))
            capaCondH = QgsProject.instance().mapLayersByName(
                'horizontales.geom')[0]
            capaCondV = QgsProject.instance().mapLayersByName('verticales')[0]
            capaConstru = QgsProject.instance().mapLayer(
                self.ACA.obtenerIdCapa('construcciones'))

            #Obtenemos los features que no deben tocarse
            for feat in capaConstru.getFeatures():
                geom = feat.geometry().buffer(-0.0000002, 1)
                if geom.intersects(self.geomEnDivision):
                    listaNoTocar.append(geom)

            for feat in capaCondH.getFeatures():
                geom = feat.geometry().buffer(-0.0000002, 1)
                if geom.intersects(self.geomEnDivision):
                    listaNoTocar.append(geom)

            for feat in capaCondV.getFeatures():
                geom = feat.geometry().buffer(-0.0000002, 1)
                if geom.intersects(self.geomEnDivision):
                    listaNoTocar.append(geom)

            bandera = True

            #Aqui checamos que cada linea no toque lo no tocable
            for i in range(0, rango):
                for comp in listaNoTocar:
                    geom = self.eventos.relaciones[i].geom
                    if geom != None:
                        if geom.buffer(0.0000001, 1).intersects(comp):
                            bandera = False
                            self.eventos.relaciones[i].rubber.setStrokeColor(
                                QColor(255, 0, 0, 255))
                        else:
                            self.eventos.relaciones[i].rubber.setStrokeColor(
                                QColor(0, 61, 240, 255))

            iface.mapCanvas().refresh()
            if bandera:  #Si todo esta en orden
                self.eventos.rubberPunto.reset(QgsWkbTypes.PointGeometry)
                self.apagarHerramientas()
                #mostramos mensaje de confirmacion
                mensaje = "La cantidad de predios que quedaran como resultado, es de: " + str(
                    cuentaSalida) + "\nDeseas continua?"
                respuesta = QMessageBox.question(
                    iface.mainWindow(), "Nota de subdivision de predio",
                    mensaje, QMessageBox.Yes, QMessageBox.No)

                #Si el usuario acepta....
                if respuesta == QMessageBox.Yes:
                    self.subdividirPredio(self.geomEnDivision, False)
                    self.rubberMarca.reset(
                        QgsWkbTypes.PolygonGeometry)  #Quitamos lo amarillito

                    for i in range(0, rango):
                        self.eventos.relaciones[i].rubber.reset(
                            QgsWkbTypes.LineGeometry)
                        self.eventos.relaciones[i].vaciarMarcadores()
                    self.eventos.recargarRelaciones()

                    capaPredios.startEditing()
                    capaPredios.dataProvider().deleteFeatures(
                        [self.predioEnDivision.id()])
                    capaPredios.triggerRepaint()
                    capaPredios.commitChanges()

                    self.VentanaAreas.close()
                    self.limpiarAreas()
                    self.vaciarRubbers()

                    self.UTI.mostrarAlerta(
                        "La division ha sido realizada con exito\nLos cambios se guardaran hasta que asignes las claves.",
                        QMessageBox().Information,
                        "Subdivision completa, Parte 1 de 2")
                    self.irAClaves(
                    )  #Mostramos la ventana que llena las claves
                    iface.actionSelect().trigger()
            else:
                self.UTI.mostrarAlerta(
                    "Las lineas de division no deben atravesar construcciones ni condominios\nLas lineas rojas presentan un corte invalido",
                    QMessageBox().Critical, "Error en subdivision")

        else:
            print('cuentasalida ', cuentaSalida)
            self.UTI.mostrarAlerta(
                "Primero debes dibujar las lineas de corte\nAsegurate que las lineas atraviesen por completo el predio",
                QMessageBox().Critical, "Error en subdivision")