OpenWalnut  1.5.0dev
WTransferFunctionPoint.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
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.
14 //
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.
19 //
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/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WTRANSFERFUNCTIONPOINT_H
26 #define WTRANSFERFUNCTIONPOINT_H
27 
28 #include "QGraphicsItem"
29 
32 
33 /**
34  * A control point for the alpha function.
35  *
36  * Internals:
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.
39  */
41 {
42 public:
43  /** type of the base class */
45 
46  /**
47  * Default constructor.
48  *
49  * \param parent pointer to parent widget
50  */
51  explicit WTransferFunctionPoint( WTransferFunctionWidget* parent = NULL );
52 
53  /**
54  * Default destructor.
55  */
56  virtual ~WTransferFunctionPoint();
57 
58  /**
59  * Set point to the left.
60  *
61  * \param left new point to the left
62  */
64 
65  /**
66  * Get point to the left.
67  *
68  * \returns point to the left
69  */
71 
72  /**
73  * Set point to the right.
74  *
75  * \param right new point to the right
76  */
78 
79  /**
80  * Get point to the right.
81  *
82  * \returns point to the right
83  */
85 
86  /**
87  * Set the line pointing to the right.
88  *
89  * \param line the new line
90  */
92 
93  /**
94  * The current line if there is one. NULL if not.
95  *
96  * \returns the line if any has been set (i.e., may be 0)
97  */
99 
100  /**
101  * Get the bounding rectangle.
102  *
103  * \returns the bounding rect of this object
104  */
105  QRectF boundingRect() const;
106 
107  /**
108  * Paint the object.
109  *
110  * \param painter the painter to use
111  * \param option the options for painting
112  */
113  virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget* );
114 
115  /**
116  * Overloaded form base class for debugging.
117  *
118  * \param point the point that should be set
119  */
120  virtual void setPos( QPointF point );
121 
122 protected:
123  /**
124  * Helper to itemChange.
125  *
126  * \param pos position that is clamped to rectangle
127  * \param rectangle the rectangle
128  */
129  void clampToRectangle( QPointF* const pos, const QRectF& rectangle ) const;
130 
131  /**
132  * Helper to itemChange.
133  *
134  * \param pos the position that is clamped between the left and right neighbors
135  */
136  void clampToLeftAndRight( QPointF* const pos ) const;
137 
138  /**
139  * Handle item changes and change requests.
140  *
141  * \param change the proposed change
142  * \param value the proposed value
143  * \returns the requested change
144  */
145  QVariant itemChange( GraphicsItemChange change, const QVariant &value );
146 
147  /**
148  * Handle mouse press events for selections and highlighting.
149  *
150  * \param event the handled event
151  */
152  void mousePressEvent( QGraphicsSceneMouseEvent *event );
153 
154 private:
155  /** the radius of the object */
156  double radius;
157 
158  /** pointer to point to the left*/
160  /** pointer to point to the right*/
162 
163  /** pointer to line to the right */
165 
166  /** reference to the parent widget */
168 };
169 
170 #endif // WTRANSFERFUNCTIONPOINT_H
171 
Line object for the connection of alpha control points.
A control point for the alpha function.
QRectF boundingRect() const
Get the bounding rectangle.
WTransferFunctionPoint * getLeft() const
Get point to the left.
WTransferFunctionPoint * left
pointer to point to the left
virtual ~WTransferFunctionPoint()
Default destructor.
void mousePressEvent(QGraphicsSceneMouseEvent *event)
Handle mouse press events for selections and highlighting.
WTransferFunctionLine * getLine() const
The current line if there is one.
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Handle item changes and change requests.
WTransferFunctionLine * line
pointer to line to the right
WTransferFunctionPoint * getRight() const
Get point to the right.
WTransferFunctionPoint * right
pointer to point to the right
virtual void setPos(QPointF point)
Overloaded form base class for debugging.
void clampToLeftAndRight(QPointF *const pos) const
Helper to itemChange.
void setLeft(WTransferFunctionPoint *left)
Set point to the left.
void setRight(WTransferFunctionPoint *right)
Set point to the right.
void setLine(WTransferFunctionLine *line)
Set the line pointing to the right.
double radius
the radius of the object
WTransferFunctionPoint(WTransferFunctionWidget *parent=NULL)
Default constructor.
WTransferFunctionWidget * _parent
reference to the parent widget
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
Paint the object.
void clampToRectangle(QPointF *const pos, const QRectF &rectangle) const
Helper to itemChange.
QGraphicsItem BaseClass
type of the base class
A widget that holds a scene to display and modify the transfer function.