1 /*******************************************************************
2 
3 Part of the Fritzing project - http://fritzing.org
4 Copyright (c) 2007-2014 Fachhochschule Potsdam - http://fh-potsdam.de
5 
6 Fritzing is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 Fritzing is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with Fritzing.  If not, see <http://www.gnu.org/licenses/>.
18 
19 ********************************************************************
20 
21 $Revision: 6904 $:
22 $Author: irascibl@gmail.com $:
23 $Date: 2013-02-26 16:26:03 +0100 (Di, 26. Feb 2013) $
24 
25 ********************************************************************/
26 
27 
28 
29 #ifndef PEGRAPHICSITEM_H_
30 #define PEGRAPHICSITEM_H_
31 
32 #include <QGraphicsRectItem>
33 #include <QDomElement>
34 #include <QGraphicsSceneHoverEvent>
35 #include <QTimer>
36 #include <QPointer>
37 #include <QTime>
38 #include <QBrush>
39 
40 class PEGraphicsItem : public QObject, public QGraphicsRectItem
41 {
42     Q_OBJECT
43 public:
44 	PEGraphicsItem(double x, double y, double width, double height, class ItemBase *);
45 	~PEGraphicsItem();
46 
47 	void hoverEnterEvent(QGraphicsSceneHoverEvent *);
48 	void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
49     void wheelEvent(QGraphicsSceneWheelEvent *);
50 	void mousePressEvent(QGraphicsSceneMouseEvent *);
51 	void mouseMoveEvent(QGraphicsSceneMouseEvent *);
52 	void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
53     void setHighlighted(bool);
54     bool highlighted();
55     void setElement(QDomElement &);
56     QDomElement & element();
57     void setOffset(QPointF);
58     QPointF offset();
59     void showTerminalPoint(bool);
60     bool showingTerminalPoint();
61 	void showMarquee(bool);
62 	bool showingMarquee();
63     void setTerminalPoint(QPointF);
64     QPointF terminalPoint();
65     void setPendingTerminalPoint(QPointF);
66     QPointF pendingTerminalPoint();
67     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
68 	void setPickAppearance(bool);
69     void flash();
70     class ItemBase * itemBase();
71 
72 signals:
73     void highlightSignal(PEGraphicsItem *);
74     void mousePressedSignal(PEGraphicsItem *, bool & ignore);
75     void mouseReleasedSignal(PEGraphicsItem *);
76     void terminalPointMoved(PEGraphicsItem *, QPointF);
77     void terminalPointChanged(PEGraphicsItem *, QPointF before, QPointF after);
78 
79 protected slots:
80     void restoreColor();
81 
82 protected:
83     bool m_highlighted;
84     bool m_flash;
85     QDomElement  m_element;
86     QPointF m_offset;
87     bool m_showTerminalPoint;
88     bool m_showMarquee;
89     QPointF m_terminalPoint;
90     QPointF m_pendingTerminalPoint;
91     bool m_dragTerminalPoint;
92     QPointF m_dragTerminalOrigin;
93     QPointF m_terminalPointOrigin;
94     bool m_drawHighlight;
95     int m_wheelAccum;
96     qreal m_savedOpacity;
97     bool m_pick;
98     class ItemBase * m_itemBase;
99 };
100 
101 #endif /* PEGRAPHICSITEM_H_ */
102