def canvasPressEvent(self, ev):
     
     if ev.button() == Qt.LeftButton:
         """ Add a new point to the rubber band """
         worldPoint = QgsMapToPixel.toMapCoordinates(self.canvas.getCoordinateTransform(), ev.pos().x(), ev.pos().y())
         self.rb.addPoint(worldPoint)
     
     elif ev.button() == Qt.RightButton:
         """ Send back the geometry to the calling class """
         self.trigger.emit(self.rb.asGeometry())
Пример #2
0
 def canvasPressEvent(self, event):
     ''' On left click, we add a point '''
     
     if event.button()  ==  1:
         # layer = self.canvas.currentLayer()
         layer = self.iface.activeLayer() 
 
         # Declare, that are we going to work
         self.started = True
         
         if layer <> None:
             x = event.pos().x()
             y = event.pos().y()
             selPoint = QPoint(x,y)
 
             # Check something snapped
             (retval,result) = self.snapper.snapToBackgroundLayers(selPoint) #@UnusedVariable
           
             # The point we want to have, is either from snapping result
             if result <> []:
                 point = result[0].snappedVertex
 
                 # If we snapped something, it's either a vertex
                 if result[0].snappedVertexNr <> -1:
                     self.firstTimeOnSegment = True
             
                 # Or a point on a segment, so we have to declare, that a point on segment is found
                 else:
                     self.firstTimeOnSegment = False
 
             # Or its some point from out in the wild
             else:
                 point = QgsMapToPixel.toMapCoordinates(self.canvas.getCoordinateTransform(), x, y)
                 self.firstTimeOnSegment = True
 
             # Bring the rubberband to the cursor i.e. the clicked point
             self.rubberBand.movePoint(point)
 
             # Set a new point to go on with
             self.appendPoint(point)
           
             # Try to remember that this point was on purpose i.e. clicked by the user
             self.lastPointMustStay = True
             self.firstTimeOnSegment = True    
Пример #3
0
 def canvasReleaseEvent(self, event):
     ''' With right click the digitizing is finished '''
     
     if event.button() == 2:
   
         # layer = self.canvas.currentLayer()
         layer = self.iface.activeLayer()
         
         x = event.pos().x()
         y = event.pos().y()
         
         if layer <> None and self.started == True: 
             selPoint = QPoint(x,y)
             (retval,result) = self.snapper.snapToBackgroundLayers(selPoint) #@UnusedVariable
     
         if result <> []:
             point = result[0].snappedVertex #@UnusedVariable
         else:
             point = QgsMapToPixel.toMapCoordinates(self.canvas.getCoordinateTransform(), x, y)  #@UnusedVariable
     
         self.sendGeometry()
Пример #4
0
    def canvasReleaseEvent(self, event):

        if event.button() == Qt.LeftButton:

            # Get the click
            x = event.pos().x()
            y = event.pos().y()
            try:
                event_point = QPoint(x, y)
            except (TypeError, KeyError):
                self.iface.actionPan().trigger()
                return

            (retval, result) = self.snapper.snapToBackgroundLayers(
                event_point)  # @UnusedVariable
            # Create point with snap reference
            if result:
                point = QgsPoint(result[0].snappedVertex)
            # Create point with mouse cursor reference
            else:
                point = QgsMapToPixel.toMapCoordinates(
                    self.canvas.getCoordinateTransform(), x, y)
            if self.point_1 is None:
                self.point_1 = point
            else:
                self.point_2 = point

            if self.point_1 is not None and self.point_2 is not None:
                self.init_create_point_form(self.point_1, self.point_2)

        elif event.button() == Qt.RightButton:
            self.cancel_map_tool()
            self.iface.setActiveLayer(self.current_layer)

        if self.layer_points:
            self.layer_points.commitChanges()
Пример #5
0
    def canvasMoveEvent(self, event):
        # QgsMessageLog.logMessage('fts: '+str(self.firstTimeOnSegment), 'state', 0)
        # QgsMessageLog.logMessage('lpc: '+str(self.lastPointMustStay), 'state', 0)
        if self.started:
            # Get the click
            x = event.pos().x()
            y = event.pos().y()
            eventPoint = QPoint(x, y)
            # only if the ctrl key is pressed
            if self.mCtrl:
                layer = self.canvas.currentLayer()
                if layer is not None:
                    (retval,
                     result) = self.snapper.snapToBackgroundLayers(eventPoint)

                # so if we have found a snapping
                if result != []:
                    # pydevd.settrace()
                    # that's the snapped point
                    point = QgsPoint(result[0].snappedVertex)
                    # if it is a vertex, not a point on a segment
                    if result[0].snappedVertexNr != -1:
                        self.rb.movePoint(point)
                        self.appendPoint(point)
                        self.lastPointMustStay = True
                        # the next point found, may  be on a segment
                        self.firstTimeOnSegment = True
                    # we are on a segment
                    else:
                        self.rb.movePoint(point)
                        # if we are on a new segment, we add the point in any case
                        if self.firstTimeOnSegment:
                            self.appendPoint(point)
                            self.lastPointMustStay = True
                            self.firstTimeOnSegment = False
                        # if we are not on a new segemnt, we have to test, if this point is realy needed
                        else:
                            # but only if we have already enough points
                            # TODO: check if this is correct for lines also (they only need two points, to be vaild)
                            if self.rb.numberOfVertices() >= 3:
                                max = self.rb.numberOfVertices()
                                lastRbP = self.rb.getPoint(0, max - 2)
                                # QgsMessageLog.logMessage(str(self.rb.getPoint(0, max-1)), 'rb', 0)
                                nextToLastRbP = self.rb.getPoint(0, max - 3)
                                # QgsMessageLog.logMessage(str(self.rb.getPoint(0, max-2)), 'rb', 0)
                                # QgsMessageLog.logMessage(str(point), 'rb', 0)
                                if not self.pointOnLine(
                                        lastRbP, nextToLastRbP,
                                        QgsPoint(point)):
                                    self.appendPoint(point)
                                    self.lastPointMustStay = False
                                else:
                                    # TODO: schauen, ob der letzte punkt ein klick war, dann nicht löschen. entsrpechend auch die "punkt auf linie" neu berechenen.
                                    if not self.lastPointMustStay:
                                        self.rb.removeLastPoint()
                                        self.rb.movePoint(point)
                                        # QgsMessageLog.logMessage('point removed', 'click', 0)
                                # else:
                                # QgsMessageLog.logMessage('sleep', 'rb', 0)
                            else:
                                self.appendPoint(point)
                                self.lastPointMustStay = False
                                self.firstTimeOnSegment = False

                else:
                    # if nothing specials happens, just update the rubberband to the cursor position
                    point = QgsMapToPixel.toMapCoordinates(
                        self.canvas.getCoordinateTransform(), x, y)
                    self.rb.movePoint(point)

            else:
                # in "not-tracing" state, just update the rubberband to the cursor position
                # but we have still to snap to act like the "normal" digitize tool
                (retval,
                 result) = self.snapper.snapToBackgroundLayers(eventPoint)
                if result != []:
                    point = QgsPoint(result[0].snappedVertex)
                else:
                    point = QgsMapToPixel.toMapCoordinates(
                        self.canvas.getCoordinateTransform(), x, y)
                self.rb.movePoint(point)
Пример #6
0
    def testPainterClipPath(self):
        region = QgsMapClippingRegion(
            QgsGeometry.fromWkt('Polygon((0 0, 1 0, 1 1, 0 1, 0 0))'))
        region.setFeatureClip(
            QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)
        region2 = QgsMapClippingRegion(
            QgsGeometry.fromWkt('Polygon((0 0, 0.1 0, 0.1 2, 0 2, 0 0))'))
        region2.setFeatureClip(
            QgsMapClippingRegion.FeatureClippingType.NoClipping)
        region3 = QgsMapClippingRegion(
            QgsGeometry.fromWkt('Polygon((0 0, 0.1 0, 0.1 2, 0 2, 0 0))'))
        region3.setFeatureClip(
            QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)

        rc = QgsRenderContext()

        for t in [
                QgsMapLayerType.VectorLayer, QgsMapLayerType.RasterLayer,
                QgsMapLayerType.MeshLayer, QgsMapLayerType.VectorTileLayer
        ]:
            path, should_clip = QgsMapClippingUtils.calculatePainterClipRegion(
                [], rc, t)
            self.assertFalse(should_clip)
            self.assertEqual(path.elementCount(), 0)

        for t in [
                QgsMapLayerType.VectorLayer, QgsMapLayerType.RasterLayer,
                QgsMapLayerType.MeshLayer, QgsMapLayerType.VectorTileLayer
        ]:
            path, should_clip = QgsMapClippingUtils.calculatePainterClipRegion(
                [region], rc, t)
            self.assertTrue(should_clip)
            self.assertEqual(
                QgsGeometry.fromQPolygonF(path.toFillPolygon()).asWkt(1),
                'Polygon ((0 1, 1 1, 1 0, 0 0, 0 1))')

        # region2 is a Intersects type clipping region, should not apply for vector layers
        path, should_clip = QgsMapClippingUtils.calculatePainterClipRegion(
            [region2], rc, QgsMapLayerType.VectorLayer)
        self.assertFalse(should_clip)
        self.assertEqual(path.elementCount(), 0)

        for t in [
                QgsMapLayerType.RasterLayer, QgsMapLayerType.MeshLayer,
                QgsMapLayerType.VectorTileLayer
        ]:
            path, should_clip = QgsMapClippingUtils.calculatePainterClipRegion(
                [region2], rc, t)
            self.assertTrue(should_clip)
            self.assertEqual(
                QgsGeometry.fromQPolygonF(path.toFillPolygon()).asWkt(1),
                'Polygon ((0 1, 0.1 1, 0.1 -1, 0 -1, 0 1))')

        for t in [
                QgsMapLayerType.VectorLayer, QgsMapLayerType.RasterLayer,
                QgsMapLayerType.MeshLayer, QgsMapLayerType.VectorTileLayer
        ]:
            path, should_clip = QgsMapClippingUtils.calculatePainterClipRegion(
                [region, region2, region3], rc, t)
            self.assertTrue(should_clip)
            self.assertEqual(
                QgsGeometry.fromQPolygonF(path.toFillPolygon()).asWkt(1),
                'Polygon ((0.1 1, 0 1, 0 0, 0.1 0, 0.1 1))')

        rc.setMapToPixel(QgsMapToPixel(5, 10, 11, 200, 150, 0))
        for t in [
                QgsMapLayerType.VectorLayer, QgsMapLayerType.RasterLayer,
                QgsMapLayerType.MeshLayer, QgsMapLayerType.VectorTileLayer
        ]:
            path, should_clip = QgsMapClippingUtils.calculatePainterClipRegion(
                [region, region3], rc, t)
            self.assertTrue(should_clip)
            self.assertEqual(
                QgsGeometry.fromQPolygonF(path.toFillPolygon()).asWkt(0),
                'Polygon ((98 77, 98 77, 98 77, 98 77, 98 77))')
Пример #7
0
    def canvasMoveEvent(self, event):
        """ Mouse movement event """

        # Hide marker
        self.vertex_marker.hide()

        try:
            # Get current mouse coordinates
            x = event.pos().x()
            y = event.pos().y()
            event_point = QPoint(x, y)
        except (TypeError, KeyError):
            self.set_action_pan()
            return

        # Snap to node
        if self.snapped_feat is None:

            # Make sure active layer is 'v_edit_node'
            cur_layer = self.iface.activeLayer()
            if cur_layer != self.layer_node:
                self.iface.setActiveLayer(self.layer_node)

            # Snapping
            (retval,
             result) = self.snapper.snapToCurrentLayer(event_point,
                                                       2)  #@UnusedVariable

            # That's the snapped features
            if result:
                # Get the point and add marker on it
                point = QgsPoint(result[0].snappedVertex)
                self.vertex_marker.setCenter(point)
                self.vertex_marker.show()
                # Set a new point to go on with
                self.rubber_band.movePoint(point)
            else:
                point = QgsMapToPixel.toMapCoordinates(
                    self.canvas.getCoordinateTransform(), x, y)
                self.rubber_band.movePoint(point)

        # Snap to arc
        else:

            # Make sure active layer is 'v_edit_arc'
            cur_layer = self.iface.activeLayer()
            if cur_layer != self.layer_arc:
                self.iface.setActiveLayer(self.layer_arc)

            # Snapping
            (retval,
             result) = self.snapper.snapToCurrentLayer(event_point,
                                                       2)  #@UnusedVariable

            if result and result[0].snappedVertexNr == -1:

                point = QgsPoint(result[0].snappedVertex)

                # Set marker
                self.vertex_marker.setIconType(QgsVertexMarker.ICON_CROSS)
                self.vertex_marker.setCenter(point)
                self.vertex_marker.show()

                # Select the arc
                result[0].layer.removeSelection()
                result[0].layer.select([result[0].snappedAtGeometry])

                # Bring the rubberband to the cursor i.e. the clicked point
                self.rubber_band.movePoint(point)

            else:
                # Bring the rubberband to the cursor i.e. the clicked point
                point = QgsMapToPixel.toMapCoordinates(
                    self.canvas.getCoordinateTransform(), x, y)
                self.rubber_band.movePoint(point)
Пример #8
0
    def canvasMoveEvent(self, event):
        ''' Mouse movement event '''      
                        
        # Hide highlight
        self.vertexMarker.hide()
            
        # Get the click
        x = event.pos().x()
        y = event.pos().y()
        eventPoint = QPoint(x,y)

        # Node layer
        layer = self.canvas.currentLayer()
        if layer is None:
            return

        # Select node or arc
        if layer.selectedFeatureCount() == 0:

            # Snap to node
            (retval,result) = self.snapper.snapToBackgroundLayers(eventPoint)   #@UnusedVariable
            
            # That's the snapped point
            if result <> [] and (result[0].layer.name() == self.layer_node.name()):

                point = QgsPoint(result[0].snappedVertex)

                # Add marker    
                self.vertexMarker.setColor(QColor(0, 255, 0))
                self.vertexMarker.setCenter(point)
                self.vertexMarker.show()
                
                # Set a new point to go on with
                #self.appendPoint(point)
                self.rubberBand.movePoint(point)

            else:
                point = QgsMapToPixel.toMapCoordinates(self.canvas.getCoordinateTransform(),  x, y)
                self.rubberBand.movePoint(point)

        else:
                
            # Snap to arc
            result = []
            (retval,result) = self.snapper.snapToBackgroundLayers(eventPoint)   #@UnusedVariable
            
            # That's the snapped point
            if (result <> []) and (result[0].layer.name() == self.layer_arc.name()) and (result[0].snappedVertexNr == -1):
            
                point = QgsPoint(result[0].snappedVertex)

                # Add marker
                self.vertexMarker.setColor(QColor(255, 0, 0))
                self.vertexMarker.setCenter(point)
                self.vertexMarker.show()
                
                # Select the arc
                self.layer_arc.removeSelection()
                self.layer_arc.select([result[0].snappedAtGeometry])

                # Bring the rubberband to the cursor i.e. the clicked point
                self.rubberBand.movePoint(point)
        
            else:
                
                # Bring the rubberband to the cursor i.e. the clicked point
                point = QgsMapToPixel.toMapCoordinates(self.canvas.getCoordinateTransform(),  x, y)
                self.rubberBand.movePoint(point)
 def canvasMoveEvent(self, ev):
     
     worldPoint = QgsMapToPixel.toMapCoordinates(self.canvas.getCoordinateTransform(), ev.pos().x(), ev.pos().y())
     self.rb.movePoint(worldPoint)
Пример #10
0
    def canvasMoveEvent(self, event):
        
        # Hide highlight
        self.vertexMarker.hide()
            
        # Get the click
        x = event.pos().x()
        y = event.pos().y()
        eventPoint = QPoint(x,y)

        # Snapping        
        (retval,result) = self.snapper.snapToBackgroundLayers(eventPoint)   #@UnusedVariable

        # That's the snapped point
        if result <> []:
            point = QgsPoint(result[0].snappedVertex)

            # Add marker    
            self.vertexMarker.setCenter(point)
            self.vertexMarker.show()
            
        # Check tracing 
        if self.started:
                        
            # Only if the ctrl key is pressed
            if self.mCtrl == True:
                 
                # So if we have found a snapping
                if result <> []:

                    # If it is a vertex, not a point on a segment
                    if result[0].snappedVertexNr <> -1: 
                        self.rubberBand.movePoint(point) 
                        self.appendPoint(point)
                        self.lastPointMustStay = True
                    
                        # The next point found, may  be on a segment
                        self.firstTimeOnSegment = True
                                          
                    # We are on a segment
                    else:
                        self.rubberBand.movePoint(point)
                    
                        # If we are on a new segment, we add the point in any case
                        if self.firstTimeOnSegment:
                            self.appendPoint(point)
                            self.lastPointMustStay = True
                            self.firstTimeOnSegment = False
                    
                        # if we are not on a new segment, we have to test, if this point is really needed
                        else:
                            # but only if we have already enough points
                            if self.rubberBand.numberOfVertices() >=3:
                                num_vertexs = self.rubberBand.numberOfVertices()    
                                lastRbP = self.rubberBand.getPoint(0, num_vertexs-2)
                                nextToLastRbP = self.rubberBand.getPoint(0, num_vertexs-3)                          
                                if not self.pointOnLine(lastRbP, nextToLastRbP, QgsPoint(point)):
                                    self.appendPoint(point)
                                    self.lastPointMustStay = False
                                else:
                                    if not self.lastPointMustStay:
                                        self.rubberBand.removeLastPoint()
                                        self.rubberBand.movePoint(point)
                            else:
                                self.appendPoint(point)
                                self.lastPointMustStay = False
                                self.firstTimeOnSegment = False
          
                else:
                    #if nothing specials happens, just update the rubberband to the cursor position
                    point = QgsMapToPixel.toMapCoordinates(self.canvas.getCoordinateTransform (), x, y)
                    self.rubberBand.movePoint(point)
          
            else:
                ''' In "not-tracing" state, just update the rubberband to the cursor position
                 but we have still to snap to act like the "normal" digitize tool '''
                if result <> []:
                    point = QgsPoint(result[0].snappedVertex)
                
                    # Add marker    
                    self.vertexMarker.setCenter(point)
                    self.vertexMarker.show()

                else:
                    point = QgsMapToPixel.toMapCoordinates(self.canvas.getCoordinateTransform(),  x, y)
                
                self.rubberBand.movePoint(point)            
Пример #11
0
    def init_config_form(self):
        """ Custom form initial configuration """
        # Get last point clicked on canvas
        last_click = self.canvas.mouseLastXY()
        self.last_point = QgsMapToPixel.toMapCoordinates(
            self.canvas.getCoordinateTransform(), last_click.x(),
            last_click.y())

        # Define class variables
        self.filter = self.field_id + " = '" + str(self.id) + "'"
        emit_point = QgsMapToolEmitPoint(self.canvas)

        # Get user permisions
        role_basic = self.controller.check_role_user("role_basic")

        # Get widget controls
        self.tab_main = self.dialog.findChild(QTabWidget, "tab_main")
        self.tbl_element = self.dialog.findChild(QTableView, "tbl_element")
        self.tbl_document = self.dialog.findChild(QTableView, "tbl_document")
        self.tbl_event_element = self.dialog.findChild(QTableView,
                                                       "tbl_event_element")
        self.tbl_event = self.dialog.findChild(QTableView, "tbl_event_node")
        self.tbl_scada = self.dialog.findChild(QTableView, "tbl_scada")
        self.tbl_scada_value = self.dialog.findChild(QTableView,
                                                     "tbl_scada_value")
        self.tbl_costs = self.dialog.findChild(QTableView, "tbl_masterplan")
        self.nodecat_id = self.dialog.findChild(QLineEdit, 'nodecat_id')
        state_type = self.dialog.findChild(QComboBox, 'state_type')
        dma_id = self.dialog.findChild(QComboBox, 'dma_id')

        # Tables
        self.tbl_upstream = self.dialog.findChild(QTableView, "tbl_upstream")
        self.tbl_upstream.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tbl_downstream = self.dialog.findChild(QTableView,
                                                    "tbl_downstream")
        self.tbl_downstream.setSelectionBehavior(QAbstractItemView.SelectRows)

        self.dialog.findChild(QPushButton, "btn_catalog").clicked.connect(
            partial(self.catalog, self.dialog, 'ud', 'node'))

        # New Workcat
        # self.dialog.findChild(QPushButton, "btn_new_workcat").clicked.connect(partial(self.cf_new_workcat, self.dialog))

        self.tbl_upstream.doubleClicked.connect(
            partial(self.open_up_down_stream, self.tbl_upstream))
        self.tbl_downstream.doubleClicked.connect(
            partial(self.open_up_down_stream, self.tbl_downstream))

        feature = self.feature
        layer = self.iface.activeLayer()

        action_copypaste = self.dialog.findChild(QAction, "actionCopyPaste")
        layer.editingStarted.connect(
            partial(self.enabled_actions, action_copypaste, True))
        layer.editingStopped.connect(
            partial(self.enabled_actions, action_copypaste, False))
        action_rotation = self.dialog.findChild(QAction, "actionRotation")
        layer.editingStarted.connect(
            partial(self.enabled_actions, action_rotation, True))
        layer.editingStopped.connect(
            partial(self.enabled_actions, action_rotation, False))
        action_interpolate = self.dialog.findChild(QAction,
                                                   "actionInterpolate")
        layer.editingStarted.connect(
            partial(self.enabled_actions, action_interpolate, True))
        layer.editingStopped.connect(
            partial(self.enabled_actions, action_interpolate, False))
        self.dialog.destroyed.connect(partial(self.dlg_destroyed, layer=layer))
        # Toolbar actions
        action = self.dialog.findChild(QAction, "actionEnabled")
        self.dialog.findChild(QAction,
                              "actionCopyPaste").setEnabled(layer.isEditable())
        self.dialog.findChild(QAction,
                              "actionRotation").setEnabled(layer.isEditable())
        self.dialog.findChild(QAction, "actionInterpolate").setEnabled(
            layer.isEditable())
        self.dialog.findChild(QAction, "actionZoom").triggered.connect(
            partial(self.action_zoom_in, self.feature, self.canvas,
                    self.layer))
        self.dialog.findChild(QAction, "actionCentered").triggered.connect(
            partial(self.action_centered, self.feature, self.canvas,
                    self.layer))
        if not role_basic:
            action.setChecked(layer.isEditable())
            layer.editingStarted.connect(
                partial(self.check_actions, action, True))
            layer.editingStopped.connect(
                partial(self.check_actions, action, False))
            self.dialog.findChild(QAction, "actionEnabled").triggered.connect(
                partial(self.action_enabled, action, self.layer))
        else:
            action.setEnabled(False)
        self.dialog.findChild(QAction, "actionZoomOut").triggered.connect(
            partial(self.action_zoom_out, self.feature, self.canvas,
                    self.layer))
        self.dialog.findChild(QAction, "actionRotation").triggered.connect(
            self.action_rotation)
        self.dialog.findChild(QAction, "actionCopyPaste").triggered.connect(
            partial(self.action_copy_paste, self.geom_type))
        self.dialog.findChild(QAction, "actionLink").triggered.connect(
            partial(self.check_link, self.dialog, True))
        self.dialog.findChild(QAction, "actionHelp").triggered.connect(
            partial(self.action_help, 'ud', 'node'))
        self.dialog.findChild(QAction, "actionInterpolate").triggered.connect(
            partial(self.activate_snapping, emit_point))

        widget_ymax = self.dialog.findChild(QLineEdit, 'ymax')
        if widget_ymax is not None:
            widget_ymax.textChanged.connect(
                partial(self.compare_depth, widget_ymax, False))
            widget_ymax.lostFocus.connect(
                partial(self.compare_depth, widget_ymax, True))

        # Manage tab 'Scada'
        self.manage_tab_scada()

        # Check if exist URL from field 'link' in main tab
        self.check_link(self.dialog)

        # Check topology for new features
        continue_insert = True
        node_over_node = True
        check_topology_node = self.controller.plugin_settings_value(
            "check_topology_node", "0")
        check_topology_arc = self.controller.plugin_settings_value(
            "check_topology_arc", "0")

        # Check if feature has geometry object
        geometry = self.feature.geometry()
        if geometry:

            if self.id.upper() == 'NULL' and check_topology_node == "0":
                self.get_topology_parameters()
                (continue_insert, node_over_node) = self.check_topology_node()

            if continue_insert and not node_over_node:
                if self.id.upper() == 'NULL' and check_topology_arc == "0":
                    self.check_topology_arc()

            # Create thread
            thread1 = Thread(self, self.controller, 3)
            thread1.start()

        self.filter = "node_id = '" + str(self.id) + "'"
        table_name = self.controller.schema_name + ".v_ui_node_x_connection_upstream"
        self.fill_table(self.tbl_upstream, table_name, self.filter)
        self.set_configuration(self.tbl_upstream,
                               "v_ui_node_x_connection_upstream")

        table_name = self.controller.schema_name + ".v_ui_node_x_connection_downstream"
        self.fill_table(self.tbl_downstream, table_name, self.filter)
        self.set_configuration(self.tbl_downstream,
                               "v_ui_node_x_connection_downstream")

        # Manage tab signal
        self.tab_connections_loaded = False
        self.tab_element_loaded = False
        self.tab_document_loaded = False
        self.tab_om_loaded = False
        self.tab_scada_loaded = False
        self.tab_cost_loaded = False
        self.tab_custom_fields_loaded = False
        self.tab_main.currentChanged.connect(self.tab_activation)

        # Load default settings
        widget_id = self.dialog.findChild(QLineEdit, 'node_id')
        if utils_giswater.getWidgetText(self.dialog,
                                        widget_id).lower() == 'null':
            self.load_default(self.dialog, "node")
            self.load_type_default(self.dialog, "nodecat_id",
                                   "nodecat_vdefault")

        self.load_state_type(self.dialog, state_type, self.geom_type)
        self.load_dma(self.dialog, dma_id, self.geom_type)
Пример #12
0
    def canvasMoveEvent(self, event):
        """ Mouse movement event """

        # Hide marker
        self.vertex_marker.hide()

        # Get the click
        x = event.pos().x()
        y = event.pos().y()

        #Plugin reloader bug, MapTool should be deactivated
        try:
            event_point = QPoint(x, y)
        except (TypeError, KeyError):
            self.set_action_pan()
            return

        # Select node or arc
        if self.snapped_feat == None:

            # Snap to node
            (retval, result) = self.snapper.snapToBackgroundLayers(
                event_point)  #@UnusedVariable
            if result:
                # Check if feature belongs to 'node' group
                exist = self.snapper_manager.check_node_group(result[0].layer)
                if exist:
                    point = QgsPoint(result[0].snappedVertex)

                    # Set marker
                    self.vertex_marker.setIconType(QgsVertexMarker.ICON_CIRCLE)
                    self.vertex_marker.setCenter(point)
                    self.vertex_marker.show()

                    # Set a new point to go on with
                    self.rubber_band.movePoint(point)

            else:
                point = QgsMapToPixel.toMapCoordinates(
                    self.canvas.getCoordinateTransform(), x, y)
                self.rubber_band.movePoint(point)

        else:

            # Snap to arc
            (retval, result) = self.snapper.snapToBackgroundLayers(
                event_point)  #@UnusedVariable
            if result and result[0].snappedVertexNr == -1:

                # Check if feature belongs to 'arc' group
                exist = self.snapper_manager.check_arc_group(result[0].layer)
                if exist:
                    point = QgsPoint(result[0].snappedVertex)

                    # Set marker
                    self.vertex_marker.setIconType(QgsVertexMarker.ICON_X)
                    self.vertex_marker.setCenter(point)
                    self.vertex_marker.show()

                    # Select the arc
                    result[0].layer.removeSelection()
                    result[0].layer.select([result[0].snappedAtGeometry])

                    # Bring the rubberband to the cursor i.e. the clicked point
                    self.rubber_band.movePoint(point)

            else:

                # Bring the rubberband to the cursor i.e. the clicked point
                point = QgsMapToPixel.toMapCoordinates(
                    self.canvas.getCoordinateTransform(), x, y)
                self.rubber_band.movePoint(point)