コード例 #1
0
    def paint_extent(self, rec):
        self.roi_x_max = rec.xMaximum()
        self.ui.XMaxLineEdit.setText(str(round(rec.xMaximum(), 3)))
        self.roi_y_min = rec.yMinimum()
        self.ui.YMinLineEdit.setText(str(round(rec.yMinimum(), 3)))
        self.roi_x_min = rec.xMinimum()
        self.ui.XMinLineEdit.setText(str(round(rec.xMinimum(), 3)))
        self.roi_y_max = rec.yMaximum()
        self.ui.YMaxLineEdit.setText(str(round(rec.yMaximum(), 3)))

        if self.extent:
            self.canvas.scene().removeItem(self.extent)
            self.extent = None
        self.extent = QgsRubberBand(self.canvas, True)
        points = [
            QgsPoint(self.roi_x_max, self.roi_y_min),
            QgsPoint(self.roi_x_max, self.roi_y_max),
            QgsPoint(self.roi_x_min, self.roi_y_max),
            QgsPoint(self.roi_x_min, self.roi_y_min),
            QgsPoint(self.roi_x_max, self.roi_y_min)
        ]
        self.extent.setToGeometry(QgsGeometry.fromPolyline(points), None)
        self.extent.setColor(QColor(227, 26, 28, 255))
        self.extent.setWidth(5)
        self.extent.setLineStyle(Qt.PenStyle(Qt.DashLine))
        self.canvas.refresh()
コード例 #2
0
 def __init__(self, canvas, callback):
     self.canvas = canvas
     QgsMapTool.__init__(self, self.canvas)
     self.callback = callback
     self.rubberBand = QgsRubberBand(self.canvas, True)
     self.rubberBand.setColor(QColor(227, 26, 28, 255))
     self.rubberBand.setWidth(5)
     self.rubberBand.setLineStyle(Qt.PenStyle(Qt.DashLine))
     self.reset()
コード例 #3
0
 def setAvoidStyleSnapRubberBand(self):
     self.rubberBand.setLineStyle(Qt.PenStyle(Qt.DashDotLine))
     self.rubberBand.setBorderColor(QColor(255, 255, 0, 200))
     self.rubberBand.setFillColor(QColor(255, 0, 0, 40))
コード例 #4
0
 def setAllowedStyleSnapRubberBand(self):
     self.rubberBand.setLineStyle(Qt.PenStyle(Qt.SolidLine))
     self.rubberBand.setBorderColor(QColor(255, 0, 0, 200))
     self.rubberBand.setFillColor(QColor(255, 0, 0, 40))