Hardware Design: SIE
Sign in or create your account | Project List | Help
Hardware Design: SIE Git Source Tree
Root/
| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 4 | ** All rights reserved. |
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com) |
| 6 | ** |
| 7 | ** This file is part of the examples of the Qt Toolkit. |
| 8 | ** |
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 10 | ** Commercial Usage |
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in |
| 12 | ** accordance with the Qt Commercial License Agreement provided with the |
| 13 | ** Software or, alternatively, in accordance with the terms contained in |
| 14 | ** a written agreement between you and Nokia. |
| 15 | ** |
| 16 | ** GNU Lesser General Public License Usage |
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 18 | ** General Public License version 2.1 as published by the Free Software |
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
| 20 | ** packaging of this file. Please review the following information to |
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| 23 | ** |
| 24 | ** In addition, as a special exception, Nokia gives you certain additional |
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception |
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| 27 | ** |
| 28 | ** GNU General Public License Usage |
| 29 | ** Alternatively, this file may be used under the terms of the GNU |
| 30 | ** General Public License version 3.0 as published by the Free Software |
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the |
| 32 | ** packaging of this file. Please review the following information to |
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be |
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. |
| 35 | ** |
| 36 | ** If you have questions regarding the use of this file, please contact |
| 37 | ** Nokia at qt-info@nokia.com. |
| 38 | ** $QT_END_LICENSE$ |
| 39 | ** |
| 40 | ****************************************************************************/ |
| 41 | |
| 42 | #ifndef DIAGRAMITEM_H |
| 43 | #define DIAGRAMITEM_H |
| 44 | |
| 45 | #include <QGraphicsPixmapItem> |
| 46 | #include <QGraphicsSimpleTextItem> |
| 47 | #include <QList> |
| 48 | #include <QtXml> |
| 49 | #include <stdio.h> |
| 50 | |
| 51 | class Arrow; |
| 52 | class DiagramTextItem; |
| 53 | |
| 54 | QT_BEGIN_NAMESPACE |
| 55 | class QPixmap; |
| 56 | class QGraphicsItem; |
| 57 | class QGraphicsScene; |
| 58 | class QTextEdit; |
| 59 | class QGraphicsSceneMouseEvent; |
| 60 | class QMenu; |
| 61 | class QGraphicsSceneContextMenuEvent; |
| 62 | class QPainter; |
| 63 | class QStyleOptionGraphicsItem; |
| 64 | class QWidget; |
| 65 | class QPolygonF; |
| 66 | QT_END_NAMESPACE |
| 67 | |
| 68 | class QObject; |
| 69 | |
| 70 | class DiagramItem : public QGraphicsPolygonItem |
| 71 | { |
| 72 | public: |
| 73 | enum { Type = UserType + 15 }; |
| 74 | |
| 75 | DiagramItem(QMenu *contextMenu, |
| 76 | QString diagramType, |
| 77 | QDomElement *domElement, |
| 78 | QGraphicsItem *parent = 0, QGraphicsScene *scene = 0, |
| 79 | QPointF position = QPointF(0,0), double zV=500); |
| 80 | |
| 81 | void removeArrow(Arrow *arrow); |
| 82 | void removeArrows(); |
| 83 | void addArrow(Arrow *arrow); |
| 84 | |
| 85 | void addText(DiagramTextItem *externalTextItem) |
| 86 | { textItems.append(externalTextItem);} |
| 87 | |
| 88 | void removeTextItem(DiagramTextItem *textItem); |
| 89 | void removeTextItems(); |
| 90 | |
| 91 | QString diagramType() const |
| 92 | { return myDiagramType; } |
| 93 | |
| 94 | QPolygonF polygon() const |
| 95 | { return myPolygon; } |
| 96 | |
| 97 | QDomElement *getDomElement() |
| 98 | {return myDomElement;} |
| 99 | |
| 100 | QPixmap image() const; |
| 101 | |
| 102 | int type() const |
| 103 | { return Type;} |
| 104 | |
| 105 | QList<DiagramTextItem *> getTextItems() const |
| 106 | { return textItems;} |
| 107 | |
| 108 | QList<Arrow *> getArrows() const |
| 109 | { return arrows;} |
| 110 | |
| 111 | unsigned char existArrow(DiagramTextItem *startItem, |
| 112 | DiagramTextItem *endItem); |
| 113 | |
| 114 | void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); |
| 115 | void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); |
| 116 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); |
| 117 | |
| 118 | QDomElement toXml(QDomDocument &) const; |
| 119 | |
| 120 | bool setValue(unsigned char ioID, QString value); |
| 121 | DiagramTextItem * pointerText(unsigned char ID); |
| 122 | bool textIsIO(unsigned char ID); |
| 123 | |
| 124 | void setColor(const QColor &color) |
| 125 | { myColor=color; setBrush(color); } |
| 126 | |
| 127 | int getID() |
| 128 | { return myID;} |
| 129 | |
| 130 | void setID(int value) |
| 131 | { myID=value;} |
| 132 | |
| 133 | bool existText(DiagramTextItem * text); |
| 134 | |
| 135 | QGraphicsScene * getOwnerScene() |
| 136 | { return myOwnerScene;} |
| 137 | |
| 138 | void updateTexts(); |
| 139 | |
| 140 | protected: |
| 141 | void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); |
| 142 | QVariant itemChange(GraphicsItemChange change, const QVariant &value); |
| 143 | |
| 144 | private: |
| 145 | QGraphicsScene *myOwnerScene; |
| 146 | QString myDiagramType; |
| 147 | int myID; |
| 148 | QPolygonF myPolygon; |
| 149 | QMenu *myContextMenu; |
| 150 | QList<Arrow *> arrows; |
| 151 | QList<DiagramTextItem *> textItems; |
| 152 | DiagramTextItem *textItem; |
| 153 | QColor myColor; |
| 154 | QDomElement *myDomElement; |
| 155 | bool positionChanged; |
| 156 | }; |
| 157 | |
| 158 | #endif |
| 159 |
Branches:
master
