Commit 3121761e authored by grunau's avatar grunau
Browse files

Display log messages in a separate widget

There is now a new widget (LogViewerWidget) dedicated to displaying log
messages. It builds upon the previous ad-hoc design, adding controls for
clearing and filtering log messages. Clearing has been implemented
already, filtering on the other hand doesn't work yet.

git-svn-id: https://camplinux.in.tum.de/svn/campvis/branches/gui-redux@507 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent e268c029
......@@ -32,6 +32,7 @@ SET(CampvisApplicationToBeMocced
gui/pipelinetreewidget.h
gui/qtcolortools.h
gui/qtdatahandle.h
gui/logviewerwidget.h
gui/properties/abstractpropertywidget.h
gui/properties/abstracttransferfunctioneditor.h
gui/properties/boolpropertywidget.h
......@@ -63,10 +64,10 @@ INCLUDE(${QT_USE_FILE})
LINK_DIRECTORIES(${CampvisGlobalLinkDirectories} ${CampvisModulesLinkDirectories})
ADD_EXECUTABLE(campvis-application
${CampvisApplicationSources} ${CampvisApplicationHeaders}
ADD_EXECUTABLE(campvis-application
${CampvisApplicationSources} ${CampvisApplicationHeaders}
${CampvisApplicationMoc}
)
)
ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisModulesDefinitions} ${CampvisApplicationDefinitions} ${QT_DEFINITIONS})
INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CampvisModulesIncludeDirs})
TARGET_LINK_LIBRARIES(campvis-application campvis-core campvis-modules tgt ${CampvisGlobalExternalLibs} ${CampvisModulesExternalLibs} ${QT_LIBRARIES})
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "logviewerwidget.h"
namespace campvis {
LogViewerWidget::LogViewerWidget(QWidget* parent)
: QWidget(parent)
{
setupGUI();
_log = new QTextEditLog(_logDisplay, this);
_log->addCat("", true);
}
LogViewerWidget::~LogViewerWidget() {
}
void LogViewerWidget::setupGUI() {
setWindowTitle(tr("Log Viewer"));
_mainLayout = new QVBoxLayout();
setLayout(_mainLayout);
_controls_layout = new QHBoxLayout();
_mainLayout->addLayout(_controls_layout);
_filter_label = new QLabel(tr("&Filter:"));
_controls_layout->addWidget(_filter_label);
_filter_line_edit = new QLineEdit();
_filter_line_edit->setPlaceholderText(tr("Start typing here to filter log messages"));
_filter_label->setBuddy(_filter_line_edit);
_controls_layout->addWidget(_filter_line_edit);
_controls_layout->addStretch();
_clear_button = new QPushButton(tr("&Clear"));
_controls_layout->addWidget(_clear_button);
_logDisplay = new QTextEdit();
_logDisplay->setReadOnly(true);
_mainLayout->addWidget(_logDisplay);
connect(_clear_button, SIGNAL(clicked()), _logDisplay, SLOT(clear()));
}
void LogViewerWidget::init() {
LogMgr.addLog(_log);
}
void LogViewerWidget::deinit() {
LogMgr.removeLog(_log);
}
}
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef LOGVIEWERWIDGET_H__
#define LOGVIEWERWIDGET_H__
#include "sigslot/sigslot.h"
#include "tgt/painter.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tgt/qt/qtthreadedcanvas.h"
#include "tbb/mutex.h"
#include "application/tools/qtexteditlog.h"
#include <QLabel>
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QString>
#include <QPushButton>
#include <QLineEdit>
#include <QTextEdit>
namespace campvis {
class LogViewerWidget : public QWidget {
Q_OBJECT;
public:
/**
* Creates a new DataContainerInspectorWidget.
* \param parent Parent Qt widget, may be 0 (default)
*/
LogViewerWidget(QWidget* parent = 0);
/**
* Destructor.
*/
~LogViewerWidget();
/**
* Initializes the underlying log and registers it with tgt.
*/
void init();
/**
* Deinitializes the underlying log and deregisters it from tgt.
*/
void deinit();
signals:
void dataContainerChanged(const QString&);
protected:
/**
* Setup the the log viewer's GUI
*/
void setupGUI();
private:
QVBoxLayout* _mainLayout; ///< Main layout of this widget
QHBoxLayout* _controls_layout; ///< Layout storing this widget's controls
QPushButton* _clear_button; ///< Button used for clearing the log display
QLineEdit* _filter_line_edit; ///< Text field where filter terms are entered
QLabel* _filter_label; ///< Button used for clearing the log display
QTextEditLog* _log; ///< Log appending messages to a QTextEdit
QTextEdit* _logDisplay; ///< Widget displaying log messages
};
}
#endif // LOGVIEWERWIDGET_H__
......@@ -52,7 +52,6 @@ namespace campvis {
, _selectedPipeline(0)
, _selectedProcessor(0)
, _logViewer(0)
, _log(0)
{
tgtAssert(_application != 0, "Application must not be 0.");
ui.setupUi(this);
......@@ -93,8 +92,7 @@ namespace campvis {
_propCollectionWidget = new PropertyCollectionWidget(_centralWidget);
rightLayout->addWidget(_propCollectionWidget);
_logViewer = new QTextEdit();
_logViewer->setReadOnly(true);
_logViewer = new LogViewerWidget();
ui.logViewerDock->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
ui.logViewerDock->setWidget(_logViewer);
......@@ -177,16 +175,14 @@ namespace campvis {
if (_dcInspectorWidget != 0)
_dcInspectorWidget->init();
_log = new QTextEditLog(_logViewer);
_log->addCat("", true);
LogMgr.addLog(_log);
_logViewer->init();
}
void MainWindow::deinit() {
if (_dcInspectorWidget != 0)
_dcInspectorWidget->deinit();
LogMgr.removeLog(_log);
_logViewer->deinit();
}
void MainWindow::addVisualizationPipelineWidget(const std::string& name, QWidget* widget) {
......
......@@ -34,6 +34,7 @@
#include "application/campvisapplication.h"
#include "application/gui/pipelinetreewidget.h"
#include "application/gui/properties/propertycollectionwidget.h"
#include "application/gui/logviewerwidget.h"
#include "application/tools/qtexteditlog.h"
#include "application/ui_mainwindow.h"
......@@ -41,7 +42,6 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QTextEdit>
#include <vector>
namespace campvis {
......@@ -152,9 +152,8 @@ namespace campvis {
AbstractPipeline* _selectedPipeline; ///< currently selected pipeline
AbstractProcessor* _selectedProcessor; ///< currently selected processor
QTextEditLog* _log; ///< Log appending messages to a QTextEdit
QTextEdit* _logViewer; ///< Widget displaying log messages
std::vector<QDockWidget*> _primaryDocks; ///< Docks located in top docking area of the main window
LogViewerWidget* _logViewer; ///< Widget displaying log messages
std::vector<QDockWidget*> _primaryDocks; ///< Docks located in top docking area of the main window
};
}
......
......@@ -4,9 +4,10 @@
namespace campvis {
QTextEditLog::QTextEditLog(QTextEdit* logDisplay, bool dateStamping, bool timeStamping,
bool showCat, bool showLevel)
: _logDisplay(logDisplay)
QTextEditLog::QTextEditLog(QTextEdit* logDisplay, QObject* parent, bool dateStamping,
bool timeStamping, bool showCat, bool showLevel)
: QObject(parent)
, _logDisplay(logDisplay)
{
tgtAssert(logDisplay != 0, "Log display widget must not be 0.");
......@@ -37,4 +38,4 @@ namespace campvis {
emit s_messageReady(QString::fromStdString(output + msg));
}
}
\ No newline at end of file
}
......@@ -25,13 +25,14 @@ namespace campvis {
* QTextEditLog doesn't take ownership of the QTextEdit instance it's passed.
*
* \param output a QTextEdit instance to which messages will be logged
* \param parent the log's parent object
* \param dateStamping should logged messages be date-stamped
* \param timeStamping should logged messages be time-stamped
* \param showCat should the category be printed along with the messages
* \param showLevel should the LogLevel be printed along with the messages
*/
QTextEditLog(QTextEdit* logDisplay, bool dateStamping = true, bool timeStamping = true,
bool showCat = true, bool showLevel = true);
QTextEditLog(QTextEdit* logDisplay, QObject* parent = 0, bool dateStamping = true,
bool timeStamping = true, bool showCat = true, bool showLevel = true);
virtual ~QTextEditLog() {}
bool isOpen() { return true; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment