30 #include "WTransferFunctionHistogram.h" 
   31 #include "WTransferFunctionWidget.h" 
   34 #include "QStyleOption" 
   35 #include "QGraphicsSceneMouseEvent" 
   50     return scene()->sceneRect();
 
   55     const int steps = 
m_data.size();
 
   58         double maxval = *std::max_element( 
m_data.begin(), 
m_data.end() );
 
   61             QRadialGradient gradient( 0.0, 0.0, 10 );
 
   62             painter->setBrush( gradient );
 
   63             gradient.setColorAt( 0, Qt::white );
 
   64             gradient.setColorAt( 1, Qt::black );
 
   66             painter->setBrush( gradient );
 
   71                 QRectF bb( this->scene()->sceneRect() );
 
   72                 histogram << QPoint( bb.right(), bb.bottom() );
 
   73                 histogram << QPoint( bb.left(), bb.bottom() );
 
   75                 for( 
int i = 0; i < steps; ++i )
 
   81                     histogram << QPoint( bb.left()+ ( 
double )bb.width()*( 
double )i/( 
double )steps,
 
   82                               bb.bottom() - ( 
double )bb.height() * std::log( 
m_data[ i ]+1 )/std::log( maxval+1+0.001 ) );
 
   84                 painter->drawPolygon( histogram );
 
   95                 QRectF bb( this->scene()->sceneRect() );
 
   96                 histogram << QPoint( bb.right(), bb.bottom() );
 
   97                 histogram << QPoint( bb.left(), bb.bottom() );
 
   99                 for( 
int i = 0; i < steps; ++i )
 
  102                     histogram << QPoint( bb.left()+ ( 
double )bb.width()*( 
double )i/( 
double )steps,
 
  103                               bb.bottom() - ( 
double )bb.height() * 
m_data[ i ]/maxval );
 
  105                 painter->drawPolygon( histogram );
 
WTransferFunctionHistogram(WTransferFunctionWidget *parent=0x0)
Default constructor.
 
virtual ~WTransferFunctionHistogram()
Default destructor.
 
QRectF boundingRect() const
Get the bounding rect of the histogram.
 
std::vector< double > m_data
the histogram data
 
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
Paint a semi-transparent histogram on top of the transfer function but below the input handles.
 
const std::vector< double > & getData() const
Get histogram data.