Esempio n. 1
0
int lh_hydracache(lua_State *L) {
  checkArg(L, 2, "hydracache");
  int id = luaInt(1);
  int val = luaInt(2);
  cacheMap(id, val);
  return 1;
  }
Esempio n. 2
0
void EqCurve::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
{
    painter->setRenderHint( QPainter::Antialiasing, true );
    if( m_modelChanged )
    {
        setModelChanged( false );
        //counts the active bands
        int activeHandles=0;
        for ( int thatHandle = 0; thatHandle<m_handle->count(); thatHandle++ )
        {
            if ( m_handle->at(thatHandle)->isActiveHandle() == true )
            {
                activeHandles++;
            }
        }
        //Computes the main curve
        //if a band is active the curve will be computed by averaging the curves of each band
        QMap<float,float> mainCurve;
        for ( int thatHandle = 0; thatHandle<m_handle->count(); thatHandle++ )
        {
            if ( m_handle->at(thatHandle)->isActiveHandle() == true )
            {
                for ( int x = 0; x < m_width ; x=x+1 )
                {
                    if ( m_handle->at( thatHandle )->getType() == highpass )
                    {
                        mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getLowCutCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
                    }
                    if ( m_handle->at(thatHandle)->getType() == lowshelf )
                    {
                        mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getLowShelfCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
                    }
                    if ( m_handle->at( thatHandle )->getType() == para )
                    {
                        mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getPeakCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
                    }
                    if ( m_handle->at( thatHandle )->getType() == highshelf )
                    {
                        mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getHighShelfCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
                    }
                    if ( m_handle->at(thatHandle)->getType() == lowpass )
                    {
                        mainCurve[x]= ( mainCurve[x] + ( m_handle->at( thatHandle )->getHighCutCurve( x ) * ( activeHandles ) ) - ( ( activeHandles * ( m_heigth/2 ) ) - m_heigth ) );
                    }
                }
            }
        }
        //compute a QPainterPath
        m_curve = QPainterPath();
        for ( int x = 0; x < m_width ; x++ )
        {
            mainCurve[x] = ( ( mainCurve[x] / activeHandles ) ) - ( m_heigth/2 );
            if ( x==0 )
            {
                m_curve.moveTo( x, mainCurve[x] );
            }
            m_curve.lineTo( x, mainCurve[x] );
        }
        //we cache the curve painting in a pixmap for saving cpu
        QPixmap cacheMap( boundingRect().size().toSize() );
        cacheMap.fill( QColor( 0, 0, 0, 0 ) );
        QPainter cachePainter( &cacheMap );
        cachePainter.setRenderHint( QPainter::Antialiasing, true );
        QPen pen;
        pen.setWidth( 2 );
        pen.setColor( Qt::white );
        cachePainter.setPen( pen );
        cachePainter.drawPath( m_curve );
        cachePainter.end();

        m_curvePixmapCache.fill( QColor( 0, 0, 0, 0 ) );
        m_curvePixmapCache.swap( cacheMap );
    }
    //we paint our cached curve pixmap
    painter->drawPixmap( 0, 0, m_width, m_heigth, m_curvePixmapCache );
    // if mouse hover a handle, m_alpha counts up slow for blend in the filled EQ curve
    // todo: a smarter way of this "if-monster"
    QColor curveColor;
    if( m_handle->at( 0 )->isMouseHover()
            || m_handle->at( 1 )->isMouseHover()
            || m_handle->at( 2 )->isMouseHover()
            || m_handle->at( 3 )->isMouseHover()
            || m_handle->at( 4 )->isMouseHover()
            || m_handle->at( 5 )->isMouseHover()
            || m_handle->at( 6 )->isMouseHover()
            || m_handle->at( 7 )->isMouseHover()
      )
    {
        if ( m_alpha < 40 )
        {
            m_alpha = m_alpha + 10;
        }
    }
    else
    {
        if ( m_alpha > 0 )
        {
            m_alpha = m_alpha - 10;
        }
    }
    //draw on mouse hover the curve of hovered filter in different colors
    for ( int i = 0; i < m_handle->count(); i++ )
    {
        if ( m_handle->at(i)->isMouseHover() )
        {
            switch ( i+1 )
            {
            case 1:
                curveColor = QColor( 163, 23, 23, 10*m_alpha/4 );
                break;
            case 2:
                curveColor = QColor( 229,108,0, 10*m_alpha/4 );
                break;
            case 3:
                curveColor = QColor( 255,240,0, 10*m_alpha/4 );
                break;
            case 4:
                curveColor = QColor( 12, 255, 0, 10*m_alpha/4 );
                break;
            case 5:
                curveColor = QColor( 0, 252, 255, 10*m_alpha/4 );
                break;
            case 6:
                curveColor = QColor( 59, 96, 235, 10*m_alpha/4 );
                break;
            case 7:
                curveColor = QColor( 112, 73, 255, 10*m_alpha/4 );
                break;
            case 8:
                curveColor = QColor( 255, 71, 227, 10*m_alpha/4 );
            }
            QPen pen ( curveColor);
            pen.setWidth( 2 );
            painter->setPen( pen );
            painter->drawPath( m_handle->at( i )->getCurvePath() );
        }
    }
    //draw on mouse hover the EQ curve filled. with m_alpha it blends in and out smooth
    QPainterPath cPath;
    cPath.addPath( m_curve );
    cPath.lineTo( cPath.currentPosition().x(), m_heigth );
    cPath.lineTo( cPath.elementAt( 0 ).x  , m_heigth );
    painter->fillPath( cPath, QBrush ( QColor( 255,255,255, m_alpha ) ) );
}