diff --git a/src/mitsuba/mitsuba.cpp b/src/mitsuba/mitsuba.cpp index b2dc8a21..c7521675 100644 --- a/src/mitsuba/mitsuba.cpp +++ b/src/mitsuba/mitsuba.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #if defined(__WINDOWS__) #include @@ -78,7 +79,8 @@ void help() { cout << " -r sec Write (partial) output images every 'sec' seconds" << endl << endl; cout << " -b res Specify the block resolution used to split images into parallel" << endl; cout << " workloads (default: 32). Only applies to some integrators." << endl << endl; - cout << " -v Be more verbose" << endl << endl; + cout << " -v Be more verbose (can be specified twice)" << endl << endl; + cout << " -L level Explicitly specify the log level (trace/debug/info/warn/error)" << endl << endl; cout << " -w Treat warnings as errors" << endl << endl; cout << " -z Disable progress bars" << endl << endl; cout << " For documentation, please refer to http://www.mitsuba-renderer.org/docs.html" << endl; @@ -149,7 +151,7 @@ int mitsuba_app(int argc, char **argv) { optind = 1; /* Parse command-line arguments */ - while ((optchar = getopt(argc, argv, "a:c:D:s:j:n:o:r:b:p:qhzvtwx")) != -1) { + while ((optchar = getopt(argc, argv, "a:c:D:s:j:n:o:r:b:p:L:qhzvtwx")) != -1) { switch (optchar) { case 'a': { std::vector paths = tokenize(optarg, ";"); @@ -194,6 +196,22 @@ int mitsuba_app(int argc, char **argv) { else logLevel = ETrace; break; + case 'L': { + std::string arg = boost::to_lower_copy(std::string(optarg)); + if (arg == "trace") + logLevel = ETrace; + else if (arg == "debug") + logLevel = EDebug; + else if (arg == "info") + logLevel = EInfo; + else if (arg == "warn") + logLevel = EWarn; + else if (arg == "error") + logLevel = EError; + else + SLog(EError, "Invalid log level!"); + } + break; case 'x': skipExisting = true; break; diff --git a/src/mitsuba/mtssrv.cpp b/src/mitsuba/mtssrv.cpp index b4dc7292..6b7364cb 100644 --- a/src/mitsuba/mtssrv.cpp +++ b/src/mitsuba/mtssrv.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef __WINDOWS__ #include @@ -108,7 +109,7 @@ int mtssrv(int argc, char **argv) { optind = 1; /* Parse command-line arguments */ - while ((optchar = getopt(argc, argv, "a:c:s:n:p:i:l:qhv")) != -1) { + while ((optchar = getopt(argc, argv, "a:c:s:n:p:i:l:L:qhv")) != -1) { switch (optchar) { case 'a': { std::vector paths = tokenize(optarg, ";"); @@ -146,6 +147,22 @@ int mtssrv(int argc, char **argv) { case 'v': logLevel = EDebug; break; + case 'L': { + std::string arg = boost::to_lower_copy(std::string(optarg)); + if (arg == "trace") + logLevel = ETrace; + else if (arg == "debug") + logLevel = EDebug; + else if (arg == "info") + logLevel = EInfo; + else if (arg == "warn") + logLevel = EWarn; + else if (arg == "error") + logLevel = EError; + else + SLog(EError, "Invalid log level!"); + } + break; case 'l': if (!strcmp("s", optarg)) { listenPort = -1; @@ -184,7 +201,8 @@ int mtssrv(int argc, char **argv) { cout << " -l port Listen for connections on a certain port (Default: " << MTS_DEFAULT_PORT << ")." << endl; cout << " To listen on stdin, specify \"-ls\" (implies -q)" << endl << endl; cout << " -n name Assign a node name to this instance (Default: host name)" << endl << endl; - cout << " -v Be more verbose" << endl << endl; + cout << " -v Be more verbose (can be specified twice)" << endl << endl; + cout << " -L level Explicitly specify the log level (trace/debug/info/warn/error)" << endl << endl; cout << " For documentation, please refer to http://www.mitsuba-renderer.org/docs.html" << endl; return 0; } diff --git a/src/mtsgui/glwidget.cpp b/src/mtsgui/glwidget.cpp index 56b37bc8..3ecdf0d6 100644 --- a/src/mtsgui/glwidget.cpp +++ b/src/mtsgui/glwidget.cpp @@ -499,6 +499,9 @@ void GLWidget::keyPressEvent(QKeyEvent *event) { } else if (event->key() == Qt::Key_R) { emit beginRendering(); } + else if (event->key() == Qt::Key_S) { + emit stopRendering(); + } if (event->isAutoRepeat() || !m_context) return; diff --git a/src/mtsgui/loaddlg.cpp b/src/mtsgui/loaddlg.cpp index 00d95e69..f290a331 100644 --- a/src/mtsgui/loaddlg.cpp +++ b/src/mtsgui/loaddlg.cpp @@ -32,7 +32,7 @@ LoadDialog::LoadDialog(QWidget *parent) : m_consoleAppender = new QConsoleAppender(); Logger *logger = Thread::getThread()->getLogger(); m_oldLogLevel = logger->getLogLevel(); - logger->setLogLevel(EDebug); + //logger->setLogLevel(EDebug); logger->addAppender(m_consoleAppender); connect(m_consoleAppender, SIGNAL(textMessage(ELogLevel, const QString &)), this, SLOT(onTextMessage(ELogLevel, const QString &)), Qt::QueuedConnection); diff --git a/src/mtsgui/mainwindow.cpp b/src/mtsgui/mainwindow.cpp index e5cff8f1..b8afae50 100644 --- a/src/mtsgui/mainwindow.cpp +++ b/src/mtsgui/mainwindow.cpp @@ -166,7 +166,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->glView, SIGNAL(quit()), this, SLOT(on_actionExit_triggered())); connect(ui->glView, SIGNAL(beginRendering()), this, SLOT(on_actionRender_triggered())); - connect(ui->glView, SIGNAL(stopRendering()), this, SLOT(updateUI())); + connect(ui->glView, SIGNAL(stopRendering()), this, SLOT(on_actionStop_triggered())); connect(ui->glView, SIGNAL(statusMessage(const QString &)), this, SLOT(onStatusMessage(const QString &)), Qt::QueuedConnection); connect(ui->glView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); @@ -269,6 +269,7 @@ bool MainWindow::initWorkersProcessArgv() { int localWorkerCount = settings.value("localWorkers", getCoreCount()).toInt(); ref scheduler = Scheduler::getInstance(); QString outputFile(""); + bool beginRendering = false; for (int i=1; igetLogger(); + QString value = args[i].mid(2); + if (value.length() == 0 && i+1setLogLevel(logLevel); + settings.setValue("verbosity", logLevel); } else if (args[i] == "-h") { cout << "Mitsuba version " << Version(MTS_VERSION).toStringComplete() << ", Copyright (c) " MTS_YEAR " Wenzel Jakob" << endl; @@ -306,6 +330,8 @@ bool MainWindow::initWorkersProcessArgv() { cout << " -o fname Write the output image to the file denoted by \"fname\"" << endl << endl; cout << " -a p1;p2;.. Add one or more entries to the resource search path" << endl << endl; cout << " -p count Override the detected number of processors." << endl << endl; + cout << " -L level Explicitly specify the log level (trace/debug/info/warn/error)" << endl << endl; + cout << " -r Immediately begin rendering" << endl << endl; cout << " For documentation, please refer to http://www.mitsuba-renderer.org/docs.html" << endl; return false; } else if (args[i].startsWith("-")) { @@ -376,6 +402,14 @@ bool MainWindow::initWorkersProcessArgv() { loadFile(toBeLoaded[i].first, toBeLoaded[i].second); scheduler->start(); + + if (beginRendering) { + for (int i=0; itabBar->count(); ++i) { + ui->tabBar->setCurrentIndex(i); + on_actionRender_triggered(); + } + } + raise(); return true; } @@ -667,6 +701,7 @@ void MainWindow::onClearRecent() { SceneContext *MainWindow::loadScene(const QString &qFileName, const QString &destFile) { ref resolver = Thread::getThread()->getFileResolver(); + ref logger = Thread::getThread()->getLogger(); fs::path filename = resolver->resolve(toFsPath(qFileName)); fs::path filePath = fs::absolute(filename).parent_path(); ref newResolver = resolver->clone();