/**************************************************************************** ** Copyright (c) 2021, Fougue Ltd. ** All rights reserved. ** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt ****************************************************************************/ #pragma once #include "../base/occ_handle.h" #include "../base/quantity.h" #include #include #include namespace Mayo { // Provides interface for animation base mechanism(backend) class IAnimationBackend { public: virtual ~IAnimationBackend() = default; virtual void setDuration(QuantityTime t) = 0; virtual bool isRunning() const = 0; virtual void start() = 0; virtual void stop() = 0; virtual double valueForProgress(double p) const = 0; // 'p' in [0,1] virtual void setTimerCallback(std::function fn) = 0; }; // Provides animation control for 3D view camera class V3dViewCameraAnimation { public: using ViewFunction = std::function&)>; V3dViewCameraAnimation(); ~V3dViewCameraAnimation() = default; bool hasBackend() const { return m_backend.get() != nullptr; } void setBackend(std::unique_ptr anim); const OccHandle& view() const { return m_view; } void setView(const OccHandle& view); QuantityTime duration() const { return m_duration; } void setDuration(QuantityTime t); bool isRunning() const; void start(); void stop(); void setCameraStart(const OccHandle& camera); void setCameraEnd(const OccHandle& camera); void configureCameraChange(const ViewFunction& fnViewChange); void setRenderFunction(ViewFunction fnViewRender); private: void updateCurrentTime(QuantityTime currTime); std::unique_ptr m_backend; OccHandle m_view; OccHandle m_cameraStart; OccHandle m_cameraEnd; QuantityTime m_duration = 1 * Quantity_Second; std::function&)> m_fnViewRender; }; } // namespace Mayo