本文整理汇总了Python中pyqtcore.QVector.__iter__方法的典型用法代码示例。如果您正苦于以下问题:Python QVector.__iter__方法的具体用法?Python QVector.__iter__怎么用?Python QVector.__iter__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtcore.QVector
的用法示例。
在下文中一共展示了QVector.__iter__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TileLayer
# 需要导入模块: from pyqtcore import QVector [as 别名]
# 或者: from pyqtcore.QVector import __iter__ [as 别名]
class TileLayer(Layer):
##
# Constructor.
##
def __init__(self, name, x, y, width, height):
super().__init__(Layer.TileLayerType, name, x, y, width, height)
self.mMaxTileSize = QSize(0, 0)
self.mGrid = QVector()
for i in range(width * height):
self.mGrid.append(Cell())
self.mOffsetMargins = QMargins()
def __iter__(self):
return self.mGrid.__iter__()
##
# Returns the maximum tile size of this layer.
##
def maxTileSize(self):
return self.mMaxTileSize
##
# Returns the margins that have to be taken into account while drawing
# this tile layer. The margins depend on the maximum tile size and the
# offset applied to the tiles.
##
def drawMargins(self):
return QMargins(self.mOffsetMargins.left(),
self.mOffsetMargins.top() + self.mMaxTileSize.height(),
self.mOffsetMargins.right() + self.mMaxTileSize.width(),
self.mOffsetMargins.bottom())
##
# Recomputes the draw margins. Needed after the tile offset of a tileset
# has changed for example.
#
# Generally you want to call Map.recomputeDrawMargins instead.
##
def recomputeDrawMargins(self):
maxTileSize = QSize(0, 0)
offsetMargins = QMargins()
i = 0
while(i<self.mGrid.size()):
cell = self.mGrid.at(i)
tile = cell.tile
if tile:
size = tile.size()
if (cell.flippedAntiDiagonally):
size.transpose()
offset = tile.offset()
maxTileSize = maxSize(size, maxTileSize)
offsetMargins = maxMargins(QMargins(-offset.x(),
-offset.y(),
offset.x(),
offset.y()),
offsetMargins)
i += 1
self.mMaxTileSize = maxTileSize
self.mOffsetMargins = offsetMargins
if (self.mMap):
self.mMap.adjustDrawMargins(self.drawMargins())
##
# Returns whether (x, y) is inside this map layer.
##
def contains(self, *args):
l = len(args)
if l==2:
x, y = args
return x >= 0 and y >= 0 and x < self.mWidth and y < self.mHeight
elif l==1:
point = args[0]
return self.contains(point.x(), point.y())
##
# Calculates the region of cells in this tile layer for which the given
# \a condition returns True.
##
def region(self, *args):
l = len(args)
if l==1:
condition = args[0]
region = QRegion()
for y in range(self.mHeight):
for x in range(self.mWidth):
if (condition(self.cellAt(x, y))):
rangeStart = x
x += 1
while(x<=self.mWidth):
if (x == self.mWidth or not condition(self.cellAt(x, y))):
rangeEnd = x
region += QRect(rangeStart + self.mX, y + self.mY,
rangeEnd - rangeStart, 1)
break
x += 1
return region
elif l==0:
##
#.........这里部分代码省略.........