tahoma2d/toonz/sources/include/ttonecurveparam.h

111 lines
3.1 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TTONECURVEPARAM_H
#define TTONECURVEPARAM_H
#include "tcommon.h"
#include "tparamset.h"
#include "tstroke.h"
#include "tnotanimatableparam.h"
#include <QList>
#ifdef _MSC_VER
2016-03-19 06:57:51 +13:00
#pragma warning(disable : 4251)
#endif
#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 DVAPI TToneCurveParam final : public TParam {
2016-06-15 18:43:10 +12:00
PERSIST_DECLARATION(TToneCurveParam)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TParamSetP m_rgbaParamSet;
TParamSetP m_rgbParamSet;
TParamSetP m_rParamSet;
TParamSetP m_gParamSet;
TParamSetP m_bParamSet;
TParamSetP m_aParamSet;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TBoolParamP m_isLinear;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
enum ToneChannel { RGBA = 0, RGB, Red, Green, Blue, Alpha } m_toneChannel;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TToneCurveParam();
TToneCurveParam(const TToneCurveParam &src);
~TToneCurveParam() {}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TParamSetP getParamSet(ToneChannel channel) const;
TParamSetP getCurrentParamSet() const;
TBoolParamP getIsLinearParam() const { return m_isLinear; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setCurrentChannel(ToneChannel channel);
ToneChannel getCurrentChannel() const { return m_toneChannel; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
TParam *clone() const override { return new TToneCurveParam(*this); }
void copy(TParam *src) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void addObserver(TParamObserver *) override;
void removeObserver(TParamObserver *) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QList<TPointD> getValue(double frame) const;
void setValue(double frame, const QList<TPointD> &value,
bool undoing = false);
void setDefaultValue(const QList<TPointD> &value);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool isLinear() const;
void setIsLinear(bool isLinear);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void addValue(double frame, const QList<TPointD> &value, int index);
void removeValue(double frame, int index);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// virtual void enableNotification(bool on) {}
// virtual bool isNotificationEnabled() const { return true;}
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
2016-06-19 20:06:29 +12:00
bool isAnimatable() const override { return true; };
bool isKeyframe(double frame) const override;
void deleteKeyframe(double frame) override;
void clearKeyframes() override;
2016-06-15 18:43:10 +12:00
void assignKeyframe(double frame, const TSmartPointerT<TParam> &src,
2016-06-19 20:06:29 +12:00
double srcFrame, bool changedOnly = false) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void getKeyframes(std::set<double> &frames) const override;
bool hasKeyframes() const override;
int getNextKeyframe(double frame) const override;
int getPrevKeyframe(double frame) const override;
double keyframeIndexToFrame(int index) const override;
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-03-19 06:57:51 +13:00
};
2016-04-15 17:11:23 +12:00
#ifdef _WIN32
2016-03-19 06:57:51 +13:00
template class DVAPI TSmartPointerT<TToneCurveParam>;
template class DVAPI TDerivedSmartPointerT<TToneCurveParam, TParam>;
#endif
class DVAPI TToneCurveParamP final
2016-06-15 18:43:10 +12:00
: public TDerivedSmartPointerT<TToneCurveParam, TParam> {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TToneCurveParamP() {}
TToneCurveParamP(TToneCurveParam *p)
: TDerivedSmartPointerT<TToneCurveParam, TParam>(p) {}
TToneCurveParamP(const TParamP &p)
: TDerivedSmartPointerT<TToneCurveParam, TParam>(p) {}
operator TParamP() const { return TParamP(m_pointer); }
2016-03-19 06:57:51 +13:00
};
#endif