hslt: '-L' command line parameter to set the log level; '-r' immediately starts rendering in mtsgui
parent
cb56d97fcf
commit
5d578e9c68
|
@ -36,6 +36,7 @@
|
||||||
#include <mitsuba/render/scenehandler.h>
|
#include <mitsuba/render/scenehandler.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
#include <mitsuba/core/getopt.h>
|
#include <mitsuba/core/getopt.h>
|
||||||
|
@ -78,7 +79,8 @@ void help() {
|
||||||
cout << " -r sec Write (partial) output images every 'sec' seconds" << endl << endl;
|
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 << " -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 << " 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 << " -w Treat warnings as errors" << endl << endl;
|
||||||
cout << " -z Disable progress bars" << endl << endl;
|
cout << " -z Disable progress bars" << endl << endl;
|
||||||
cout << " For documentation, please refer to http://www.mitsuba-renderer.org/docs.html" << 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;
|
optind = 1;
|
||||||
/* Parse command-line arguments */
|
/* 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) {
|
switch (optchar) {
|
||||||
case 'a': {
|
case 'a': {
|
||||||
std::vector<std::string> paths = tokenize(optarg, ";");
|
std::vector<std::string> paths = tokenize(optarg, ";");
|
||||||
|
@ -194,6 +196,22 @@ int mitsuba_app(int argc, char **argv) {
|
||||||
else
|
else
|
||||||
logLevel = ETrace;
|
logLevel = ETrace;
|
||||||
break;
|
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':
|
case 'x':
|
||||||
skipExisting = true;
|
skipExisting = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <mitsuba/core/bitmap.h>
|
#include <mitsuba/core/bitmap.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
@ -108,7 +109,7 @@ int mtssrv(int argc, char **argv) {
|
||||||
|
|
||||||
optind = 1;
|
optind = 1;
|
||||||
/* Parse command-line arguments */
|
/* 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) {
|
switch (optchar) {
|
||||||
case 'a': {
|
case 'a': {
|
||||||
std::vector<std::string> paths = tokenize(optarg, ";");
|
std::vector<std::string> paths = tokenize(optarg, ";");
|
||||||
|
@ -146,6 +147,22 @@ int mtssrv(int argc, char **argv) {
|
||||||
case 'v':
|
case 'v':
|
||||||
logLevel = EDebug;
|
logLevel = EDebug;
|
||||||
break;
|
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':
|
case 'l':
|
||||||
if (!strcmp("s", optarg)) {
|
if (!strcmp("s", optarg)) {
|
||||||
listenPort = -1;
|
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 << " -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 << " 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 << " -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;
|
cout << " For documentation, please refer to http://www.mitsuba-renderer.org/docs.html" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,6 +499,9 @@ void GLWidget::keyPressEvent(QKeyEvent *event) {
|
||||||
} else if (event->key() == Qt::Key_R) {
|
} else if (event->key() == Qt::Key_R) {
|
||||||
emit beginRendering();
|
emit beginRendering();
|
||||||
}
|
}
|
||||||
|
else if (event->key() == Qt::Key_S) {
|
||||||
|
emit stopRendering();
|
||||||
|
}
|
||||||
|
|
||||||
if (event->isAutoRepeat() || !m_context)
|
if (event->isAutoRepeat() || !m_context)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -32,7 +32,7 @@ LoadDialog::LoadDialog(QWidget *parent) :
|
||||||
m_consoleAppender = new QConsoleAppender();
|
m_consoleAppender = new QConsoleAppender();
|
||||||
Logger *logger = Thread::getThread()->getLogger();
|
Logger *logger = Thread::getThread()->getLogger();
|
||||||
m_oldLogLevel = logger->getLogLevel();
|
m_oldLogLevel = logger->getLogLevel();
|
||||||
logger->setLogLevel(EDebug);
|
//logger->setLogLevel(EDebug);
|
||||||
logger->addAppender(m_consoleAppender);
|
logger->addAppender(m_consoleAppender);
|
||||||
connect(m_consoleAppender, SIGNAL(textMessage(ELogLevel, const QString &)),
|
connect(m_consoleAppender, SIGNAL(textMessage(ELogLevel, const QString &)),
|
||||||
this, SLOT(onTextMessage(ELogLevel, const QString &)), Qt::QueuedConnection);
|
this, SLOT(onTextMessage(ELogLevel, const QString &)), Qt::QueuedConnection);
|
||||||
|
|
|
@ -166,7 +166,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
|
|
||||||
connect(ui->glView, SIGNAL(quit()), this, SLOT(on_actionExit_triggered()));
|
connect(ui->glView, SIGNAL(quit()), this, SLOT(on_actionExit_triggered()));
|
||||||
connect(ui->glView, SIGNAL(beginRendering()), this, SLOT(on_actionRender_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 &)),
|
connect(ui->glView, SIGNAL(statusMessage(const QString &)), this, SLOT(onStatusMessage(const QString &)),
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
connect(ui->glView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
|
connect(ui->glView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
|
||||||
|
@ -269,6 +269,7 @@ bool MainWindow::initWorkersProcessArgv() {
|
||||||
int localWorkerCount = settings.value("localWorkers", getCoreCount()).toInt();
|
int localWorkerCount = settings.value("localWorkers", getCoreCount()).toInt();
|
||||||
ref<Scheduler> scheduler = Scheduler::getInstance();
|
ref<Scheduler> scheduler = Scheduler::getInstance();
|
||||||
QString outputFile("");
|
QString outputFile("");
|
||||||
|
bool beginRendering = false;
|
||||||
|
|
||||||
for (int i=1; i<args.count(); ++i) {
|
for (int i=1; i<args.count(); ++i) {
|
||||||
if (args[i].startsWith("-D")) {
|
if (args[i].startsWith("-D")) {
|
||||||
|
@ -296,6 +297,29 @@ bool MainWindow::initWorkersProcessArgv() {
|
||||||
unsigned int numCores = value.toUInt(&ok, 10);
|
unsigned int numCores = value.toUInt(&ok, 10);
|
||||||
if (ok)
|
if (ok)
|
||||||
localWorkerCount = numCores;
|
localWorkerCount = numCores;
|
||||||
|
} else if (args[i].startsWith("-r")) {
|
||||||
|
beginRendering = true;
|
||||||
|
} else if (args[i].startsWith("-L")) {
|
||||||
|
Logger *logger = Thread::getThread()->getLogger();
|
||||||
|
QString value = args[i].mid(2);
|
||||||
|
if (value.length() == 0 && i+1<args.count())
|
||||||
|
value = args[++i];
|
||||||
|
value = value.toLower();
|
||||||
|
ELogLevel logLevel = EDebug;
|
||||||
|
if (value == "trace")
|
||||||
|
logLevel = ETrace;
|
||||||
|
else if (value == "debug")
|
||||||
|
logLevel = EDebug;
|
||||||
|
else if (value == "info")
|
||||||
|
logLevel = EInfo;
|
||||||
|
else if (value == "warn")
|
||||||
|
logLevel = EWarn;
|
||||||
|
else if (value == "error")
|
||||||
|
logLevel = EError;
|
||||||
|
else
|
||||||
|
SLog(EError, "Invalid log level!");
|
||||||
|
logger->setLogLevel(logLevel);
|
||||||
|
settings.setValue("verbosity", logLevel);
|
||||||
} else if (args[i] == "-h") {
|
} else if (args[i] == "-h") {
|
||||||
cout << "Mitsuba version " << Version(MTS_VERSION).toStringComplete()
|
cout << "Mitsuba version " << Version(MTS_VERSION).toStringComplete()
|
||||||
<< ", Copyright (c) " MTS_YEAR " Wenzel Jakob" << endl;
|
<< ", 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 << " -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 << " -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 << " -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;
|
cout << " For documentation, please refer to http://www.mitsuba-renderer.org/docs.html" << endl;
|
||||||
return false;
|
return false;
|
||||||
} else if (args[i].startsWith("-")) {
|
} else if (args[i].startsWith("-")) {
|
||||||
|
@ -376,6 +402,14 @@ bool MainWindow::initWorkersProcessArgv() {
|
||||||
loadFile(toBeLoaded[i].first, toBeLoaded[i].second);
|
loadFile(toBeLoaded[i].first, toBeLoaded[i].second);
|
||||||
|
|
||||||
scheduler->start();
|
scheduler->start();
|
||||||
|
|
||||||
|
if (beginRendering) {
|
||||||
|
for (int i=0; i<ui->tabBar->count(); ++i) {
|
||||||
|
ui->tabBar->setCurrentIndex(i);
|
||||||
|
on_actionRender_triggered();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
raise();
|
raise();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -667,6 +701,7 @@ void MainWindow::onClearRecent() {
|
||||||
|
|
||||||
SceneContext *MainWindow::loadScene(const QString &qFileName, const QString &destFile) {
|
SceneContext *MainWindow::loadScene(const QString &qFileName, const QString &destFile) {
|
||||||
ref<FileResolver> resolver = Thread::getThread()->getFileResolver();
|
ref<FileResolver> resolver = Thread::getThread()->getFileResolver();
|
||||||
|
ref<Logger> logger = Thread::getThread()->getLogger();
|
||||||
fs::path filename = resolver->resolve(toFsPath(qFileName));
|
fs::path filename = resolver->resolve(toFsPath(qFileName));
|
||||||
fs::path filePath = fs::absolute(filename).parent_path();
|
fs::path filePath = fs::absolute(filename).parent_path();
|
||||||
ref<FileResolver> newResolver = resolver->clone();
|
ref<FileResolver> newResolver = resolver->clone();
|
||||||
|
|
Loading…
Reference in New Issue