28 #include "QStyleOption"
29 #include "QGraphicsSceneMouseEvent"
31 #include "WTransferFunctionWidget.h"
33 #include "WTransferFunctionPoint.h"
36 :
BaseClass(), radius( 6.0 ), left( 0x0 ), right( 0x0 ), line( 0x0 ), _parent( parent )
38 this->setFlag( ItemIsMovable );
39 this->setFlag( ItemSendsGeometryChanges );
82 const double padding( 2 );
83 const double diameter(
radius * 2 );
84 return QRectF( -
radius - padding, -
radius - padding, diameter + padding, diameter + padding );
89 QRadialGradient gradient( 0.0, 0.0,
radius );
91 if( option->state & QStyle::State_Sunken )
93 gradient.setColorAt( 0, QColor( Qt::yellow ).lighter( 120 ) );
94 gradient.setColorAt( 1, QColor( Qt::darkYellow ).lighter( 120 ) );
95 painter->setPen( QPen( Qt::red, 0 ) );
99 gradient.setColorAt( 0, Qt::yellow );
100 gradient.setColorAt( 1, Qt::darkYellow );
101 painter->setPen( QPen( Qt::black, 0 ) );
104 painter->setBrush( gradient );
106 const double diameter(
radius*2 );
107 painter->drawEllipse( -
radius, -
radius, diameter, diameter );
124 return BaseClass::itemChange( change, value );
126 if( ( change == ItemPositionHasChanged || change == ItemPositionChange ) && scene() )
128 QPointF newPos = value.toPointF();
130 QRectF boundingBox( this->scene()->sceneRect() );
134 newPos = ( QPointF( 0, newPos.y() ) );
139 newPos = ( QPointF( boundingBox.x() + boundingBox.width(), newPos.y() ) );
148 this->setToolTip( QString(
"isovalue=" ) + QString::number( newPos.x() ) +
" alpha=" + QString::number( newPos.y() ) );
151 return BaseClass::itemChange( change, value );
157 BaseClass::mousePressEvent( event );
167 if( pos->x() <=
left->pos().x() )
169 ( *pos ) = QPointF(
left->pos().x() + 1, pos->y() );
174 if( pos->x() >=
right->pos().x() )
176 ( *pos ) = QPointF(
right->pos().x() - 1, pos->y() );
187 const qreal xMin( rectangle.x() );
188 const qreal xMax( xMin + rectangle.width() );
189 const qreal yMin( rectangle.y() );
190 const qreal yMax( yMin + rectangle.height() );
198 ( *pos ) = QPointF( x, y );
203 BaseClass::setPos( point );
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.