Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 35a402e5 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Starting work on refactoring the camera API:

* Introducing new data type CameraData
* Introducing CameraProvider and TrackballCameraProvider processors (in base module)
* Introducing AbstractProcessor::ignorePropertyChanges() and AbstractProcessor::observePropertyChanges()
* Added debug output to NumericProperty if it clamps values to the property's value range

refs #141
parent 331b5f32
// ================================================================================================
//
// 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 "cameradata.h"
namespace campvis {
CameraData::CameraData(const tgt::Camera& camera /*= tgt::Camera()*/)
: AbstractData()
, _camera(camera)
{
}
CameraData::~CameraData() {
}
CameraData* CameraData::clone() const {
return new CameraData(*this);
}
size_t CameraData::getLocalMemoryFootprint() const {
return sizeof(*this);
}
size_t CameraData::getVideoMemoryFootprint() const {
return 0;
}
const tgt::Camera& CameraData::getCamera() const {
return _camera;
}
tgt::Camera& CameraData::getCamera() {
return _camera;
}
void CameraData::setCamera(const tgt::Camera& camera) {
_camera = camera;
}
}
\ No newline at end of file
// ================================================================================================
//
// 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 CAMERADATA_H__
#define CAMERADATA_H__
#include "tgt/camera.h"
#include "core/datastructures/abstractdata.h"
#include <vector>
namespace tgt {
}
namespace campvis {
/**
* Data object storing camera data.
*/
class CameraData : public AbstractData {
public:
/**
* Constructor, creating a new CameraData object initialized by \a camera.
* \param camera Camera object used for initialization (optional)
*/
explicit CameraData(const tgt::Camera& camera = tgt::Camera());
/**
* Destructor.
*/
virtual ~CameraData();
/// \see AbstractData::clone()
virtual CameraData* clone() const;
/// \see AbstractData::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
/// \see AbstractData::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/**
* Const getter for the camera settings.
* \return _camera
*/
const tgt::Camera& getCamera() const;
/**
* Non-const getter for the camera settings.
* \return _camera
*/
tgt::Camera& getCamera();
/**
* Sets the camera settings to \a camera.
* \param camera New camera settings.
*/
void setCamera(const tgt::Camera& camera);
protected:
tgt::Camera _camera; ///< The tgt::Camera object storing the camera setup
};
}
#endif // CAMERADATA_H__
......@@ -38,6 +38,7 @@ namespace campvis {
{
_enabled = true;
_clockExecutionTime = false;
_ignorePropertyChanges = 0;
_locked = 0;
_level = VALID;
}
......@@ -81,12 +82,14 @@ namespace campvis {
}
void AbstractProcessor::onPropertyChanged(const AbstractProperty* prop) {
tbb::spin_rw_mutex::scoped_lock lock(_mtxInvalidationMap, false);
auto it = _invalidationMap.find(prop);
if (it != _invalidationMap.end())
invalidate(it->second);
else
LDEBUG("Caught an property changed signal that was not registered with an invalidation level. Did you forget to call addProperty()?");
if (_ignorePropertyChanges == 0) {
tbb::spin_rw_mutex::scoped_lock lock(_mtxInvalidationMap, false);
auto it = _invalidationMap.find(prop);
if (it != _invalidationMap.end())
invalidate(it->second);
else
LDEBUG("Caught an property changed signal that was not registered with an invalidation level. Did you forget to call addProperty()?");
}
}
bool AbstractProcessor::getEnabled() const {
......@@ -169,4 +172,11 @@ namespace campvis {
tbb::spin_rw_mutex::scoped_lock lock(_mtxInvalidationMap, true);
_invalidationMap[&prop] = invalidationLevel;
}
void AbstractProcessor::ignorePropertyChanges() {
++_ignorePropertyChanges;
}
void AbstractProcessor::observePropertyChanges() {
--_ignorePropertyChanges;
}
}
......@@ -291,6 +291,18 @@ namespace campvis {
validate(static_cast<int>(il));
}
/**
* Sets that incoming change signals from properties are ignored.
* \see observePropertyChanges()
*/
void ignorePropertyChanges();
/**
* Sets that incoming signals from properties are no longer ignored.
* \see ignorePropertyChanges()
*/
void observePropertyChanges();
/// Signal emitted when the processor has been invalidated.
sigslot::signal1<AbstractProcessor*> s_invalidated;
......@@ -351,6 +363,7 @@ namespace campvis {
tbb::atomic<bool> _enabled; ///< flag whether this processor is currently enabled
tbb::atomic<bool> _clockExecutionTime; ///< flag whether to measure the execution time of this processor
tbb::atomic<int> _ignorePropertyChanges; ///< flag whether signals from properties shall be ignored
/// Flag whether this processor is currently locked
/// (This implies, that all properties are locked and it is not valid to call process())
......
......@@ -46,9 +46,12 @@ namespace {
template<typename T>
struct NumericPropertyTraits<T, true> {
static T validateValue(const T& value, const T& minValue, const T& maxValue) {
if (value >= minValue && value <= maxValue)
if (value >= minValue && value <= maxValue) {
return value;
}
else {
if (tgt::LogManager::isInited())
LDEBUGC("CAMPVis.core.properties.NumericProperty", "Validating value " << value << ": Out of bounds [" << minValue << ", " << maxValue << "], clamping to range!");
return (value < minValue) ? minValue : maxValue;
}
}
......@@ -63,10 +66,14 @@ namespace {
T toReturn(value);
for (size_t i = 0; i < value.size; ++i) {
if (toReturn[i] < minValue[i])
if (toReturn[i] < minValue[i]) {
if (tgt::LogManager::isInited())
LDEBUGC("CAMPVis.core.properties.NumericProperty", "Validating value " << value << ": Out of bounds [" << minValue << ", " << maxValue << "], clamping to range!");
toReturn[i] = minValue[i];
else if (toReturn[i] > maxValue[i])
}
else if (toReturn[i] > maxValue[i]) {
toReturn[i] = maxValue[i];
}
}
return toReturn;
}
......
// ================================================================================================
//
// 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 "cameraprovider.h"
#include "core/datastructures/cameradata.h"
namespace campvis {
static const GenericOption<tgt::Camera::ProjectionMode> projectionOptions[3] = {
GenericOption<tgt::Camera::ProjectionMode>("perspective", "Perspective", tgt::Camera::PERSPECTIVE),
GenericOption<tgt::Camera::ProjectionMode>("orthographic", "Orthographice", tgt::Camera::ORTHOGRAPHIC),
GenericOption<tgt::Camera::ProjectionMode>("frustum", "Frustum", tgt::Camera::FRUSTUM)
};
const std::string CameraProvider::loggerCat_ = "CAMPVis.modules.io.CameraProvider";
CameraProvider::CameraProvider()
: AbstractProcessor()
, p_cameraId("CameraId", "Camera ID", "camera", DataNameProperty::WRITE)
, p_position("Position", "Camera Position", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f))
, p_focus("Focus", "Camera Focus", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f))
, p_upVector("UpVector", "Camera Up Vector", tgt::vec3(0.f, 1.f, 0.f), tgt::vec3(-1.f), tgt::vec3(1.f))
, p_fov("FoV", "Field of View", 45.f, 1.f, 180.f)
, p_aspectRatio("AspectRatio", "Aspect Ratio", 1.f, .001f, 100.f)
, p_clippingPlanes("ClippingPlanes", "Near/Far Clipping Planes", tgt::vec2(.1f, 50.f), tgt::vec2(0.f), tgt::vec2(10000.f))
, p_projectionMode("ProjectionMode", "Projection Mode", projectionOptions, 3)
{
addProperty(p_cameraId);
addProperty(p_position);
addProperty(p_focus);
addProperty(p_upVector);
addProperty(p_fov);
addProperty(p_aspectRatio);
addProperty(p_clippingPlanes);
addProperty(p_projectionMode);
}
CameraProvider::~CameraProvider() {
}
void CameraProvider::updateResult(DataContainer& dataContainer) {
CameraData* cameraData = new CameraData(tgt::Camera(
p_position.getValue(),
p_focus.getValue(),
p_upVector.getValue(),
p_fov.getValue(),
p_aspectRatio.getValue(),
p_clippingPlanes.getValue().x,
p_clippingPlanes.getValue().y+.1f,
p_projectionMode.getOptionValue()));
dataContainer.addData(p_cameraId.getValue(), cameraData);
validate(INVALID_RESULT);
}
}
\ No newline at end of file
// ================================================================================================
//
// 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 CAMERAPROVIDER_H__
#define CAMERAPROVIDER_H__
#include <string>
#include "tgt/camera.h"
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/floatingpointproperty.h"
#include "core/properties/optionproperty.h"
namespace campvis {
/**
* Generates CameraData objects.
*/
class CameraProvider : public AbstractProcessor {
public:
/**
* Constructs a new CameraProvider Processor
**/
CameraProvider();
/**
* Destructor
**/
virtual ~CameraProvider();
/// \see AbstractProcessor::updateResult()
virtual void updateResult(DataContainer& dataContainer);
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "CameraProvider"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Generates CameraData objects."; };
/// \see AbstractProcessor::getAuthor()
virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
DataNameProperty p_cameraId; ///< Name/ID for the CameraData object
Vec3Property p_position; /// location of the camera
Vec3Property p_focus; /// location, the camera looks at
Vec3Property p_upVector; /// up vector, always normalized
FloatProperty p_fov; ///< Field of View
FloatProperty p_aspectRatio; ///< Aspect Ratio
Vec2Property p_clippingPlanes; ///< Near and far clipping planes
GenericOptionProperty<tgt::Camera::ProjectionMode> p_projectionMode; ///< Projection mode
protected:
static const std::string loggerCat_;
};
}
#endif // CAMERAPROVIDER_H__
\ No newline at end of file
// ================================================================================================
//
// 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 "tgt/assert.h"
#include "tgt/event/mouseevent.h"
#include "trackballcameraprovider.h"
#include "core/datastructures/cameradata.h"
#include "core/datastructures/imagedata.h"
#include "core/pipeline/visualizationprocessor.h"
namespace campvis {
// = TrackballNavigationEventHandler ==============================================================
static const GenericOption<TrackballCameraProvider::AutomationMode> automationOptions[3] = {
GenericOption<TrackballCameraProvider::AutomationMode>("manual", "Fully Manual", TrackballCameraProvider::FullManual),
GenericOption<TrackballCameraProvider::AutomationMode>("semiAutomatic", "SemiAutomatic", TrackballCameraProvider::SemiAutomatic),
GenericOption<TrackballCameraProvider::AutomationMode>("automatic", "Fully Automatic", TrackballCameraProvider::FullAutomatic)
};
const std::string TrackballCameraProvider::loggerCat_ = "CAMPVis.modules.io.TrackballCameraProvider";
TrackballCameraProvider::TrackballCameraProvider(IVec2Property* canvasSize)
: CameraProvider()
, p_automationMode("AutomationMode", "Automation Mode", automationOptions, 3)
, p_image("ReferenceImage", "Reference Image", "", DataNameProperty::READ)
, p_llf("LLF", "Bounding Box LLF", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f))
, p_urb("URB", "Bounding Box URB", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f))
, _canvasSize(canvasSize)
, _trackball(0)
{
_dirty = false;
addProperty(p_automationMode);
addProperty(p_image, INVALID_RESULT | INVALID_PROPERTIES);
addProperty(p_llf);
addProperty(p_urb);
_trackball = new tgt::Trackball(this, _canvasSize->getValue());
_canvasSize->s_changed.connect(this, &TrackballCameraProvider::onRenderTargetSizeChanged);
}
TrackballCameraProvider::~TrackballCameraProvider() {
_canvasSize->s_changed.disconnect(this);
delete _trackball;
}
void TrackballCameraProvider::onEvent(tgt::Event* e) {
if (typeid(*e) == typeid(tgt::MouseEvent)) {
tgt::MouseEvent* me = static_cast<tgt::MouseEvent*>(e);
if (me->action() == tgt::MouseEvent::PRESSED) {
for (std::vector<VisualizationProcessor*>::iterator it = _lqModeProcessors.begin(); it != _lqModeProcessors.end(); ++it)
(*it)->p_lqMode.setValue(true);
_trackball->mousePressEvent(me);
}
else if (me->action() == tgt::MouseEvent::RELEASED) {
for (std::vector<VisualizationProcessor*>::iterator it = _lqModeProcessors.begin(); it != _lqModeProcessors.end(); ++it)
(*it)->p_lqMode.setValue(false);
_trackball->mouseReleaseEvent(me);
}
else if (me->action() == tgt::MouseEvent::MOTION) {
_trackball->mouseMoveEvent(me);
}
else if (me->action() == tgt::MouseEvent::WHEEL)
_trackball->wheelEvent(me);
}
else if (typeid(*e) == typeid(tgt::KeyEvent)) {
_trackball->keyEvent(static_cast<tgt::KeyEvent*>(e));
}
}
tgt::Camera* TrackballCameraProvider::getCamera() {
if (!_dirty) {
_localCopy = tgt::Camera(
p_position.getValue(),
p_focus.getValue(),
p_upVector.getValue(),
p_fov.getValue(),
p_aspectRatio.getValue(),
p_clippingPlanes.getValue().x,
p_clippingPlanes.getValue().y,
p_projectionMode.getOptionValue());
}
_dirty = true;
return &_localCopy;
}
void TrackballCameraProvider::update() {
ignorePropertyChanges();
p_position.setValue(_localCopy.getPosition());
p_focus.setValue(_localCopy.getFocus());
p_upVector.setValue(_localCopy.getUpVector());
p_fov.setValue(_localCopy.getFovy());
p_aspectRatio.setValue(_localCopy.getRatio());
p_clippingPlanes.setValue(tgt::vec2(_localCopy.getNearDist(), _localCopy.getFarDist()));
switch (_localCopy.getProjectionMode()) {
case tgt::Camera::PERSPECTIVE:
p_projectionMode.selectById("perspective");
break;
case tgt::Camera::ORTHOGRAPHIC:
p_projectionMode.selectById("orthographic");
break;
case tgt::Camera::FRUSTUM:
p_projectionMode.selectById("frustum");
break;
}
_dirty = false;
observePropertyChanges();
invalidate(AbstractProcessor::INVALID_RESULT);
}
void TrackballCameraProvider::onRenderTargetSizeChanged(const AbstractProperty* prop) {
_trackball->setViewprtSize(_canvasSize->getValue());
float ratio = static_cast<float>(_canvasSize->getValue().x) / static_cast<float>(_canvasSize->getValue().y);
p_aspectRatio.setValue(ratio);
}
void TrackballCameraProvider::updateProperties(DataContainer& data) {
// convert data
ScopedTypedData<ImageData> img(data, p_image.getValue());
if (img != 0) {
tgt::Bounds volumeExtent = img->getWorldBounds();
tgt::vec3 pos = volumeExtent.center() - tgt::vec3(0, 0, tgt::length(volumeExtent.diagonal()));
if (_trackball->getSceneBounds() != volumeExtent) {
_trackball->setSceneBounds(volumeExtent);
_trackball->setCenter(volumeExtent.center());
_trackball->reinitializeCamera(pos, volumeExtent.center(), p_upVector.getValue());
}
}
validate(INVALID_PROPERTIES);
}
void TrackballCameraProvider::addLqModeProcessor(VisualizationProcessor* vp) {