Beispiel #1
0
void CropWindowTool::preRender()
{
    const Box2f resolutionGate = static_cast<SceneView *>( view() )->resolutionGate();
    if( resolutionGate.isEmpty() )
    {
        m_overlay->setVisible( false );
        return;
    }

    if( !activePlug()->getValue() )
    {
        return;
    }

    m_overlay->setVisible( true );

    if( !m_overlayDirty )
    {
        return;
    }

    Box2f cropWindow( V2f( 0 ), V2f( 1 ) );
    findCropWindowPlug();
    if( m_cropWindowPlug )
    {
        cropWindow = m_cropWindowPlug->getValue();
    }

    BlockedConnection blockedConnection( m_overlayRectangleChangedConnection );
    m_overlay->setRectangle(
        Box2f(
            V2f(
                lerp( resolutionGate.min.x, resolutionGate.max.x, cropWindow.min.x ),
                lerp( resolutionGate.min.y, resolutionGate.max.y, cropWindow.min.y )
            ),
            V2f(
                lerp( resolutionGate.min.x, resolutionGate.max.x, cropWindow.max.x ),
                lerp( resolutionGate.min.y, resolutionGate.max.y, cropWindow.max.y )
            )
        )
    );

    m_overlayDirty = false;
}