70 lines
2.4 KiB
C++
70 lines
2.4 KiB
C++
#ifndef GRAPHICSFUNCTIONMODELITEM_H
|
||
#define GRAPHICSFUNCTIONMODELITEM_H
|
||
|
||
#include "graphicsItem/graphicsBaseItem.h"
|
||
#include "propertyType/configEventData.h"
|
||
|
||
class BaseItemPropertyProxy;
|
||
class GraphicsEventContext;
|
||
class EventExecutor;
|
||
|
||
class GraphicsFunctionModelItem : public GraphicsProjectModelItem //功能模item
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
Q_PROPERTY(QMap<QString,bool> PropertyVisible READ getMap WRITE setMap)
|
||
Q_PROPERTY(EventList Events READ getEvents WRITE setEvents)
|
||
public:
|
||
GraphicsFunctionModelItem(QGraphicsItem *parent);
|
||
virtual ~GraphicsFunctionModelItem();
|
||
|
||
QMap<QString,bool> getMap(); //bool值为数据源指针类型
|
||
void setMap(QMap<QString,bool>);
|
||
|
||
void setPropertyProxy(BaseItemPropertyProxy* p) {_pPropertyProxy = p;}
|
||
BaseItemPropertyProxy* getPropertyProxy() {return _pPropertyProxy;}
|
||
|
||
EventList getEvents() const;
|
||
void setEvents(const EventList& events);
|
||
void triggerEvents(const QString& triggerType);
|
||
|
||
QSharedPointer<GraphicsEventContext> eventContext() const {
|
||
return m_eventContext;
|
||
}
|
||
protected:
|
||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||
void executeEvent(const EventData& event);
|
||
protected:
|
||
BaseItemPropertyProxy* _pPropertyProxy; //属性页代理
|
||
QVector<EventData> m_events; //HMI组态的事件
|
||
QSharedPointer<GraphicsEventContext> m_eventContext;
|
||
QSharedPointer<EventExecutor> m_eventExecutor;
|
||
};
|
||
|
||
|
||
class GraphicsFunctionModelGroup : public GraphicsFunctionModelItem //功能模group
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
GraphicsFunctionModelGroup(QGraphicsItem *parent);
|
||
virtual ~GraphicsFunctionModelGroup();
|
||
virtual void addItem(GraphicsFunctionModelItem* item);
|
||
virtual void updateLayout();
|
||
virtual void setLayout(int n) {m_direction = n;}
|
||
virtual void setGroupType(int n) {_groupType = n;}
|
||
virtual int getGroupType() {return _groupType;}
|
||
virtual void setSpacing(qreal spacing) {
|
||
if (m_spacing != spacing) {
|
||
m_spacing = spacing;
|
||
updateLayout();
|
||
}
|
||
}
|
||
QRectF updateBoundRect();
|
||
protected:
|
||
QList<GraphicsBaseItem*> m_childItems;
|
||
int m_direction = 1; //组内布局,0横1纵
|
||
int m_spacing = 0; //间距
|
||
int _groupType = 0; //组类型,0联合(子item独立连接),1聚合(子item仅作展示)
|
||
};
|
||
#endif
|