mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 09:30:25 +08:00
git-svn-id: http://rtabmap.googlecode.com/svn/branches/0.3/rtabmap@52 f169173b-cf89-36c8-b27e-44dbe73f0c83
78 lines
2.2 KiB
C++
78 lines
2.2 KiB
C++
/*
|
|
* Copyright (C) 2010-2011, Mathieu Labbe and IntRoLab - Universite de Sherbrooke
|
|
*
|
|
* This file is part of RTAB-Map.
|
|
*
|
|
* RTAB-Map is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* RTAB-Map is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with RTAB-Map. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "ConsoleWidget.h"
|
|
#include <utilite/ULogger.h>
|
|
#include <utilite/UEventsManager.h>
|
|
#include <QtGui/QMessageBox>
|
|
|
|
namespace rtabmap {
|
|
|
|
ConsoleWidget::ConsoleWidget(QWidget * parent) :
|
|
QWidget(parent)
|
|
{
|
|
_ui.setupUi(this);
|
|
UEventsManager::addHandler(this);
|
|
connect(this, SIGNAL(msgReceived(const QString &, int)), this, SLOT(appendMsg(const QString &, int)));
|
|
_ui.textEdit->document()->setMaximumBlockCount(100);
|
|
_ui.textEdit->setFontPointSize(10);
|
|
}
|
|
|
|
ConsoleWidget::~ConsoleWidget()
|
|
{
|
|
}
|
|
|
|
void ConsoleWidget::handleEvent(UEvent * anEvent)
|
|
{
|
|
// WARNING, don't put a log message here! otherwise it could be recursively called.
|
|
if(anEvent->getClassName().compare("ULogEvent") == 0)
|
|
{
|
|
ULogEvent * logEvent = (ULogEvent*)anEvent;
|
|
emit msgReceived(logEvent->getMsg().c_str(), logEvent->getCode());
|
|
if(logEvent->getCode() == ULogger::kFatal)
|
|
{
|
|
//The application will exit, so warn the user.
|
|
QMessageBox::critical(this, tr("Fatal error occurred"), tr("Error! :\n \"%1\"\nThe application will now exit...").arg(logEvent->getMsg().c_str()), QMessageBox::Ok);
|
|
}
|
|
}
|
|
}
|
|
|
|
void ConsoleWidget::appendMsg(const QString & msg, int level)
|
|
{
|
|
switch(level)
|
|
{
|
|
case 0:
|
|
_ui.textEdit->setTextColor(Qt::darkGreen);
|
|
break;
|
|
case 2:
|
|
_ui.textEdit->setTextColor(Qt::darkYellow);
|
|
break;
|
|
case 3:
|
|
case 4:
|
|
_ui.textEdit->setTextColor(Qt::darkRed);
|
|
break;
|
|
default:
|
|
_ui.textEdit->setTextColor(Qt::black);
|
|
break;
|
|
}
|
|
_ui.textEdit->append(msg);
|
|
}
|
|
|
|
}
|