void ProgressPanel::onItemRightClicked(QPoint globalPos, const TableItemPtr& item) { ProgressTaskInfoPtr task; { QMutexLocker k(&_imp->tasksMutex); task = _imp->findTask(item); } if (!task) { return; } ProcessHandlerPtr hasProcess = task->getProcess(); Menu m(this); QAction* showLogAction = 0; if (hasProcess) { showLogAction = new QAction(tr("Show Process Log"), &m); m.addAction(showLogAction); } QAction* triggered = 0; if ( !m.isEmpty() ) { triggered = m.exec(globalPos); } if ( (triggered == showLogAction) && showLogAction ) { const QString& log = hasProcess->getProcessLog(); LogWindowModal window(log,this); window.setWindowTitle( tr("Background Render Log") ); ignore_result(window.exec()); } }
void ProgressPanel::startTask(const NodePtr& node, const int firstFrame, const int lastFrame, const int frameStep, const bool canPause, const bool canCancel, const QString& message, const boost::shared_ptr<ProcessHandler>& process) { assert( QThread::currentThread() == qApp->thread() ); if (!node) { return; } assert( (canPause && firstFrame != INT_MIN && lastFrame != INT_MAX) || !canPause ); ProgressTaskInfoPtr task; { QMutexLocker k(&_imp->tasksMutex); task = _imp->findTask(node); } if (task) { task->cancelTask(false, 1); removeTaskFromTable(task); } QMutexLocker k(&_imp->tasksMutex); task.reset( new ProgressTaskInfo(this, node, firstFrame, lastFrame, frameStep, canPause, canCancel, message, process) ); if ( canPause || node->getEffectInstance()->isOutput() ) { task->createItems(); QTimer::singleShot( NATRON_DISPLAY_PROGRESS_PANEL_AFTER_MS, this, SLOT(onShowProgressPanelTimerTriggered()) ); } if (process) { connectProcessSlots( task.get(), process.get() ); } if (!process) { if ( node->getEffectInstance()->isOutput() ) { OutputEffectInstance* isOutput = dynamic_cast<OutputEffectInstance*>( node->getEffectInstance().get() ); if (isOutput) { boost::shared_ptr<RenderEngine> engine = isOutput->getRenderEngine(); assert(engine); QObject::connect( engine.get(), SIGNAL(frameRendered(int,double)), task.get(), SLOT(onRenderEngineFrameComputed(int,double)) ); QObject::connect( engine.get(), SIGNAL(renderFinished(int)), task.get(), SLOT(onRenderEngineStopped(int)) ); QObject::connect( task.get(), SIGNAL(taskCanceled()), engine.get(), SLOT(abortRendering_non_blocking()) ); } } }
void ProgressPanel::addTaskToTable(const ProgressTaskInfoPtr& task) { assert( QThread::currentThread() == qApp->thread() ); int rc = _imp->model->rowCount(); TableItemPtr item = task->getTableItem(); _imp->model->insertTopLevelItem(rc, item); task->setCellWidgets(rc, _imp->view); _imp->lastTaskAdded = task; _imp->tasksOrdered.push_back(task); }
void ProgressPanel::doProgressEndOnMainThread(const NodePtr& node) { ProgressTaskInfoPtr task; { QMutexLocker k(&_imp->tasksMutex); task = _imp->findTask(node); } if (!task) { return; } task->cancelTask(false, 0); task.reset(); }
void ProgressPanel::onTaskRestarted(const NodePtr& node, const boost::shared_ptr<ProcessHandler>& process) { QMutexLocker k(&_imp->tasksMutex); ProgressTaskInfoPtr task; task = _imp->findTask(node); if (!task) { return; } //The process may have changed if (process) { task->setProcesshandler(process); connectProcessSlots(task.get(), process.get()); } }
bool ProgressPanel::updateTask(const NodePtr& node, const double progress) { bool isMainThread = QThread::currentThread() == qApp->thread(); ProgressTaskInfoPtr foundTask; { QMutexLocker k(&_imp->tasksMutex); foundTask = _imp->findTask(node); } if (!foundTask) { return false; } if (!isMainThread) { Q_EMIT s_doProgressUpdateOnMainThread(foundTask, progress); } else { doProgressOnMainThread(foundTask, progress); } if ( foundTask->wasCanceled() ) { return false; } if (isMainThread) { if (_imp->processEventsRecursionCounter == 0) { ++_imp->processEventsRecursionCounter; { #ifdef DEBUG boost_adaptbx::floating_point::exception_trapping trap(0); #endif QCoreApplication::processEvents(); } --_imp->processEventsRecursionCounter; } } return true; }
void ProgressPanel::doProgressOnMainThread(const ProgressTaskInfoPtr& task, double progress) { task->updateProgressBar(progress, progress); }
void ProgressPanel::startTask(const NodePtr& node, const TimeValue firstFrame, const TimeValue lastFrame, const TimeValue frameStep, const bool canPause, const bool canCancel, const QString& message, const ProcessHandlerPtr& process) { assert( QThread::currentThread() == qApp->thread() ); if (!node) { return; } assert( (canPause && firstFrame != INT_MIN && lastFrame != INT_MAX) || !canPause ); ProgressTaskInfoPtr task; { QMutexLocker k(&_imp->tasksMutex); task = _imp->findTask(node); } if (task) { task->cancelTask(false, 1); removeTaskFromTable(task); } QMutexLocker k(&_imp->tasksMutex); task.reset( new ProgressTaskInfo(this, node, firstFrame, lastFrame, frameStep, canPause, canCancel, message, process) ); if ( canPause || node->getEffectInstance()->isOutput() ) { task->createItems(); QTimer::singleShot( NATRON_DISPLAY_PROGRESS_PANEL_AFTER_MS, this, SLOT(onShowProgressPanelTimerTriggered()) ); } if (process) { connectProcessSlots( task.get(), process.get() ); } if (!process) { if ( node->getEffectInstance()->isOutput() ) { if ( getGui() && !getGui()->isGUIFrozen() && appPTR->getCurrentSettings()->isAutoTurboEnabled() ) { getGui()->onFreezeUIButtonClicked(true); } RenderEnginePtr engine = node->getRenderEngine(); assert(engine); QObject::connect( engine.get(), SIGNAL(frameRendered(int,double)), task.get(), SLOT(onRenderEngineFrameComputed(int,double)) ); QObject::connect( engine.get(), SIGNAL(renderFinished(int)), task.get(), SLOT(onRenderEngineStopped(int)) ); QObject::connect( task.get(), SIGNAL(taskCanceled()), engine.get(), SLOT(abortRendering_non_blocking()) ); } } _imp->tasks[node] = task; } // ProgressPanel::startTask