Exemplo n.º 1
0
void KoColorPanel::keyPressEvent( QKeyEvent* e )
{
    Position newPos( validPosition( m_focusPosition ) );
    if ( e->key() == Qt::Key_Up ) {
        if ( newPos.y == 0 )
            e->ignore();
        else
            --newPos.y;
    }
    else if ( e->key() == Qt::Key_Down ) {
        if ( newPos < Position( m_colorMap.count() % COLS, lines() - 2 ) )
            ++newPos.y;
        else
            e->ignore();
    }
    else if ( e->key() == Qt::Key_Left ) {
        if ( newPos.x == 0 )
            e->ignore();
        else
            --newPos.x;
    }
    else if ( e->key() == Qt::Key_Right ) {
        if ( newPos.x < COLS - 1 && newPos < Position( m_colorMap.count() % COLS - 1, lines() - 1 ) )
            ++newPos.x;
        else
            e->ignore();
    }
    else if ( e->key() == Qt::Key_Return ) {
        if ( isVisible() && parentWidget() && parentWidget()->inherits( "QPopupMenu" ) )
            parentWidget()->close();
        emit colorSelected( mapToColor( m_focusPosition ) );
    }
    updateFocusPosition( newPos );
}
Exemplo n.º 2
0
void KoColorPanel::mouseMoveEvent( QMouseEvent* e )
{
    if ( e->state() & Qt::LeftButton ) {
        QPoint p = m_pressedPos - e->pos();
        if ( p.manhattanLength() > QApplication::startDragDistance() ) {
            QColor color( mapToColor( m_pressedPos ) );
            if ( color.isValid() ) {
                KColorDrag *drag = new KColorDrag( color, this, name() );
                drag->dragCopy();
            }
        }
    }
    else
        updateFocusPosition( mapToPosition( e->pos() ) );
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool ScalarMapperRangeBased::updateTexture(TextureImage* image) const
{
    CVF_ASSERT(image);

    image->allocate(m_textureSize, 1);

    // For now fill with white so we can see any errors more easily
    image->fill(Color4ub(Color3::WHITE));

    uint ic;
    for (ic = 0; ic < m_textureSize; ic++)
    {
        const Color4ub clr(mapToColor(domainValue(((double)ic)/(m_textureSize-1))), 255); 
        image->setPixel(ic, 0, clr);
    }
 
    return true;
}
Exemplo n.º 4
0
QColor KoColorPanel::mapToColor( const QPoint& point ) const
{
    return mapToColor( mapToPosition( point ) );
}
Exemplo n.º 5
0
void KoColorPanel::mouseReleaseEvent( QMouseEvent* )
{
    if ( isVisible() && parentWidget() && parentWidget()->inherits( "QPopupMenu" ) )
        parentWidget()->close();
    emit colorSelected( mapToColor( m_pressedPos ) );
}