Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ttonecurveparam.h"
Toshihiro Shimizu 890ddd
#include "texception.h"
Toshihiro Shimizu 890ddd
#include "tstream.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qlist></qlist>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
PERSIST_IDENTIFIER(TToneCurveParam, "toneCurveParam")
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TToneCurveParam::TToneCurveParam()
Toshihiro Shimizu 890ddd
	: TParam()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_toneChannel = RGBA;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::vector<tpointd> points;</tpointd>
Toshihiro Shimizu 890ddd
	//Inserisco dei punti fuori dal range(0-255) perche' mi consentono di gestire i primi punti come speciali.
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(-40, 0));
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(-20, 0));
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(-20, 0));
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(0, 0));
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(16, 16));
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(239, 239));
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(255, 255));
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(275, 255));
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(275, 255));
Toshihiro Shimizu 890ddd
	points.push_back(TPointD(295, 255));
Toshihiro Shimizu 890ddd
	m_rgbaParamSet = new TParamSet("redgreenbluealphachannel");
Toshihiro Shimizu 890ddd
	m_rgbParamSet = new TParamSet("redgreenbluechannel");
Toshihiro Shimizu 890ddd
	m_rParamSet = new TParamSet("redchannel");
Toshihiro Shimizu 890ddd
	m_gParamSet = new TParamSet("greenchannel");
Toshihiro Shimizu 890ddd
	m_bParamSet = new TParamSet("bluechannel");
Toshihiro Shimizu 890ddd
	m_aParamSet = new TParamSet("alphachannel");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_isLinear = new TBoolParam(false);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
	for (i = 0; i < (int)points.size(); i++) {
Toshihiro Shimizu 890ddd
		m_rgbaParamSet->addParam(new TPointParam(points[i]), "point");
Toshihiro Shimizu 890ddd
		m_rgbParamSet->addParam(new TPointParam(points[i]), "point");
Toshihiro Shimizu 890ddd
		m_rParamSet->addParam(new TPointParam(points[i]), "point");
Toshihiro Shimizu 890ddd
		m_gParamSet->addParam(new TPointParam(points[i]), "point");
Toshihiro Shimizu 890ddd
		m_bParamSet->addParam(new TPointParam(points[i]), "point");
Toshihiro Shimizu 890ddd
		m_aParamSet->addParam(new TPointParam(points[i]), "point");
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TParamSetP getClonedParamSet(TParamSetP srcParamSet)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TParamSetP dstParamSet = new TParamSet(srcParamSet->getName());
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
	for (i = 0; i < srcParamSet->getParamCount(); i++) {
Toshihiro Shimizu 890ddd
		TParamP param = srcParamSet->getParam(i);
Toshihiro Shimizu 890ddd
		dstParamSet->addParam(param->clone(), param->getName());
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	return dstParamSet;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TToneCurveParam::TToneCurveParam(const TToneCurveParam &src)
Toshihiro Shimizu 890ddd
	: TParam(src.getName())
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_rgbaParamSet = getClonedParamSet(src.getParamSet(RGBA));
Toshihiro Shimizu 890ddd
	m_rgbParamSet = getClonedParamSet(src.getParamSet(RGB));
Toshihiro Shimizu 890ddd
	m_rParamSet = getClonedParamSet(src.getParamSet(Red));
Toshihiro Shimizu 890ddd
	m_gParamSet = getClonedParamSet(src.getParamSet(Green));
Toshihiro Shimizu 890ddd
	m_bParamSet = getClonedParamSet(src.getParamSet(Blue));
Toshihiro Shimizu 890ddd
	m_aParamSet = getClonedParamSet(src.getParamSet(Alpha));
Toshihiro Shimizu 890ddd
	m_toneChannel = src.getCurrentChannel();
Toshihiro Shimizu 890ddd
	m_isLinear = src.getIsLinearParam()->clone();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::copy(TParam *src)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TToneCurveParam *p = dynamic_cast<ttonecurveparam *="">(src);</ttonecurveparam>
Toshihiro Shimizu 890ddd
	if (!p)
Toshihiro Shimizu 890ddd
		throw TException("invalid source for copy");
Toshihiro Shimizu 890ddd
	setName(src->getName());
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->copy(p->getParamSet(RGBA).getPointer());
Toshihiro Shimizu 890ddd
	m_rgbParamSet->copy(p->getParamSet(RGB).getPointer());
Toshihiro Shimizu 890ddd
	m_rParamSet->copy(p->getParamSet(Red).getPointer());
Toshihiro Shimizu 890ddd
	m_gParamSet->copy(p->getParamSet(Green).getPointer());
Toshihiro Shimizu 890ddd
	m_bParamSet->copy(p->getParamSet(Blue).getPointer());
Toshihiro Shimizu 890ddd
	m_aParamSet->copy(p->getParamSet(Alpha).getPointer());
Toshihiro Shimizu 890ddd
	m_isLinear->copy(p->getIsLinearParam().getPointer());
Toshihiro Shimizu 890ddd
	m_toneChannel = p->getCurrentChannel();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::addObserver(TParamObserver *observer)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->addObserver(observer);
Toshihiro Shimizu 890ddd
	m_rgbParamSet->addObserver(observer);
Toshihiro Shimizu 890ddd
	m_rParamSet->addObserver(observer);
Toshihiro Shimizu 890ddd
	m_gParamSet->addObserver(observer);
Toshihiro Shimizu 890ddd
	m_bParamSet->addObserver(observer);
Toshihiro Shimizu 890ddd
	m_aParamSet->addObserver(observer);
Toshihiro Shimizu 890ddd
	m_isLinear->addObserver(observer);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::removeObserver(TParamObserver *observer)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->removeObserver(observer);
Toshihiro Shimizu 890ddd
	m_rgbParamSet->removeObserver(observer);
Toshihiro Shimizu 890ddd
	m_rParamSet->removeObserver(observer);
Toshihiro Shimizu 890ddd
	m_gParamSet->removeObserver(observer);
Toshihiro Shimizu 890ddd
	m_bParamSet->removeObserver(observer);
Toshihiro Shimizu 890ddd
	m_aParamSet->removeObserver(observer);
Toshihiro Shimizu 890ddd
	m_isLinear->removeObserver(observer);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TParamSetP TToneCurveParam::getParamSet(ToneChannel channel) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (channel == RGBA)
Toshihiro Shimizu 890ddd
		return m_rgbaParamSet;
Toshihiro Shimizu 890ddd
	else if (channel == RGB)
Toshihiro Shimizu 890ddd
		return m_rgbParamSet;
Toshihiro Shimizu 890ddd
	else if (channel == Red)
Toshihiro Shimizu 890ddd
		return m_rParamSet;
Toshihiro Shimizu 890ddd
	else if (channel == Green)
Toshihiro Shimizu 890ddd
		return m_gParamSet;
Toshihiro Shimizu 890ddd
	else if (channel == Blue)
Toshihiro Shimizu 890ddd
		return m_bParamSet;
Toshihiro Shimizu 890ddd
	else if (channel == Alpha)
Toshihiro Shimizu 890ddd
		return m_aParamSet;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	return 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TParamSetP TToneCurveParam::getCurrentParamSet() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return getParamSet(m_toneChannel);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::setCurrentChannel(ToneChannel channel)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_toneChannel = channel;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QList<tpointd> TToneCurveParam::getValue(double frame) const</tpointd>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
	QList<tpointd> points;</tpointd>
Toshihiro Shimizu 890ddd
	for (i = 0; i < getCurrentParamSet()->getParamCount(); i++) {
Toshihiro Shimizu 890ddd
		TPointParamP pointParam = getCurrentParamSet()->getParam(i);
Toshihiro Shimizu 890ddd
		points.push_back(pointParam->getValue(frame));
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	return points;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::setValue(double frame, const QList<tpointd> &value, bool undoing)</tpointd>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (value.size() == 0)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	int paramCount = getCurrentParamSet()->getParamCount();
Toshihiro Shimizu 890ddd
	assert(paramCount == value.size());
Toshihiro Shimizu 890ddd
	int i = 0;
Toshihiro Shimizu 890ddd
	for (i = 0; i < paramCount; i++) {
Toshihiro Shimizu 890ddd
		TPointParamP param = getCurrentParamSet()->getParam(i);
Toshihiro Shimizu 890ddd
		TPointD point = value.at(i);
Toshihiro Shimizu 890ddd
		param->setValue(frame, point);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool TToneCurveParam::isLinear() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_isLinear->getValue();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::setIsLinear(bool isLinear)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_isLinear->setValue(isLinear);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::addValue(double frame, const QList<tpointd> &value, int index)</tpointd>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	getCurrentParamSet()->insertParam(new TPointParam(value.at(index - 1)), "point", index - 1);
Toshihiro Shimizu 890ddd
	getCurrentParamSet()->insertParam(new TPointParam(value.at(index)), "point", index);
Toshihiro Shimizu 890ddd
	getCurrentParamSet()->insertParam(new TPointParam(value.at(index + 1)), "point", index + 1);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::removeValue(double frame, int index)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	getCurrentParamSet()->removeParam(getCurrentParamSet()->getParam(index - 1));
Toshihiro Shimizu 890ddd
	getCurrentParamSet()->removeParam(getCurrentParamSet()->getParam(index - 1));
Toshihiro Shimizu 890ddd
	getCurrentParamSet()->removeParam(getCurrentParamSet()->getParam(index - 1));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::setDefaultValue(const QList<tpointd> &value)</tpointd>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int pointCount = value.size();
Toshihiro Shimizu 890ddd
	if (pointCount == 0)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int paramCount = getCurrentParamSet()->getParamCount();
Toshihiro Shimizu 890ddd
	assert(paramCount == pointCount);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
	for (i = 0; i < pointCount; i++) {
Toshihiro Shimizu 890ddd
		TPointParamP param = getCurrentParamSet()->getParam(i);
Toshihiro Shimizu 890ddd
		TPointD paramPoint(param->getValue(0));
Toshihiro Shimizu 890ddd
		TPointD strokePoint(value.at(i));
Toshihiro Shimizu 890ddd
		param->setDefaultValue(strokePoint);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	m_isLinear->setDefaultValue(false);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
string TToneCurveParam::getValueAlias(double frame, int precision)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return getCurrentParamSet()->getValueAlias(frame, precision) + m_isLinear->getValueAlias(frame, precision);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool TToneCurveParam::isKeyframe(double frame) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (m_rgbaParamSet->isKeyframe(frame) || m_rgbParamSet->isKeyframe(frame) || m_rParamSet->isKeyframe(frame) ||
Toshihiro Shimizu 890ddd
		m_gParamSet->isKeyframe(frame) || m_bParamSet->isKeyframe(frame) || m_aParamSet->isKeyframe(frame))
Toshihiro Shimizu 890ddd
		return true;
Toshihiro Shimizu 890ddd
	return false;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::deleteKeyframe(double frame)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->deleteKeyframe(frame);
Toshihiro Shimizu 890ddd
	m_rgbParamSet->deleteKeyframe(frame);
Toshihiro Shimizu 890ddd
	m_rParamSet->deleteKeyframe(frame);
Toshihiro Shimizu 890ddd
	m_gParamSet->deleteKeyframe(frame);
Toshihiro Shimizu 890ddd
	m_bParamSet->deleteKeyframe(frame);
Toshihiro Shimizu 890ddd
	m_aParamSet->deleteKeyframe(frame);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::clearKeyframes()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->clearKeyframes();
Toshihiro Shimizu 890ddd
	m_rgbParamSet->clearKeyframes();
Toshihiro Shimizu 890ddd
	m_rParamSet->clearKeyframes();
Toshihiro Shimizu 890ddd
	m_gParamSet->clearKeyframes();
Toshihiro Shimizu 890ddd
	m_bParamSet->clearKeyframes();
Toshihiro Shimizu 890ddd
	m_aParamSet->clearKeyframes();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::assignKeyframe(double frame, const TSmartPointerT<tparam> &src,</tparam>
Toshihiro Shimizu 890ddd
									 double srcFrame, bool changedOnly)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->assignKeyframe(frame, src, srcFrame, changedOnly);
Toshihiro Shimizu 890ddd
	m_rgbParamSet->assignKeyframe(frame, src, srcFrame, changedOnly);
Toshihiro Shimizu 890ddd
	m_rParamSet->assignKeyframe(frame, src, srcFrame, changedOnly);
Toshihiro Shimizu 890ddd
	m_gParamSet->assignKeyframe(frame, src, srcFrame, changedOnly);
Toshihiro Shimizu 890ddd
	m_bParamSet->assignKeyframe(frame, src, srcFrame, changedOnly);
Toshihiro Shimizu 890ddd
	m_aParamSet->assignKeyframe(frame, src, srcFrame, changedOnly);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::getKeyframes(std::set<double> &frames) const</double>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->getKeyframes(frames);
Toshihiro Shimizu 890ddd
	m_rgbParamSet->getKeyframes(frames);
Toshihiro Shimizu 890ddd
	m_rParamSet->getKeyframes(frames);
Toshihiro Shimizu 890ddd
	m_gParamSet->getKeyframes(frames);
Toshihiro Shimizu 890ddd
	m_bParamSet->getKeyframes(frames);
Toshihiro Shimizu 890ddd
	m_aParamSet->getKeyframes(frames);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool TToneCurveParam::hasKeyframes() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (m_rgbaParamSet->hasKeyframes() || m_rgbParamSet->hasKeyframes() || m_rParamSet->hasKeyframes() ||
Toshihiro Shimizu 890ddd
		m_gParamSet->hasKeyframes() || m_bParamSet->hasKeyframes() || m_aParamSet->hasKeyframes())
Toshihiro Shimizu 890ddd
		return true;
Toshihiro Shimizu 890ddd
	return false;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int TToneCurveParam::getNextKeyframe(double frame) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	std::set<double> frames;</double>
Toshihiro Shimizu 890ddd
	getKeyframes(frames);
Toshihiro Shimizu 890ddd
	std::set<double>::iterator it = frames.upper_bound(frame);</double>
Toshihiro Shimizu 890ddd
	if (it == frames.end())
Toshihiro Shimizu 890ddd
		return -1;
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		return std::distance(frames.begin(), it);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int TToneCurveParam::getPrevKeyframe(double frame) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	std::set<double> frames;</double>
Toshihiro Shimizu 890ddd
	getKeyframes(frames);
Toshihiro Shimizu 890ddd
	std::set<double>::iterator it = frames.lower_bound(frame);</double>
Toshihiro Shimizu 890ddd
	if (it == frames.begin())
Toshihiro Shimizu 890ddd
		return -1;
Toshihiro Shimizu 890ddd
	else {
Toshihiro Shimizu 890ddd
		--it;
Toshihiro Shimizu 890ddd
		return std::distance(frames.begin(), it);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
double TToneCurveParam::keyframeIndexToFrame(int index) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	std::set<double> frames;</double>
Toshihiro Shimizu 890ddd
	getKeyframes(frames);
Toshihiro Shimizu 890ddd
	assert(0 <= index && index < (int)frames.size());
Toshihiro Shimizu 890ddd
	std::set<double>::const_iterator it = frames.begin();</double>
Toshihiro Shimizu 890ddd
	std::advance(it, index);
Toshihiro Shimizu 890ddd
	return *it;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::loadData(TIStream &is)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	string tagName;
Toshihiro Shimizu 890ddd
	is.openChild(tagName);
Toshihiro Shimizu 890ddd
	assert(tagName == "tonecurve");
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->removeAllParam();
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->loadData(is);
Toshihiro Shimizu 890ddd
	m_rgbParamSet->removeAllParam();
Toshihiro Shimizu 890ddd
	m_rgbParamSet->loadData(is);
Toshihiro Shimizu 890ddd
	m_rParamSet->removeAllParam();
Toshihiro Shimizu 890ddd
	m_rParamSet->loadData(is);
Toshihiro Shimizu 890ddd
	m_gParamSet->removeAllParam();
Toshihiro Shimizu 890ddd
	m_gParamSet->loadData(is);
Toshihiro Shimizu 890ddd
	m_bParamSet->removeAllParam();
Toshihiro Shimizu 890ddd
	m_bParamSet->loadData(is);
Toshihiro Shimizu 890ddd
	m_aParamSet->removeAllParam();
Toshihiro Shimizu 890ddd
	m_aParamSet->loadData(is);
Toshihiro Shimizu 890ddd
	is.openChild(tagName);
Toshihiro Shimizu 890ddd
	m_isLinear->loadData(is);
Toshihiro Shimizu 890ddd
	is.closeChild();
Toshihiro Shimizu 890ddd
	is.closeChild();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TToneCurveParam::saveData(TOStream &os)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	os.openChild("tonecurve");
Toshihiro Shimizu 890ddd
	m_rgbaParamSet->saveData(os);
Toshihiro Shimizu 890ddd
	m_rgbParamSet->saveData(os);
Toshihiro Shimizu 890ddd
	m_rParamSet->saveData(os);
Toshihiro Shimizu 890ddd
	m_gParamSet->saveData(os);
Toshihiro Shimizu 890ddd
	m_bParamSet->saveData(os);
Toshihiro Shimizu 890ddd
	m_aParamSet->saveData(os);
Toshihiro Shimizu 890ddd
	os.openChild("isLineaer");
Toshihiro Shimizu 890ddd
	m_isLinear->saveData(os);
Toshihiro Shimizu 890ddd
	os.closeChild();
Toshihiro Shimizu 890ddd
	os.closeChild();
Toshihiro Shimizu 890ddd
}