The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 62bf8ec5 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Updated TrackballCameraProvider and related cgt classes:

* Implemented the actual logic behind the automation mode property in TrackballCameraProvider
* Added mouse wheel zoom support to cgt::Trackball
* Renamed cgt::IHasCamera to cgt::AbstractCameraProxy

closes #642
parent 5791fec6
......@@ -88,8 +88,10 @@ namespace campvis {
}
void AbstractProperty::setVisible(bool isVisible) {
_isVisible = isVisible;
s_visibilityChanged.emitSignal(this);
if (_isVisible != isVisible) {
_isVisible = isVisible;
s_visibilityChanged.emitSignal(this);
}
}
}
......@@ -55,12 +55,12 @@ namespace cgt {
* Intermediate wrapper class for easier integration of cgt::Navigation into projects using
* separated cameras and canvases.
*/
class CGT_API IHasCamera {
class CGT_API AbstractCameraProxy {
public:
/**
* Pure virtual destructor
*/
virtual ~IHasCamera() {};
virtual ~AbstractCameraProxy() {};
/**
* Returns the camera to modify by Navigation.
......@@ -89,12 +89,12 @@ protected:
// navigation manipulates the camera of a certain canvas.
// we only need a pointer to this canvas, not to the camera (see getCamera).
IHasCamera* hcam_;
AbstractCameraProxy* hcam_;
public:
Navigation(IHasCamera* hcam) {
Navigation(AbstractCameraProxy* hcam) {
hcam_ = hcam;
}
......
......@@ -34,7 +34,7 @@
namespace cgt {
Trackball::Trackball(IHasCamera* hcam, const ivec2& viewportSize, bool defaultEventHandling, Timer* continuousSpinTimer)
Trackball::Trackball(AbstractCameraProxy* hcam, const ivec2& viewportSize, bool defaultEventHandling, Timer* continuousSpinTimer)
: Navigation(hcam),
viewportSize_(viewportSize),
continuousSpin_(false),
......@@ -265,12 +265,22 @@ void Trackball::move(vec2 newMouse) {
}
void Trackball::zoom(float factor) {
// zoom factor is inverse proportional to scaling of the look vector, so invert:
factor = 1.f / factor;
getCamera()->setPosition( (1.f-factor) * getCamera()->getFocus()
+ factor * getCamera()->getPosition());
updateClippingPlanes();
hcam_->update();
if (getCamera()->getProjectionMode() == Camera::ORTHOGRAPHIC) {
auto frustum = getCamera()->getFrustum();
frustum.setLeft(frustum.getLeft() / factor);
frustum.setRight(frustum.getRight() / factor);
frustum.setBottom(frustum.getBottom() / factor);
frustum.setTop(frustum.getTop() / factor);
getCamera()->setFrustum(frustum);
}
else {
// zoom factor is inverse proportional to scaling of the look vector, so invert:
factor = 1.f / factor;
getCamera()->setPosition( (1.f-factor) * getCamera()->getFocus()
+ factor * getCamera()->getPosition());
updateClippingPlanes();
hcam_->update();
}
}
void Trackball::zoom(vec2 newMouse) {
......
......@@ -65,7 +65,7 @@ class CGT_API Trackball : public Navigation {
/// cgt::Timer-object. As we need a toolkit-specific timer,
/// trackball cannot create it itself, the user has to provide
/// it to the constructor.
Trackball(IHasCamera* hcam, const ivec2& viewportSize, bool defaultEventHandling = true, Timer* continousSpinTimer = NULL);
Trackball(AbstractCameraProxy* hcam, const ivec2& viewportSize, bool defaultEventHandling = true, Timer* continousSpinTimer = NULL);
/// Destructor
virtual ~Trackball();
......
......@@ -69,7 +69,7 @@ namespace campvis {
/// \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; };
virtual ProcessorState getProcessorState() const { return AbstractProcessor::STABLE; };
DataNameProperty p_cameraId; ///< Name/ID for the CameraData object
......
......@@ -53,16 +53,17 @@ namespace campvis {
, p_automationMode("AutomationMode", "Automation Mode", automationOptions, 3)
, p_image("ReferenceImage", "Reference Image", "", DataNameProperty::READ)
, p_llf("LLF", "Bounding Box LLF", cgt::vec3(0.f), cgt::vec3(-10000.f), cgt::vec3(10000.f))
, p_urb("URB", "Bounding Box URB", cgt::vec3(0.f), cgt::vec3(-10000.f), cgt::vec3(10000.f))
, p_urb("URB", "Bounding Box URB", cgt::vec3(1.f), cgt::vec3(-10000.f), cgt::vec3(10000.f))
, _canvasSize(canvasSize)
, _trackball(nullptr)
{
_dirty = false;
p_automationMode.selectByOption(FullAutomatic);
addProperty(p_automationMode);
addProperty(p_automationMode, INVALID_RESULT | INVALID_PROPERTIES);
addProperty(p_image, INVALID_RESULT | INVALID_PROPERTIES);
addProperty(p_llf);
addProperty(p_urb);
addProperty(p_llf, INVALID_RESULT | INVALID_PROPERTIES);
addProperty(p_urb, INVALID_RESULT | INVALID_PROPERTIES);
if (_canvasSize != nullptr) {
_canvasSize->s_changed.connect(this, &TrackballCameraProvider::onRenderTargetSizeChanged);
......@@ -165,10 +166,53 @@ namespace campvis {
}
void TrackballCameraProvider::updateProperties(DataContainer& data) {
// convert data
ScopedTypedData<IHasWorldBounds> img(data, p_image.getValue());
if (img != 0) {
reinitializeCamera(img->getWorldBounds());
if (p_automationMode.getOptionValue() == FullAutomatic) {
// convert data
ScopedTypedData<IHasWorldBounds> img(data, p_image.getValue());
if (img != 0) {
cgt::Bounds b = img->getWorldBounds();
p_llf.setValue(b.getLLF());
p_urb.setValue(b.getURB());
reinitializeCamera(b);
}
p_position.setVisible(false);
p_focus.setVisible(false);
p_upVector.setVisible(false);
p_fov.setVisible(false);
p_aspectRatio.setVisible(false);
p_clippingPlanes.setVisible(false);
p_image.setVisible(true);
p_llf.setVisible(false);
p_urb.setVisible(false);
}
else if (p_automationMode.getOptionValue() == SemiAutomatic) {
reinitializeCamera(cgt::Bounds(p_llf.getValue(), p_urb.getValue()));
p_position.setVisible(false);
p_focus.setVisible(false);
p_upVector.setVisible(false);
p_fov.setVisible(false);
p_aspectRatio.setVisible(false);
p_clippingPlanes.setVisible(false);
p_image.setVisible(false);
p_llf.setVisible(true);
p_urb.setVisible(true);
}
else if (p_automationMode.getOptionValue() == FullManual) {
p_position.setVisible(true);
p_focus.setVisible(true);
p_upVector.setVisible(true);
p_fov.setVisible(true);
p_aspectRatio.setVisible(true);
p_clippingPlanes.setVisible(true);
p_image.setVisible(false);
p_llf.setVisible(false);
p_urb.setVisible(false);
}
}
......@@ -202,9 +246,9 @@ namespace campvis {
}
void TrackballCameraProvider::reinitializeCamera(const cgt::Bounds& worldBounds) {
cgt::vec3 pos = worldBounds.center() - cgt::vec3(0, 0, cgt::length(worldBounds.diagonal()));
if (_trackball->getSceneBounds() != worldBounds) {
cgt::vec3 pos = worldBounds.center() - cgt::vec3(0, 0, cgt::length(worldBounds.diagonal()));
_trackball->setSceneBounds(worldBounds);
_trackball->setCenter(worldBounds.center());
_trackball->reinitializeCamera(pos, worldBounds.center(), p_upVector.getValue());
......
......@@ -48,7 +48,7 @@ namespace campvis {
/**
* Generates CameraData objects.
*/
class CAMPVIS_MODULES_API TrackballCameraProvider : public CameraProvider, public cgt::EventListener, public cgt::IHasCamera {
class CAMPVIS_MODULES_API TrackballCameraProvider : public CameraProvider, public cgt::EventListener, public cgt::AbstractCameraProxy {
public:
/// Trackball automation mode
enum AutomationMode {
......@@ -67,6 +67,16 @@ namespace campvis {
**/
virtual ~TrackballCameraProvider();
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "TrackballCameraProvider"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Provides trackball navigation interaction metaphors when generating 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::STABLE; };
/// \see AbstractProcessor::init()
virtual void init();
/// \see AbstractProcessor::deinit()
......@@ -78,10 +88,10 @@ namespace campvis {
/// \see cgt::EventListener::onEvent()
virtual void onEvent(cgt::Event* e);
/// \see cgt::Camera::IHasCamera::getCamera()
/// \see cgt::Camera::AbstractCameraProxy::getCamera()
virtual cgt::Camera* getCamera();
/// \see cgt::Camera::IHasCamera::update()
/// \see cgt::Camera::AbstractCameraProxy::update()
virtual void update();
......
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