1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
23
//---------------------------------------------------------------------------
25
#ifndef WTRANSFERFUNCTIONPOINT_H
26
#define WTRANSFERFUNCTIONPOINT_H
28
#include "QtGui/QGraphicsItem"
30
class WTransferFunctionWidget;
31
class WTransferFunctionLine;
34
* A control point for the alpha function.
37
* The point has pointers to its left and right neighbors (double-linked list)
38
* and a pointer to the line connecting this point to the next point to the right.
40
class WTransferFunctionPoint : public QGraphicsItem
43
/** type of the base class */
44
typedef QGraphicsItem BaseClass;
47
* Default constructor.
49
* \param parent pointer to parent widget
51
explicit WTransferFunctionPoint( WTransferFunctionWidget* parent = NULL );
56
virtual ~WTransferFunctionPoint();
59
* Set point to the left.
61
* \param left new point to the left
63
void setLeft( WTransferFunctionPoint* left );
66
* Get point to the left.
68
* \returns point to the left
70
WTransferFunctionPoint *getLeft() const;
73
* Set point to the right.
75
* \param right new point to the right
77
void setRight( WTransferFunctionPoint* right );
80
* Get point to the right.
82
* \returns point to the right
84
WTransferFunctionPoint *getRight() const;
87
* Set the line pointing to the right.
89
* \param line the new line
91
void setLine( WTransferFunctionLine* line );
94
* The current line if there is one. NULL if not.
96
* \returns the line if any has been set (i.e., may be 0)
98
WTransferFunctionLine* getLine() const;
101
* Get the bounding rectangle.
103
* \returns the bounding rect of this object
105
QRectF boundingRect() const;
110
* \param painter the painter to use
111
* \param option the options for painting
113
virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget* );
116
* Overloaded form base class for debugging.
118
* \param point the point that should be set
120
virtual void setPos( QPointF point );
124
* Helper to itemChange.
126
* \param pos position that is clamped to rectangle
127
* \param rectangle the rectangle
129
void clampToRectangle( QPointF* const pos, const QRectF& rectangle ) const;
132
* Helper to itemChange.
134
* \param pos the position that is clamped between the left and right neighbors
136
void clampToLeftAndRight( QPointF* const pos ) const;
139
* Handle item changes and change requests.
141
* \param change the proposed change
142
* \param value the proposed value
143
* \returns the requested change
145
QVariant itemChange( GraphicsItemChange change, const QVariant &value );
148
* Handle mouse press events for selections and highlighting.
150
* \param event the handled event
152
void mousePressEvent( QGraphicsSceneMouseEvent *event );
155
/** the radius of the object */
158
/** pointer to point to the left*/
159
WTransferFunctionPoint *left;
160
/** pointer to point to the right*/
161
WTransferFunctionPoint *right;
163
/** pointer to line to the right */
164
WTransferFunctionLine *line;
166
/** reference to the parent widget */
167
WTransferFunctionWidget* _parent;
170
#endif // WTRANSFERFUNCTIONPOINT_H