DAWorkbench 0.0.1
DAWorkbench API
载入中...
搜索中...
未找到
DAGraphicsItem.h
1#ifndef DAGRAPHICSITEM_H
2#define DAGRAPHICSITEM_H
3#include <QGraphicsObject>
4#include "DAUtils/DAXMLFileInterface.h"
5#include "DAGraphicsViewGlobal.h"
6class QDomDocument;
7class QDomElement;
8
9namespace DA
10{
11class DAGraphicsScene;
18class DAGRAPHICSVIEW_API DAGraphicsItem : public QGraphicsObject, public DAXMLFileInterface
19{
20 Q_OBJECT
21 DA_DECLARE_PRIVATE(DAGraphicsItem)
22public:
23 enum
24 {
26 };
27 virtual int type() const override
28 {
29 return (Type);
30 }
31
32public:
33 DAGraphicsItem(QGraphicsItem* parent = nullptr);
35 // 保存到xml中
36 virtual bool saveToXml(QDomDocument* doc, QDomElement* parentElement, const QVersionNumber& ver) const override;
37 virtual bool loadFromXml(const QDomElement* parentElement, const QVersionNumber& ver) override;
38 // 设置边框画笔,如果设置一个QPen,则不绘制边框
39 void setBorderPen(const QPen& p);
40 QPen getBorderPen() const;
41 // 设置是否显示边框
42 void setShowBorder(bool on);
43 bool isShowBorder() const;
44 // 允许选中
45 void setSelectable(bool on = true);
46 bool isSelectable() const;
47 // 是否允许移动
48 void setMovable(bool on = true);
49 bool isMovable() const;
50 // 背景
51 void setBackgroundBrush(const QBrush& b);
52 QBrush getBackgroundBrush() const;
53 // 设置是否显示背景
54 void enableShowBackground(bool on);
55 bool isShowBackground() const;
56 // 分组位置发生改变的事件
57 virtual void groupPositionChanged(const QPointF& p);
58 // 设置在场景的位置,如果没有分组,和setPos一样,如果分组了,最终也能保证位置在pos位置
59 void setScenePos(const QPointF& p);
60 void setScenePos(qreal x, qreal y);
61 // 获取item的id,id是这个id唯一的标识,id主要为了能单独的找到这个item,在分组加载时使用
62 uint64_t getItemID() const;
63 void setItemID(uint64_t id);
64 // dynamic_cast为DAGraphicsItem
65 static DAGraphicsItem* cast(QGraphicsItem* i);
66 // 判断是否为只读模式
67 bool isSceneReadOnly() const;
68
69protected:
70 // 获取DAGraphicsScene
71 DAGraphicsScene* daScene() const;
72 virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) override;
73};
74
75}
76
77#endif // DAGRAPHICSITEM_H
DAGraphicsView的基本元件
Definition DAGraphicsItem.h:19
这是带着undostack的GraphicsScene 此QGraphicsScene支持:
Definition DAGraphicsScene.h:30
所有支持xml文件保存的类继承于它,从而提供saveToXml和loadFromXml接口
Definition DAXMLFileInterface.h:29
序列化类都是带异常的,使用中需要处理异常
Definition AppMainWindow.cpp:44
@ ItemType_DAGraphicsItem
针对DAGraphicsResizeableItem的类型
Definition DAGraphicsViewGlobal.h:75