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


Python QtWidgets.QGraphicsPolygonItem方法代码示例

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


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

示例1: draw_polygons

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPolygonItem [as 别名]
def draw_polygons(self):
        sf = shapefile.Reader(self.shapefile)       
        polygons = sf.shapes() 
        for polygon in polygons:
            # convert shapefile geometries into shapely geometries
            # to extract the polygons of a multipolygon
            polygon = shapely.geometry.shape(polygon)
            # if it is a polygon, we use a list to make it iterable
            if polygon.geom_type == 'Polygon':
                polygon = [polygon]
            for land in polygon:
                qt_polygon = QtGui.QPolygonF() 
                longitudes, latitudes = land.exterior.coords.xy
                for lon, lat in zip(longitudes, latitudes):
                    px, py = self.to_canvas_coordinates(lon, lat)
                    if px > 1e+10:
                        continue
                    qt_polygon.append(QtCore.QPointF(px, py))
                polygon_item = QtWidgets.QGraphicsPolygonItem(qt_polygon)
                polygon_item.setBrush(self.land_brush)
                polygon_item.setPen(self.land_pen)
                polygon_item.setZValue(1)
                yield polygon_item 
开发者ID:afourmy,项目名称:pyNMS,代码行数:25,代码来源:geographical_view.py

示例2: __init__

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPolygonItem [as 别名]
def __init__(self):
        super().__init__()
        self.ui = Ui_NozzlePreview()
        self.ui.setupUi(self)

        self.brush = QBrush()
        self.brush.setStyle(1)
        self.scene = QGraphicsScene(self)
        self.upper = QGraphicsPolygonItem()
        self.lower = QGraphicsPolygonItem()
        self.upper.setBrush(self.brush)
        self.lower.setBrush(self.brush)
        self.scene.addItem(self.upper)
        self.scene.addItem(self.lower)
        self.ui.tabCrossSection.setScene(self.scene)

        self.ui.tabWidget.currentChanged.connect(self.rescale) 
开发者ID:reilleya,项目名称:openMotor,代码行数:19,代码来源:nozzlePreviewWidget.py

示例3: initMap

# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QGraphicsPolygonItem [as 别名]
def initMap(self):
        features = json.load(
            open("Data/world.json", encoding="utf8")).get("features")
        for feature in features:
            geometry = feature.get("geometry")
            if not geometry:
                continue
            _type = geometry.get("type")
            coordinates = geometry.get("coordinates")
            for coordinate in coordinates:
                if _type == "Polygon":
                    polygon = QPolygonF(
                        [QPointF(latitude, -longitude) for latitude, longitude in coordinate])
                    item = QGraphicsPolygonItem(polygon)
                    item.setPen(QPen(self.borderColor, 0))
                    item.setBrush(QBrush(self.backgroundColor))
                    item.setPos(0, 0)
                    self._scene.addItem(item)
                elif _type == "MultiPolygon":
                    for _coordinate in coordinate:
                        polygon = QPolygonF(
                            [QPointF(latitude, -longitude) for latitude, longitude in _coordinate])
                        item = QGraphicsPolygonItem(polygon)
                        item.setPen(QPen(self.borderColor, 0))
                        item.setBrush(QBrush(self.backgroundColor))
                        item.setPos(0, 0)
                        self._scene.addItem(item) 
开发者ID:PyQt5,项目名称:PyQt,代码行数:29,代码来源:WorldMap.py


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