|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef T_PARAM_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define T_PARAM_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tpersist.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsmartpointer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include <set></set>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TPARAM_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TParamObserver;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Shinya Kitaoka |
120a6e |
//! This class is an abstract class and is a generic interface to the features
|
|
Shinya Kitaoka |
120a6e |
//! of an object.
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Shinya Kitaoka |
120a6e |
It is used to access to the parameters of an object, with the purpose
|
|
Shinya Kitaoka |
120a6e |
to store and retrieve the key features.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TParam : public TSmartObject, public TPersist {
|
|
Shinya Kitaoka |
120a6e |
DECLARE_CLASS_CODE
|
|
Shinya Kitaoka |
120a6e |
std::string m_name;
|
|
Shinya Kitaoka |
120a6e |
std::string m_description;
|
|
Shinya Kitaoka |
120a6e |
std::string m_label;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
The contructor store the name of the parameter and initialize his
|
|
Shinya Kitaoka |
120a6e |
interface with I/O through the class TPersist.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
TParam(std::string name = "", std::string description = "",
|
|
Shinya Kitaoka |
120a6e |
std::string label = "")
|
|
Shinya Kitaoka |
120a6e |
: TSmartObject(m_classCode)
|
|
Shinya Kitaoka |
120a6e |
, TPersist()
|
|
Shinya Kitaoka |
120a6e |
, m_name(name)
|
|
Shinya Kitaoka |
120a6e |
, m_description(description)
|
|
Shinya Kitaoka |
120a6e |
, m_label(label) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
virtual ~TParam() {}
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns the name of the parameter.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
std::string getName() const { return m_name; };
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This method sets the name of the parameter to \e name.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
void setName(const std::string &name) { m_name = name; };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Return the description.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
std::string getDescription() const { return m_description; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Set the description.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
void setDescription(const std::string &description) {
|
|
Shinya Kitaoka |
120a6e |
m_description = description;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool hasUILabel() const { return m_label != "" ? true : false; }
|
|
Shinya Kitaoka |
120a6e |
void setUILabel(const std::string &l) { m_label = l; };
|
|
Shinya Kitaoka |
120a6e |
std::string getUILabel() const { return m_label; };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This method must be implemented with a clone function, i.e a function
|
|
Shinya Kitaoka |
120a6e |
that make
|
|
Shinya Kitaoka |
120a6e |
a new copy of the parameter.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual TParam *clone() const = 0;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Performs a copy function of the parameter in an existing object.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual void copy(TParam *src) = 0;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
An observer is a generic class that takes care and manages of canghes
|
|
Shinya Kitaoka |
120a6e |
in the parameters.
|
|
Shinya Kitaoka |
120a6e |
This method must be implemented with a function that add objects to an
|
|
Shinya Kitaoka |
120a6e |
observer internal list.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual void addObserver(TParamObserver *) = 0;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Removes \e this from the observer.
|
|
Shinya Kitaoka |
120a6e |
\sa addObserver()
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual void removeObserver(TParamObserver *) = 0;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This method is used to sets the status changing notification of the
|
|
Shinya Kitaoka |
120a6e |
parameter. i.e the
|
|
Shinya Kitaoka |
120a6e |
observer must take care of the changes.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual void enableNotification(bool on) {}
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This method must return \e true if the notification status is
|
|
Shinya Kitaoka |
120a6e |
enabled.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual bool isNotificationEnabled() const { return true; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This pure virtual method must return a string with the value of the
|
|
Shinya Kitaoka |
120a6e |
parameter
|
|
Shinya Kitaoka |
120a6e |
and the precision needed.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual std::string getValueAlias(double frame, int precision) = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
virtual bool isAnimatable() const = 0;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
It must returns \e true if the \e frame is a keyframe.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual bool isKeyframe(double frame) const = 0;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Removes \e frame from the list of the keyframes associated to this
|
|
Shinya Kitaoka |
120a6e |
parameter.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual void deleteKeyframe(double frame) = 0;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Removes all keyframes from this parameter.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual void clearKeyframes() = 0;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Makes the \e frame associated to this parameter a keyframe
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual void assignKeyframe(double frame, const TSmartPointerT<tparam> &src,</tparam>
|
|
Shinya Kitaoka |
120a6e |
double srcFrame, bool changedOnly = false) = 0;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This function must be overridden with a method that returns as a
|
|
Shinya Kitaoka |
120a6e |
reference
|
|
Shinya Kitaoka |
120a6e |
a list of keyframes in the form of a standard list.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual void getKeyframes(std::set<double> &frames) const {}</double>
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This method must return true if there are keyframes associated to this
|
|
Shinya Kitaoka |
120a6e |
parameter.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual bool hasKeyframes() const { return false; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This method must return the index of the keyframe (if any) after the
|
|
Shinya Kitaoka |
120a6e |
\e frame, otherwiswe
|
|
Shinya Kitaoka |
120a6e |
returns -1.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual int getNextKeyframe(double frame) const { return -1; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This method must return the index of the keyframe (if any) before the
|
|
Shinya Kitaoka |
120a6e |
\e frame, otherwiswe
|
|
Shinya Kitaoka |
120a6e |
returns -1.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual int getPrevKeyframe(double frame) const { return -1; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
This method must returns a frame given the index \e index. A frame is
|
|
Shinya Kitaoka |
120a6e |
a double value representing
|
|
Shinya Kitaoka |
120a6e |
a frame.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
virtual double keyframeIndexToFrame(int index) const { return 0.0; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
// not implemented
|
|
Shinya Kitaoka |
120a6e |
TParam(const TParam &);
|
|
Shinya Kitaoka |
120a6e |
TParam &operator=(const TParam &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<tparam>;</tparam>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
typedef TSmartPointerT<tparam> TParamP;</tparam>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Shinya Kitaoka |
120a6e |
#define DVAPI_PARAM_SMARTPOINTER(PARAM) \
|
|
Shinya Kitaoka |
120a6e |
template class DVAPI TSmartPointerT<param>; \
|
|
Shinya Kitaoka |
120a6e |
template class DVAPI TDerivedSmartPointerT<param, tparam="">;</param,>
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI_PARAM_SMARTPOINTER(PARAM)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define DEFINE_PARAM_SMARTPOINTER(PARAM, TYPE) \
|
|
Shinya Kitaoka |
120a6e |
DVAPI_PARAM_SMARTPOINTER(PARAM) \
|
|
Shinya Kitaoka |
120a6e |
\
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI PARAM##P final : public TDerivedSmartPointerT<param, tparam=""> { \</param,>
|
|
Shinya Kitaoka |
120a6e |
public: \
|
|
Shinya Kitaoka |
120a6e |
PARAM##P(PARAM *p = 0) : DerivedSmartPointer(p) {} \
|
|
Shinya Kitaoka |
120a6e |
PARAM##P(TYPE v) : DerivedSmartPointer(new PARAM(v)) {} \
|
|
Shinya Kitaoka |
120a6e |
PARAM##P(TParamP &p) : DerivedSmartPointer(p) {} \
|
|
Shinya Kitaoka |
120a6e |
PARAM##P(const TParamP &p) : DerivedSmartPointer(p) {} \
|
|
Shinya Kitaoka |
120a6e |
operator TParamP() const { return TParamP(m_pointer); } \
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|