diff --git a/Sources/Sources.pro b/Sources/Sources.pro index 016423a..61a3edc 100644 --- a/Sources/Sources.pro +++ b/Sources/Sources.pro @@ -87,7 +87,8 @@ HEADERS = glwidget.h \ utils/glslshaderparser.h \ utils/glslparsedshadercontainer.h \ utils/contextinfo/contextwidget.h \ - utils/contextinfo/renderwindow.h + utils/contextinfo/renderwindow.h \ + formimagebatch.h SOURCES = glwidget.cpp \ main.cpp \ @@ -118,7 +119,8 @@ SOURCES = glwidget.cpp \ properties/PropertyABColor.cpp \ properties/PropertyDelegateABColor.cpp \ utils/contextinfo/contextwidget.cpp \ - utils/contextinfo/renderwindow.cpp + utils/contextinfo/renderwindow.cpp \ + formimagebatch.cpp RESOURCES += content.qrc @@ -145,7 +147,8 @@ FORMS += \ allaboutdialog.ui \ dialogshortcuts.ui \ dockwidget3dsettings.ui \ - properties/Dialog3DGeneralSettings.ui + properties/Dialog3DGeneralSettings.ui \ + formimagebatch.ui ICON = resources/icons/icon.icns diff --git a/Sources/formimagebatch.cpp b/Sources/formimagebatch.cpp new file mode 100644 index 0000000..1d26c46 --- /dev/null +++ b/Sources/formimagebatch.cpp @@ -0,0 +1,14 @@ +#include "formimagebatch.h" +#include "ui_formimagebatch.h" + +FormImageBatch::FormImageBatch(QWidget *parent) : + QWidget(parent), + ui(new Ui::FormImageBatch) +{ + ui->setupUi(this); +} + +FormImageBatch::~FormImageBatch() +{ + delete ui; +} diff --git a/Sources/formimagebatch.h b/Sources/formimagebatch.h new file mode 100644 index 0000000..165cddd --- /dev/null +++ b/Sources/formimagebatch.h @@ -0,0 +1,22 @@ +#ifndef FORMIMAGEBATCH_H +#define FORMIMAGEBATCH_H + +#include + +namespace Ui { +class FormImageBatch; +} + +class FormImageBatch : public QWidget +{ + Q_OBJECT + +public: + explicit FormImageBatch(QWidget *parent = 0); + ~FormImageBatch(); + +private: + Ui::FormImageBatch *ui; +}; + +#endif // FORMIMAGEBATCH_H diff --git a/Sources/formimagebatch.ui b/Sources/formimagebatch.ui new file mode 100644 index 0000000..a558f18 --- /dev/null +++ b/Sources/formimagebatch.ui @@ -0,0 +1,112 @@ + + + FormImageBatch + + + + 0 + 0 + 400 + 300 + + + + Form + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + QLayout::SetMinimumSize + + + + + Source folder + + + + + + + Output folder + + + + + + + Run batch + + + + + + + + + 3 + + + 3 + + + + + Source path + + + + + + + true + + + + + + + Output path + + + + + + + true + + + + + + + + + 3 + + + QLayout::SetMaximumSize + + + + + + + + diff --git a/Sources/formimageprop.cpp b/Sources/formimageprop.cpp index 5dc8261..8c0ee07 100644 --- a/Sources/formimageprop.cpp +++ b/Sources/formimageprop.cpp @@ -274,7 +274,7 @@ bool FormImageProp::loadFile(const QString &fileName) { QFileInfo fileInfo(fileName); QImage _image; - +// qDebug() << "Opening file: " << fileName; // Targa support added if(fileInfo.completeSuffix().compare("tga") == 0){ TargaImage tgaImage; diff --git a/Sources/formimageprop.h b/Sources/formimageprop.h index a531bd8..7573793 100644 --- a/Sources/formimageprop.h +++ b/Sources/formimageprop.h @@ -30,7 +30,7 @@ class FormImageProp : public FormImageBase void setupPopertiesGUI(); void reloadSettings(); - + bool loadFile(const QString &fileName); ~FormImageProp(); @@ -85,7 +85,7 @@ public slots: private: - bool loadFile(const QString &fileName); + void pasteImageFromClipboard(QImage& _image); diff --git a/Sources/main.cpp b/Sources/main.cpp index 395ef52..7395a3f 100644 --- a/Sources/main.cpp +++ b/Sources/main.cpp @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) regABSliderDelegates(); regABColorDelegates(); - qInstallMessageHandler(customMessageHandler); +// qInstallMessageHandler(customMessageHandler); qDebug() << "Starting application:"; qDebug() << "Application dir:" << QApplication::applicationDirPath(); diff --git a/Sources/mainwindow.cpp b/Sources/mainwindow.cpp index 2e75705..d7573ce 100644 --- a/Sources/mainwindow.cpp +++ b/Sources/mainwindow.cpp @@ -142,6 +142,7 @@ void MainWindow::initializeApp() connect(settingsContainer,SIGNAL(forceSaveCurrentConfig()),this,SLOT(saveSettings())); connect(ui->pushButtonProjectManager,SIGNAL(toggled(bool)),settingsContainer,SLOT(setVisible(bool))); + // ------------------------------------------------------- // 3D settings widget // ------------------------------------------------------- @@ -388,6 +389,12 @@ void MainWindow::initializeApp() connect(ui->checkBoxToggleMouseLoop ,SIGNAL(toggled(bool)),glWidget,SLOT(toggleMouseWrap(bool))); connect(ui->checkBoxToggleMouseLoop ,SIGNAL(toggled(bool)),glImage ,SLOT(toggleMouseWrap(bool))); + // batch settings + connect(ui->pushButtonImageBatchSource ,SIGNAL(pressed()),this,SLOT(selectSourceImages())); + connect(ui->pushButtonImageBatchOutput ,SIGNAL(pressed()),this,SLOT(selectOutputPath())); + connect(ui->pushButtonImageBatchRun ,SIGNAL(pressed()),this,SLOT(runBatch())); + + #ifdef Q_OS_MAC @@ -728,7 +735,8 @@ void MainWindow::saveImages(){ } bool MainWindow::saveAllImages(const QString &dir){ - QFileInfo fileInfo(dir); + + QFileInfo fileInfo(dir); if (!fileInfo.exists()) { QMessageBox::information(this, QGuiApplication::applicationDisplayName(), tr("Cannot save to %1.").arg(QDir::toNativeSeparators(dir))); @@ -1321,6 +1329,87 @@ void MainWindow::selectContrastInputImage(int mode){ replotAllImages(); } +void MainWindow::selectSourceImages(){ + + QString startPath; + if(recentDir.exists()) startPath = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first(); + else startPath = recentDir.absolutePath(); + + QString source = QFileDialog::getExistingDirectory(this, tr("Select source directory"), + startPath, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + QDir dir(source); + qDebug() << "Selecting source folder for batch processing: " << source; + + QStringList filters; + filters << "*.png" << "*.jpg" << "*.bmp" << "*.tga"; + QFileInfoList fileInfoList = dir.entryInfoList(filters, QDir::Files | QDir::NoDotAndDotDot); + + ui->listWidgetImageBatch->clear(); + foreach (QFileInfo fileInfo, fileInfoList) { + qDebug() << "Found:" << fileInfo.absoluteFilePath(); + ui->listWidgetImageBatch->addItem(fileInfo.fileName()); + } + ui->lineEditImageBatchSource->setText(source); +} + +void MainWindow::selectOutputPath(){ + + QString startPath; + if(recentDir.exists()) startPath = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first(); + else startPath = recentDir.absolutePath(); + + QString path = QFileDialog::getExistingDirectory(this, tr("Select source directory"), + startPath, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + ui->lineEditImageBatchOutput->setText(path); +} + +void MainWindow::runBatch(){ + + QString sourceFolder = ui->lineEditImageBatchSource->text(); + QString outputFolder = ui->lineEditImageBatchOutput->text(); + + // check if output path exists + if(!QDir(outputFolder).exists() || outputFolder == ""){ + QMessageBox msgBox; + msgBox.setText("Info"); + msgBox.setInformativeText("Output path is not provided"); + msgBox.setStandardButtons(QMessageBox::Cancel); + msgBox.exec(); + return; + } + + qDebug() << "Starting batch mode: this may take some time"; + + + while(ui->listWidgetImageBatch->count() > 0){ + QListWidgetItem* item = ui->listWidgetImageBatch->takeItem(0); + ui->labelBatchProgress->setText("Images left: " + QString::number(ui->listWidgetImageBatch->count()+1)); + ui->labelBatchProgress->repaint(); + QCoreApplication::processEvents(); + + QString imageName = item->text(); + ui->lineEditOutputName->setText(imageName); + QString imagePath = sourceFolder + "/" + imageName; + + qDebug() << "Processing image: " << imagePath; + diffuseImageProp->loadFile(imagePath); + convertFromBase(); + saveAllImages(outputFolder); + + delete item; + ui->listWidgetImageBatch->repaint(); + QCoreApplication::processEvents(); + } + + ui->labelBatchProgress->setText("Done..."); + +} + + void MainWindow::randomizeAngles(){ FBOImageProporties::seamlessRandomTiling.randomize(); replotAllImages(); diff --git a/Sources/mainwindow.h b/Sources/mainwindow.h index fdf8356..3f5a594 100644 --- a/Sources/mainwindow.h +++ b/Sources/mainwindow.h @@ -6,6 +6,7 @@ #include #include #include + #include #include "CommonObjects.h" @@ -136,6 +137,10 @@ public slots: void resetRandomPatches(); void selectContrastInputImage(int mode); + // batch tool + void selectSourceImages(); + void selectOutputPath(); + void runBatch(); private: // saves all textures to given directory bool saveAllImages(const QString &dir); diff --git a/Sources/mainwindow.ui b/Sources/mainwindow.ui index 8831171..eaefb91 100644 --- a/Sources/mainwindow.ui +++ b/Sources/mainwindow.ui @@ -62,7 +62,7 @@ QTabWidget::East - 0 + 11 Qt::ElideMiddle @@ -119,8 +119,8 @@ 0 0 - 369 - 691 + 383 + 697 @@ -197,8 +197,8 @@ 0 0 - 369 - 691 + 383 + 697 @@ -278,8 +278,8 @@ 0 0 - 369 - 691 + 383 + 697 @@ -353,8 +353,8 @@ 0 0 - 369 - 691 + 383 + 697 @@ -428,8 +428,8 @@ 0 0 - 369 - 691 + 383 + 697 @@ -500,8 +500,8 @@ 0 0 - 369 - 691 + 383 + 697 @@ -578,8 +578,8 @@ 0 0 - 369 - 691 + 383 + 697 @@ -638,8 +638,8 @@ 0 0 - 367 - 689 + 381 + 695 @@ -707,8 +707,8 @@ 0 0 - 367 - 689 + 381 + 695 @@ -812,8 +812,8 @@ 0 0 - 380 - 702 + 383 + 657 @@ -2112,8 +2112,8 @@ 0 0 - 369 - 691 + 383 + 697 @@ -2690,6 +2690,80 @@ + + + Batch + + + + + + + + Select folder + + + + + + + Output folder + + + + + + + Run + + + + + + + + + + + Source folder + + + + + + + Output folder + + + + + + + true + + + + + + + false + + + + + + + + + + + + Progress: + + + + + @@ -3257,14 +3331,18 @@ - - - Project manager - - - true - - + + + + + Projects manager + + + true + + + + @@ -3279,7 +3357,7 @@ 0 0 1289 - 25 + 19