DAWorkbench 0.0.1
DAWorkbench API
载入中...
搜索中...
未找到
DAWorkFlowGraphicsScene.h
1#ifndef DAWORKFLOWGRAPHICSSCENE_H
2#define DAWORKFLOWGRAPHICSSCENE_H
3#include <QGraphicsScene>
4#include "DAGuiAPI.h"
5#include <QHash>
6#include <QUndoStack>
7#include "DAWorkFlow.h"
8#include "DANodeGraphicsScene.h"
9
10class QGraphicsSceneWheelEvent;
11namespace DA
12{
13class DAGraphicsPixmapItem;
18{
19 Q_OBJECT
20public:
25 {
27 AddTextItemAction
28 };
29 Q_ENUM(SceneActionFlag)
30public:
31 DAWorkFlowGraphicsScene(QObject* parent = 0);
33 // 设置鼠标动作,一旦设置鼠标动作,鼠标点击后就会触发此动作,continuous来标记动作结束后继续保持还是还原为无动作
34 void setPreDefineSceneAction(SceneActionFlag mf);
35 //===================================================
36 // 背景图相关操作
37 //===================================================
38 // 设置背景item,如果外部调用getBackgroundPixmapItem并删除,需要通过此函数把保存的item设置为null
39 void setBackgroundPixmapItem(DAGraphicsPixmapItem* item);
40 DAGraphicsPixmapItem* removeBackgroundPixmapItem();
41 // 允许item跟随背景图移动
42 void enableItemMoveWithBackground(bool on);
43 // 允许移动图元时,其它和此图元链接起来的图元跟随移动
44 void setEnableItemLinkageMove(bool on);
45 bool isEnableItemLinkageMove() const;
46 // 是否item跟随背景图移动
47 bool isEnableItemMoveWithBackground() const;
48 // 添加一个背景图,如果多次调用,此函数返回的QGraphicsPixmapItem* 是一样的,也就是只会创建一个QGraphicsPixmapItem*
49 DAGraphicsPixmapItem* setBackgroundPixmap(const QPixmap& pixmap);
50 // 获取背景图item,如果没有设置返回一个nullptr
51 DAGraphicsPixmapItem* getBackgroundPixmapItem() const;
52
53 // 设置文本字体
54 QFont getDefaultTextFont() const;
55 void setDefaultTextFont(const QFont& f);
56 // 设置文本颜色
57 QColor getDefaultTextColor() const;
58 void setDefaultTextColor(const QColor& c);
59
60protected:
61 DAGraphicsPixmapItem* ensureGetBackgroundPixmapItem();
62 DAGraphicsPixmapItem* createBackgroundPixmapItem();
63
64protected:
65#if 0
66 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
67 virtual void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
68 virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
69 virtual void dropEvent(QGraphicsSceneDragDropEvent* event) override;
70#endif
71
72private slots:
73#if DA_USE_QGRAPHICSOBJECT
74 void backgroundPixmapItemXChanged();
75 void backgroundPixmapItemYChanged();
76#endif
77 void onItemsPositionChanged(const QList< QGraphicsItem* >& items,
78 const QList< QPointF >& oldPos,
79 const QList< QPointF >& newPos);
80
81private:
82 DAGraphicsPixmapItem* mBackgroundPixmapItem;
83 SceneActionFlag mMouseAction;
84 bool mEnableItemMoveWithBackground;
85 bool mEnableItemLinkageMove { false };
86 QColor mTextColor;
87 QFont mTextFont;
88 QPointF mBackgroundPixmapItemLastPos;
89};
90} // end of namespace DA
91#endif // GGRAPHICSSCENE_H
支持缩放编辑的图片item
Definition DAGraphicsPixmapItem.h:13
DAAbstractNodeGraphicsItem对应的QGraphicsScene,通过此scene,管理DAWorkFlow内容
Definition DANodeGraphicsScene.h:25
The DAWorkFlowGraphicsScene class
Definition DAWorkFlowGraphicsScene.h:18
SceneActionFlag
鼠标动作标记
Definition DAWorkFlowGraphicsScene.h:25
@ AddRectItemAction
开始添加矩形
Definition DAWorkFlowGraphicsScene.h:26
序列化类都是带异常的,使用中需要处理异常
Definition AppMainWindow.cpp:44