Commit ae1a997d authored by schultezub's avatar schultezub
Browse files

* added quick and dirty timer to IntPropertWidget

* added scene bounds getter to TrackballNavigationEventHandler

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@521 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent af58935c
......@@ -29,19 +29,45 @@
#include "intpropertywidget.h"
#include <QCheckBox>
#include <QTimer>
#include <QGridLayout>
#include <QWidget>
namespace campvis {
IntPropertyWidget::IntPropertyWidget(IntProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
, _spinBox(0)
, _timer(0)
{
_spinBox = new QSpinBox(this);
_timer = new QTimer(this);
_timer->setSingleShot(false);
QWidget* widget = new QWidget(this);
QGridLayout* layout = new QGridLayout(widget);
widget->setLayout(layout);
_spinBox = new QSpinBox(widget);
_spinBox->setMinimum(property->getMinValue());
_spinBox->setMaximum(property->getMaxValue());
_spinBox->setValue(property->getValue());
addWidget(_spinBox);
layout->addWidget(_spinBox, 0, 0, 1, 2);
_cbEnableTimer = new QCheckBox("Enable Timer", widget);
layout->addWidget(_cbEnableTimer, 1, 0);
_sbInterval = new QSpinBox(widget);
_sbInterval->setMinimum(1);
_sbInterval->setMaximum(2000);
_sbInterval->setValue(50);
layout->addWidget(_sbInterval, 1, 1);
addWidget(widget);
connect(_timer, SIGNAL(timeout()), this, SLOT(onTimer()));
connect(_spinBox, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
connect(_cbEnableTimer, SIGNAL(stateChanged(int)), this, SLOT(onEnableTimerChanged(int)));
connect(_sbInterval, SIGNAL(valueChanged(int)), this, SLOT(onIntervalValueChanged(int)));
property->s_minMaxChanged.connect(this, &IntPropertyWidget::onPropertyMinMaxChanged);
}
......@@ -71,4 +97,26 @@ namespace campvis {
}
}
void IntPropertyWidget::onIntervalValueChanged(int value) {
_timer->setInterval(value);
}
void IntPropertyWidget::onEnableTimerChanged(int state) {
if (state == Qt::Checked) {
_timer->setInterval(_sbInterval->value());
_timer->start();
}
else if (state == Qt::Unchecked) {
_timer->stop();
}
}
void IntPropertyWidget::onTimer() {
IntProperty* prop = static_cast<IntProperty*>(_property);
if (prop->getValue() < prop->getMaxValue())
prop->increment();
else
prop->setValue(prop->getMinValue());
}
}
\ No newline at end of file
......@@ -35,6 +35,9 @@
#include <QSpinBox>
class QCheckBox;
class QTimer;
namespace campvis {
/**
* Widget for a IntProperty
......@@ -63,6 +66,9 @@ namespace campvis {
private slots:
void onValueChanged(int value);
void onIntervalValueChanged(int value);
void onEnableTimerChanged(int state);
void onTimer();
private:
/// Slot getting called when the property's min or max value has changed, so that the widget can be updated.
......@@ -70,6 +76,10 @@ namespace campvis {
QSpinBox* _spinBox;
QTimer* _timer;
QCheckBox* _cbEnableTimer;
QSpinBox* _sbInterval;
};
// ================================================================================================
......
......@@ -134,4 +134,8 @@ namespace campvis {
_trackball->setSceneBounds(bounds);
}
const tgt::Bounds& TrackballNavigationEventHandler::getSceneBounds() const {
return _trackball->getSceneBounds();
}
}
......@@ -119,6 +119,12 @@ namespace campvis {
*/
void setSceneBounds(const tgt::Bounds& bounds);
/**
* Returns the current scene bounds for this trackball.
* \return _sceneBounds
*/
const tgt::Bounds& getSceneBounds() const;
protected:
VisualizationPipeline* _parentPipeline; ///< The parent VisualizationPipeline
CameraProperty* _cameraProperty; ///< The CameraProperty to apply the navigation to
......
......@@ -65,6 +65,14 @@ class TGT_API Bounds {
addPoint(v2);
}
bool operator== (const Bounds& rhs) const {
return (llf_ == rhs.llf_) && (urb_ == rhs.urb_);
}
bool operator!= (const Bounds& rhs) const {
return (llf_ != rhs.llf_) || (urb_ != rhs.urb_);
}
/**
* Enlarges the box (if necessary) to contain v
*/
......
......@@ -168,6 +168,11 @@ void Navigation::updateClippingPlanes() {
getCamera()->setFarDist(diag + 2 * dist);
}
const tgt::Bounds& Navigation::getSceneBounds() const {
return _sceneBounds;
}
/***********************************************************************
......
......@@ -102,6 +102,12 @@ public:
* \param bounds New bounds for the rendered scene.
*/
void setSceneBounds(const tgt::Bounds& bounds);
/**
* Returns the current scene bounds for this trackball.
* \return _sceneBounds
*/
const tgt::Bounds& getSceneBounds() const;
// void setCanvas(GLCanvas* hcam) { hcam_ = hcam; }
// GLCanvas* getCanvas() const { return hcam_->; }
......
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