コード例 #1
0
    def __init__(self, anchor, parent=None):
        QGraphicsObject.__init__(self, parent=parent)
        MapItem.__init__(self)
        self.setZValue(200.0)

        anchorPos = self._posForAnchors[anchor]
        self._anchorPos = QPointF(anchorPos)
        self._anchor = anchor

        self._border = QGraphicsRectItem(parent=self)
        self._border.setPen(QPen(Qt.NoPen))
        self._border.setBrush(QBrush(QColor(190, 190, 190, 160)))

        self._entries = list()

        imgfile = os.path.dirname(__file__) + os.sep + 'zoom_in_symbol.png'
        img = QPixmap(24, 24)
        img.load(imgfile)
        img = img.scaled(24, 24)
        img = ImageButton(img, parent=self)
        self.zoom_in_button = img
        self.addEntry(self.zoom_in_button)

        imgfile = os.path.dirname(__file__) + os.sep + 'zoom_out_symbol.png'
        img2 = QPixmap(24, 24)
        img2.load(imgfile)
        img2 = img2.scaled(24, 24)
        img2 = ImageButton(img2, parent=self)
        self.zoom_out_button = img2
        self.addEntry(self.zoom_out_button)
コード例 #2
0
    def __init__(self,
                 textPen='black',
                 barBrush=(190, 190, 190, 160),
                 barPen=(190, 190, 190, 240),
                 barBrushHover=(110, 110, 110, 255),
                 barPenHover=(90, 90, 90, 255),
                 anchor=Qt.BottomRightCorner,
                 anchorPos=None,
                 parent=None):
        """Construct a scale bar with text on the right bottom of the map

        Keyword Args:
            textPen: QPen to use for drawing the text. Default 'black'.
            barBrush: QBrush to use for drawing the scale bar. Default (190, 190, 190, 160)
            barPen: QPen to use for drawing the scale bar border. Default (190, 190, 190, 240)
            barBrushHover:  QBrush to use for drawing the scale bar when the mouse is over it.
                Default (110, 110, 110, 255).
            barPenHover: QPen to use for drawing the scale bar borderwhen the mouse is over it.
                Default (90, 90, 90, 255).
            parent: Parent item
            anchor (Qt.Corner): The *corner* used as anchor for the item, Valid values are within the
                Qt.Corner enum
            anchorPos (QPointF): The distance between the item and the *corner*

        Note:
            Almost all the argumnets accepted by the functions.makeBrush() and functions.makePen()
            are accepted.
        """
        QGraphicsObject.__init__(self, parent=parent)
        MapItem.__init__(self)

        self.setZValue(100)

        self._textPen = makePen(textPen)
        self._barBrush = makeBrush(barBrush)
        self._barPen = makePen(barPen)
        self._barBrushHover = makeBrush(barBrushHover)
        self._barPenHover = makePen(barPenHover)

        self._scaleView = MapScaleItem._defaultScaleVisualization.copy()
        self._minZoomScale = min(self._scaleView.keys())
        self._maxZoomScale = max(self._scaleView.keys())

        self.setAcceptHoverEvents(True)
        self._hover = False

        if anchorPos is None:
            anchorPos = self._posForAnchors[anchor]
        self._anchorPos = QPointF(anchorPos)
        self._anchor = anchor

        self._barWidth = 0  # The width of the scale bar
        self._text = ''  # The text to display near the scale bar
        self._zoom = 0  # The current zoom level
        self._meters = 0  # The number of meters used to evaluate the size of the scale bar and its text
        self._meterPerPixelsEquator = 0  # The number of meters each pixel represents at the equator
        self._textRect = QRectF()  # The bounding rect of text
コード例 #3
0
ファイル: imagebutton.py プロジェクト: bthcode/PyTileMap
    def __init__(self, img, parent=None):
        '''
        Args:
            img: A QPixmap instance

        Keyword Args:
            parent: A pyqt window instance
        '''
        QGraphicsObject.__init__(self, parent=parent)
        self.image = QGraphicsPixmapItem(img, parent=self)
        self.parent = parent
コード例 #4
0
ファイル: maplegenditem.py プロジェクト: allebacco/PyTileMap
    def __init__(self, pos=None, parent=None):
        QGraphicsObject.__init__(self, parent=parent)
        MapItem.__init__(self)
        self.setZValue(200.0)

        self._anchorPos = QPointF(pos) if pos is not None else QPointF(10.0, 10.0)

        self._border = QGraphicsRectItem(parent=self)
        self._border.setPen(QPen(Qt.NoPen))
        self._border.setBrush(QBrush(QColor(190, 190, 190, 160)))

        self._entries = list()
        self._entriesGroup = QGraphicsItemGroup(parent=self)
コード例 #5
0
ファイル: mapescaleitem.py プロジェクト: allebacco/PyTileMap
    def __init__(self, textPen='black', barBrush=(190, 190, 190, 160), barPen=(190, 190, 190, 240),
                 barBrushHover=(110, 110, 110, 255), barPenHover=(90, 90, 90, 255),
                 anchor=Qt.BottomRightCorner, anchorPos=None, parent=None):
        """Construct a scale bar with text on the right bottom of the map

        Keyword Args:
            textPen: QPen to use for drawing the text. Default 'black'.
            barBrush: QBrush to use for drawing the scale bar. Default (190, 190, 190, 160)
            barPen: QPen to use for drawing the scale bar border. Default (190, 190, 190, 240)
            barBrushHover:  QBrush to use for drawing the scale bar when the mouse is over it.
                Default (110, 110, 110, 255).
            barPenHover: QPen to use for drawing the scale bar borderwhen the mouse is over it.
                Default (90, 90, 90, 255).
            parent: Parent item
            anchor (Qt.Corner): The *corner* used as anchor for the item, Valid values are within the
                Qt.Corner enum
            anchorPos (QPointF): The distance between the item and the *corner*

        Note:
            Almost all the argumnets accepted by the functions.makeBrush() and functions.makePen()
            are accepted.
        """
        QGraphicsObject.__init__(self, parent=parent)
        MapItem.__init__(self)

        self.setZValue(100)

        self._textPen = makePen(textPen)
        self._barBrush = makeBrush(barBrush)
        self._barPen = makePen(barPen)
        self._barBrushHover = makeBrush(barBrushHover)
        self._barPenHover = makePen(barPenHover)

        self._scaleView = MapScaleItem._defaultScaleVisualization.copy()
        self._minZoomScale = min(self._scaleView.keys())
        self._maxZoomScale = max(self._scaleView.keys())

        self.setAcceptHoverEvents(True)
        self._hover = False

        if anchorPos is None:
            anchorPos = self._posForAnchors[anchor]
        self._anchorPos = QPointF(anchorPos)
        self._anchor = anchor

        self._barWidth = 0  # The width of the scale bar
        self._text = ''  # The text to display near the scale bar
        self._zoom = 0  # The current zoom level
        self._meters = 0  # The number of meters used to evaluate the size of the scale bar and its text
        self._meterPerPixelsEquator = 0  # The number of meters each pixel represents at the equator
        self._textRect = QRectF()  # The bounding rect of text
コード例 #6
0
    def __init__(self, pos=None, parent=None):
        QGraphicsObject.__init__(self, parent=parent)
        MapItem.__init__(self)
        self.setZValue(200.0)

        self._anchorPos = QPointF(pos) if pos is not None else QPointF(
            10.0, 10.0)

        self._border = QGraphicsRectItem(parent=self)
        self._border.setPen(QPen(Qt.NoPen))
        self._border.setBrush(QBrush(QColor(190, 190, 190, 160)))

        self._entries = list()
        self._entriesGroup = QGraphicsItemGroup(parent=self)