當前位置: 首頁>>代碼示例>>Python>>正文


Python QVector.isEmpty方法代碼示例

本文整理匯總了Python中pyqtcore.QVector.isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Python QVector.isEmpty方法的具體用法?Python QVector.isEmpty怎麽用?Python QVector.isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyqtcore.QVector的用法示例。


在下文中一共展示了QVector.isEmpty方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: autoMapInternal

# 需要導入模塊: from pyqtcore import QVector [as 別名]
# 或者: from pyqtcore.QVector import isEmpty [as 別名]
    def autoMapInternal(self, where, touchedLayer):
        self.mError = ''
        self.mWarning = ''
        if (not self.mMapDocument):
            return
        automatic = touchedLayer != None
        if (not self.mLoaded):
            mapPath = QFileInfo(self.mMapDocument.fileName()).path()
            rulesFileName = mapPath + "/rules.txt"
            if (self.loadFile(rulesFileName)):
                self.mLoaded = True
            else:
                self.errorsOccurred.emit(automatic)
                return
                
        passedAutoMappers = QVector()
        if (touchedLayer):
            for a in self.mAutoMappers:
                if (a.ruleLayerNameUsed(touchedLayer.name())):
                    passedAutoMappers.append(a)
        else:
            passedAutoMappers = self.mAutoMappers

        if (not passedAutoMappers.isEmpty()):
            # use a pointer to the region, so each automapper can manipulate it and the
            # following automappers do see the impact
            region = QRegion(where)
        
            undoStack = self.mMapDocument.undoStack()
            undoStack.beginMacro(self.tr("Apply AutoMap rules"))
            aw = AutoMapperWrapper(self.mMapDocument, passedAutoMappers, region)
            undoStack.push(aw)
            undoStack.endMacro()

        for automapper in self.mAutoMappers:
            self.mWarning += automapper.warningString()
            self.mError += automapper.errorString()

        if self.mWarning != '':
            self.warningsOccurred.emit(automatic)
        if self.mError != '':
            self.errorsOccurred.emit(automatic)
開發者ID:theall,項目名稱:Python-Tiled,代碼行數:44,代碼來源:automappingmanager.py

示例2: StampBrush

# 需要導入模塊: from pyqtcore import QVector [as 別名]
# 或者: from pyqtcore.QVector import isEmpty [as 別名]
class StampBrush(AbstractTileTool):
    ##
    # Emitted when the currently selected tiles changed. The stamp brush emits
    # this signal instead of setting its stamp directly so that the fill tool
    # also gets the new stamp.
    ##
    currentTilesChanged = pyqtSignal(list)
    
    ##
    # Emitted when a stamp was captured from the map. The stamp brush emits
    # this signal instead of setting its stamp directly so that the fill tool
    # also gets the new stamp.
    ##
    stampCaptured = pyqtSignal(TileStamp)
    
    def __init__(self, parent = None):
        super().__init__(self.tr("Stamp Brush"),
                           QIcon(":images/22x22/stock-tool-clone.png"),
                           QKeySequence(self.tr("B")),
                           parent)
        ##
        # This stores the current behavior.
        ##
        self.mBrushBehavior = BrushBehavior.Free

        self.mIsRandom = False
        self.mCaptureStart = QPoint()
        self.mRandomCellPicker = RandomPicker()
        ##
        # mStamp is a tile layer in which is the selection the user made
        # either by rightclicking (Capture) or at the tilesetdock
        ##
        self.mStamp = TileStamp()
        self.mPreviewLayer = None
        self.mMissingTilesets = QVector()
        self.mPrevTilePosition = QPoint()
        self.mStampReference = QPoint()

    def __del__(self):
        pass

    def tr(self, sourceText, disambiguation = '', n = -1):
        return QCoreApplication.translate('StampBrush', sourceText, disambiguation, n)

    def mousePressed(self, event):
        if (not self.brushItem().isVisible()):
            return
        if (event.button() == Qt.LeftButton):
            x = self.mBrushBehavior
            if x==BrushBehavior.Line:
                self.mStampReference = self.tilePosition()
                self.mBrushBehavior = BrushBehavior.LineStartSet
            elif x==BrushBehavior.Circle:
                self.mStampReference = self.tilePosition()
                self.mBrushBehavior = BrushBehavior.CircleMidSet
            elif x==BrushBehavior.LineStartSet:
                self.doPaint()
                self.mStampReference = self.tilePosition()
            elif x==BrushBehavior.CircleMidSet:
                self.doPaint()
            elif x==BrushBehavior.Paint:
                self.beginPaint()
            elif x==BrushBehavior.Free:
                self.beginPaint()
                self.mBrushBehavior = BrushBehavior.Paint
            elif x==BrushBehavior.Capture:
                pass
        else:
            if (event.button() == Qt.RightButton):
                self.beginCapture()

    def mouseReleased(self, event):
        x = self.mBrushBehavior
        if x==BrushBehavior.Capture:
            if (event.button() == Qt.RightButton):
                self.endCapture()
                self.mBrushBehavior = BrushBehavior.Free
        elif x==BrushBehavior.Paint:
            if (event.button() == Qt.LeftButton):
                self.mBrushBehavior = BrushBehavior.Free
                # allow going over different variations by repeatedly clicking
                self.updatePreview()
        else:
            # do nothing?
            pass

    def modifiersChanged(self, modifiers):
        if self.mStamp.isEmpty():
            return
        if (modifiers & Qt.ShiftModifier):
            if (modifiers & Qt.ControlModifier):
                if self.mBrushBehavior == BrushBehavior.LineStartSet:
                    self.mBrushBehavior = BrushBehavior.CircleMidSet
                else:
                    self.mBrushBehavior = BrushBehavior.Circle
            else:
                if self.mBrushBehavior == BrushBehavior.CircleMidSet:
                    self.mBrushBehavior = BrushBehavior.LineStartSet
                else:
                    self.mBrushBehavior = BrushBehavior.Line
#.........這裏部分代碼省略.........
開發者ID:theall,項目名稱:Python-Tiled,代碼行數:103,代碼來源:stampbrush.py

示例3: BucketFillTool

# 需要導入模塊: from pyqtcore import QVector [as 別名]
# 或者: from pyqtcore.QVector import isEmpty [as 別名]
class BucketFillTool(AbstractTileTool):
    def tr(self, sourceText, disambiguation = '', n = -1):
        return QCoreApplication.translate('BucketFillTool', sourceText, disambiguation, n)

    def __init__(self, parent = None):
        super().__init__(self.tr("Bucket Fill Tool"),
                           QIcon(":images/22x22/stock-tool-bucket-fill.png"),
                           QKeySequence(self.tr("F")),
                           parent)
        self.mStamp = TileStamp()
        self.mFillOverlay = None
        self.mFillRegion = QRegion()
        self.mMissingTilesets = QVector()
        self.mIsActive = False
        self.mLastShiftStatus = False
        ##
        # Indicates if the tool is using the random mode.
        ##
        self.mIsRandom = False
        ##
        # Contains the value of mIsRandom at that time, when the latest call of
        # tilePositionChanged() took place.
        # This variable is needed to detect if the random mode was changed during
        # mFillOverlay being brushed at an area.
        ##
        self.mLastRandomStatus = False
        ##
        # Contains all used random cells to use in random mode.
        # The same cell can be in the list multiple times to make different
        # random weights possible.
        ##
        self.mRandomCellPicker = RandomPicker()

    def __del__(self):
        pass

    def activate(self, scene):
        super().activate(scene)
        self.mIsActive = True
        self.tilePositionChanged(self.tilePosition())

    def deactivate(self, scene):
        super().deactivate(scene)
        self.mFillRegion = QRegion()
        self.mIsActive = False

    def mousePressed(self, event):
        if (event.button() != Qt.LeftButton or self.mFillRegion.isEmpty()):
            return
        if (not self.brushItem().isVisible()):
            return
        
        preview = self.mFillOverlay
        if not preview:
            return

        paint = PaintTileLayer(self.mapDocument(),
                                       self.currentTileLayer(),
                                       preview.x(),
                                       preview.y(),
                                       preview)

        paint.setText(QCoreApplication.translate("Undo Commands", "Fill Area"))

        if not self.mMissingTilesets.isEmpty():
            for tileset in self.mMissingTilesets:
                AddTileset(self.mapDocument(), tileset, paint)

            self.mMissingTilesets.clear()
            
        fillRegion = QRegion(self.mFillRegion)
        self.mapDocument().undoStack().push(paint)
        self.mapDocument().emitRegionEdited(fillRegion, self.currentTileLayer())

    def mouseReleased(self, event):
        pass

    def modifiersChanged(self, modifiers):
        # Don't need to recalculate fill region if there was no fill region
        if (not self.mFillOverlay):
            return
        self.tilePositionChanged(self.tilePosition())

    def languageChanged(self):
        self.setName(self.tr("Bucket Fill Tool"))
        self.setShortcut(QKeySequence(self.tr("F")))

    ##
    # Sets the stamp that is drawn when filling. The BucketFillTool takes
    # ownership over the stamp layer.
    ##
    def setStamp(self, stamp):
        # Clear any overlay that we presently have with an old stamp
        self.clearOverlay()
        self.mStamp = stamp
        self.updateRandomListAndMissingTilesets()
        if (self.mIsActive and self.brushItem().isVisible()):
            self.tilePositionChanged(self.tilePosition())

    ##
#.........這裏部分代碼省略.........
開發者ID:theall,項目名稱:Python-Tiled,代碼行數:103,代碼來源:bucketfilltool.py

示例4: Tile

# 需要導入模塊: from pyqtcore import QVector [as 別名]
# 或者: from pyqtcore.QVector import isEmpty [as 別名]

#.........這裏部分代碼省略.........
            return -1
        return t

    ##
    # Set the terrain type of a given corner.
    ##
    def setCornerTerrainId(self, corner, terrainId):
        self.setTerrain(setTerrainCorner(self.mTerrain, corner, terrainId))

    ##
    # Returns the terrain for each corner of this tile.
    ##
    def terrain(self):
        return self.mTerrain

    ##
    # Set the terrain for each corner of the tile.
    ##
    def setTerrain(self, terrain):
        if (self.mTerrain == terrain):
            return
        self.mTerrain = terrain
        self.mTileset.markTerrainDistancesDirty()

    ##
    # Returns the probability of this terrain type appearing while painting (0-100%).
    ##
    def probability(self):
        return self.mProbability

    ##
    # Set the relative probability of this tile appearing while painting.
    ##
    def setProbability(self, probability):
        self.mProbability = probability

    ##
    # @return The group of objects associated with this tile. This is generally
    #         expected to be used for editing collision shapes.
    ##
    def objectGroup(self):
        return self.mObjectGroup

    ##
    # Sets \a objectGroup to be the group of objects associated with this tile.
    # The Tile takes ownership over the ObjectGroup and it can't also be part of
    # a map.
    ##
    def setObjectGroup(self, objectGroup):
        if (self.mObjectGroup == objectGroup):
            return
        del self.mObjectGroup
        self.mObjectGroup = objectGroup

    ##
    # Swaps the object group of this tile with \a objectGroup. The tile releases
    # ownership over its existing object group and takes ownership over the new
    # one.
    #
    # @return The previous object group referenced by this tile.
    ##
    def swapObjectGroup(self, objectGroup):
        previousObjectGroup = self.mObjectGroup
        self.mObjectGroup = objectGroup
        return previousObjectGroup

    def frames(self):
        return self.mFrames

    ##
    # Sets the animation frames to be used by this tile. Resets any currently
    # running animation.
    ##
    def setFrames(self, frames):
        self.mFrames = frames
        self.mCurrentFrameIndex = 0
        self.mUnusedTime = 0

    def isAnimated(self):
        return not self.mFrames.isEmpty()

    def currentFrameIndex(self):
        return self.mCurrentFrameIndex

    ##
    # Advances this tile animation by the given amount of milliseconds. Returns
    # whether this caused the current tileId to change.
    ##
    def advanceAnimation(self, ms):
        if (not self.isAnimated()):
            return False
        self.mUnusedTime += ms
        frame = self.mFrames.at(self.mCurrentFrameIndex)
        previousTileId = frame.tileId
        while (frame.duration > 0 and self.mUnusedTime > frame.duration):
            self.mUnusedTime -= frame.duration
            self.mCurrentFrameIndex = (self.mCurrentFrameIndex + 1) % self.mFrames.size()
            frame = self.mFrames.at(self.mCurrentFrameIndex)

        return previousTileId != frame.tileId
開發者ID:theall,項目名稱:Python-Tiled,代碼行數:104,代碼來源:tile.py


注:本文中的pyqtcore.QVector.isEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。