~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to src/qt4gui/controlPanel/transferFunction/WTransferFunctionPoint.h

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "QtGui/QGraphicsItem"
 
29
 
 
30
class WTransferFunctionWidget;
 
31
class WTransferFunctionLine;
 
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
 */
 
40
class WTransferFunctionPoint : public QGraphicsItem
 
41
{
 
42
public:
 
43
    /** type of the base class */
 
44
    typedef QGraphicsItem BaseClass;
 
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
     */
 
63
    void setLeft( WTransferFunctionPoint* left );
 
64
 
 
65
    /**
 
66
     * Get point to the left.
 
67
     *
 
68
     * \returns point to the left
 
69
     */
 
70
    WTransferFunctionPoint *getLeft() const;
 
71
 
 
72
    /**
 
73
     * Set point to the right.
 
74
     *
 
75
     * \param right new point to the right
 
76
     */
 
77
    void setRight( WTransferFunctionPoint* right );
 
78
 
 
79
     /**
 
80
     * Get point to the right.
 
81
     *
 
82
     * \returns point to the right
 
83
     */
 
84
    WTransferFunctionPoint *getRight() const;
 
85
 
 
86
     /**
 
87
      * Set the line pointing to the right.
 
88
      *
 
89
      * \param line the new line
 
90
      */
 
91
    void setLine( WTransferFunctionLine* line );
 
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
      */
 
98
    WTransferFunctionLine* getLine() const;
 
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*/
 
159
    WTransferFunctionPoint *left;
 
160
    /** pointer to point to the right*/
 
161
    WTransferFunctionPoint *right;
 
162
 
 
163
    /** pointer to line to the right */
 
164
    WTransferFunctionLine *line;
 
165
 
 
166
    /** reference to the parent widget */
 
167
    WTransferFunctionWidget* _parent;
 
168
};
 
169
 
 
170
#endif  // WTRANSFERFUNCTIONPOINT_H
 
171