Commit df8c3e9f authored by schultezub's avatar schultezub
Browse files

reintegrated branch gui-redux: r520

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@523 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parents 93cdefc6 4c4e6d0c
......@@ -20,6 +20,10 @@ FILE(GLOB CampvisApplicationHeaders
tools/*.h
)
FILE(GLOB CampvisApplicationForms
ui/*.ui
)
SET(CampvisApplicationToBeMocced
gui/mainwindow.h
gui/datacontainerinspectorcanvas.h
......@@ -28,6 +32,8 @@ SET(CampvisApplicationToBeMocced
gui/pipelinetreewidget.h
gui/qtcolortools.h
gui/qtdatahandle.h
gui/logviewerwidget.h
gui/loghighlighter.h
gui/properties/abstractpropertywidget.h
gui/properties/abstracttransferfunctioneditor.h
gui/properties/boolpropertywidget.h
......@@ -43,6 +49,8 @@ SET(CampvisApplicationToBeMocced
gui/properties/simpletransferfunctioneditor.h
gui/properties/stringpropertywidget.h
gui/properties/transferfunctionpropertywidget.h
tools/qtexteditlog.h
tools/bufferinglog.h
)
LIST(APPEND CampvisApplicationDefinitions "-DCAMPVIS_SOURCE_DIR=\"${CampvisHome}\"")
......@@ -53,14 +61,16 @@ LIST(APPEND CampvisApplicationDefinitions "-DCAMPVIS_SOURCE_DIR=\"${CampvisHome}
FIND_PACKAGE(Qt4 ${CampvisRequiredQtVersion} REQUIRED QtCore QtGui QtOpenGL)
QT4_WRAP_CPP(CampvisApplicationMoc ${CampvisApplicationToBeMocced})
LIST(APPEND CampvisApplicationSources ${CampvisApplicationMoc})
QT4_WRAP_UI(CampvisApplicationFormsHeaders ${CampvisApplicationForms})
LIST(APPEND CampvisApplicationSources ${CampvisApplicationFormsHeaders})
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})
......
......@@ -238,6 +238,7 @@ namespace campvis {
// create canvas and painter for the VisPipeline and connect all together
tgt::QtThreadedCanvas* canvas = CtxtMgr.createContext(name, "CAMPVis", tgt::ivec2(512, 512));
GLJobProc.registerContext(canvas);
_mainWindow->addVisualizationPipelineWidget(name, canvas);
canvas->init();
TumVisPainter* painter = new TumVisPainter(canvas, vp);
......@@ -251,4 +252,10 @@ namespace campvis {
CtxtMgr.releaseCurrentContext();
}
}
\ No newline at end of file
void CampVisApplication::registerDockWidget(Qt::DockWidgetArea area, QDockWidget* dock) {
tgtAssert(dock != 0, "Dock widget must not be 0.");
_mainWindow->addDockWidget(area, dock);
}
}
......@@ -34,6 +34,7 @@
#include "sigslot/sigslot.h"
#include <QApplication>
#include <QDockWidget>
#include <utility>
#include <vector>
......@@ -108,6 +109,15 @@ namespace campvis {
*/
void addVisualizationPipeline(const std::string& name, VisualizationPipeline* vp);
/**
* Adds a dock widget to the main window.
* The dock widget will be automatically docked in the specified area.
*
* \param area Area of the main window to which the dock widget should be added.
* \param dock The dock widget to add to the main window.
*/
void registerDockWidget(Qt::DockWidgetArea area, QDockWidget* dock);
/**
* Runs the actual application.
* Make sure to call init() before.
......
......@@ -133,6 +133,7 @@ namespace campvis {
_infoWidgetLayout->addWidget(_btnSaveToFile);
_canvas = new DataContainerInspectorCanvas(_infoWidget);
_canvas->setMinimumSize(QSize(100, 100));
_infoWidgetLayout->addWidget(_canvas, 1);
_pcWidget = new PropertyCollectionWidget(_infoWidget);
......
// ================================================================================================
//
// 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.
//
// ================================================================================================
#include "loghighlighter.h"
#include <QPalette>
namespace campvis {
LogHighlighter::LogHighlighter(QTextEdit* parent)
: QSyntaxHighlighter(parent)
, _filterRegExp(0)
{
QBrush fgBrush = QBrush(Qt::white);
// Firefox's green highlight
QBrush bgBrush = QBrush(QColor(56, 216, 120));
_filterMatchFormat.setBackground(bgBrush);
_filterMatchFormat.setForeground(fgBrush);
}
LogHighlighter::~LogHighlighter() {
setFilterRegExp(0);
}
void LogHighlighter::setFilterRegExp(const QRegExp* filterRegExp) {
if (_filterRegExp != 0) {
delete _filterRegExp;
}
_filterRegExp = filterRegExp;
}
void LogHighlighter::highlightBlock(const QString& text)
{
if (_filterRegExp != 0) {
highlightFilterMatches(text);
}
}
void LogHighlighter::highlightFilterMatches(const QString &text) {
int pos = 0;
while ((pos = _filterRegExp->indexIn(text, pos)) != -1) {
int matchedLength = _filterRegExp->matchedLength();
setFormat(pos, matchedLength, _filterMatchFormat);
pos += matchedLength;
}
}
}
// ================================================================================================
//
// 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 LOGHIGHLIGHTER_H__
#define LOGHIGHLIGHTER_H__
#include <QTextEdit>
#include <QSyntaxHighlighter>
namespace campvis {
class LogHighlighter : public QSyntaxHighlighter {
Q_OBJECT;
public:
/**
* Constructs a LogHighlighter and installs it on parent.
*
* The specified QTextEdit also becomes the owner of the LogHighlighter.
*
* \param parent the QTextEdit to install the LogHighlighter on
*/
LogHighlighter(QTextEdit* parent);
/**
* Destructor.
*/
~LogHighlighter();
/**
* Highlights the given log block.
*
* This function is called when necessary by the rich text engine, i.e. on new/changed log
* messages.
*
* \param text the log block to highlight
*/
void highlightBlock(const QString &text);
/**
* Set the current filter regexp to highlight.
*
* \param filterRegExp the current filter regexp
*/
void setFilterRegExp(const QRegExp* filterRegExp);
private:
/**
* Highlight all matches of the current regexp in the given log block.
*
* \param text the log block to highlight
*/
void highlightFilterMatches(const QString &text);
const QRegExp* _filterRegExp; ///< Current filter regexp
QTextCharFormat _filterMatchFormat; ///< Format for highlighting filter matches
};
}
#endif // LOGHIGHLIGHTER_H__
// ================================================================================================
//
// 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)
, _filterRegExp(0)
{
setupGUI();
_log = new BufferingLog(100, this);
_log->addCat("", true);
connect(_log, SIGNAL(s_messageAppended(const QString&)),
this, SLOT(appendMessage(const QString&)));
}
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);
// Use the system's default monospace font at the default size in the log viewer
QFont monoFont = QFont("Monospace");
monoFont.setStyleHint(QFont::TypeWriter);
monoFont.setPointSize(QFont().pointSize() + 1);
_logDisplay->document()->setDefaultFont(monoFont);
_logHighlighter = new LogHighlighter(_logDisplay);
connect(_clear_button, SIGNAL(clicked()), this, SLOT(clearMessages()));
connect(_filter_line_edit, SIGNAL(textEdited(const QString&)), this, SLOT(filterLogMessages(const QString&)));
}
void LogViewerWidget::init() {
LogMgr.addLog(_log);
}
void LogViewerWidget::deinit() {
LogMgr.removeLog(_log);
}
void LogViewerWidget::appendMessage(const QString& message)
{
_logMessages.push_back(message);
displayMessage(message);
}
void LogViewerWidget::displayMessage(const QString& message)
{
if (_filterRegExp == 0 || _filterRegExp->indexIn(message) != -1) {
_logDisplay->append(message);
}
}
void LogViewerWidget::clearMessages()
{
_logDisplay->clear();
_logMessages.clear();
}
void LogViewerWidget::filterLogMessages(const QString& text)
{
if (text.length() == 0) {
_filterRegExp = 0;
} else {
_filterRegExp = new QRegExp(text, Qt::CaseInsensitive, QRegExp::FixedString);
}
_logDisplay->clear();
_logHighlighter->setFilterRegExp(_filterRegExp);
for (std::deque<QString>::iterator it = _logMessages.begin(); it != _logMessages.end(); it++) {
displayMessage(*it);
}
}
}
// ================================================================================================
//
// 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/bufferinglog.h"
#include "application/gui/loghighlighter.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();
protected:
/**
* Setup the the log viewer's GUI
*/
void setupGUI();
public slots:
/**
* Append the given message to the log viewer
*
* This function adds the specified message to the log viewer's message cache and
* displays it.
*
* \param message message to append to the log viewer
*/
void appendMessage(const QString& message);
private slots:
/**
* Display the given message in the log viewer
*
* \param message message to display in the log viewer
*/
void displayMessage(const QString& message);
/**
* Delete all messages from the log viewer
*/
void clearMessages();
/**
* Filter out log messages that don't contain the given text.
*
* \param text text to look for in log messages
*/
void filterLogMessages(const QString& text);
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
BufferingLog* _log; ///< Log buffering messages
std::deque<QString> _logMessages; ///< Queue storing a limited number of recent log messages
QTextEdit* _logDisplay; ///< Widget displaying log messages
const QRegExp* _filterRegExp; ///< Current filter regexp
LogHighlighter* _logHighlighter; ///< Highlighter for log messages
};
}
#endif // LOGVIEWERWIDGET_H__
......@@ -46,12 +46,15 @@ namespace campvis {
, _pipelineWidget(0)
, _propCollectionWidget(0)
, _dcInspectorWidget(0)
, _dcInspectorDock(0)
, _btnExecute(0)
, _btnShowDataContainerInspector(0)
, _selectedPipeline(0)
, _selectedProcessor(0)
, _logViewer(0)
{
tgtAssert(_application != 0, "Application must not be 0.");
ui.setupUi(this);
setup();
}
......@@ -63,18 +66,18 @@ namespace campvis {
void MainWindow::setup() {
qRegisterMetaType<QtDataHandle>("QtDataHandle");
_dcInspectorWidget = new DataContainerInspectorWidget();
_dcInspectorWidget->show();
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
_centralWidget = new QWidget(this);
QHBoxLayout* mainLayout = new QHBoxLayout();
mainLayout->setSpacing(4);
setTabPosition(Qt::TopDockWidgetArea, QTabWidget::North);
_pipelineWidget = new PipelineTreeWidget(_centralWidget);
mainLayout->addWidget(_pipelineWidget);
_pipelineWidget = new PipelineTreeWidget();
ui.pipelineTreeDock->setWidget(_pipelineWidget);
QWidget* rightWidget = new QWidget(_centralWidget);
mainLayout->addWidget(rightWidget);
QWidget* rightWidget = new QWidget();
ui.pipelinePropertiesDock->setWidget(rightWidget);
QVBoxLayout* rightLayout = new QVBoxLayout();
rightLayout->setSpacing(4);
......@@ -89,8 +92,11 @@ namespace campvis {
_propCollectionWidget = new PropertyCollectionWidget(_centralWidget);
rightLayout->addWidget(_propCollectionWidget);
_centralWidget->setLayout(mainLayout);
setCentralWidget(_centralWidget);
_logViewer = new LogViewerWidget();
ui.logViewerDock->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
ui.logViewerDock->setWidget(_logViewer);
_dcInspectorWidget = new DataContainerInspectorWidget();
connect(
this, SIGNAL(updatePipelineWidget(const std::vector<AbstractPipeline*>&)),
......@@ -123,8 +129,6 @@ namespace campvis {
if (AbstractPipeline* pipeline = dynamic_cast<AbstractPipeline*>(ptr)) {
_selectedPipeline = pipeline;
_selectedProcessor = 0;
if (_dcInspectorWidget != 0)
onBtnShowDataContainerInspectorClicked();
}
else if (AbstractProcessor* processor = dynamic_cast<AbstractProcessor*>(ptr)) {
_selectedProcessor = processor;
......@@ -162,19 +166,52 @@ namespace campvis {
void MainWindow::onBtnShowDataContainerInspectorClicked() {
if (_selectedPipeline != 0) {
if (_dcInspectorDock == 0) {
_dcInspectorDock = dockPrimaryWidget("Data Container inspector", _dcInspectorWidget);
} else {
// Activate the dock's tab
_dcInspectorDock->setVisible(true);
_dcInspectorDock->raise();
}
_dcInspectorWidget->setDataContainer(&(_selectedPipeline->getDataContainer()));
_dcInspectorWidget->show();
}
}
void MainWindow::init() {
if (_dcInspectorWidget != 0)
_dcInspectorWidget->init();
_logViewer->init();
}
void MainWindow::deinit() {
</