mirror of
https://github.com/leozide/leocad
synced 2025-02-06 08:46:06 +01:00
Update to improved render dialog (#335)
This commit is contained in:
parent
94cf93ae8c
commit
56fbb2ce18
2 changed files with 32 additions and 2 deletions
|
@ -168,7 +168,9 @@ void lcRenderDialog::on_RenderButton_clicked()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mProcess = new QProcess(this);
|
mProcess = new QProcess(this);
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
connect(mProcess, SIGNAL(readyReadStandardError()), this, SLOT(ReadStdErr()));
|
connect(mProcess, SIGNAL(readyReadStandardError()), this, SLOT(ReadStdErr()));
|
||||||
|
#endif
|
||||||
mProcess->start(POVRayPath, Arguments);
|
mProcess->start(POVRayPath, Arguments);
|
||||||
|
|
||||||
if (mProcess->waitForStarted())
|
if (mProcess->waitForStarted())
|
||||||
|
@ -189,6 +191,7 @@ void lcRenderDialog::ReadStdErr()
|
||||||
{
|
{
|
||||||
QString StdErr = QString(mProcess->readAllStandardError());
|
QString StdErr = QString(mProcess->readAllStandardError());
|
||||||
mStdErrList.append(StdErr);
|
mStdErrList.append(StdErr);
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
QRegExp RegexPovRayProgress("Rendered (\\d+) of (\\d+) pixels.*");
|
QRegExp RegexPovRayProgress("Rendered (\\d+) of (\\d+) pixels.*");
|
||||||
RegexPovRayProgress.setCaseSensitivity(Qt::CaseInsensitive);
|
RegexPovRayProgress.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
if (RegexPovRayProgress.indexIn(StdErr) == 0)
|
if (RegexPovRayProgress.indexIn(StdErr) == 0)
|
||||||
|
@ -196,6 +199,7 @@ void lcRenderDialog::ReadStdErr()
|
||||||
ui->RenderProgress->setMaximum(RegexPovRayProgress.cap(2).toInt());
|
ui->RenderProgress->setMaximum(RegexPovRayProgress.cap(2).toInt());
|
||||||
ui->RenderProgress->setValue(RegexPovRayProgress.cap(1).toInt());
|
ui->RenderProgress->setValue(RegexPovRayProgress.cap(1).toInt());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcRenderDialog::Update()
|
void lcRenderDialog::Update()
|
||||||
|
@ -267,6 +271,11 @@ void lcRenderDialog::Update()
|
||||||
|
|
||||||
Header->PixelsRead = PixelsWritten;
|
Header->PixelsRead = PixelsWritten;
|
||||||
|
|
||||||
|
ui->RenderProgress->setMaximum(mImage.width() * mImage.height());
|
||||||
|
ui->RenderProgress->setValue(int(Header->PixelsRead));
|
||||||
|
|
||||||
|
ui->preview->setPixmap(QPixmap::fromImage(mImage.scaled(LC_POVRAY_PREVIEW_WIDTH, LC_POVRAY_PREVIEW_HEIGHT, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
|
||||||
|
|
||||||
if (PixelsWritten == Width * Height)
|
if (PixelsWritten == Width * Height)
|
||||||
ShowResult();
|
ShowResult();
|
||||||
#endif
|
#endif
|
||||||
|
@ -277,8 +286,10 @@ void lcRenderDialog::ShowResult()
|
||||||
ReadStdErr();
|
ReadStdErr();
|
||||||
ui->RenderProgress->setValue(ui->RenderProgress->maximum());
|
ui->RenderProgress->setValue(ui->RenderProgress->maximum());
|
||||||
|
|
||||||
if (mProcess->exitStatus() != QProcess::NormalExit || mProcess->exitCode() != 0)
|
bool Error = (mProcess->exitStatus() != QProcess::NormalExit || mProcess->exitCode() != 0);
|
||||||
|
if (Error)
|
||||||
{
|
{
|
||||||
|
WriteStdLog(Error);
|
||||||
QMessageBox error;
|
QMessageBox error;
|
||||||
error.setWindowTitle(tr("Error"));
|
error.setWindowTitle(tr("Error"));
|
||||||
error.setIcon(QMessageBox::Critical);
|
error.setIcon(QMessageBox::Critical);
|
||||||
|
@ -301,6 +312,24 @@ void lcRenderDialog::ShowResult()
|
||||||
if (!Result)
|
if (!Result)
|
||||||
QMessageBox::information(this, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, Writer.errorString()));
|
QMessageBox::information(this, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, Writer.errorString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteStdLog();
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcRenderDialog::WriteStdLog(bool Error){
|
||||||
|
QFile LogFile(QDir::toNativeSeparators(
|
||||||
|
QFileInfo(lcGetActiveProject()->GetFileName()).absolutePath() + "/" +
|
||||||
|
(Error ? "stderr-povrayrender" : "stdout-povrayrender")));
|
||||||
|
if (LogFile.open(QFile::WriteOnly | QIODevice::Truncate | QFile::Text)) {
|
||||||
|
QTextStream out(&LogFile);
|
||||||
|
foreach (QString line, mStdErrList) {
|
||||||
|
out << line;
|
||||||
|
}
|
||||||
|
LogFile.close();
|
||||||
|
} else {
|
||||||
|
QMessageBox::information(this, tr("Error"), tr("Error writing to %1 file '%2':\n%3")
|
||||||
|
.arg(Error ? "stderr" : "stdout").arg(LogFile.fileName(), LogFile.errorString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcRenderDialog::on_OutputBrowseButton_clicked()
|
void lcRenderDialog::on_OutputBrowseButton_clicked()
|
||||||
|
|
|
@ -22,6 +22,7 @@ public slots:
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void ReadStdErr();
|
void ReadStdErr();
|
||||||
|
void WriteStdLog(bool = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString GetOutputFileName() const;
|
QString GetOutputFileName() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue