From 84685dfc8de61dea3043e0b170d1e849480d11db Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 18 Oct 2014 22:38:04 +0200 Subject: [PATCH] mtsgui: handle the -o parameter --- src/mtsgui/main.cpp | 4 ++-- src/mtsgui/mainwindow.cpp | 22 +++++++++++++++------- src/mtsgui/mainwindow.h | 4 ++-- src/mtsgui/sceneloader.cpp | 6 +++--- src/mtsgui/sceneloader.h | 2 ++ 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/mtsgui/main.cpp b/src/mtsgui/main.cpp index f58f0e91..88002585 100644 --- a/src/mtsgui/main.cpp +++ b/src/mtsgui/main.cpp @@ -48,8 +48,8 @@ #if defined(__WINDOWS__) // Always use the High Performance GPU on machines using NVIDIA Optimus // http://stackoverflow.com/questions/10535950/forcing-nvidia-gpu-programmatically-in-optimus-laptops [January 2014] -extern "C" { - _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; +extern "C" { + _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; } #endif diff --git a/src/mtsgui/mainwindow.cpp b/src/mtsgui/mainwindow.cpp index ea13b4c1..e5cff8f1 100644 --- a/src/mtsgui/mainwindow.cpp +++ b/src/mtsgui/mainwindow.cpp @@ -264,9 +264,11 @@ MainWindow::~MainWindow() { bool MainWindow::initWorkersProcessArgv() { QSettings settings; - QStringList args = qApp->arguments(), toBeLoaded; + QStringList args = qApp->arguments(); + std::vector > toBeLoaded; int localWorkerCount = settings.value("localWorkers", getCoreCount()).toInt(); ref scheduler = Scheduler::getInstance(); + QString outputFile(""); for (int i=1; iappendPath(value.toStdString()); + } else if (args[i].startsWith("-o")) { + outputFile = args[i].mid(2); + if (outputFile.length() == 0 && i+1start(); raise(); @@ -657,7 +665,7 @@ void MainWindow::onClearRecent() { settings.setValue("recentFileList", QStringList()); } -SceneContext *MainWindow::loadScene(const QString &qFileName) { +SceneContext *MainWindow::loadScene(const QString &qFileName, const QString &destFile) { ref resolver = Thread::getThread()->getFileResolver(); fs::path filename = resolver->resolve(toFsPath(qFileName)); fs::path filePath = fs::absolute(filename).parent_path(); @@ -674,7 +682,7 @@ SceneContext *MainWindow::loadScene(const QString &qFileName) { loaddlg->show(); retry: - loadingThread = new SceneLoader(newResolver, filename, m_parameters); + loadingThread = new SceneLoader(newResolver, filename, toFsPath(destFile), m_parameters); loadingThread->start(); while (loadingThread->isRunning()) { @@ -735,11 +743,11 @@ retry: return result; } -void MainWindow::loadFile(QString filename) { +void MainWindow::loadFile(QString filename, const QString &destFile) { QFileInfo fInfo(filename); fInfo.makeAbsolute(); - SceneContext *context = loadScene(filename); + SceneContext *context = loadScene(filename, destFile); if (context == NULL) return; m_contextMutex.lock(); diff --git a/src/mtsgui/mainwindow.h b/src/mtsgui/mainwindow.h index ee6e668f..7647b5af 100644 --- a/src/mtsgui/mainwindow.h +++ b/src/mtsgui/mainwindow.h @@ -117,13 +117,13 @@ class MainWindow : public QMainWindow { public: MainWindow(QWidget *parent = 0); ~MainWindow(); - void loadFile(QString filename); + void loadFile(QString filename, const QString &destFile = ""); void adjustSize(); bool isActive(); bool initWorkersProcessArgv(); protected: - SceneContext *loadScene(const QString &filename); + SceneContext *loadScene(const QString &filename, const QString &destFile = ""); void resizeEvent(QResizeEvent *event); void changeEvent(QEvent *e); void updateRecentFileActions(); diff --git a/src/mtsgui/sceneloader.cpp b/src/mtsgui/sceneloader.cpp index c23e9d5e..38ae555b 100644 --- a/src/mtsgui/sceneloader.cpp +++ b/src/mtsgui/sceneloader.cpp @@ -32,8 +32,8 @@ XERCES_CPP_NAMESPACE_USE SceneLoader::SceneLoader(FileResolver *resolver, const fs::path &filename, - const std::map ¶meters) - : Thread("load"), m_resolver(resolver), m_filename(fromFsPath(filename)), + const fs::path &destFile, const std::map ¶meters) + : Thread("load"), m_resolver(resolver), m_filename(fromFsPath(filename)), m_destFile(destFile), m_parameters(parameters) { m_wait = new WaitFlag(); m_versionError = false; @@ -115,7 +115,7 @@ void SceneLoader::run() { ref scene = handler->getScene(); scene->setSourceFile(filename); - scene->setDestinationFile(filePath / baseName); + scene->setDestinationFile(m_destFile.empty() ? (filePath / baseName) : m_destFile); scene->initialize(); if (scene->getIntegrator() == NULL) diff --git a/src/mtsgui/sceneloader.h b/src/mtsgui/sceneloader.h index a13368e7..c4ce67fe 100644 --- a/src/mtsgui/sceneloader.h +++ b/src/mtsgui/sceneloader.h @@ -30,6 +30,7 @@ class SceneLoader : public Thread { public: SceneLoader(FileResolver *resolver, const fs::path &filename, + const fs::path &destFile, const std::map ¶meters); void run(); @@ -47,6 +48,7 @@ private: SceneContext *m_result; std::string m_error; const QString m_filename; + fs::path m_destFile; bool m_versionError; Version m_version; const std::map &m_parameters;