Commit 3a5c6b23 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Merge branch 'gui-redux' of /mnt/bigone/git/repositories/berge/campvis into development

parents b34862f7 4853ed7d
......@@ -8,6 +8,7 @@ FILE(GLOB CampvisApplicationSources
*.cpp
gui/*.cpp
gui/properties/*.cpp
gui/adjusterwidgets/*.cpp
tools/*.cpp
)
......@@ -17,6 +18,7 @@ FILE(GLOB CampvisApplicationHeaders
glsl/*.vert
gui/*.h
gui/properties/*.h
gui/adjusterwidgets/*.h
tools/*.h
)
......@@ -34,6 +36,11 @@ SET(CampvisApplicationToBeMocced
gui/qtdatahandle.h
gui/logviewerwidget.h
gui/loghighlighter.h
gui/pipelinemdisubwindow.h
gui/visualizationpipelinewidget.h
gui/visualizationpipelinewrapper.h
gui/adjusterwidgets/doubleadjusterwidget.h
gui/adjusterwidgets/intadjusterwidget.h
gui/properties/abstractpropertywidget.h
gui/properties/abstracttransferfunctioneditor.h
gui/properties/boolpropertywidget.h
......
......@@ -190,12 +190,16 @@ namespace campvis {
getCanvas()->getEventHandler()->addListenerToFront(_pipeline);
}
void TumVisPainter::onRenderTargetChanged() {
void TumVisPainter::repaint() {
GLJobProc.enqueueJob(getCanvas(), makeJobOnHeap(this, &TumVisPainter::paint), OpenGLJobProcessor::PaintJob);
}
void TumVisPainter::onRenderTargetChanged() {
repaint();
}
void TumVisPainter::setCanvas(tgt::GLCanvas* canvas) {
tgtAssert(dynamic_cast<tgt::QtThreadedCanvas*>(canvas) != 0, "Canvas must be of type QtThreadedCanvas!");
Painter::setCanvas(canvas);
}
}
\ No newline at end of file
}
......@@ -79,9 +79,9 @@ namespace campvis {
void run();
/**
* Performs the actual rendering of the pipeline's render target
* Schedule a repaint job for the pipeline's render target
*/
virtual void paint();
virtual void repaint();
/// \see tgt::Painter::sizeChanged
virtual void sizeChanged(const tgt::ivec2& size);
......@@ -114,6 +114,11 @@ namespace campvis {
void onRenderTargetChanged();
private:
/**
* Performs the actual rendering of the pipeline's render target
*/
virtual void paint();
static const std::string loggerCat_;
VisualizationPipeline* _pipeline; ///< Pipeline to render
......
// ================================================================================================
//
// 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.
//
// ================================================================================================
#ifndef ABSTRACTADJUSTERWIDGET_H__
#define ABSTRACTADJUSTERWIDGET_H__
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QSlider>
#include <QSpinBox>
namespace campvis {
namespace {
template<typename T>
struct AdjusterWidgetTraits {};
template<>
struct AdjusterWidgetTraits<double> {
typedef QDoubleSpinBox SpinBoxType;
};
template<>
struct AdjusterWidgetTraits<int> {
typedef QSpinBox SpinBoxType;
};
}
// ================================================================================================
/**
* Base class for widgets providing two ways of adjusting numeric values.
*
* AbstractAdjusterWidget consists of a slider, which can be used to quickly change numeric values, and a spin box,
* which is better suited for precise adjustments.
*/
template<typename T>
class AbstractAdjusterWidget : public QWidget {
public:
/**
* Creates a new AbstractAdjusterWidget.
* \param parent parent Qt widget
*/
AbstractAdjusterWidget(QWidget* parent = 0);
/**
* Return the adjuster's current value.
*/
T value() const;
/**
* Return the adjuster's minimum value.
*/
T minimum() const;
/**
* Change the adjuster's minimum value.
* \param minimum new minimum value for the adjuster
*/
void setMinimum(T minimum);
/**
* Return the adjuster's maximum value.
*/
T maximum() const;
/**
* Change the adjuster's maximum value.
* \param maximum new maximum value for the adjuster
*/
void setMaximum(T maximum);
/**
* Return the adjuster's single step value.
*/
T singleStep() const;
/**
* Change the adjuster's single step value.
* \param value new single step value for the adjuster
*/
void setSingleStep(T value);
protected:
/**
* Change the adjuster's current value.
* \param value new value for the adjuster
*/
void setValueImpl(T value);
/// Slot getting called when the spin box's value changes
void onSpinBoxValueChangedImpl(T value);
/// Slot getting called when the slider's value changes
void onSliderValueChangedImpl(T value);
/**
* Set the slider's value.
*
* The slider's value will be set to \p value.
*
* \param value the slider's new value
*/
virtual void setSliderValue(T value);
/**
* Set the slider's properties.
*
* The slider's step, minimum, and maximum value will be updated with the provided arguments.
*
* \param stepValue the slider's new step value
* \param minValue the slider's new minimum value
* \param maxValue the slider's new maximum value
*/
virtual void setSliderProperties(T stepValue, T minValue, T maxValue);
QSlider* _slider; ///< Slider allowing the user to quickly change the value
typename AdjusterWidgetTraits<T>::SpinBoxType* _spinBox; ///< Spin box displaying the current value
};
// ================================================================================================
template<typename T>
AbstractAdjusterWidget<T>::AbstractAdjusterWidget(QWidget* parent /*= 0*/)
: QWidget(parent)
, _slider(0)
, _spinBox(0)
{
_spinBox = new typename AdjusterWidgetTraits<T>::SpinBoxType;
_spinBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
_slider = new QSlider(Qt::Horizontal);
QHBoxLayout* layout = new QHBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(_slider);
layout->addWidget(_spinBox);
setLayout(layout);
}
template<typename T>
T AbstractAdjusterWidget<T>::value() const
{
return _spinBox->value();
}
template<typename T>
void AbstractAdjusterWidget<T>::setValueImpl(T value)
{
_spinBox->setValue(value);
setSliderValue(value);
}
template<typename T>
T AbstractAdjusterWidget<T>::minimum() const
{
return _spinBox->minimum();
}
template<typename T>
void AbstractAdjusterWidget<T>::setMinimum(T minimum)
{
_spinBox->setMinimum(minimum);
setSliderProperties(_spinBox->singleStep(), minimum, _spinBox->maximum());
}
template<typename T>
T AbstractAdjusterWidget<T>::maximum() const
{
return _spinBox->maximum();
}
template<typename T>
void AbstractAdjusterWidget<T>::setMaximum(T maximum)
{
_spinBox->setMaximum(maximum);
setSliderProperties(_spinBox->singleStep(), _spinBox->minimum(), maximum);
}
template<typename T>
T AbstractAdjusterWidget<T>::singleStep() const
{
return _spinBox->singleStep();
}
template<typename T>
void AbstractAdjusterWidget<T>::setSingleStep(T value)
{
_spinBox->setSingleStep(value);
setSliderProperties(value, _spinBox->minimum(), _spinBox->maximum());
}
template<typename T>
void AbstractAdjusterWidget<T>::onSpinBoxValueChangedImpl(T value) {
setSliderValue(value);
}
template<typename T>
void AbstractAdjusterWidget<T>::onSliderValueChangedImpl(T value) {
_spinBox->blockSignals(true);
_spinBox->setValue(value);
_spinBox->blockSignals(false);
}
template<typename T>
void AbstractAdjusterWidget<T>::setSliderValue(T value) {
_slider->blockSignals(true);
_slider->setValue(value);
_slider->blockSignals(false);
}
template<typename T>
void AbstractAdjusterWidget<T>::setSliderProperties(T stepValue, T minValue, T maxValue) {
_slider->blockSignals(true);
_slider->setMinimum(minValue);
_slider->setMaximum(maxValue);
_slider->setSingleStep(stepValue);
_slider->blockSignals(false);
}
}
#endif // ABSTRACTADJUSTERWIDGET_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 "doubleadjusterwidget.h"
#include <cmath>
namespace campvis {
DoubleAdjusterWidget::DoubleAdjusterWidget(QWidget* parent /*= 0*/)
: AbstractAdjusterWidget<double>(parent)
{
setSliderProperties(_spinBox->singleStep(), _spinBox->minimum(), _spinBox->maximum());
connect(_spinBox, SIGNAL(valueChanged(double)), this, SLOT(onSpinBoxValueChanged(double)));
connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
}
void DoubleAdjusterWidget::setValue(double value)
{
setValueImpl(value);
}
void DoubleAdjusterWidget::setDecimals(int prec)
{
_spinBox->setDecimals(prec);
setSliderProperties(_spinBox->singleStep(), _spinBox->minimum(), _spinBox->maximum());
}
void DoubleAdjusterWidget::onSpinBoxValueChanged(double value) {
onSpinBoxValueChangedImpl(value);
emit valueChanged(value);
}
void DoubleAdjusterWidget::onSliderValueChanged(int value) {
const double newValue = _spinBox->minimum() + value * _spinBox->singleStep();
onSliderValueChangedImpl(newValue);
emit valueChanged(newValue);
}
void DoubleAdjusterWidget::setSliderValue(double value) {
AbstractAdjusterWidget<double>::setSliderValue(std::ceil((value - minimum()) / singleStep()));
}
void DoubleAdjusterWidget::setSliderProperties(double stepValue, double minValue, double maxValue) {
// by default minimum and single step are 0 and 1, respectively, so we don't have to change them
AbstractAdjusterWidget<double>::setSliderProperties(1, 0, std::ceil((maxValue - minValue) / stepValue));
setSliderValue(value());
}
}
// ================================================================================================
//
// 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 DOUBLEADJUSTERWIDGET_H__
#define DOUBLEADJUSTERWIDGET_H__
#include "abstractadjusterwidget.h"
namespace campvis {
/**
* Widget providing two ways of adjusting double-precision floating-point values.
*
* DoubleAdjusterWidget consists of a slider, which can be used to quickly change numeric values, and a spin box,
* which is better suited for precise adjustments.
*/
class DoubleAdjusterWidget : public AbstractAdjusterWidget<double> {
Q_OBJECT
public:
/**
* Creates a new DoubleAdjusterWidget.
* \param parent parent Qt widget
*/
DoubleAdjusterWidget(QWidget* parent = 0);
/**
* Set how many decimals the adjuster will use for displaying and interpreting doubles.
* \param prec number of decimals the adjuster will use
*/
void setDecimals(int prec);
public slots:
/**
* Change the adjuster's current value.
* \param value new value for the adjuster
*/
void setValue(double value);
signals:
/**
* This signal is emitted whenever the adjuster's value is changed.
* \param value new value of the adjuster
*/
void valueChanged(double value);
protected:
/**
* Calculate and set the slider's value.
*
* The slider's value will be based on the provided current value of the adjuster, as well as its step and
* minimum value.
*
* \param value the adjuster's new value
*/
void setSliderValue(double value);
/**
* Calculate and set the slider's properties.
*
* The slider's properties will be based on the provided step, minimum, and maximum value of the adjuster.
*
* \param stepValue the adjuster's step value
* \param minValue the adjuster's minimum value
* \param maxValue the adjuster's maximum value
*/
void setSliderProperties(double stepValue, double minValue, double maxValue);
private slots:
/// Slot getting called when the spin box's value changes
void onSpinBoxValueChanged(double value);
/// Slot getting called when the slider's value changes
void onSliderValueChanged(int value);
};
}
#endif // DOUBLEADJUSTERWIDGET_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 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 "intadjusterwidget.h"
#include <QHBoxLayout>
namespace campvis {
IntAdjusterWidget::IntAdjusterWidget(QWidget* parent /*= 0*/)
: AbstractAdjusterWidget<int>(parent)
{
setSliderProperties(_spinBox->singleStep(), _spinBox->minimum(), _spinBox->maximum());
connect(_spinBox, SIGNAL(valueChanged(int)), this, SLOT(onSpinBoxValueChanged(int)));
connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
}
void IntAdjusterWidget::setValue(int value)
{
setValueImpl(value);
}
void IntAdjusterWidget::onSpinBoxValueChanged(int value) {
onSpinBoxValueChangedImpl(value);
emit valueChanged(value);
}
void IntAdjusterWidget::onSliderValueChanged(int value) {
onSliderValueChangedImpl(value);
emit valueChanged(value);
}
}
// ================================================================================================
//
// 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 INTADJUSTERWIDGET_H__
#define INTADJUSTERWIDGET_H__
#include "abstractadjusterwidget.h"
namespace campvis {
/**