|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tdoubleparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=========================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TRangeParamImp
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamImp(const DoublePair &v)
|
|
Toshihiro Shimizu |
890ddd |
: m_min(new TDoubleParam(v.first)), m_max(new TDoubleParam(v.second))
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamImp(const TRangeParamImp &src)
|
|
Toshihiro Shimizu |
890ddd |
: m_min(src.m_min->clone()), m_max(src.m_max->clone())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~TRangeParamImp() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_min, m_max;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_IDENTIFIER(TRangeParam, "rangeParam")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRangeParam::TRangeParam(const DoublePair &v)
|
|
Toshihiro Shimizu |
890ddd |
: m_data(new TRangeParamImp(v))
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(m_data->m_min, "min");
|
|
Toshihiro Shimizu |
890ddd |
addParam(m_data->m_max, "max");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRangeParam::TRangeParam(const TRangeParam &src)
|
|
Toshihiro Shimizu |
890ddd |
: TParamSet(src.getName()), m_data(new TRangeParamImp(*src.m_data))
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addParam(m_data->m_min, "min");
|
|
Toshihiro Shimizu |
890ddd |
addParam(m_data->m_max, "max");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRangeParam::~TRangeParam()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
delete m_data;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TRangeParam::copy(TParam *src)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRangeParam *p = dynamic_cast<trangeparam *="">(src);</trangeparam>
|
|
Toshihiro Shimizu |
890ddd |
if (!p)
|
|
Toshihiro Shimizu |
890ddd |
throw TException("invalid source for copy");
|
|
Toshihiro Shimizu |
890ddd |
setName(src->getName());
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_min->copy(p->m_data->m_min.getPointer());
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_max->copy(p->m_data->m_max.getPointer());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DoublePair TRangeParam::getDefaultValue() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return DoublePair(m_data->m_min->getDefaultValue(), m_data->m_max->getDefaultValue());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DoublePair TRangeParam::getValue(double frame) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return DoublePair(m_data->m_min->getValue(frame), m_data->m_max->getValue(frame));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TRangeParam::setValue(double frame, const DoublePair &v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
beginParameterChange();
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_min->setValue(frame, v.first);
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_max->setValue(frame, v.second);
|
|
Toshihiro Shimizu |
890ddd |
endParameterChange();
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TRangeParam::setDefaultValue(const DoublePair &v)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_min->setDefaultValue(v.first);
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_max->setDefaultValue(v.second);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TRangeParam::loadData(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
string childName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(childName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (childName == "min")
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_min->loadData(is);
|
|
Toshihiro Shimizu |
890ddd |
else if (childName == "max")
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_max->loadData(is);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
throw TException("unknown tag");
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TRangeParam::saveData(TOStream &os)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("min");
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_min->saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("max");
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_max->saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP &TRangeParam::getMin()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_data->m_min;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP &TRangeParam::getMax()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_data->m_max;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#ifdef BUTTA
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TRangeParam::getNextKeyframe(double frame) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int f_min = m_data->m_min->getNextKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
int f_max = m_data->m_max->getNextKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
if (f_min <= f_max && f_min != -1)
|
|
Toshihiro Shimizu |
890ddd |
return f_min;
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
if (f_max != -1)
|
|
Toshihiro Shimizu |
890ddd |
return f_max;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return -1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TRangeParam::getPrevKeyframe(double frame) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int f_min = m_data->m_min->getPrevKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
int f_max = m_data->m_max->getPrevKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
if (f_min >= f_max)
|
|
Toshihiro Shimizu |
890ddd |
return f_min;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return f_max;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TRangeParam::deleteKeyframe(double frame, bool undoing)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_min->deleteKeyframe(frame, undoing);
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_max->deleteKeyframe(frame, undoing);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TRangeParam::isKeyframe(double frame) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bool min, max;
|
|
Toshihiro Shimizu |
890ddd |
min = m_data->m_min->isKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
max = m_data->m_max->isKeyframe(frame);
|
|
Toshihiro Shimizu |
890ddd |
return (min || max);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|