本文整理汇总了Python中pyqtcore.QVector.contains方法的典型用法代码示例。如果您正苦于以下问题:Python QVector.contains方法的具体用法?Python QVector.contains怎么用?Python QVector.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtcore.QVector
的用法示例。
在下文中一共展示了QVector.contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cellsInRegion
# 需要导入模块: from pyqtcore import QVector [as 别名]
# 或者: from pyqtcore.QVector import contains [as 别名]
def cellsInRegion(list, r):
cells = QVector()
for tilelayer in list:
for rect in r.rects():
for x in range(rect.left(), rect.right()+1):
for y in range(rect.top(), rect.bottom()+1):
cell = tilelayer.cellAt(x, y)
if (not cells.contains(cell)):
cells.append(cell)
return cells
示例2: TileStampManager
# 需要导入模块: from pyqtcore import QVector [as 别名]
# 或者: from pyqtcore.QVector import contains [as 别名]
class TileStampManager(QObject):
setStamp = pyqtSignal(TileStamp)
def __init__(self, toolManager, parent = None):
super().__init__(parent)
self.mStampsByName = QMap()
self.mQuickStamps = QVector()
for i in range(TileStampManager.quickStampKeys().__len__()):
self.mQuickStamps.append(0)
self.mTileStampModel = TileStampModel(self)
self.mToolManager = toolManager
prefs = preferences.Preferences.instance()
prefs.stampsDirectoryChanged.connect(self.stampsDirectoryChanged)
self.mTileStampModel.stampAdded.connect(self.stampAdded)
self.mTileStampModel.stampRenamed.connect(self.stampRenamed)
self.mTileStampModel.stampChanged.connect(self.saveStamp)
self.mTileStampModel.stampRemoved.connect(self.deleteStamp)
self.loadStamps()
def __del__(self):
# needs to be over here where the TileStamp type is complete
pass
##
# Returns the keys used for quickly accessible tile stamps.
# Note: To store a tile layer <Ctrl> is added. The given keys will work
# for recalling the stored values.
##
def quickStampKeys():
keys=[Qt.Key_1, Qt.Key_2, Qt.Key_3, Qt.Key_4, Qt.Key_5, Qt.Key_6, Qt.Key_7, Qt.Key_8, Qt.Key_9]
return keys
def tileStampModel(self):
return self.mTileStampModel
def createStamp(self):
stamp = self.tampFromContext(self.mToolManager.selectedTool())
if (not stamp.isEmpty()):
self.mTileStampModel.addStamp(stamp)
return stamp
def addVariation(self, targetStamp):
stamp = stampFromContext(self.mToolManager.selectedTool())
if (stamp.isEmpty()):
return
if (stamp == targetStamp): # avoid easy mistake of adding duplicates
return
for variation in stamp.variations():
self.mTileStampModel.addVariation(targetStamp, variation)
def selectQuickStamp(self, index):
stamp = self.mQuickStamps.at(index)
if (not stamp.isEmpty()):
self.setStamp.emit(stamp)
def createQuickStamp(self, index):
stamp = stampFromContext(self.mToolManager.selectedTool())
if (stamp.isEmpty()):
return
self.setQuickStamp(index, stamp)
def extendQuickStamp(self, index):
quickStamp = self.mQuickStamps[index]
if (quickStamp.isEmpty()):
self.createQuickStamp(index)
else:
self.addVariation(quickStamp)
def stampsDirectoryChanged(self):
# erase current stamps
self.mQuickStamps.fill(TileStamp())
self.mStampsByName.clear()
self.mTileStampModel.clear()
self.loadStamps()
def eraseQuickStamp(self, index):
stamp = self.mQuickStamps.at(index)
if (not stamp.isEmpty()):
self.mQuickStamps[index] = TileStamp()
if (not self.mQuickStamps.contains(stamp)):
self.mTileStampModel.removeStamp(stamp)
def setQuickStamp(self, index, stamp):
stamp.setQuickStampIndex(index)
# make sure existing quickstamp is removed from stamp model
self.eraseQuickStamp(index)
self.mTileStampModel.addStamp(stamp)
self.mQuickStamps[index] = stamp
def loadStamps(self):
prefs = preferences.Preferences.instance()
stampsDirectory = prefs.stampsDirectory()
stampsDir = QDir(stampsDirectory)
iterator = QDirIterator(stampsDirectory,
["*.stamp"],
QDir.Files | QDir.Readable)
while (iterator.hasNext()):
#.........这里部分代码省略.........
示例3: compareLayerTo
# 需要导入模块: from pyqtcore import QVector [as 别名]
# 或者: from pyqtcore.QVector import contains [as 别名]
def compareLayerTo(setLayer, listYes, listNo, ruleRegion, offset):
if (listYes.isEmpty() and listNo.isEmpty()):
return False
cells = QVector()
if (listYes.isEmpty()):
cells = cellsInRegion(listNo, ruleRegion)
if (listNo.isEmpty()):
cells = cellsInRegion(listYes, ruleRegion)
for rect in ruleRegion.rects():
for x in range(rect.left(), rect.right()+1):
for y in range(rect.top(), rect.bottom()+1):
# this is only used in the case where only one list has layers
# it is needed for the exception mentioned above
ruleDefinedListYes = False
matchListYes = False
matchListNo = False
if (not setLayer.contains(x + offset.x(), y + offset.y())):
return False
c1 = setLayer.cellAt(x + offset.x(),
y + offset.y())
# ruleDefined will be set when there is a tile in at least
# one layer. if there is a tile in at least one layer, only
# the given tiles in the different listYes layers are valid.
# if there is given no tile at all in the listYes layers,
# consider all tiles valid.
for comparedTileLayer in listYes:
if (not comparedTileLayer.contains(x, y)):
return False
c2 = comparedTileLayer.cellAt(x, y)
if (not c2.isEmpty()):
ruleDefinedListYes = True
if (not c2.isEmpty() and c1 == c2):
matchListYes = True
for comparedTileLayer in listNo:
if (not comparedTileLayer.contains(x, y)):
return False
c2 = comparedTileLayer.cellAt(x, y)
if (not c2.isEmpty() and c1 == c2):
matchListNo = True
# when there are only layers in the listNo
# check only if these layers are unmatched
# no need to check explicitly the exception in this case.
if (listYes.isEmpty()):
if (matchListNo):
return False
else:
continue
# when there are only layers in the listYes
# check if these layers are matched, or if the exception works
if (listNo.isEmpty()):
if (matchListYes):
continue
if (not ruleDefinedListYes and not cells.contains(c1)):
continue
return False
# there are layers in both lists:
# no need to consider ruleDefinedListXXX
if ((matchListYes or not ruleDefinedListYes) and not matchListNo):
continue
else:
return False
return True