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