more natural stop/preview button behavior
parent
20c5a58cf4
commit
2f6e02abf3
|
@ -123,7 +123,7 @@ struct SceneContext {
|
||||||
float progress;
|
float progress;
|
||||||
QString eta, progressName;
|
QString eta, progressName;
|
||||||
ref<Bitmap> framebuffer;
|
ref<Bitmap> framebuffer;
|
||||||
EMode mode;
|
EMode mode, cancelMode;
|
||||||
Float gamma, exposure, clamping;
|
Float gamma, exposure, clamping;
|
||||||
bool srgb;
|
bool srgb;
|
||||||
int pathLength, shadowMapResolution;
|
int pathLength, shadowMapResolution;
|
||||||
|
|
|
@ -456,9 +456,12 @@ void GLWidget::timerImpulse() {
|
||||||
if (m_context->renderJob) {
|
if (m_context->renderJob) {
|
||||||
m_context->renderJob->cancel();
|
m_context->renderJob->cancel();
|
||||||
m_context->cancelled = true;
|
m_context->cancelled = true;
|
||||||
|
m_context->cancelMode = EPreview;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else if (m_context->mode != EPreview) {
|
||||||
m_context->mode = EPreview;
|
m_context->mode = EPreview;
|
||||||
|
// causes updateUI to be called in the main window
|
||||||
|
emit stopRendering();
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPreview();
|
resetPreview();
|
||||||
|
@ -658,8 +661,8 @@ void GLWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
if (!m_preview->isRunning())
|
if (!m_preview->isRunning())
|
||||||
return;
|
return;
|
||||||
if (event->buttons() == 0) {
|
if (event->buttons() == 0) {
|
||||||
if (m_didSetCursor) {
|
|
||||||
m_mouseButtonDown = false;
|
m_mouseButtonDown = false;
|
||||||
|
if (m_didSetCursor) {
|
||||||
resetPreview();
|
resetPreview();
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
QCursor::setPos(m_initialMousePos);
|
QCursor::setPos(m_initialMousePos);
|
||||||
|
|
|
@ -499,6 +499,7 @@ void MainWindow::onProgressMessage(const RenderJob *job, const QString &name,
|
||||||
context->progressName = name + ": ";
|
context->progressName = name + ": ";
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionOpen_triggered() {
|
void MainWindow::on_actionOpen_triggered() {
|
||||||
QFileDialog *dialog = new QFileDialog(this, Qt::Sheet);
|
QFileDialog *dialog = new QFileDialog(this, Qt::Sheet);
|
||||||
dialog->setNameFilter(tr("Mitsuba scenes (*.xml);;EXR images (*.exr)"));
|
dialog->setNameFilter(tr("Mitsuba scenes (*.xml);;EXR images (*.exr)"));
|
||||||
|
@ -662,23 +663,10 @@ void MainWindow::updateUI() {
|
||||||
bool fallback = ui->glView->isUsingSoftwareFallback();
|
bool fallback = ui->glView->isUsingSoftwareFallback();
|
||||||
|
|
||||||
ui->actionStop->setEnabled(isShowingRendering);
|
ui->actionStop->setEnabled(isShowingRendering);
|
||||||
if (isShowingRendering && !isRendering) {
|
if (isShowingRendering && !isRendering)
|
||||||
if (ui->actionStop->text() != tr("Preview")) {
|
|
||||||
QIcon icon;
|
|
||||||
ui->actionStop->setText(tr("Preview"));
|
|
||||||
ui->actionStop->setToolTip(tr("Return to the realtime preview"));
|
ui->actionStop->setToolTip(tr("Return to the realtime preview"));
|
||||||
icon.addFile(QString::fromUtf8(":/resources/fpreview.png"), QSize(), QIcon::Normal, QIcon::Off);
|
else
|
||||||
ui->actionStop->setIcon(icon);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (ui->actionStop->text() != tr("Stop")) {
|
|
||||||
QIcon icon;
|
|
||||||
ui->actionStop->setText(tr("Stop"));
|
|
||||||
ui->actionStop->setToolTip(tr("Stop rendering"));
|
ui->actionStop->setToolTip(tr("Stop rendering"));
|
||||||
icon.addFile(QString::fromUtf8(":/resources/stop.png"), QSize(), QIcon::Normal, QIcon::Off);
|
|
||||||
ui->actionStop->setIcon(icon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->actionRender->setEnabled(isInactiveScene);
|
ui->actionRender->setEnabled(isInactiveScene);
|
||||||
ui->actionRefresh->setEnabled(isInactiveScene);
|
ui->actionRefresh->setEnabled(isInactiveScene);
|
||||||
|
@ -1133,6 +1121,7 @@ void MainWindow::on_actionRender_triggered() {
|
||||||
scene->setBlockSize(m_blockSize);
|
scene->setBlockSize(m_blockSize);
|
||||||
context->renderJob = new RenderJob("rend", scene, m_renderQueue, NULL,
|
context->renderJob = new RenderJob("rend", scene, m_renderQueue, NULL,
|
||||||
context->sceneResID, -1, -1, false);
|
context->sceneResID, -1, -1, false);
|
||||||
|
context->cancelMode = ERender;
|
||||||
if (context->mode != ERender)
|
if (context->mode != ERender)
|
||||||
ui->glView->downloadFramebuffer();
|
ui->glView->downloadFramebuffer();
|
||||||
context->cancelled = false;
|
context->cancelled = false;
|
||||||
|
@ -1358,6 +1347,7 @@ void MainWindow::onJobFinished(const RenderJob *job, bool cancelled) {
|
||||||
tr("The rendering job did not complete successfully. Please check the log."),
|
tr("The rendering job did not complete successfully. Please check the log."),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
} else {
|
} else {
|
||||||
|
context->mode = context->cancelMode;
|
||||||
if (ui->tabBar->currentIndex() != -1 &&
|
if (ui->tabBar->currentIndex() != -1 &&
|
||||||
m_context[ui->tabBar->currentIndex()] == context)
|
m_context[ui->tabBar->currentIndex()] == context)
|
||||||
ui->glView->resumePreview();
|
ui->glView->resumePreview();
|
||||||
|
|
Loading…
Reference in New Issue