DAWorkbench 0.0.1
DAWorkbench API
载入中...
搜索中...
未找到
DAGraphicsLabelItem.h
1#ifndef DAGRAPHICSLABELITEM_H
2#define DAGRAPHICSLABELITEM_H
3#include <QFont>
4#include <QGraphicsSimpleTextItem>
5#include <QVersionNumber>
6#include "DAGraphicsViewGlobal.h"
7#include "DAXMLFileInterface.h"
8#include "DAShapeKeyPoint.h"
9class QDomDocument;
10class QDomElement;
11namespace DA
12{
13
17class DAGRAPHICSVIEW_API DAGraphicsLabelItem : public QGraphicsSimpleTextItem, public DAXMLFileInterface
18{
19 DA_DECLARE_PRIVATE(DAGraphicsLabelItem)
20public:
24 enum
25 {
27 };
28 int type() const override
29 {
30 return (Type);
31 }
32
33public:
34 DAGraphicsLabelItem(QGraphicsItem* parent = nullptr);
35 DAGraphicsLabelItem(const QString& str, QGraphicsItem* parent = nullptr);
37 // 保存到xml中
38 virtual bool saveToXml(QDomDocument* doc, QDomElement* parentElement, const QVersionNumber& ver) const override;
39 virtual bool loadFromXml(const QDomElement* itemElement, const QVersionNumber& ver) override;
40 // 获取item的id,id是这个id唯一的标识,id主要为了能单独的找到这个item,在分组加载时使用
41 uint64_t getItemID() const;
42 void setItemID(uint64_t id);
43 // 设置相对父窗口的相对定位
44 void setRelativePosition(qreal xp, qreal yp);
45 QPointF getRelativePosition() const;
46 bool isHaveRelativePosition() const;
47 // 设置吸附点,如果设置了吸附点,那么RelativePosition无效
48 void setAttachPoint(DAShapeKeyPoint parentAttachPoint);
49 // 原点,原点主要用于对齐
50 void setOriginPoint(DAShapeKeyPoint originPoint);
51 DAShapeKeyPoint getOriginPoint() const;
52 // 更新相对位置
53 void updatePosition();
54 // 设置是否被选中
55 void setSelectable(bool on);
56
57protected:
58 virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) override;
59};
60}
61#endif // DAGRAPHICSLABELITEM_H
The DAGraphicsLabelItem class
Definition DAGraphicsLabelItem.h:18
所有支持xml文件保存的类继承于它,从而提供saveToXml和loadFromXml接口
Definition DAXMLFileInterface.h:29
序列化类都是带异常的,使用中需要处理异常
Definition AppMainWindow.cpp:44
@ ItemType_DAGraphicsLabelItem
标准label
Definition DAGraphicsViewGlobal.h:77