Esempio n. 1
0
static void connectProcessSlots(ProgressTaskInfo* task, ProcessHandler* process)
{
    QObject::connect(task,SIGNAL(taskCanceled()),process,SLOT(onProcessCanceled()));
    QObject::connect(process,SIGNAL(processCanceled()),task,SLOT(onProcessCanceled()));
    QObject::connect(process,SIGNAL(frameRendered(int,double)),task,SLOT(onRenderEngineFrameComputed(int,double)));
    QObject::connect(process,SIGNAL(processFinished(int)),task,SLOT(onRenderEngineStopped(int)));

}
void
RenderingProgressDialog::onProcessDeleted()
{
    assert(_imp->_process);
    QObject::disconnect( this,SIGNAL(canceled()),_imp->_process.get(),SLOT(onProcessCanceled()) );
    QObject::disconnect( _imp->_process.get(),SIGNAL(processCanceled()),this,SLOT(onProcessCanceled()) );
    QObject::disconnect( _imp->_process.get(),SIGNAL(frameRendered(int)),this,SLOT(onFrameRendered(int,double)) );
    QObject::disconnect( _imp->_process.get(),SIGNAL(processFinished(int)),this,SLOT(onProcessFinished(int)) );
    QObject::disconnect( _imp->_process.get(),SIGNAL(deleted()),this,SLOT(onProcessDeleted()) );
}
void
RenderingProgressDialog::onVideoEngineStopped(int retCode)
{
    if (retCode == 1) {
        onProcessCanceled();
    } else {
        onProcessFinished(0);
    }
}
Esempio n. 4
0
void
ProcessHandler::onDataWrittenToSocket()
{
    ///always running in the main thread
    assert( QThread::currentThread() == qApp->thread() );

    QString str = QString::fromUtf8(_bgProcessOutputSocket->readLine());
    while ( str.endsWith(QLatin1Char('\n')) ) {
        str.chop(1);
    }
    _processLog.append(QString::fromUtf8("Message received: ") + str + QLatin1Char('\n'));
    if ( str.startsWith(QString::fromUtf8(kFrameRenderedStringShort) )) {
        str = str.remove(QString::fromUtf8(kFrameRenderedStringShort));
        
        double progressPercent = 0.;
        int foundProgress = str.lastIndexOf(QString::fromUtf8(kProgressChangedStringShort));
        if (foundProgress != -1) {
            QString progressStr = str.mid(foundProgress);
            progressStr.remove(QString::fromUtf8(kProgressChangedStringShort));
            progressPercent = progressStr.toDouble();
            str = str.mid(0, foundProgress);
        }
        if (!str.isEmpty()) {
            //The report does not have extended timer infos
            Q_EMIT frameRendered(str.toInt(), progressPercent);
            
        }
        
    } else if ( str.startsWith(QString::fromUtf8(kRenderingFinishedStringShort)) ) {
        ///don't do anything
    } else if ( str.startsWith(QString::fromUtf8(kBgProcessServerCreatedShort)) ) {
        str = str.remove(QString::fromUtf8(kBgProcessServerCreatedShort));
        ///the bg process wants us to create the pipe for its input
        if (!_bgProcessInputSocket) {
            _bgProcessInputSocket = new QLocalSocket();
            QObject::connect( _bgProcessInputSocket, SIGNAL(connected()), this, SLOT(onInputPipeConnectionMade()) );
            _bgProcessInputSocket->connectToServer(str,QLocalSocket::ReadWrite);
        }
    } else if ( str.startsWith(QString::fromUtf8(kRenderingStartedShort)) ) {
        ///if the user pressed cancel prior to the pipe being created, wait for it to be created and send the abort
        ///message right away
        if (_earlyCancel) {
            _bgProcessInputSocket->waitForConnected(5000);
            _earlyCancel = false;
            onProcessCanceled();
        }
    } else {
        _processLog.append(QString::fromUtf8("Error: Unable to interpret message.\n"));
        throw std::runtime_error("ProcessHandler::onDataWrittenToSocket() received erroneous message");
    }
}
Esempio n. 5
0
void ProcessHandler::onDataWrittenToSocket() {
    
    ///always running in the main thread
    assert(QThread::currentThread() == qApp->thread());
    
    QString str = _bgProcessOutputSocket->readLine();
    while(str.endsWith('\n')) {
        str.chop(1);
    }
    _processLog.append("Message received: " + str + '\n');
    if (str.startsWith(kFrameRenderedStringShort)) {
        str = str.remove(kFrameRenderedStringShort);
        emit frameRendered(str.toInt());
    } else if (str.startsWith(kRenderingFinishedStringShort)) {
        ///don't do anything
    } else if (str.startsWith(kProgressChangedStringShort)) {
        str = str.remove(kProgressChangedStringShort);
        emit frameProgress(str.toInt());
        
    } else if (str.startsWith(kBgProcessServerCreatedShort)) {
        str = str.remove(kBgProcessServerCreatedShort);
        ///the bg process wants us to create the pipe for its input
        if (!_bgProcessInputSocket) {
            _bgProcessInputSocket = new QLocalSocket();
            QObject::connect(_bgProcessInputSocket, SIGNAL(connected()), this, SLOT(onInputPipeConnectionMade()));
            _bgProcessInputSocket->connectToServer(str,QLocalSocket::ReadWrite);
        }
    } else if(str.startsWith(kRenderingStartedShort)) {
        ///if the user pressed cancel prior to the pipe being created, wait for it to be created and send the abort
        ///message right away
        if (_earlyCancel) {
            _bgProcessInputSocket->waitForConnected(5000);
            _earlyCancel = false;
            onProcessCanceled();
        }
    } else {
        _processLog.append("Error: Unable to interpret message.\n");
        throw std::runtime_error("ProcessHandler::onDataWrittenToSocket() received erroneous message");
    }

}
RenderingProgressDialog::RenderingProgressDialog(Gui* gui,
                                                 const QString & sequenceName,
                                                 int firstFrame,
                                                 int lastFrame,
                                                 int frameStep,
                                                 const boost::shared_ptr<ProcessHandler> & process,
                                                 QWidget* parent)
    : QDialog(parent,Qt::WindowStaysOnTopHint)
      , _imp( new RenderingProgressDialogPrivate(gui,sequenceName,firstFrame,lastFrame,frameStep,process) )

{
    setMinimumWidth(fontMetrics().width(_imp->_sequenceName) + 100);
    setWindowTitle(_imp->_sequenceName);
    _imp->_mainLayout = new QVBoxLayout(this);
    setLayout(_imp->_mainLayout);
    _imp->_mainLayout->setContentsMargins(5, 5, 0, 0);
    _imp->_mainLayout->setSpacing(5);

    QWidget* totalProgressContainer = new QWidget(this);
    QHBoxLayout* totalProgressLayout = new QHBoxLayout(totalProgressContainer);
    _imp->_mainLayout->addWidget(totalProgressContainer);

    
    _imp->_totalProgressLabel = new Label(tr("Total progress:"),totalProgressContainer);
    totalProgressLayout->addWidget(_imp->_totalProgressLabel);
    
    _imp->_totalProgressInfo = new Label("0%",totalProgressContainer);
    totalProgressLayout->addWidget(_imp->_totalProgressInfo);
    
    QWidget* waitTimeContainer = new QWidget(this);
    QHBoxLayout* waitTimeLayout = new QHBoxLayout(waitTimeContainer);
    _imp->_mainLayout->addWidget(waitTimeContainer);

    _imp->_estimatedWaitTimeLabel = new Label(tr("Time remaining:"),waitTimeContainer);
    waitTimeLayout->addWidget(_imp->_estimatedWaitTimeLabel);
    
    _imp->_estimatedWaitTimeInfo = new Label("...",waitTimeContainer);
    waitTimeLayout->addWidget(_imp->_estimatedWaitTimeInfo);

    _imp->_totalProgressBar = new QProgressBar(this);
    _imp->_totalProgressBar->setRange(0, 100);
    _imp->_totalProgressBar->setMinimumWidth(150);
    
    _imp->_mainLayout->addWidget(_imp->_totalProgressBar);
    
    
    _imp->_cancelButton = new Button(tr("Cancel"),this);
    _imp->_cancelButton->setMaximumWidth(50);
    _imp->_mainLayout->addWidget(_imp->_cancelButton);

    QObject::connect( _imp->_cancelButton, SIGNAL(clicked()), this, SLOT(onCancelButtonClicked()) );


    if (process) {
        QObject::connect( this,SIGNAL(canceled()),process.get(),SLOT(onProcessCanceled()) );
        QObject::connect( process.get(),SIGNAL(processCanceled()),this,SLOT(onProcessCanceled()) );
        QObject::connect( process.get(),SIGNAL(frameRendered(int,double)),this,SLOT(onFrameRendered(int,double)) );
        QObject::connect( process.get(),SIGNAL(processFinished(int)),this,SLOT(onProcessFinished(int)) );
        QObject::connect( process.get(),SIGNAL(deleted()),this,SLOT(onProcessDeleted()) );
    }
}