Skip to content

Commit

Permalink
Blender render #416
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Sep 20, 2020
1 parent 5a363be commit 79221f8
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 130 deletions.
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 23, 2019
# Copyright (c) 2017 - 2020 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.0.1760
pkgver=2.4.0.1761
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/alldeps/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lpub3d (2.4.0.1760) debian; urgency=medium
lpub3d (2.4.0.1761) debian; urgency=medium

* LPub3D version 2.4.0.1.1760_20200920 for Linux
* LPub3D version 2.4.0.1.1761_20200920 for Linux

-- Trevor SANDY <[email protected]> Sun, 20 Sep 2020 10:08:43 +0200
-- Trevor SANDY <[email protected]> Sun, 20 Sep 2020 10:09:23 +0200
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/debian/lpub3d.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.0.1760
Version: 2.4.0.1761
Maintainer: Trevor SANDY <[email protected]>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/alldeps/lpub3d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.0.1760
Version: 2.4.0.1761
Release: <B_CNT>%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -728,5 +728,5 @@ update-mime-database /usr/share/mime >/dev/null || true
update-desktop-database || true
%endif

* Sun Sep 20 2020 - trevor.dot.sandy.at.gmail.dot.com 2.4.0.1760
* Sun Sep 20 2020 - trevor.dot.sandy.at.gmail.dot.com 2.4.0.1761
- LPub3D Linux package (rpm) release
Binary file modified builds/utilities/ci/secure/.secrets.tar.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion builds/utilities/version.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2 4 0 1 1760 d177c6f
2 4 0 1 1761 5a363be
2 changes: 1 addition & 1 deletion mainApp/docs/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LPub3D 2.4.0.1.1760 (20 09 2020 10:08:43)
LPub3D 2.4.0.1.1761 (20 09 2020 10:09:23)

Features, enhancements, fixes and changes
------------
Expand Down
2 changes: 1 addition & 1 deletion mainApp/docs/RELEASE_NOTES.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table class="tg">
<tr>
<th class="tg-0pky">
<h4><a id="LPub3D_0"></a>LPub3D 2.4.0.1.1760 (20 09 2020 10:08:43)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.0.1.1761 (20 09 2020 10:09:23)</h4>
<hr>
<p>
LPub3D Continuous release.<br>
Expand Down
208 changes: 124 additions & 84 deletions mainApp/metagui.cpp

Large diffs are not rendered by default.

19 changes: 7 additions & 12 deletions mainApp/metagui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,7 @@ public slots:
void setDefaultColor(int value) const;
void colorButtonClicked(bool);
void setModelSize(bool);
void validateColourScheme(QString const &);

void update();
void reject();
Expand Down Expand Up @@ -1859,9 +1860,8 @@ public slots:
LBL_ENVIRONMENT_PATH, // 2 QLineEdit/QPushButton
LBL_LDCONFIG_PATH, // 3 QLineEdit/QPushButton
LBL_LDRAW_DIRECTORY, // 4 QLineEdit/QPushButton
LBL_IMAGES_DIRECTORY, // 5 QLineEdit/QPushButton
LBL_LSYNTH_DIRECTORY, // 6 QLineEdit/QPushButton
LBL_STUDLOGO_DIRECTORY, // 7 QLineEdit/QPushButton
LBL_LSYNTH_DIRECTORY, // 5 QLineEdit/QPushButton
LBL_STUDLOGO_DIRECTORY, // 6 QLineEdit/QPushButton

NUM_BLENDER_PATHS
};
Expand Down Expand Up @@ -1972,8 +1972,8 @@ public slots:
};

struct ComboOptItems {
QString valueStr;
QString labelStr;
QString data;
QString items;
};

static BlenderSettings blenderSettings [];
Expand All @@ -1982,15 +1982,10 @@ public slots:
static BlenderSettings defaultPaths [];
static ComboOptItems comboOptItems [];

static QString ldrawDirectoryKey;
static QString customLDConfigKey;
static QString fadeStepsKey;
static QString highlightStepKey;
static bool documentRender;
static QString blenderVersion;
static QString searchDirectoriesKey;
static QString parameterFileKey;
static QString blenderVersion;

static bool documentRender;

QAction *defaultColourEditAction;
QAction *blenderPathEditAction;
Expand Down
2 changes: 1 addition & 1 deletion mainApp/nativeviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ void Gui::saveCurrent3DViewerModel(const QString &modelFile)
ActiveView->SetCamera(cameraName/*cameraName.toLatin1().constData()*/);

// Save the current model
if (!lcGetActiveProject()->Save(modelFile, true /*saveImageSize*/))
if (!lcGetActiveProject()->Save(modelFile))
emit gui->messageSig(LOG_ERROR, QString("Failed to save current model to file [%1]").arg(modelFile));

// Reset the camera
Expand Down
2 changes: 1 addition & 1 deletion mainApp/org.trevorsandy.lpub3d.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<binary>lpub3d24</binary>
​</provides>
<releases>
<release version="2.4.0.1760" date="2020-09-20">
<release version="2.4.0.1761" date="2020-09-20">
<description>
<p>LPub3D Linux AppImage package</p>
</description>
Expand Down
65 changes: 48 additions & 17 deletions mainApp/renderdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "paths.h"
#include "lpub.h"
#include "metagui.h"
#include "parmswindow.h"

#define RENDER_DEFAULT_WIDTH 1280
#define RENDER_DEFAULT_HEIGHT 720
Expand Down Expand Up @@ -49,6 +50,7 @@ RenderDialog::RenderDialog(QWidget* Parent, int renderType, int importOnly)

ui->OutputEdit->setText(Render::getRenderImageFile(renderType));
ui->OutputEdit->setValidator(new QRegExpValidator(QRegExp("^.*\\.png$",Qt::CaseInsensitive)));
ui->StandardOutButton->setEnabled(false);

mCsiKeyList = gui->getViewerConfigKey(mViewerStepKey).split(";").last().split("_");

Expand All @@ -70,6 +72,8 @@ RenderDialog::RenderDialog(QWidget* Parent, int renderType, int importOnly)

mTransBackground = true;

setMinimumSize(100, 100);

} else if (mRenderType == BLENDER_RENDER) {

QString title = mImportOnly ? "Import" : "Render";
Expand All @@ -96,30 +100,29 @@ RenderDialog::RenderDialog(QWidget* Parent, int renderType, int importOnly)
if (!blenderInstalled)
ui->RenderButton->setToolTip(tr("Blender not configured. Click 'Settings' to configure."));

bool useConfigSize = false;
if (QFileInfo(Preferences::blenderRenderConfigFile).exists())
{
QSettings Settings(Preferences::blenderRenderConfigFile, QSettings::IniFormat);
if (Settings.value(QString("%1/cropImage").arg(IMPORTLDRAW), QString()).toBool())
{
useConfigSize = true;
mWidth = gui->GetImageWidth();
mHeight = gui->GetImageHeight();
}
}

adjustSize();
if (!mImportOnly)
setMinimumWidth(useConfigSize ? mWidth : ui->preview->geometry().width());
ui->preview->hide();
}

connect(&mUpdateTimer, SIGNAL(timeout()), this, SLOT(Update()));
connect(&mUpdateTimer, SIGNAL(timeout()), this, SLOT(UpdateElapsedTime()));

mUpdateTimer.start(500);

if (mRenderType == BLENDER_RENDER) {
adjustSize();
if (!mImportOnly)
setMinimumWidth(int(ui->preview->geometry().width()));
ui->preview->hide();
} else {
setMinimumSize(100, 100);
}
setSizeGripEnabled(true);
}

Expand Down Expand Up @@ -173,6 +176,7 @@ void RenderDialog::on_RenderButton_clicked()
return;
}

ui->StandardOutButton->setEnabled(false);
mPreviewWidth = ui->preview->width();
mPreviewHeight = ui->preview->height();

Expand Down Expand Up @@ -511,6 +515,9 @@ void RenderDialog::on_RenderButton_clicked()
{
ui->RenderButton->setText(tr("Cancel"));
ui->RenderProgress->setValue(ui->RenderProgress->minimum());
ui->TimeLabel->setText(QString("Loading LDraw model... %1")
.arg(gui->elapsedTime(mRenderTime.elapsed())));
QApplication::processEvents();
emit gui->messageSig(LOG_INFO, QString("Blender render process [%1] running...").arg(mProcess->processId()));
}
else
Expand Down Expand Up @@ -573,11 +580,11 @@ void RenderDialog::ReadStdOut()
{
QString StdOut = QString(mProcess->readAllStandardOutput());
mStdOutList.append(StdOut);
QRegExp rxBlenderProgress("\\/(\\d+) Tiles, Denoised (\\d+) tiles",Qt::CaseInsensitive);
if (StdOut.contains(rxBlenderProgress))
QRegExp rxRenderProgress("\\/(\\d+) Tiles, Denoised (\\d+) tiles",Qt::CaseInsensitive);
if (StdOut.contains(rxRenderProgress))
{
mBlendProgValue = rxBlenderProgress.cap(2).toInt();
mBlendProgMax = rxBlenderProgress.cap(1).toInt();
mBlendProgValue = rxRenderProgress.cap(2).toInt();
mBlendProgMax = rxRenderProgress.cap(1).toInt();
ui->RenderProgress->setMaximum(mBlendProgMax);
ui->RenderProgress->setValue(mBlendProgValue);
emit gui->messageSig(LOG_INFO, QString("Rendered Tile %1/%2")
Expand Down Expand Up @@ -631,6 +638,8 @@ void RenderDialog::WriteStdOut()
for (const QString& Line : mStdOutList)
Out << Line;
file.close();
if (mStdOutList.size())
ui->StandardOutButton->setEnabled(true);
}
else
{
Expand Down Expand Up @@ -713,7 +722,6 @@ void RenderDialog::Update()

if (PixelsWritten == Width * Height)
ui->RenderProgress->setValue(ui->RenderProgress->maximum());

}
}

Expand Down Expand Up @@ -790,14 +798,16 @@ void RenderDialog::ShowResult()
Success = QFileInfo(FileName).exists();
if (Success){

mPreviewWidth = mWidth;
mPreviewHeight = mHeight;

QImageReader reader(FileName);
mImage = reader.read();
mImage = mImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);;
mImage = mImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);

mPreviewWidth = mImage.width();
mPreviewHeight = mImage.height();

ui->preview->setPixmap(QPixmap::fromImage(mImage.scaled(mPreviewWidth, mPreviewHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
setMinimumSize(100, 100);
adjustSize();
ui->preview->show();
}
}
Expand Down Expand Up @@ -888,6 +898,10 @@ bool RenderDialog::PromptCancel()
#endif
mProcess->kill();
CloseProcess();
if (mStdOutList.size()){
WriteStdOut();
ui->StandardOutButton->setEnabled(true);
}
ui->TimeLabel->setText(QString("Tiles: %1/%2, Render Cancelled.")
.arg(mBlendProgValue)
.arg(mBlendProgMax));
Expand Down Expand Up @@ -920,6 +934,7 @@ void RenderDialog::resetOutputEdit(bool)
ui->RenderProgress->setRange(0,1);
ui->RenderProgress->setValue(0);
ui->TimeLabel->setText(QString());
ui->StandardOutButton->setEnabled(false);
if (mRenderType == BLENDER_RENDER ) {
ui->preview->hide();
adjustSize();
Expand All @@ -942,3 +957,19 @@ RenderProcess::~RenderProcess(){
waitForFinished();
}
}

void RenderDialog::on_StandardOutButton_clicked()
{
QString renderType = mRenderType == POVRAY_RENDER ? "POVRay" : "Blender";
QFileInfo fileInfo(GetLogFileName(true/*stdOut*/));
if (!fileInfo.exists()) {
emit gui->messageSig(LOG_ERROR, QString("%1 Standard output file not found: %2.")
.arg(renderType).arg(fileInfo.absoluteFilePath()));
return;
}
QString title = QString("%1 Render Standard Output").arg(renderType);
QString status = QString("View %1 render process standard output").arg(renderType);
gui->displayParmsFile(fileInfo.absoluteFilePath());
gui->parmsWindow->setWindowTitle(tr(title.toLatin1(),status.toLatin1()));
gui->parmsWindow->show();
}
3 changes: 2 additions & 1 deletion mainApp/renderdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ class RenderDialog : public QDialog
int importOnly = 0);
~RenderDialog();

public slots:
private slots:
void reject();
void on_RenderSettingsButton_clicked();
void on_RenderButton_clicked();
void on_OutputBrowseButton_clicked();
void on_StandardOutButton_clicked();
void resetOutputEdit(bool);
void Update();

Expand Down
17 changes: 13 additions & 4 deletions mainApp/renderdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<item>
<widget class="QLabel" name="outputLabel">
<property name="text">
<string>Output:</string>
<string>Rendered Image:</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -88,6 +88,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="RenderButton">
<property name="text">
<string>Render</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="ProgressLine">
<property name="orientation">
Expand All @@ -96,9 +103,12 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="RenderButton">
<widget class="QPushButton" name="StandardOutButton">
<property name="toolTip">
<string>View render process standard output</string>
</property>
<property name="text">
<string>Render</string>
<string>Output...</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -131,7 +141,6 @@
<tabstop>OutputEdit</tabstop>
<tabstop>OutputBrowseButton</tabstop>
<tabstop>RenderSettingsButton</tabstop>
<tabstop>RenderButton</tabstop>
</tabstops>
<resources/>
<connections/>
Expand Down

0 comments on commit 79221f8

Please sign in to comment.