Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TDOUBLEPARAM_H
Toshihiro Shimizu 890ddd
#define TDOUBLEPARAM_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tgeometry.h"
Toshihiro Shimizu 890ddd
#include "tfilepath.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzBase includes
Toshihiro Shimizu 890ddd
#include "tparam.h"
Toshihiro Shimizu 890ddd
#include "tparamchange.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// STD includes
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
//=========================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//    Forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TDoubleParam;
Toshihiro Shimizu 890ddd
class TDoubleKeyframe;
Toshihiro Shimizu 890ddd
class TMeasure;
Toshihiro Shimizu 890ddd
class TExpression;
Toshihiro Shimizu 890ddd
class TDoubleKeyframe;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace TSyntax
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
class Grammar;
Toshihiro Shimizu 890ddd
class CalculatorNodeVisitor;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef WIN32
Toshihiro Shimizu 890ddd
template class DVAPI TPersistDeclarationT<tdoubleparam>;</tdoubleparam>
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//**************************************************************************
Toshihiro Shimizu 890ddd
//    TDoubleParam  declaration
Toshihiro Shimizu 890ddd
//**************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI TDoubleParam : public TParam
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	PERSIST_DECLARATION(TDoubleParam)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	class Imp;
Toshihiro Shimizu 890ddd
	Imp *m_imp;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TDoubleParam(double v = 0.0);
Toshihiro Shimizu 890ddd
	TDoubleParam(const TDoubleParam &src);
Toshihiro Shimizu 890ddd
	~TDoubleParam();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDoubleParam &operator=(const TDoubleParam &);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TParam *clone() const { return new TDoubleParam(*this); }
Toshihiro Shimizu 890ddd
	void copy(TParam *src);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	string getMeasureName() const;
Toshihiro Shimizu 890ddd
	void setMeasureName(string name);
Toshihiro Shimizu 890ddd
	TMeasure *getMeasure() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setValueRange(double min, double max, double step = 1.0);
Toshihiro Shimizu 890ddd
	bool getValueRange(double &min, double &max, double &step) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double getDefaultValue() const;
Toshihiro Shimizu 890ddd
	void setDefaultValue(double value);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double getValue(double frame, bool leftmost = false) const;
Toshihiro Shimizu 890ddd
	// note: if frame is a keyframe separating two segments of different types
Toshihiro Shimizu 890ddd
	// (e.g. expression and linear) then getValue(frame,true) can be != getValue(frame,false)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool setValue(double frame, double value);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// returns the incoming speed vector for keyframe kIndex. kIndex-1 must be speedinout
Toshihiro Shimizu 890ddd
	// if kIndex is not speedinout and handle are linked then recomputes speed.y taking
Toshihiro Shimizu 890ddd
	// in account the next segment
Toshihiro Shimizu 890ddd
	TPointD getSpeedIn(int kIndex) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// returns the outcoming speed vector for keyframe kIndex. kIndex must be speedinout
Toshihiro Shimizu 890ddd
	TPointD getSpeedOut(int kIndex) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//TPointD getSpeed(double frame);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// a specific grammar defines expressions as 'peg2.ns' and allows to
Toshihiro Shimizu 890ddd
	// create a link to the appropriate data source (e.g.
Toshihiro Shimizu 890ddd
	// the correct stageobject tree)
Toshihiro Shimizu 890ddd
	const TSyntax::Grammar *getGrammar() const;
Toshihiro Shimizu 890ddd
	void setGrammar(const TSyntax::Grammar *grammar); // doesn't get ownership.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void accept(TSyntax::CalculatorNodeVisitor &visitor);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! cycle controls extrapolation after the last keyframe
Toshihiro Shimizu 890ddd
	void enableCycle(bool enabled);
Toshihiro Shimizu 890ddd
	bool isCycleEnabled() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getKeyframeCount() const;
Toshihiro Shimizu 890ddd
	void getKeyframes(std::set<double> &frames) const;</double>
Toshihiro Shimizu 890ddd
	double keyframeIndexToFrame(int index) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const TDoubleKeyframe &getKeyframe(int index) const;
Toshihiro Shimizu 890ddd
	const TDoubleKeyframe &getKeyframeAt(double frame) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! assign k to the kIndex-th keyframe; postcondition: m_frame order is maintained
Toshihiro Shimizu 890ddd
	void setKeyframe(int kIndex, const TDoubleKeyframe &k);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! call setKeyframe(it.first,it.second) for each it in ks; postcondition: m_frame order is maintained
Toshihiro Shimizu 890ddd
	void setKeyframes(const std::map<int, tdoublekeyframe=""> &ks);</int,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! create a keyframe in k.m_frame (if is needed) and assign k to it
Toshihiro Shimizu 890ddd
	void setKeyframe(const TDoubleKeyframe &k);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool isKeyframe(double frame) const;
Toshihiro Shimizu 890ddd
	bool hasKeyframes() const;
Toshihiro Shimizu 890ddd
	void deleteKeyframe(double frame);
Toshihiro Shimizu 890ddd
	void clearKeyframes();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getClosestKeyframe(double frame) const;
Toshihiro Shimizu 890ddd
	int getNextKeyframe(double frame) const;
Toshihiro Shimizu 890ddd
	int getPrevKeyframe(double frame) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void assignKeyframe(
Toshihiro Shimizu 890ddd
		double frame,
Toshihiro Shimizu 890ddd
		const TParamP &src, double srcFrame,
Toshihiro Shimizu 890ddd
		bool changedOnly);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool isAnimatable() const { return true; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void addObserver(TParamObserver *observer);
Toshihiro Shimizu 890ddd
	void removeObserver(TParamObserver *observer);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const std::set<tparamobserver *=""> &observers() const;</tparamobserver>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! no keyframes, default value not changed
Toshihiro Shimizu 890ddd
	bool isDefault() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void loadData(TIStream &is);
Toshihiro Shimizu 890ddd
	void saveData(TOStream &os);
Toshihiro Shimizu 890ddd
	string getStreamTag() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	string getValueAlias(double frame, int precision);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DEFINE_PARAM_SMARTPOINTER(TDoubleParam, double)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // TDOUBLEPARAM_H