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


Python pyqtcore.QVector类代码示例

本文整理汇总了Python中pyqtcore.QVector的典型用法代码示例。如果您正苦于以下问题:Python QVector类的具体用法?Python QVector怎么用?Python QVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: readObjectTypes

    def readObjectTypes(self, fileName):
        self.mError = ''
        objectTypes = QVector()
        file = QFile(fileName)
        if (not file.open(QIODevice.ReadOnly | QIODevice.Text)):
            self.mError = QCoreApplication.translate(
                        "ObjectTypes", "Could not open file.")
            return objectTypes

        reader = QXmlStreamReader(file)
        if (not reader.readNextStartElement() or reader.name() != "objecttypes"):
            self.mError = QCoreApplication.translate(
                        "ObjectTypes", "File doesn't contain object types.")
            return objectTypes

        while (reader.readNextStartElement()):
            if (reader.name() == "objecttype"):
                atts = reader.attributes()
                name = QString(atts.value("name"))
                color = QColor(atts.value("color"))
                objectTypes.append(ObjectType(name, color))

            reader.skipCurrentElement()

        if (reader.hasError()):
            self.mError = QCoreApplication.translate("ObjectTypes", "%s\n\nLine %d, column %d"%(reader.errorString(), reader.lineNumber(), reader.columnNumber()))
            return objectTypes

        return objectTypes
开发者ID:theall,项目名称:Python-Tiled,代码行数:29,代码来源:objecttypes.py

示例2: drawGrid

    def drawGrid(self, painter, rect, gridColor):
        tileWidth = self.map().tileWidth()
        tileHeight = self.map().tileHeight()
        r = rect.toAlignedRect()
        r.adjust(-tileWidth / 2, -tileHeight / 2, tileWidth / 2, tileHeight / 2)
        startX = int(max(0.0, self.screenToTileCoords_(r.topLeft()).x()))
        startY = int(max(0.0, self.screenToTileCoords_(r.topRight()).y()))
        endX = int(min(self.map().width(), self.screenToTileCoords_(r.bottomRight()).x()))
        endY = int(min(self.map().height(), self.screenToTileCoords_(r.bottomLeft()).y()))
        gridColor.setAlpha(128)
        gridPen = QPen(gridColor)
        gridPen.setCosmetic(True)
        _x = QVector()
        _x.append(2)
        _x.append(2)
        gridPen.setDashPattern(_x)
        painter.setPen(gridPen)
        for y in range(startY, endY+1):
            start = self.tileToScreenCoords(startX, y)
            end = self.tileToScreenCoords(endX, y)
            painter.drawLine(start, end)

        for x in range(startX, endX+1):
            start = self.tileToScreenCoords(x, startY)
            end = self.tileToScreenCoords(x, endY)
            painter.drawLine(start, end)
开发者ID:theall,项目名称:Python-Tiled,代码行数:26,代码来源:isometricrenderer.py

示例3: drawGrid

    def drawGrid(self, painter, rect, gridColor):
        tileWidth = self.map().tileWidth()
        tileHeight = self.map().tileHeight()
        if (tileWidth <= 0 or tileHeight <= 0):
            return
        startX = max(0,  int(rect.x() / tileWidth) * tileWidth)
        startY = max(0,  int(rect.y() / tileHeight) * tileHeight)
        endX = min(math.ceil(rect.right()), self.map().width() * tileWidth + 1)
        endY = min(math.ceil(rect.bottom()), self.map().height() * tileHeight + 1)
        gridColor.setAlpha(128)
        gridPen = QPen(gridColor)
        gridPen.setCosmetic(True)
        _x = QVector()
        _x.append(2)
        _x.append(2)
        gridPen.setDashPattern(_x)
        if (startY < endY):
            gridPen.setDashOffset(startY)
            painter.setPen(gridPen)
            for x in range(startX, endX, tileWidth):
                painter.drawLine(x, startY, x, endY - 1)

        if (startX < endX):
            gridPen.setDashOffset(startX)
            painter.setPen(gridPen)
            for y in range(startY, endY, tileHeight):
                painter.drawLine(startX, y, endX - 1, y)
开发者ID:theall,项目名称:Python-Tiled,代码行数:27,代码来源:orthogonalrenderer.py

示例4: offsetTiles

    def offsetTiles(self, offset, bounds, wrapX, wrapY):
        newGrid = QVector()
        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
开发者ID:theall,项目名称:Python-Tiled,代码行数:35,代码来源:tilelayer.py

示例5: removeObjectTypes

 def removeObjectTypes(self, indexes):
     rows = QVector()
     for index in indexes:
         rows.append(index.row())
     rows = sorted(rows)
     for i in range(len(rows) - 1, -1, -1):
         row = rows[i]
         self.beginRemoveRows(QModelIndex(), row, row)
         self.mObjectTypes.remove(row)
         self.endRemoveRows()
开发者ID:theall,项目名称:Python-Tiled,代码行数:10,代码来源:objecttypesmodel.py

示例6: cellsInRegion

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
开发者ID:theall,项目名称:Python-Tiled,代码行数:11,代码来源:automapper.py

示例7: __readAnimationFrames

    def __readAnimationFrames(self):
        frames = QVector()
        while (self.xml.readNextStartElement()):
            if (self.xml.name() == "frame"):
                atts = self.xml.attributes()
                frame = Frame()
                frame.tileId = Int(atts.value("tileid"))
                frame.duration = Int(atts.value("duration"))
                frames.append(frame)
                self.xml.skipCurrentElement()
            else:
                self.__readUnknownElement()

        return frames
开发者ID:theall,项目名称:Python-Tiled,代码行数:14,代码来源:mapreader.py

示例8: __init__

 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()
开发者ID:theall,项目名称:Python-Tiled,代码行数:28,代码来源:bucketfilltool.py

示例9: __init__

 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()
开发者ID:theall,项目名称:Python-Tiled,代码行数:7,代码来源:tilelayer.py

示例10: __init__

    def __init__(self, parent = None):
        super().__init__(self.tr("Select Objects"),
              QIcon(":images/22x22/tool-select-objects.png"),
              QKeySequence(self.tr("S")),
              parent)
        self.mSelectionRectangle = SelectionRectangle()
        self.mOriginIndicator = OriginIndicator()
        self.mMousePressed = False
        self.mHoveredObjectItem = None
        self.mClickedObjectItem = None
        self.mClickedRotateHandle = None
        self.mClickedResizeHandle = None
        self.mResizingLimitHorizontal = False
        self.mResizingLimitVertical = False
        self.mMode = Mode.Resize
        self.mAction = Action.NoAction
        self.mRotateHandles = [0, 0, 0, 0]
        self.mResizeHandles = [0, 0, 0, 0, 0, 0, 0, 0]
        self.mAlignPosition = QPointF()
        self.mMovingObjects = QVector()
        self.mScreenStart = QPoint()
        self.mStart = QPointF()
        self.mModifiers = 0
        self.mOrigin = QPointF()

        for i in range(AnchorPosition.CornerAnchorCount):
            self.mRotateHandles[i] = RotateHandle(i)
        for i in range(AnchorPosition.AnchorCount):
            self.mResizeHandles[i] = ResizeHandle(i)
开发者ID:theall,项目名称:Python-Tiled,代码行数:29,代码来源:objectselectiontool.py

示例11: __init__

    def __init__(self, parent = None):
        super().__init__(parent)

        ##
        # The current map document.
        ##
        self.mMapDocument = None
        ##
        # For each new file of rules a new AutoMapper is setup. In this vector we
        # can store all of the AutoMappers in order.
        ##
        self.mAutoMappers = QVector()
        ##
        # This tells you if the rules for the current map document were already
        # loaded.
        ##
        self.mLoaded = False
        ##
        # Contains all errors which occurred until canceling.
        # If mError is not empty, no serious result can be expected.
        ##
        self.mError = ''
        ##
        # Contains all strings, which try to explain unusual and unexpected
        # behavior.
        ##
        self.mWarning = QString()
开发者ID:theall,项目名称:Python-Tiled,代码行数:27,代码来源:automappingmanager.py

示例12: __init__

    def __init__(self, mapDocument, autoMapper, where):
        super().__init__()
        
        self.mLayersAfter = QVector()
        self.mLayersBefore = QVector()
        self.mMapDocument = mapDocument
        map = self.mMapDocument.Map()
        touchedLayers = QSet()
        index = 0
        while (index < autoMapper.size()):
            a = autoMapper.at(index)
            if (a.prepareAutoMap()):
                touchedLayers|= a.getTouchedTileLayers()
                index += 1
            else:
                autoMapper.remove(index)

        for layerName in touchedLayers:
            layerindex = map.indexOfLayer(layerName)
            self.mLayersBefore (map.layerAt(layerindex).clone())

        for a in autoMapper:
            a.autoMap(where)
        for layerName in touchedLayers:
            layerindex = map.indexOfLayer(layerName)
            # layerindex exists, because AutoMapper is still alive, dont check
            self.mLayersAfter (map.layerAt(layerindex).clone())

        # reduce memory usage by saving only diffs
        for i in range(self.mLayersAfter.size()):
            before = self.mLayersBefore.at(i)
            after = self.mLayersAfter.at(i)
            diffRegion = before.computeDiffRegion(after).boundingRect()
            before1 = before.copy(diffRegion)
            after1 = after.copy(diffRegion)
            before1.setPosition(diffRegion.topLeft())
            after1.setPosition(diffRegion.topLeft())
            before1.setName(before.name())
            after1.setName(after.name())
            self.mLayersBefore.replace(i, before1)
            self.mLayersAfter.replace(i, after1)
            del before
            del after

        for a in autoMapper:
            a.cleanAll()
开发者ID:theall,项目名称:Python-Tiled,代码行数:46,代码来源:automapperwrapper.py

示例13: flip

    def flip(self, direction):
        newGrid = QVector()
        for i in range(self.mWidth * self.mHeight):
            newGrid.append(Cell())
        for y in range(self.mHeight):
            for x in range(self.mWidth):
                dest = newGrid[x + y * self.mWidth]
                if (direction == FlipDirection.FlipHorizontally):
                    source = self.cellAt(self.mWidth - x - 1, y)
                    dest = source
                    dest.flippedHorizontally = not source.flippedHorizontally
                elif (direction == FlipDirection.FlipVertically):
                    source = self.cellAt(x, self.mHeight - y - 1)
                    dest = source
                    dest.flippedVertically = not source.flippedVertically

        self.mGrid = newGrid
开发者ID:theall,项目名称:Python-Tiled,代码行数:17,代码来源:tilelayer.py

示例14: resize

    def resize(self, size, offset):
        if (self.size() == size and offset.isNull()):
            return
        newGrid = QVector()
        for i in range(size.width() * size.height()):
            newGrid.append(Cell())
        # Copy over the preserved part
        startX = max(0, -offset.x())
        startY = max(0, -offset.y())
        endX = min(self.mWidth, size.width() - offset.x())
        endY = min(self.mHeight, size.height() - offset.y())
        for y in range(startY, endY):
            for x in range(startX, endX):
                index = x + offset.x() + (y + offset.y()) * size.width()
                newGrid[index] = self.cellAt(x, y)

        self.mGrid = newGrid
        self.setSize(size)
开发者ID:theall,项目名称:Python-Tiled,代码行数:18,代码来源:tilelayer.py

示例15: autoMapInternal

    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,代码行数:42,代码来源:automappingmanager.py


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