Developer Documentation
Loading...
Searching...
No Matches
connectionPoint.hh
1/*===========================================================================*\
2* *
3* OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39* *
40\*===========================================================================*/
41
42
43
44#ifndef VSI_CONNECTIONPOINT_HH
45#define VSI_CONNECTIONPOINT_HH
46
47//== INCLUDES =================================================================
48#include <QGraphicsItem>
49#include <QGraphicsLayoutItem>
50#include <QGraphicsSceneMouseEvent>
51#include <QString>
52#include <QTimer>
53#include <QPointF>
54
55//== NAMESPACES ===============================================================
56namespace VSI {
57
58//== FORWARDDECLARATIONS ======================================================
59class GraphicsScene;
60class ElementInOut;
61
62//== CLASS DEFINITION =========================================================
63
67class ConnectionPoint : public QObject, public QGraphicsEllipseItem, public QGraphicsLayoutItem
68{
69 Q_OBJECT
70 Q_INTERFACES(QGraphicsLayoutItem)
71
72 public:
73
75 enum State {
76 NoValue = 0,
77 Optional = 1,
78 RuntimeInput = 2,
79 UserInput = 3,
80 Connected = 4,
81 OutputNotConnected = 5
82 };
83
85 ConnectionPoint (ElementInOut *_e, QGraphicsItem *_parent);
86
89
91 ElementInOut *inOut () const { return inout_; };
92
94 QPointF connectPos ();
95
97 virtual void setGeometry (const QRectF &_rect);
98
100 void setState (State _state);
101
103 void setWidth (int _width);
104
105 // painting
106 void paint (QPainter *_painter, const QStyleOptionGraphicsItem *_option, QWidget *_widget = 0);
107
108 protected:
109
110 // start a new connection on press
111 void mousePressEvent (QGraphicsSceneMouseEvent *_event);
112
113 // highlight connection if mouse over
114 void hoverEnterEvent (QGraphicsSceneHoverEvent *_event);
115 void hoverLeaveEvent (QGraphicsSceneHoverEvent *_event);
116
117 // size informations for layouting
118 virtual QSizeF sizeHint ( Qt::SizeHint _which, const QSizeF & _constraint = QSizeF()) const;
119
120 private:
121
122 ElementInOut *inout_;
123
124 int width_;
125};
126
127}
128
129#endif
State
State of the connection point.
QPointF connectPos()
Position for connections.
void setWidth(int _width)
Sets the diameter.
ElementInOut * inOut() const
Input/output element.
~ConnectionPoint()
Destructor.
void setState(State _state)
sets the state
virtual void setGeometry(const QRectF &_rect)
Sets the geometry.