Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tparamset.h"
Toshihiro Shimizu 890ddd
#include "tundo.h"
Toshihiro Shimizu 890ddd
//#include "tparam.h"
Toshihiro Shimizu 890ddd
#include "tdoubleparam.h"
Toshihiro Shimizu 890ddd
#include "tstream.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <set></set>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace {
Shinya Kitaoka 120a6e
void doRelease(const std::pair<tparam *,="" std::string=""> ¶m) {</tparam>
Shinya Kitaoka 120a6e
  param.first->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class TParamSetImp final : public TParamObserver {
Shinya Kitaoka 120a6e
  friend class TParamSet;
Shinya Kitaoka 120a6e
  TParamSet *m_param;
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">> m_params;</std::pair<tparam>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // ChangeBlock *m_changeBlock;
Shinya Kitaoka 120a6e
  bool m_draggingEnabled, m_notificationEnabled;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TParamSetImp(TParamSet *param)
Shinya Kitaoka 120a6e
      : m_param(param)
Shinya Kitaoka 120a6e
      //, m_changeBlock(0)
Shinya Kitaoka 120a6e
      , m_draggingEnabled(false)
Shinya Kitaoka 120a6e
      , m_notificationEnabled(true) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ~TParamSetImp() {
Shinya Kitaoka 120a6e
    std::for_each(m_params.begin(), m_params.end(), doRelease);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  // std::set<tparamsetobserver*> m_observers;</tparamsetobserver*>
Shinya Kitaoka 120a6e
  std::set<tparamobserver *=""> m_paramObservers;</tparamobserver>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  template <typename t=""></typename>
Shinya Kitaoka 120a6e
  void notify(const T &change);
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void onChange(const TParamChange &change) override {}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
TParamSet::TParamSet(std::string name)
Shinya Kitaoka 120a6e
    : TParam(name), m_imp(new TParamSetImp(this)) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TParamSet::TParamSet(const TParamSet &src)
Shinya Kitaoka 120a6e
    : TParam(src.getName()), m_imp(new TParamSetImp(this)) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TParamSet::~TParamSet() { delete m_imp; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
template <class container=""></class>
Shinya Kitaoka d1f6c4
class MyBackInsertIterator final : public
Shinya Kitaoka d1f6c4
std::iterator
Shinya Kitaoka 120a6e
void, void, void, void>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
  Container &container;
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
  MyBackInsertIterator(Container &c) : container(c) {}
Shinya Kitaoka 120a6e
  MyBackInsertIterator<container> &operator=(const typename</container>
Shinya Kitaoka 120a6e
Container::value_type &value)
Toshihiro Shimizu 890ddd
  {
Toshihiro Shimizu 890ddd
    container.push_back(value);
Toshihiro Shimizu 890ddd
    return *this;
Toshihiro Shimizu 890ddd
  }
Toshihiro Shimizu 890ddd
  MyBackInsertIterator<container>&operator*()</container>
Toshihiro Shimizu 890ddd
  {
Toshihiro Shimizu 890ddd
  return *this;
Toshihiro Shimizu 890ddd
  }
Toshihiro Shimizu 890ddd
  MyBackInsertIterator<container>&operator++()</container>
Toshihiro Shimizu 890ddd
  {
Toshihiro Shimizu 890ddd
  return *this;
Toshihiro Shimizu 890ddd
  }
Toshihiro Shimizu 890ddd
  MyBackInsertIterator<container>&operator++(int)</container>
Toshihiro Shimizu 890ddd
  {
Toshihiro Shimizu 890ddd
  return *this;
Toshihiro Shimizu 890ddd
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::beginParameterChange() {
Shinya Kitaoka 120a6e
  //  assert(0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // std::set<tparamsetobserver*>::iterator it = m_imp->m_observers.begin();</tparamsetobserver*>
Shinya Kitaoka 120a6e
  // for (;it != m_imp->m_observers.end(); ++it)
Shinya Kitaoka 120a6e
  //  (*it)->onBeginChangeBlock(this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // assert(!m_imp->m_changeBlock);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::vector<tparam *=""> params;</tparam>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
MyBackInsertIterator<vector<pair<tparam*, string=""> > ></vector<pair<tparam*,>
Shinya Kitaoka 120a6e
myBackInsertIterator(params);
Toshihiro Shimizu 890ddd
copy(m_imp->m_params.begin(), m_imp->m_params.end(), myIterator);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator it2 =</std::pair<tparam>
Shinya Kitaoka 120a6e
      m_imp->m_params.begin();
Shinya Kitaoka 120a6e
  for (; it2 != m_imp->m_params.end(); ++it2) params.push_back(it2->first);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // m_imp->m_changeBlock = new ChangeBlock;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::endParameterChange(){
Shinya Kitaoka 120a6e
    //  assert(0);
Shinya Kitaoka 120a6e
    // assert(m_imp->m_changeBlock);
Shinya Kitaoka 120a6e
    /*
Shinya Kitaoka 120a6e
TParamSetChange change(this, m_imp->m_changeBlock->m_firstAffectedFrame,
Shinya Kitaoka 120a6e
                         m_imp->m_changeBlock->m_lastAffectedFrame,
Shinya Kitaoka 120a6e
                         m_imp->m_changeBlock->m_changes, false);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
change.m_dragging = m_imp->m_draggingEnabled;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//delete m_imp->m_changeBlock;
Toshihiro Shimizu 890ddd
//m_imp->m_changeBlock = 0;
Toshihiro Shimizu 890ddd
//m_imp->notify(change);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//std::set<tparamsetobserver*>::iterator it = m_imp->m_observers.begin();</tparamsetobserver*>
Toshihiro Shimizu 890ddd
//for (;it != m_imp->m_observers.end(); ++it)
Toshihiro Shimizu 890ddd
//  (*it)->onEndChangeBlock(this);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
m_imp->notify(change);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::addParam(const TParamP ¶m, const std::string &name) {
Shinya Kitaoka 120a6e
  std::pair<tparam *,="" std::string=""> paramToInsert =</tparam>
Shinya Kitaoka 120a6e
      std::make_pair(param.getPointer(), name);
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator it =</std::pair<tparam>
Shinya Kitaoka 120a6e
      std::find(m_imp->m_params.begin(), m_imp->m_params.end(), paramToInsert);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (it == m_imp->m_params.end()) {
Shinya Kitaoka 120a6e
    param->addRef();
Shinya Kitaoka 120a6e
    param->addObserver(m_imp);
Shinya Kitaoka 120a6e
    m_imp->m_params.push_back(paramToInsert);
Shinya Kitaoka 120a6e
    // TParamSetParamAdded psParamAdded(this, param.getPointer(), name, false);
Shinya Kitaoka 120a6e
    if (param->getName().empty()) param->setName(name);
Shinya Kitaoka 120a6e
    // m_imp->notify(psParamAdded);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::insertParam(const TParamP ¶m, const std::string &name,
Shinya Kitaoka 120a6e
                            int index) {
Shinya Kitaoka 120a6e
  std::pair<tparam *,="" std::string=""> paramToInsert =</tparam>
Shinya Kitaoka 120a6e
      std::make_pair(param.getPointer(), name);
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator it =</std::pair<tparam>
Shinya Kitaoka 120a6e
      std::find(m_imp->m_params.begin(), m_imp->m_params.end(), paramToInsert);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (it == m_imp->m_params.end()) {
Shinya Kitaoka 120a6e
    param->addRef();
Shinya Kitaoka 120a6e
    param->addObserver(m_imp);
Shinya Kitaoka 120a6e
    it = m_imp->m_params.begin();
Shinya Kitaoka 120a6e
    int f;
Shinya Kitaoka 120a6e
    for (f = 0; f < index; f++) it++;
Shinya Kitaoka 120a6e
    m_imp->m_params.insert(it, paramToInsert);
Shinya Kitaoka 120a6e
    if (param->getName().empty()) param->setName(name);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace {
Shinya Kitaoka 120a6e
class matchesParam {
Shinya Kitaoka 120a6e
  TParamP m_param;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  matchesParam(const TParamP ¶m) : m_param(param) {}
Shinya Kitaoka 120a6e
  bool operator()(const std::pair<tparam *,="" std::string=""> ¶m) {</tparam>
Shinya Kitaoka 120a6e
    return m_param.getPointer() == param.first;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::removeParam(const TParamP ¶m) {
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator it = std::find_if(</std::pair<tparam>
Shinya Kitaoka 120a6e
      m_imp->m_params.begin(), m_imp->m_params.end(), matchesParam(param));
Shinya Kitaoka 120a6e
  if (it != m_imp->m_params.end()) {
Shinya Kitaoka 120a6e
    param->removeObserver(m_imp);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    // TParamSetParamRemoved psParamRemoved(this, param.getPointer(),
Shinya Kitaoka 120a6e
    // it->second, false);
Shinya Kitaoka 120a6e
    // m_imp->notify(psParamRemoved);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    param->release();
Shinya Kitaoka 120a6e
    m_imp->m_params.erase(it);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::removeAllParam() {
Shinya Kitaoka 120a6e
  while (!m_imp->m_params.empty()) {
Shinya Kitaoka 120a6e
    std::vector<std::pair<tparam *,="" std::string="">>::iterator it =</std::pair<tparam>
Shinya Kitaoka 120a6e
        m_imp->m_params.begin();
Shinya Kitaoka 120a6e
    TParam *param = it->first;
Shinya Kitaoka 120a6e
    param->removeObserver(m_imp);
Shinya Kitaoka 120a6e
    param->release();
Shinya Kitaoka 120a6e
    m_imp->m_params.erase(it);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TParamSet::getParamCount() const { return m_imp->m_params.size(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TParamP TParamSet::getParam(int i) const {
Shinya Kitaoka 120a6e
  assert(i >= 0 && i < (int)m_imp->m_params.size());
Shinya Kitaoka 120a6e
  return m_imp->m_params[i].first;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string TParamSet::getParamName(int i) const {
Shinya Kitaoka 120a6e
  assert(i >= 0 && i < (int)m_imp->m_params.size());
Shinya Kitaoka 120a6e
  return m_imp->m_params[i].second;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TParamSet::getParamIdx(const std::string &name) const {
Shinya Kitaoka 120a6e
  int i, paramsCount = m_imp->m_params.size();
Shinya Kitaoka 120a6e
  for (i = 0; i < paramsCount; ++i)
Shinya Kitaoka 120a6e
    if (m_imp->m_params[i].second == name) break;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return i;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::getAnimatableParams(std::vector<tparamp> ¶ms,</tparamp>
Shinya Kitaoka 120a6e
                                    bool recursive) {
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator it =</std::pair<tparam>
Shinya Kitaoka 120a6e
      m_imp->m_params.begin();
Shinya Kitaoka 120a6e
  for (; it != m_imp->m_params.end(); ++it) {
Shinya Kitaoka 120a6e
    TParam *param = it->first;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TDoubleParamP dparam = TParamP(param);
Shinya Kitaoka 120a6e
    if (dparam)
Shinya Kitaoka 120a6e
      params.push_back(dparam);
Shinya Kitaoka 120a6e
    else {
Shinya Kitaoka 120a6e
      TParamSetP paramset = TParamP(param);
Shinya Kitaoka 120a6e
      if (paramset && recursive)
Shinya Kitaoka 120a6e
        paramset->getAnimatableParams(params, recursive);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::addObserver(TParamObserver *observer) {
Shinya Kitaoka 120a6e
  // TParamSetObserver *obs = dynamic_cast<tparamsetobserver *="">(observer);</tparamsetobserver>
Shinya Kitaoka 120a6e
  // if (obs)
Shinya Kitaoka 120a6e
  //  m_imp->m_observers.insert(obs);
Shinya Kitaoka 120a6e
  // else
Shinya Kitaoka 120a6e
  m_imp->m_paramObservers.insert(observer);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <typename t=""></typename>
Shinya Kitaoka 120a6e
void TParamSetImp::notify(const T &change) {
Shinya Kitaoka 120a6e
  if (m_notificationEnabled) {
Shinya Kitaoka 120a6e
    //  for (std::set<tparamsetobserver*>::iterator it = m_observers.begin();</tparamsetobserver*>
Shinya Kitaoka 120a6e
    //                                              it!= m_observers.end();
Shinya Kitaoka 120a6e
    //                                              ++it)
Shinya Kitaoka 120a6e
    //    (*it)->onChange(change);
Shinya Kitaoka 120a6e
    for (std::set<tparamobserver *="">::iterator paramIt =</tparamobserver>
Shinya Kitaoka 120a6e
             m_paramObservers.begin();
Shinya Kitaoka 120a6e
         paramIt != m_paramObservers.end(); ++paramIt)
Shinya Kitaoka 120a6e
      (*paramIt)->onChange(change);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::removeObserver(TParamObserver *observer) {
Shinya Kitaoka 120a6e
  // TParamSetObserver *obs = dynamic_cast<tparamsetobserver *="">(observer);</tparamsetobserver>
Shinya Kitaoka 120a6e
  // if (obs)
Shinya Kitaoka 120a6e
  //  m_imp->m_observers.erase(obs);
Shinya Kitaoka 120a6e
  // else
Shinya Kitaoka 120a6e
  m_imp->m_paramObservers.erase(observer);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::enableDragging(bool on) {
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator it =</std::pair<tparam>
Shinya Kitaoka 120a6e
      m_imp->m_params.begin();
Shinya Kitaoka 120a6e
  for (; it != m_imp->m_params.end(); ++it) {
Shinya Kitaoka 120a6e
    TDoubleParamP dparam(it->first);
Shinya Kitaoka 120a6e
    // if (dparam)
Shinya Kitaoka 120a6e
    //  dparam->enableDragging(on);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_imp->m_draggingEnabled = on;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
namespace {
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DoEnableNotification final : public std::binary_function {
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
  DoEnableNotification() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void operator() (const pair<tparam*, string=""> ¶m, bool on)</tparam*,>
Toshihiro Shimizu 890ddd
  {
Toshihiro Shimizu 890ddd
    return param->first->enableNotification(on);
Toshihiro Shimizu 890ddd
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::enableNotification(bool on) {
Shinya Kitaoka 120a6e
  //  std::for_each(m_imp->m_params.begin(), m_imp->m_params.end(),
Shinya Kitaoka 120a6e
  //  std::bind2nd(DoEnableNotification, on));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator it =</std::pair<tparam>
Shinya Kitaoka 120a6e
      m_imp->m_params.begin();
Shinya Kitaoka 120a6e
  for (; it != m_imp->m_params.end(); ++it) {
Shinya Kitaoka 120a6e
    it->first->enableNotification(on);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_imp->m_notificationEnabled = on;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TParamSet::isNotificationEnabled() const {
Shinya Kitaoka 120a6e
  return m_imp->m_notificationEnabled;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TParamSet::isKeyframe(double frame) const {
Shinya Kitaoka 120a6e
  for (int i = 0; i < getParamCount(); i++)
Shinya Kitaoka 120a6e
    if (getParam(i)->isKeyframe(frame)) return true;
Shinya Kitaoka 120a6e
  return false;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::getKeyframes(std::set<double> &frames) const {</double>
Shinya Kitaoka 120a6e
  for (int i = 0; i < getParamCount(); i++) getParam(i)->getKeyframes(frames);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
double TParamSet::keyframeIndexToFrame(int index) const {
Shinya Kitaoka 120a6e
  std::set<double> frames;</double>
Shinya Kitaoka 120a6e
  getKeyframes(frames);
Shinya Kitaoka 120a6e
  assert(0 <= index && index < (int)frames.size());
Shinya Kitaoka 120a6e
  std::set<double>::const_iterator it = frames.begin();</double>
Shinya Kitaoka 120a6e
  std::advance(it, index);
Shinya Kitaoka 120a6e
  return *it;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TParamSet::getNextKeyframe(double frame) const {
Shinya Kitaoka 120a6e
  std::set<double> frames;</double>
Shinya Kitaoka 120a6e
  getKeyframes(frames);
Shinya Kitaoka 120a6e
  std::set<double>::iterator it = frames.upper_bound(frame);</double>
Shinya Kitaoka 120a6e
  if (it == frames.end())
Shinya Kitaoka 120a6e
    return -1;
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    return std::distance(frames.begin(), it);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TParamSet::getPrevKeyframe(double frame) const {
Shinya Kitaoka 120a6e
  std::set<double> frames;</double>
Shinya Kitaoka 120a6e
  getKeyframes(frames);
Shinya Kitaoka 120a6e
  std::set<double>::iterator it = frames.lower_bound(frame);</double>
Shinya Kitaoka 120a6e
  if (it == frames.begin())
Shinya Kitaoka 120a6e
    return -1;
Shinya Kitaoka 120a6e
  else {
Shinya Kitaoka 120a6e
    --it;
Shinya Kitaoka 120a6e
    return std::distance(frames.begin(), it);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TParamSet::hasKeyframes() const {
Shinya Kitaoka 120a6e
  for (int i = 0; i < getParamCount(); i++)
Shinya Kitaoka 120a6e
    if (getParam(i)->hasKeyframes()) return true;
Shinya Kitaoka 120a6e
  return false;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TParamSet::getKeyframeCount() const {
Shinya Kitaoka 120a6e
  std::set<double> frames;</double>
Shinya Kitaoka 120a6e
  getKeyframes(frames);
Shinya Kitaoka 120a6e
  return frames.size();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::deleteKeyframe(double frame) {
Shinya Kitaoka 120a6e
  for (int i = 0; i < getParamCount(); i++) getParam(i)->deleteKeyframe(frame);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::clearKeyframes() {
Shinya Kitaoka 120a6e
  for (int i = 0; i < getParamCount(); i++) getParam(i)->clearKeyframes();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::assignKeyframe(double frame, const TParamP &src,
Shinya Kitaoka 120a6e
                               double srcFrame, bool changedOnly) {
Shinya Kitaoka 120a6e
  TParamSetP paramSetSrc = src;
Shinya Kitaoka 120a6e
  if (!paramSetSrc) return;
Shinya Kitaoka 120a6e
  if (getParamCount() != paramSetSrc->getParamCount()) return;
Shinya Kitaoka 120a6e
  for (int i = 0; i < getParamCount(); i++)
Shinya Kitaoka 120a6e
    getParam(i)->assignKeyframe(frame, paramSetSrc->getParam(i), srcFrame,
Shinya Kitaoka 120a6e
                                changedOnly);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TParam *TParamSet::clone() const { return new TParamSet(*this); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::copy(TParam *src) {
Shinya Kitaoka 120a6e
  TParamSet *p = dynamic_cast<tparamset *="">(src);</tparamset>
Shinya Kitaoka 120a6e
  if (!p) throw TException("invalid source for copy");
Shinya Kitaoka 120a6e
  int srcParamCount = p->getParamCount();
Shinya Kitaoka 120a6e
  removeAllParam();
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < srcParamCount; i++) {
Shinya Kitaoka 120a6e
    TParamP param = p->getParam(i);
Shinya Kitaoka 120a6e
    addParam(param->clone(), param->getName());
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::loadData(TIStream &is) {
Shinya Kitaoka 120a6e
  std::string tagName;
Shinya Kitaoka 120a6e
  is.openChild(tagName);
Shinya Kitaoka 120a6e
  while (!is.eos()) {
Shinya Kitaoka 120a6e
    std::string paramName;
Shinya Kitaoka 120a6e
    is.openChild(paramName);
Shinya Kitaoka 120a6e
    TPersist *p = 0;
Shinya Kitaoka 120a6e
    is >> p;
Shinya Kitaoka 120a6e
    TParam *param = dynamic_cast<tparam *="">(p);</tparam>
Shinya Kitaoka 120a6e
    assert(param);
Shinya Kitaoka 120a6e
    addParam(param, paramName);
Shinya Kitaoka 120a6e
    is.closeChild();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  is.closeChild();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TParamSet::saveData(TOStream &os) {
Shinya Kitaoka 120a6e
  os.openChild(getName());
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator it =</std::pair<tparam>
Shinya Kitaoka 120a6e
      m_imp->m_params.begin();
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator end =</std::pair<tparam>
Shinya Kitaoka 120a6e
      m_imp->m_params.end();
Shinya Kitaoka 120a6e
  while (it != end) {
Shinya Kitaoka 120a6e
    os.openChild(it->second);
Shinya Kitaoka 120a6e
    // it->first->saveData(os);
Shinya Kitaoka 120a6e
    os << it->first;
Shinya Kitaoka 120a6e
    os.closeChild();
Shinya Kitaoka 120a6e
    ++it;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  os.closeChild();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
std::string TParamSet::getValueAlias(double frame, int precision) {
Shinya Kitaoka 120a6e
  std::string alias = "(";
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator end =</std::pair<tparam>
Shinya Kitaoka 120a6e
      m_imp->m_params.begin();
Shinya Kitaoka 120a6e
  std::advance(end, m_imp->m_params.size() - 1);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::vector<std::pair<tparam *,="" std::string="">>::iterator it =</std::pair<tparam>
Shinya Kitaoka 120a6e
      m_imp->m_params.begin();
Shinya Kitaoka 120a6e
  for (; it != end; ++it)
Shinya Kitaoka 120a6e
    alias += it->first->getValueAlias(frame, precision) + ",";
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  alias += it->first->getValueAlias(frame, precision);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  alias += ")";
Shinya Kitaoka 120a6e
  return alias;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TPersistDeclarationT<tparamset> TParamSet::m_declaration("TParamSet");</tparamset>