本文整理汇总了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)