WorkflowFileRendererDialog.cpp 3.03 KB
Newer Older
1 2 3
/*****************************************************************************
 * WorkflowFileRendererDialog.cpp: Display a render feedback.
 *****************************************************************************
Ludovic Fauvet's avatar
Ludovic Fauvet committed
4
 * Copyright (C) 2008-2010 VideoLAN
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
 *          Christophe Courtaut <christophe.courtaut@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

24
#include "WorkflowFileRendererDialog.h"
25 26 27

#include "vlmc.h"
#include "MainWorkflow.h"
28
#include "WorkflowFileRenderer.h"
29

30 31
WorkflowFileRendererDialog::WorkflowFileRendererDialog( WorkflowFileRenderer* renderer,
                                                        quint32 width, quint32 height ) :
32
        m_width( width ),
33 34
        m_height( height ),
        m_renderer( renderer )
35 36
{
    m_ui.setupUi( this );
37 38
    connect( m_ui.cancelButton, SIGNAL( clicked() ), m_renderer, SLOT( stop() ) );
    connect( m_ui.cancelButton, SIGNAL( clicked() ), this, SLOT( close() ) );
39
    connect( m_renderer, SIGNAL( renderComplete() ), this, SLOT( accept() ) );
40 41 42 43
    connect( m_renderer, SIGNAL( frameChanged( qint64 ) ), this, SLOT( frameChanged( qint64 ) ) );
    connect( m_renderer, SIGNAL( imageUpdated( const uchar* ) ),
             this, SLOT( updatePreview( const uchar* ) ),
             Qt::QueuedConnection );
44 45
}

46 47
void
WorkflowFileRendererDialog::setOutputFileName( const QString& outputFileName )
48 49
{
    m_ui.nameLabel->setText( outputFileName );
50
    m_ui.previewLabel->setMinimumSize( m_width, m_height );
51 52 53
    setWindowTitle( "Rendering to " + outputFileName );
}

54 55
void
WorkflowFileRendererDialog::setProgressBarValue( int val )
56 57 58
{
    m_ui.progressBar->setValue( val );
}
59

60 61
void
WorkflowFileRendererDialog::updatePreview( const uchar* buff )
62
{
63
    m_ui.previewLabel->setPixmap(
64
            QPixmap::fromImage( QImage( buff, m_width, m_height,
65
                                        QImage::Format_RGB32 ) ) );
66
}
67

68 69
void
WorkflowFileRendererDialog::frameChanged( qint64 frame )
70
{
71 72 73 74 75 76 77 78
    qint64 totalFrames = MainWorkflow::getInstance()->getLengthFrame();

    if ( frame <= totalFrames )
    {
        m_ui.frameCounter->setText( tr("Rendering frame %1 / %2").arg(QString::number( frame ),
                                        QString::number( totalFrames ) ) );
        setProgressBarValue( frame * 100 / totalFrames );
    }
79
}