• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyqtcore.QVector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __init__

    def __init__(self, parent = None):
        super().__init__(parent)
        self.mScale = 1
        self.mZoomFactors = QVector()
        self.mGestureStartScale = 0
        self.mComboBox = None
        self.mComboRegExp = QRegExp("^\\s*(\\d+)\\s*%?\\s*$")
        self.mComboValidator = None

        for i in range(zoomFactorCount):
            self.mZoomFactors.append(zoomFactors[i])
开发者ID:theall,项目名称:Python-Tiled,代码行数:11,代码来源:zoomable.py


示例17: SetProperty

class SetProperty(QUndoCommand):
    ##
    # Constructs a new 'Set Property' command.
    #
    # @param mapDocument  the map document of the object's map
    # @param objects      the objects of which the property should be changed
    # @param name         the name of the property to be changed
    # @param value        the new value of the property
    ##
    def __init__(self, mapDocument, objects, name, value, parent = None):
        super().__init__(parent)

        self.mProperties = QVector()
        self.mMapDocument = mapDocument
        self.mObjects = objects
        self.mName = name
        self.mValue = value

        for obj in self.mObjects:
            prop = ObjectProperty()
            prop.existed = obj.hasProperty(self.mName)
            prop.previousValue = obj.property(self.mName)
            self.mProperties.append(prop)

        if (self.mObjects.size() > 1 or self.mObjects[0].hasProperty(self.mName)):
            self.setText(QCoreApplication.translate("Undo Commands", "Set Property"))
        else:
            self.setText(QCoreApplication.translate("Undo Commands", "Add Property"))

    def undo(self):
        for i in range(self.mObjects.size()):
            if (self.mProperties[i].existed):
                self.mMapDocument.setProperty(self.mObjects[i], self.mName, self.mProperties[i].previousValue)
            else:
                self.mMapDocument.removeProperty(self.mObjects[i], self.mName)

    def redo(self):
        for obj in self.mObjects:
            self.mMapDocument.setProperty(obj, self.mName, self.mValue)
开发者ID:theall,项目名称:Python-Tiled,代码行数:39,代码来源:changeproperties.py


示例18: __init__

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


示例19: __init__

    def __init__(self, mapDocument, objects, name, value, parent = None):
        super().__init__(parent)

        self.mProperties = QVector()
        self.mMapDocument = mapDocument
        self.mObjects = objects
        self.mName = name
        self.mValue = value

        for obj in self.mObjects:
            prop = ObjectProperty()
            prop.existed = obj.hasProperty(self.mName)
            prop.previousValue = obj.property(self.mName)
            self.mProperties.append(prop)

        if (self.mObjects.size() > 1 or self.mObjects[0].hasProperty(self.mName)):
            self.setText(QCoreApplication.translate("Undo Commands", "Set Property"))
        else:
            self.setText(QCoreApplication.translate("Undo Commands", "Add Property"))
开发者ID:theall,项目名称:Python-Tiled,代码行数:19,代码来源:changeproperties.py


示例20: __init__

    def __init__(self, parent):
        super().__init__(parent)
        self.mMapDocument = None
        self.mSelectedTool = None
        self.mActiveTool = None
        self.mObjectSelectionItem = None
        self.mUnderMouse = False
        self.mCurrentModifiers = Qt.NoModifier,
        self.mDarkRectangle = QGraphicsRectItem()
        self.mDefaultBackgroundColor = Qt.darkGray

        self.mLayerItems = QVector()
        self.mObjectItems = QMap()
        self.mObjectLineWidth = 0.0
        self.mSelectedObjectItems = QSet()
        self.mLastMousePos = QPointF()
        self.mShowTileObjectOutlines = False
        self.mHighlightCurrentLayer = False
        self.mGridVisible = False

        self.setBackgroundBrush(self.mDefaultBackgroundColor)
        tilesetManager = TilesetManager.instance()
        tilesetManager.tilesetChanged.connect(self.tilesetChanged)
        tilesetManager.repaintTileset.connect(self.tilesetChanged)
        prefs = preferences.Preferences.instance()
        prefs.showGridChanged.connect(self.setGridVisible)
        prefs.showTileObjectOutlinesChanged.connect(self.setShowTileObjectOutlines)
        prefs.objectTypesChanged.connect(self.syncAllObjectItems)
        prefs.highlightCurrentLayerChanged.connect(self.setHighlightCurrentLayer)
        prefs.gridColorChanged.connect(self.update)
        prefs.objectLineWidthChanged.connect(self.setObjectLineWidth)
        self.mDarkRectangle.setPen(QPen(Qt.NoPen))
        self.mDarkRectangle.setBrush(Qt.black)
        self.mDarkRectangle.setOpacity(darkeningFactor)
        self.addItem(self.mDarkRectangle)
        self.mGridVisible = prefs.showGrid()
        self.mObjectLineWidth = prefs.objectLineWidth()
        self.mShowTileObjectOutlines = prefs.showTileObjectOutlines()
        self.mHighlightCurrentLayer = prefs.highlightCurrentLayer()
        # Install an event filter so that we can get key events on behalf of the
        # active tool without having to have the current focus.
        QCoreApplication.instance().installEventFilter(self)
开发者ID:theall,项目名称:Python-Tiled,代码行数:42,代码来源:mapscene.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyqtgraph.image函数代码示例发布时间:2022-05-27
下一篇:
Python pyqtcore.QMap类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap