MNE-CPP  beta 1.0
pluginitem.h
Go to the documentation of this file.
1 //=============================================================================================================
36 #ifndef PLUGINITEM_H
37 #define PLUGINITEM_H
38 
40 
41 #include <QGraphicsPixmapItem>
42 #include <QLinearGradient>
43 #include <QList>
44 
45 class QPixmap;
46 class QGraphicsItem;
47 class QGraphicsScene;
48 class QGraphicsSceneMouseEvent;
49 class QMenu;
50 class QGraphicsSceneContextMenuEvent;
51 class QPainter;
52 class QStyleOptionGraphicsItem;
53 class QWidget;
54 class QPolygonF;
55 
56 
57 
58 //*************************************************************************************************************
59 //=============================================================================================================
60 // DEFINE NAMESPACE MNEX
61 //=============================================================================================================
62 
63 namespace MNEX
64 {
65 
66 class Arrow;
67 
68 
69 
70 class PluginItem : public QGraphicsPolygonItem
71 {
72 public:
73  enum { Type = UserType + 15 };
74  PluginItem(IPlugin::SPtr pPlugin, QMenu *contextMenu, QGraphicsItem *parent = 0);
75 
76  ~PluginItem();
77 
78  void removeArrow(Arrow *arrow);
79  void removeArrows();
80  IPlugin::PluginType diagramType() const { return m_pPlugin->getType(); }
81  IPlugin::SPtr plugin() { return m_pPlugin; }
82 
83  QPolygonF polygon() const { return m_qPolygon; }
84  void addArrow(Arrow *arrow);
85  QPixmap image() const;
86 
87  int type() const { return Type;}
88 
89  void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
90 
91 protected:
92  void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
93  QVariant itemChange(GraphicsItemChange change, const QVariant &value);
94 
95 private:
96  IPlugin::SPtr m_pPlugin;
97 
98  qint32 m_iWidth;
99  qint32 m_iHeight;
100  QPolygonF m_qPolygon;
101 
102  QLinearGradient m_qLinearGradientFace;
103  QColor m_qColorContour;
104 
105  QMenu *m_contextMenu;
106  QList<Arrow *> arrows;
107 };
108 
109 } //NAMESPACE
110 
111 #endif // PLUGINITEM_H
Contains declaration of IPlugin interface class.
QSharedPointer< IPlugin > SPtr
Definition: IPlugin.h:108
Definition: arrow.h:75