当前位置: 首页>>代码示例>>Python>>正文


Python QgsLayoutItemPolyline.rectWithFrame方法代码示例

本文整理汇总了Python中qgis.core.QgsLayoutItemPolyline.rectWithFrame方法的典型用法代码示例。如果您正苦于以下问题:Python QgsLayoutItemPolyline.rectWithFrame方法的具体用法?Python QgsLayoutItemPolyline.rectWithFrame怎么用?Python QgsLayoutItemPolyline.rectWithFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsLayoutItemPolyline的用法示例。


在下文中一共展示了QgsLayoutItemPolyline.rectWithFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testBounds

# 需要导入模块: from qgis.core import QgsLayoutItemPolyline [as 别名]
# 或者: from qgis.core.QgsLayoutItemPolyline import rectWithFrame [as 别名]
    def testBounds(self):
        pr = QgsProject()
        l = QgsLayout(pr)

        p = QPolygonF()
        p.append(QPointF(50.0, 30.0))
        p.append(QPointF(100.0, 10.0))
        p.append(QPointF(200.0, 100.0))
        shape = QgsLayoutItemPolyline(p, l)

        props = {}
        props["color"] = "255,0,0,255"
        props["width"] = "6.0"
        props["capstyle"] = "square"

        style = QgsLineSymbol.createSimple(props)
        shape.setSymbol(style)

        # scene bounding rect should include symbol outline
        bounds = shape.sceneBoundingRect()
        self.assertEqual(bounds.left(), 47.0)
        self.assertEqual(bounds.right(), 203.0)
        self.assertEqual(bounds.top(), 7.0)
        self.assertEqual(bounds.bottom(), 103.0)

        # rectWithFrame should include symbol outline too
        bounds = shape.rectWithFrame()
        self.assertEqual(bounds.left(), -3.0)
        self.assertEqual(bounds.right(), 153.0)
        self.assertEqual(bounds.top(), -3.0)
        self.assertEqual(bounds.bottom(), 93.0)
开发者ID:dmarteau,项目名称:QGIS,代码行数:33,代码来源:test_qgslayoutpolyline.py


注:本文中的qgis.core.QgsLayoutItemPolyline.rectWithFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。