def toSearchRect(self, point): size = 20 rect = QRectF() rect.setLeft(point.x() - size) rect.setRight(point.x() + size) rect.setTop(point.y() - size) rect.setBottom(point.y() + size) transform = self.canvas.getCoordinateTransform() ll = transform.toMapCoordinates(rect.left(), rect.bottom()) ur = transform.toMapCoordinates(rect.right(), rect.top()) rect = QgsRectangle(ur, ll) return rect
def paint_MODEL_SPACE_2D(self): rect = self.rect() painter = QPainter(self) painter.fillRect(rect, self.plugIn.canvas.canvasColor()) painter.setRenderHint(QPainter.Antialiasing) # PICKBOX x1 = rect.width() / 3 y1 = rect.height() - rect.height() / 3 color = QColor( self.tempQadVariables.get( QadMsg.translate("Environment variables", "PICKBOXCOLOR"))) pickSize = 5 painter.setPen(QPen(color, 1, Qt.SolidLine)) painter.drawRect(x1 - pickSize, y1 - pickSize, 2 * pickSize, 2 * pickSize) # CROSSHAIRS color = QColor( self.tempQadVariables.get( QadMsg.translate("Environment variables", "CURSORCOLOR"))) cursorSize = 20 painter.setPen(QPen(color, 1, Qt.SolidLine)) painter.drawLine(x1 - pickSize, y1, x1 - pickSize - cursorSize, y1) painter.drawLine(x1 + pickSize, y1, x1 + pickSize + cursorSize, y1) painter.drawLine(x1, y1 - pickSize, x1, y1 - pickSize - cursorSize) painter.drawLine(x1, y1 + pickSize, x1, y1 + pickSize + cursorSize) # AUTOTRECK_VECTOR x1 = rect.width() / 3 color = QColor( self.tempQadVariables.get( QadMsg.translate("Environment variables", "AUTOTRECKINGVECTORCOLOR"))) painter.setPen(QPen(color, 1, Qt.DashLine)) painter.drawLine(x1, 0, x1, rect.height()) painter.drawLine(x1 + rect.height() * 2 / 3, 0, x1 - rect.height() / 3, rect.height()) # AUTOSNAP x1 = rect.width() / 3 y1 = rect.height() / 3 color = QColor( self.tempQadVariables.get( QadMsg.translate("Environment variables", "AUTOSNAPCOLOR"))) pickSize = 5 painter.setPen(QPen(color, 2, Qt.SolidLine)) painter.drawRect(x1 - pickSize, y1 - pickSize, 2 * pickSize, 2 * pickSize) # DYNAMIC INPUT x1 = rect.width() / 3 y1 = rect.height() - rect.height() / 3 cursorSize = 20 fMetrics = painter.fontMetrics() msg1 = "12.3456" sz1 = fMetrics.size(Qt.TextSingleLine, msg1 + "__") dynInputRect1 = QRectF(x1 + cursorSize, y1 + cursorSize, sz1.width(), sz1.height() + 2) msg2 = "78.9012" sz2 = fMetrics.size(Qt.TextSingleLine, msg2 + "__") dynInputRect2 = QRectF(dynInputRect1.right() + sz1.height() / 3, dynInputRect1.top(), sz2.width(), sz2.height() + 2) # DYNAMIC INPUT COMMAND DESCR BACKGROUND color = QColor( self.tempQadVariables.get( QadMsg.translate("Environment variables", "DYNEDITBACKCOLOR"))) painter.fillRect(dynInputRect1, color) painter.fillRect(dynInputRect2, color) # DYNAMIC INPUT COMMAND DESCR BORDER color = QColor( self.tempQadVariables.get( QadMsg.translate("Environment variables", "DYNEDITBORDERCOLOR"))) painter.setPen(QPen(color, 1, Qt.SolidLine)) painter.drawRect(dynInputRect1) painter.drawRect(dynInputRect2) # DYNAMIC INPUT COMMAND DESCR FOREGROUND color = QColor( self.tempQadVariables.get( QadMsg.translate("Environment variables", "DYNEDITFORECOLOR"))) painter.setPen(QPen(color, 1, Qt.SolidLine)) painter.drawText(dynInputRect1, msg1) painter.drawText(dynInputRect2, msg2)