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