本文整理匯總了Python中pyqtcore.QVector.begin方法的典型用法代碼示例。如果您正苦於以下問題:Python QVector.begin方法的具體用法?Python QVector.begin怎麽用?Python QVector.begin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyqtcore.QVector
的用法示例。
在下文中一共展示了QVector.begin方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TileLayer
# 需要導入模塊: from pyqtcore import QVector [as 別名]
# 或者: from pyqtcore.QVector import begin [as 別名]
#.........這裏部分代碼省略.........
for i in range(self.mWidth * self.mHeight):
newGrid.append(Cell())
for y in range(self.mHeight):
for x in range(self.mWidth):
# Skip out of bounds tiles
if (not bounds.contains(x, y)):
newGrid[x + y * self.mWidth] = self.cellAt(x, y)
continue
# Get position to pull tile value from
oldX = x - offset.x()
oldY = y - offset.y()
# Wrap x value that will be pulled from
if (wrapX and bounds.width() > 0):
while oldX < bounds.left():
oldX += bounds.width()
while oldX > bounds.right():
oldX -= bounds.width()
# Wrap y value that will be pulled from
if (wrapY and bounds.height() > 0):
while oldY < bounds.top():
oldY += bounds.height()
while oldY > bounds.bottom():
oldY -= bounds.height()
# Set the new tile
if (self.contains(oldX, oldY) and bounds.contains(oldX, oldY)):
newGrid[x + y * self.mWidth] = self.cellAt(oldX, oldY)
else:
newGrid[x + y * self.mWidth] = Cell()
self.mGrid = newGrid
def canMergeWith(self, other):
return other.isTileLayer()
def mergedWith(self, other):
o = other
unitedBounds = self.bounds().united(o.bounds())
offset = self.position() - unitedBounds.topLeft()
merged = self.clone()
merged.resize(unitedBounds.size(), offset)
merged.merge(o.position() - unitedBounds.topLeft(), o)
return merged
##
# Returns the region where this tile layer and the given tile layer
# are different. The relative positions of the layers are taken into
# account. The returned region is relative to this tile layer.
##
def computeDiffRegion(self, other):
ret = QRegion()
dx = other.x() - self.mX
dy = other.y() - self.mY
r = QRect(0, 0, self.width(), self.height())
r &= QRect(dx, dy, other.width(), other.height())
for y in range(r.top(), r.bottom()+1):
for x in range(r.left(), r.right()+1):
if (self.cellAt(x, y) != other.cellAt(x - dx, y - dy)):
rangeStart = x
while (x <= r.right() and self.cellAt(x, y) != other.cellAt(x - dx, y - dy)):
x += 1
rangeEnd = x
ret += QRect(rangeStart, y, rangeEnd - rangeStart, 1)
return ret
##
# Returns True if all tiles in the layer are empty.
##
def isEmpty(self):
i = 0
while(i<self.mGrid.size()):
if (not self.mGrid.at(i).isEmpty()):
return False
i += 1
return True
##
# Returns a duplicate of this TileLayer.
#
# \sa Layer.clone()
##
def clone(self):
return self.initializeClone(TileLayer(self.mName, self.mX, self.mY, self.mWidth, self.mHeight))
def begin(self):
return self.mGrid.begin()
def end(self):
return self.mGrid.end()
def initializeClone(self, clone):
super().initializeClone(clone)
clone.mGrid = self.mGrid
clone.mMaxTileSize = self.mMaxTileSize
clone.mOffsetMargins = self.mOffsetMargins
return clone