| #pragma once |
| |
| #ifndef T_PARAM_INCLUDED |
| #define T_PARAM_INCLUDED |
| |
| #include "tpersist.h" |
| #include "tsmartpointer.h" |
| #include <set> |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TPARAM_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| class TParamObserver; |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TParam : public TSmartObject, public TPersist { |
| DECLARE_CLASS_CODE |
| std::string m_name; |
| std::string m_description; |
| std::string m_label; |
| |
| public: |
| |
| |
| |
| |
| TParam(std::string name = "", std::string description = "", |
| std::string label = "") |
| : TSmartObject(m_classCode) |
| , TPersist() |
| , m_name(name) |
| , m_description(description) |
| , m_label(label) {} |
| |
| virtual ~TParam() {} |
| |
| |
| |
| std::string getName() const { return m_name; }; |
| |
| |
| |
| void setName(const std::string &name) { m_name = name; }; |
| |
| |
| |
| |
| std::string getDescription() const { return m_description; } |
| |
| |
| |
| void setDescription(const std::string &description) { |
| m_description = description; |
| } |
| |
| bool hasUILabel() const { return m_label != "" ? true : false; } |
| void setUILabel(const std::string &l) { m_label = l; }; |
| std::string getUILabel() const { return m_label; }; |
| |
| |
| |
| |
| |
| |
| virtual TParam *clone() const = 0; |
| |
| |
| |
| virtual void copy(TParam *src) = 0; |
| |
| |
| |
| |
| |
| |
| virtual void addObserver(TParamObserver *) = 0; |
| |
| |
| |
| |
| virtual void removeObserver(TParamObserver *) = 0; |
| |
| |
| |
| |
| |
| virtual void enableNotification(bool on) {} |
| |
| |
| |
| |
| virtual bool isNotificationEnabled() const { return true; } |
| |
| |
| |
| |
| |
| |
| virtual std::string getValueAlias(double frame, int precision) = 0; |
| |
| virtual bool isAnimatable() const = 0; |
| |
| |
| |
| virtual bool isKeyframe(double frame) const = 0; |
| |
| |
| |
| |
| virtual void deleteKeyframe(double frame) = 0; |
| |
| |
| |
| virtual void clearKeyframes() = 0; |
| |
| |
| |
| virtual void assignKeyframe(double frame, const TSmartPointerT<TParam> &src, |
| double srcFrame, bool changedOnly = false) = 0; |
| |
| |
| |
| |
| |
| virtual void getKeyframes(std::set<double> &frames) const {} |
| |
| |
| |
| |
| virtual bool hasKeyframes() const { return false; } |
| |
| |
| |
| |
| |
| virtual int getNextKeyframe(double frame) const { return -1; } |
| |
| |
| |
| |
| |
| virtual int getPrevKeyframe(double frame) const { return -1; } |
| |
| |
| |
| |
| |
| virtual double keyframeIndexToFrame(int index) const { return 0.0; } |
| |
| private: |
| |
| TParam(const TParam &); |
| TParam &operator=(const TParam &); |
| }; |
| |
| |
| |
| #ifdef _WIN32 |
| template class DVAPI TSmartPointerT<TParam>; |
| #endif |
| typedef TSmartPointerT<TParam> TParamP; |
| |
| |
| |
| #ifdef _WIN32 |
| #define DVAPI_PARAM_SMARTPOINTER(PARAM) \ |
| template class DVAPI TSmartPointerT<PARAM>; \ |
| template class DVAPI TDerivedSmartPointerT<PARAM, TParam>; |
| #else |
| #define DVAPI_PARAM_SMARTPOINTER(PARAM) |
| #endif |
| |
| #define DEFINE_PARAM_SMARTPOINTER(PARAM, TYPE) \ |
| DVAPI_PARAM_SMARTPOINTER(PARAM) \ |
| \ |
| class DVAPI PARAM##P final : public TDerivedSmartPointerT<PARAM, TParam> { \ |
| public: \ |
| PARAM##P(PARAM *p = 0) : DerivedSmartPointer(p) {} \ |
| PARAM##P(TYPE v) : DerivedSmartPointer(new PARAM(v)) {} \ |
| PARAM##P(TParamP &p) : DerivedSmartPointer(p) {} \ |
| PARAM##P(const TParamP &p) : DerivedSmartPointer(p) {} \ |
| operator TParamP() const { return TParamP(m_pointer); } \ |
| }; |
| |
| #endif |