Пример #1
0
void MainWindow::slotShowRenderDialog()
{
    if (m_project->renderTask() != NULL) {
        disconnect(SIGNAL(signalRendererContinue()), m_project->renderTask());
    }
    
    RenderingDialog renderingDialog(m_project, this);
    if (renderingDialog.exec() == QDialog::Accepted) {
        
        RenderTask_sV *task = renderingDialog.buildTask();
        if (task != 0) {
            task->moveToThread(&m_rendererThread);
            
            if (m_project->renderTask() != NULL) {
                disconnect(SIGNAL(signalRendererContinue()), m_project->renderTask());
            }
            //m_project->replaceRenderTask(task);
            
            if (m_renderProgressDialog == NULL) {
                m_renderProgressDialog = new ProgressDialog(this);
                m_renderProgressDialog->setWindowTitle(tr("Rendering progress"));
            } else {
                m_renderProgressDialog->disconnect();
            }
            
            connect(task, SIGNAL(signalNewTask(QString,int)), m_renderProgressDialog, SLOT(slotNextTask(QString,int)));
            connect(task, SIGNAL(signalItemDesc(QString)), m_renderProgressDialog, SLOT(slotTaskItemDescription(QString)));
            connect(task, SIGNAL(signalTaskProgress(int)), m_renderProgressDialog, SLOT(slotTaskProgress(int)));
            connect(task, SIGNAL(signalRenderingFinished(QString)), m_renderProgressDialog, SLOT(slotAllTasksFinished(QString)));
            connect(task, SIGNAL(signalRenderingAborted(QString)), this, SLOT(slotRenderingAborted(QString)));
            connect(task, SIGNAL(signalRenderingAborted(QString)), m_renderProgressDialog, SLOT(close()));
            connect(task, SIGNAL(signalRenderingStopped(QString)), m_renderProgressDialog, SLOT(slotAborted(QString)));
            connect(m_renderProgressDialog, SIGNAL(signalAbortTask()), task, SLOT(slotStopRendering()));
            //connect(this, SIGNAL(signalRendererContinue()), task, SLOT(slotContinueRendering()), Qt::UniqueConnection);
            
            connect(task, SIGNAL(workFlowRequested()), &m_rendererThread, SLOT(start()));
            connect(&m_rendererThread, SIGNAL(started()), task, SLOT(slotContinueRendering()));
 
            connect(task, SIGNAL(signalRenderingFinished(QString)), &m_rendererThread, SLOT(quit()));
            // done another way ?!
            connect(task, SIGNAL(signalRenderingFinished(QString)), task, SLOT(deleteLater()));
             
            //connect(&m_rendererThread, &QThread::finished, task, &QObject::deleteLater);
            // let's start
            m_rendererThread.wait(); // If the thread is not running, this will immediately return.
            
            m_renderProgressDialog->show();
            
            //emit signalRendererContinue();
            //m_rendererThread.exec ();
            m_rendererThread.start();
            task->requestWork();
        }
    } else {
    	QMessageBox(QMessageBox::Warning, tr("Aborted"), tr("Aborted by user"), QMessageBox::Ok).exec();
    }
}
Пример #2
0
/**
 *  start an optical flow on a thread
 *
 *  @param threadid  the thread on which to run our flow
 *  @param frameSize size of frame for calcul (small/orig)
 *  @param direction flow direction
 */
void Project_sV::startFlow(int threadid,const FrameSize frameSize,int direction)
{
    thread[threadid] = new QThread();
    worker[threadid] = new WorkerFlow();
    
    // set on what to work ...
    worker[threadid]->setFrameSize(frameSize);
    worker[threadid]->setProject(this);
    worker[threadid]->setDirection(direction);
    worker[threadid]->setFlowSource(flowSource());
    
    worker[threadid]->moveToThread(thread[threadid]);
    //connect(worker, SIGNAL(valueChanged(QString)), ui->label, SLOT(setText(QString)));
    connect(worker[threadid], SIGNAL(workFlowRequested()), thread[threadid], SLOT(start()));
    connect(thread[threadid], SIGNAL(started()), worker[threadid], SLOT(doWorkFlow()));
    connect(worker[threadid], SIGNAL(finished()), thread[threadid], SLOT(quit()), Qt::DirectConnection);
    
    // let's start
    thread[threadid]->wait(); // If the thread is not running, this will immediately return.
    
    worker[threadid]->requestWork();
}