Пример #1
0
 def applyMask(self, bool):
     self.__show_mask_preview = bool
     if bool:
         self.setMask(
             QBitmap(self.__pmap.createHeuristicMask().scaled(self.size())))
     else:
         self.setMask(QBitmap())
Пример #2
0
    def __init__(self, parent, canvasLayer):
        QTreeWidgetItem.__init__(self)
        self.legend = parent
        self.canvasLayer = canvasLayer
        self.canvasLayer.layer().setLayerName(
            self.legend.normalizeLayerName(
                unicode(self.canvasLayer.layer().name())))
        self.setText(0, self.canvasLayer.layer().name())
        self.isVect = (self.canvasLayer.layer().type() == 0
                       )  # 0: Vector, 1: Raster
        self.layerId = self.canvasLayer.layer().id()

        if self.isVect:
            geom = self.canvasLayer.layer().dataProvider().geometryType()

        self.setCheckState(0, Qt.Checked)

        if self.isVect:
            pm = QPixmap(20, 20)
            icon = QIcon()
            if geom == 1 or geom == 4 or geom == 8 or geom == 11:  # Point
                icon.addPixmap(QPixmap(imgs_dir + "mIconPointLayer.png"),
                               QIcon.Normal, QIcon.On)
            elif geom == 2 or geom == 5 or geom == 9 or geom == 12:  # Polyline
                icon.addPixmap(QPixmap(imgs_dir + "mIconLineLayer.png"),
                               QIcon.Normal, QIcon.On)
            elif geom == 3 or geom == 6 or geom == 10 or geom == 13:  # Polygon
                icon.addPixmap(QPixmap(imgs_dir + "mIconPolygonLayer.png"),
                               QIcon.Normal, QIcon.On)
            else:  # Not a valid WKT Geometry
                geom = self.canvasLayer.layer().geometryType()  # QGis Geometry
                if geom == 0:  # Point
                    icon.addPixmap(QPixmap(imgs_dir + "mIconPointLayer.png"),
                                   QIcon.Normal, QIcon.On)
                elif geom == 1:  # Line
                    icon.addPixmap(QPixmap(imgs_dir + "mIconLineLayer.png"),
                                   QIcon.Normal, QIcon.On)
                elif geom == 2:  # Polygon
                    icon.addPixmap(QPixmap(imgs_dir + "mIconPolygonLayer.png"),
                                   QIcon.Normal, QIcon.On)
                else:
                    raise RuntimeError, 'Unknown geometry: ' + str(geom)

        else:
            qimg = self.canvasLayer.layer().previewAsImage(QSize(20, 20))
            icon = QIcon(QBitmap().fromImage(qimg))

        self.setIcon(0, icon)

        #self.setToolTip( 0, self.canvasLayer.layer().publicSource() )
        layerFont = QFont()
        layerFont.setBold(True)
        self.setFont(0, layerFont)

        # Display layer properties
        self.properties = self.legend.pyQGisApp.getLayerProperties(
            self.canvasLayer.layer())
        self.child = QTreeWidgetItem(self)
        self.child.setFlags(Qt.NoItemFlags)  # Avoid the item to be selected
        self.displayLayerProperties()
Пример #3
0
 def __onResize(self, event):
     self.__fixed_label.move(0, self.geometry().height() - 35)
     self.__fixed_label.resize(self.geometry().width(),
                               self.__fixed_label.geometry().height())
     self.setIndicatorPos(QPoint(self.width() - self.__indicator.width(),
                                 0))
     self.__pmap.scaled(self.size())
     if self.__show_mask_preview:
         self.setMask(
             QBitmap(self.__pmap.createHeuristicMask().scaled(self.size())))
Пример #4
0
 def round(self):
     bmp = QBitmap(self.size())
     p = QPainter()
     p.begin(bmp)
     p.fillRect(bmp.rect(), Qt.white)
     p.setBrush(QColor(0,0,0))
     p.drawRoundedRect(bmp.rect(), 5, 5)
     p.setPen(QColor(255,255,255,255))
     p.drawPoints(QPointF(self.width()-2,self.height()-1), QPointF(self.width()-1,self.height()-2))
     p.setPen(QColor(0,0,0))
     p.drawPoints(QPointF(0,2),QPointF(3,0),QPointF(2,0),QPointF(1,1))
     p.end()
     self.setMask(bmp)
Пример #5
0
    def __updateMask(self):
        opt = QStyleOption()
        opt.init(self)
        rect = opt.rect

        size = rect.size()
        mask = QBitmap(size)

        p = QPainter(mask)
        p.setRenderHint(QPainter.Antialiasing)
        p.setBrush(Qt.black)
        p.setPen(Qt.NoPen)
        p.drawRoundedRect(rect, self.__radius, self.__radius)
        p.end()

        self.setMask(mask)
Пример #6
0
    def adjustMask(self):
        """
        Updates the alpha mask for this popup widget.
        """
        if self.currentMode() == XPopupWidget.Mode.Dialog:
            self.clearMask()
            return

        path = self.borderPath()
        bitmap = QBitmap(self.width(), self.height())
        bitmap.fill(QColor('white'))

        painter = QPainter()
        painter.begin(bitmap)
        painter.setRenderHint(QPainter.Antialiasing)
        pen = QPen(QColor('black'))
        pen.setWidthF(0.75)
        painter.setPen(pen)
        painter.setBrush(QColor('black'))
        painter.drawPath(path)
        painter.end()

        self.setMask(bitmap)
Пример #7
0
 def __onResize(self, event):
     self.__pmap.scaled(self.size())
     if self.__show_mask_preview:
         self.setMask(QBitmap(self.__pmap.createHeuristicMask().scaled(self.size())))