示例#1
0
    def readItemFromStream(self, stream, offset=0):
        type = ""
        position = QPointF()
        matrix = QTransform()

        rotateangle=0#add by yangrongdong
        type=stream.readQString()
        stream >> position >> matrix
        if offset:
            position += QPointF(offset, offset)
        if type == "文字2":
            text = ""
            font = QFont()
            text=stream.readQString()
            stream >> font
            item=TextItem(text, position, self.scene, font, matrix)
        elif type == "矩形2":
            rect = QRectF()
            stream >> rect
            style = Qt.PenStyle(stream.readInt16())
            brush = stream.readInt16()
            item=BoxItem(position, self.scene, style, brush, rect, matrix)
        elif type == "矩形":
            rect = QRectF()
            stream >> rect
            style = Qt.PenStyle(stream.readInt16())
            brush = stream.readInt16()
            item=BoxItem(position, self.scene, style, brush, rect, matrix)
        elif type == "图片":
            pixmap = QPixmap()
            stream >> pixmap
            item = GraphicsPixmapItem(self.scene, pixmap, 
                                      position, matrix)
            item.CompMode = stream.readInt16()
        if type in ('文字2','矩形','矩形2','图片'):
            sc          = stream.readFloat()
            rotateangle = stream.readFloat()
            item_Zvalue = stream.readInt16()
            item_order  = stream.readInt16()
            item_desc   = stream.readQString()
            item.setRotation(rotateangle)
            item.setScale(sc)
            #QMessageBox.warning(self, "read"+type, "ItemDesciption: "+item_desc)
            item.setZValue(item_Zvalue)
            item.setData(self.view.ItemId,item_order)
            item.setData(self.view.ItemDesciption, item_desc)