OpenWalnut  1.5.0dev
WTransferFunctionLine.cpp
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 #include <iostream>
26 
27 #include "WTransferFunctionLine.h"
28 #include "WTransferFunctionPoint.h"
29 #include "WTransferFunctionWidget.h"
30 
31 #include "QPainter"
32 #include "QStyleOption"
33 #include "QGraphicsSceneMouseEvent"
34 
36  : BaseClass(), lineWidth( 2.0 ), left( 0x0 ), right( 0x0 )
37 {
38  setPen( QPen( Qt::black, lineWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
39  //this->setFlag( ItemIsMovable ); //< this has to be implemented
40  setZValue( 2 );
41  setOpacity( 0.6 );
42 }
43 
45 {
46 }
47 
49 {
50  left = point;
51 }
52 
54 {
55  return left;
56 }
57 
59 {
60  right = point;
61 }
62 
64 {
65  return right;
66 }
67 
68 void WTransferFunctionLine::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget* widget )
69 {
70  if( left && right )
71  {
72  // update the line before painting according to our neighboring points
73  QLineF line( left->pos(), right->pos() );
74  setLine( line );
75  }
76  else
77  {
78  //std::cout << "line not initialized, yet" << std::endl;
79  }
80  // base class does the pointing for us.
81  BaseClass::paint( painter, option, widget );
82 }
83 
void setRight(WTransferFunctionPoint *right)
Sets point to the right.
void setLeft(WTransferFunctionPoint *left)
Sets point to the left.
WTransferFunctionPoint * right
the point to the right
virtual ~WTransferFunctionLine()
Default destructor.
WTransferFunctionPoint * getLeft() const
Get the point to the left.
WTransferFunctionPoint * getRight() const
Get the point to the right.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Paint the line.
double lineWidth
the width of the line used for painting
WTransferFunctionPoint * left
the point to the left
WTransferFunctionLine(WTransferFunctionWidget *parent=0x0)
Default constructor.
A control point for the alpha function.
A widget that holds a scene to display and modify the transfer function.