Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "tpointparam.h"
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
Shinya Kitaoka 120a6e
class TPointParamImp {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TPointParamImp(const TPointD &p)
Shinya Kitaoka 120a6e
      : m_x(new TDoubleParam(p.x)), m_y(new TDoubleParam(p.y)) {}
Shinya Kitaoka 120a6e
  TPointParamImp(const TPointParamImp &src)
Shinya Kitaoka 120a6e
      : m_x(src.m_x->clone()), m_y(src.m_y->clone()) {}
Shinya Kitaoka 120a6e
  ~TPointParamImp() {}
Shinya Kitaoka 120a6e
  TDoubleParamP m_x, m_y;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
PERSIST_IDENTIFIER(TPointParam, "pointParam")
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TPointParam::TPointParam(const TPointD &p, bool from_plugin)
Shinya Kitaoka 120a6e
    : m_data(new TPointParamImp(p)), m_from_plugin(from_plugin) {
Shinya Kitaoka 120a6e
  addParam(m_data->m_x, "x");
Shinya Kitaoka 120a6e
  addParam(m_data->m_y, "y");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TPointParam::TPointParam(const TPointParam &src)
Shinya Kitaoka 120a6e
    : TParamSet(src.getName())
Shinya Kitaoka 120a6e
    , m_data(new TPointParamImp(*src.m_data))
Shinya Kitaoka 120a6e
    , m_from_plugin(src.m_from_plugin) {
Shinya Kitaoka 120a6e
  addParam(m_data->m_x, "x");
Shinya Kitaoka 120a6e
  addParam(m_data->m_y, "y");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TPointParam::~TPointParam() { delete m_data; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TPointParam::copy(TParam *src) {
Shinya Kitaoka 120a6e
  TPointParam *p = dynamic_cast<tpointparam *="">(src);</tpointparam>
Shinya Kitaoka 120a6e
  if (!p) throw TException("invalid source for copy");
Shinya Kitaoka 120a6e
  setName(src->getName());
Shinya Kitaoka 120a6e
  m_data->m_x->copy(p->m_data->m_x.getPointer());
Shinya Kitaoka 120a6e
  m_data->m_y->copy(p->m_data->m_y.getPointer());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TPointD TPointParam::getDefaultValue() const {
Shinya Kitaoka 120a6e
  return TPointD(m_data->m_x->getDefaultValue(),
Shinya Kitaoka 120a6e
                 m_data->m_y->getDefaultValue());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TPointD TPointParam::getValue(double frame) const {
Shinya Kitaoka 120a6e
  return TPointD(m_data->m_x->getValue(frame), m_data->m_y->getValue(frame));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TPointParam::setValue(double frame, const TPointD &p) {
Shinya Kitaoka 120a6e
  beginParameterChange();
Shinya Kitaoka 120a6e
  m_data->m_x->setValue(frame, p.x);
Shinya Kitaoka 120a6e
  m_data->m_y->setValue(frame, p.y);
Shinya Kitaoka 120a6e
  endParameterChange();
Shinya Kitaoka 120a6e
  return true;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TPointParam::setDefaultValue(const TPointD &p) {
Shinya Kitaoka 120a6e
  m_data->m_x->setDefaultValue(p.x);
Shinya Kitaoka 120a6e
  m_data->m_y->setDefaultValue(p.y);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TPointParam::loadData(TIStream &is) {
Shinya Kitaoka 120a6e
  std::string childName;
Shinya Kitaoka 120a6e
  while (is.openChild(childName)) {
Shinya Kitaoka 120a6e
    if (childName == "x")
Shinya Kitaoka 120a6e
      m_data->m_x->loadData(is);
Shinya Kitaoka 120a6e
    else if (childName == "y")
Shinya Kitaoka 120a6e
      m_data->m_y->loadData(is);
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      throw TException("unknown coord");
Shinya Kitaoka 120a6e
    is.closeChild();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TPointParam::saveData(TOStream &os) {
Shinya Kitaoka 120a6e
  os.openChild("x");
Shinya Kitaoka 120a6e
  m_data->m_x->saveData(os);
Shinya Kitaoka 120a6e
  os.closeChild();
Shinya Kitaoka 120a6e
  os.openChild("y");
Shinya Kitaoka 120a6e
  m_data->m_y->saveData(os);
Shinya Kitaoka 120a6e
  os.closeChild();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TDoubleParamP &TPointParam::getX() { return m_data->m_x; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TDoubleParamP &TPointParam::getY() { return m_data->m_y; }