-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmy_diagram_path_item.h
43 lines (35 loc) · 1.42 KB
/
my_diagram_path_item.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef MY_DIAGRAM_PATH_ITEM_H
#define MY_DIAGRAM_PATH_ITEM_H
namespace Ui
{
class My_diagram_path_item;
}
class My_diagram_arrow;
#include"QGraphicsPathItem"
class My_diagram_path_item : public QGraphicsPathItem
{
public:
enum { Type = UserType + 17 };//Ïåðå÷èñëåíèå Type ÿâëÿåòñÿ óíèêàëüíûì èäåíòèôèêàòîðîì êëàññà. Îí èñïîëüçóåòñÿ qgraphicsitem_cast(), êîòîðûé äåëàåò äèíàìè÷åñêîå ïðèâåäåíèå ãðàôè÷åñêèõ ýëåìåíòîâ. Êîíñòàíòà UserType ÿâëÿåòñÿ ìèíèìàëüíûì çíà÷åíèåì, êîòîðûì ìîæåò áûòü ïîëüçîâàòåëüñêèé òèï ãðàôè÷åñêîãî ýëåìåíòà.
enum DiagramType { Actor = 11 };
My_diagram_path_item(DiagramType diagramType, QMenu *contextMenu, QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
void removeArrow(My_diagram_arrow *arrow);
void removeArrows();
DiagramType diagramType() const
{ return myDiagramType; }
void addArrow(My_diagram_arrow *arrow);
QPainterPath get_path() const
{ return myPath; }
QPixmap image() const;
int type() const
{ return Type;}
QPolygonF poligon();
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
DiagramType myDiagramType;//Òèï ýëåìåòà (Êâàäðàò, ðîìá è ò.ä.)
QPainterPath myPath;
QMenu *myContextMenu;
QList<My_diagram_arrow *> arrows;// ñïèñîê ñòðåëîê êîòîðûå ñ íèì ñîåäèíåíû
};
#endif // MY_DIAGRAM_PATH_ITEM_H