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
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
class ChangeBlock {
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
  ChangeBlock()
Toshihiro Shimizu 890ddd
      : m_firstAffectedFrame ( TParamChange::m_maxFrame)
Toshihiro Shimizu 890ddd
      , m_lastAffectedFrame  ( TParamChange::m_minFrame)
Toshihiro Shimizu 890ddd
    {
Toshihiro Shimizu 890ddd
    }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  ~ChangeBlock()
Toshihiro Shimizu 890ddd
    {
Toshihiro Shimizu 890ddd
    }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  void add(const TParamChange &change)
Toshihiro Shimizu 890ddd
    {
Toshihiro Shimizu 890ddd
    m_firstAffectedFrame = tmin(m_firstAffectedFrame, change.m_firstAffectedFrame);
Toshihiro Shimizu 890ddd
    m_lastAffectedFrame  = tmax(m_lastAffectedFrame , change.m_lastAffectedFrame);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
    m_changes.push_back(change.clone());
Toshihiro Shimizu 890ddd
    }
Toshihiro Shimizu 890ddd
  vector<tparamchange*> m_changes;</tparamchange*>
Toshihiro Shimizu 890ddd
double m_firstAffectedFrame;
Toshihiro Shimizu 890ddd
double m_lastAffectedFrame;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
namespace
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
void doRelease(const pair<tparam *,="" string=""> ¶m)</tparam>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	param.first->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TParamSetImp : public TParamObserver
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	friend class TParamSet;
Toshihiro Shimizu 890ddd
	TParamSet *m_param;
Toshihiro Shimizu 890ddd
	vector<pair<tparam *,="" string="">> m_params;</pair<tparam>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// ChangeBlock *m_changeBlock;
Toshihiro Shimizu 890ddd
	bool m_draggingEnabled, m_notificationEnabled;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TParamSetImp(TParamSet *param) : m_param(param)
Toshihiro Shimizu 890ddd
									 //, m_changeBlock(0)
Toshihiro Shimizu 890ddd
									 ,
Toshihiro Shimizu 890ddd
									 m_draggingEnabled(false), m_notificationEnabled(true)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	~TParamSetImp()
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		std::for_each(m_params.begin(), m_params.end(), doRelease);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	// std::set<tparamsetobserver*> m_observers;</tparamsetobserver*>
Toshihiro Shimizu 890ddd
	std::set<tparamobserver *=""> m_paramObservers;</tparamobserver>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	template <typename t=""></typename>
Toshihiro Shimizu 890ddd
	void notify(const T &change);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onChange(const TParamChange &change)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		/*
Toshihiro Shimizu 890ddd
    if (!m_changeBlock)  // se non stiamo modificando un blocco di parametri, invio la notifica
Toshihiro Shimizu 890ddd
      {
Toshihiro Shimizu 890ddd
      vector<tparam*> params; </tparam*>
Toshihiro Shimizu 890ddd
      params.push_back(change.m_param);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
      TParamSetChange psChange(m_param, change.m_firstAffectedFrame, change.m_lastAffectedFrame, 
Toshihiro Shimizu 890ddd
                               params, change.m_undoing);
Toshihiro Shimizu 890ddd
      notify(psChange);
Toshihiro Shimizu 890ddd
      }
Toshihiro Shimizu 890ddd
    else
Toshihiro Shimizu 890ddd
      notify(change);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
    if (!m_changeBlock)  // se non stiamo modificando un blocco di parametri, invio la notifica
Toshihiro Shimizu 890ddd
      notify(change);
Toshihiro Shimizu 890ddd
    else
Toshihiro Shimizu 890ddd
      {
Toshihiro Shimizu 890ddd
      //metto da parte la TParamChange, per poi alla fine notificare una TParamSetChange
Toshihiro Shimizu 890ddd
      m_changeBlock->add(change);
Toshihiro Shimizu 890ddd
      }
Toshihiro Shimizu 890ddd
      */
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TParamSet::TParamSet(string name)
Toshihiro Shimizu 890ddd
	: TParam(name)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_imp = new TParamSetImp(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TParamSet::TParamSet(const TParamSet &src)
Toshihiro Shimizu 890ddd
	: TParam(src.getName())
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_imp = new TParamSetImp(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TParamSet::~TParamSet()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	delete m_imp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
template <class container=""></class>
Toshihiro Shimizu 890ddd
class MyBackInsertIterator : public std::iterator<std::output_iterator_tag, void="" void,=""></std::output_iterator_tag,>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
  Container &container;
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
  MyBackInsertIterator(Container &c) : container(c) {}
Toshihiro Shimizu 890ddd
  MyBackInsertIterator<container> &operator=(const typename Container::value_type &value)</container>
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
Toshihiro Shimizu 890ddd
void TParamSet::beginParameterChange()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	//  assert(0);
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)->onBeginChangeBlock(this);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//assert(!m_imp->m_changeBlock);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	vector<tparam *=""> params;</tparam>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
MyBackInsertIterator<vector<pair<tparam*, string=""> > > myBackInsertIterator(params);</vector<pair<tparam*,>
Toshihiro Shimizu 890ddd
copy(m_imp->m_params.begin(), m_imp->m_params.end(), myIterator);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator it2 = m_imp->m_params.begin();</pair<tparam>
Toshihiro Shimizu 890ddd
	for (; it2 != m_imp->m_params.end(); ++it2)
Toshihiro Shimizu 890ddd
		params.push_back(it2->first);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// m_imp->m_changeBlock = new ChangeBlock;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::endParameterChange(){
Toshihiro Shimizu 890ddd
	//  assert(0);
Toshihiro Shimizu 890ddd
	//assert(m_imp->m_changeBlock);
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
TParamSetChange change(this, m_imp->m_changeBlock->m_firstAffectedFrame, 
Toshihiro Shimizu 890ddd
                             m_imp->m_changeBlock->m_lastAffectedFrame, 
Toshihiro Shimizu 890ddd
                             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
Toshihiro Shimizu 890ddd
void TParamSet::addParam(const TParamP ¶m, const string &name)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	pair<tparam *,="" string=""> paramToInsert = std::make_pair(param.getPointer(), name);</tparam>
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator it =</pair<tparam>
Toshihiro Shimizu 890ddd
		std::find(m_imp->m_params.begin(), m_imp->m_params.end(), paramToInsert);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (it == m_imp->m_params.end()) {
Toshihiro Shimizu 890ddd
		param->addRef();
Toshihiro Shimizu 890ddd
		param->addObserver(m_imp);
Toshihiro Shimizu 890ddd
		m_imp->m_params.push_back(paramToInsert);
Toshihiro Shimizu 890ddd
		//TParamSetParamAdded psParamAdded(this, param.getPointer(), name, false);
Toshihiro Shimizu 890ddd
		if (param->getName().empty())
Toshihiro Shimizu 890ddd
			param->setName(name);
Toshihiro Shimizu 890ddd
		//m_imp->notify(psParamAdded);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::insertParam(const TParamP ¶m, const string &name, int index)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	pair<tparam *,="" string=""> paramToInsert = std::make_pair(param.getPointer(), name);</tparam>
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator it =</pair<tparam>
Toshihiro Shimizu 890ddd
		std::find(m_imp->m_params.begin(), m_imp->m_params.end(), paramToInsert);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (it == m_imp->m_params.end()) {
Toshihiro Shimizu 890ddd
		param->addRef();
Toshihiro Shimizu 890ddd
		param->addObserver(m_imp);
Toshihiro Shimizu 890ddd
		it = m_imp->m_params.begin();
Toshihiro Shimizu 890ddd
		int f;
Toshihiro Shimizu 890ddd
		for (f = 0; f < index; f++)
Toshihiro Shimizu 890ddd
			it++;
Toshihiro Shimizu 890ddd
		m_imp->m_params.insert(it, paramToInsert);
Toshihiro Shimizu 890ddd
		if (param->getName().empty())
Toshihiro Shimizu 890ddd
			param->setName(name);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
class matchesParam
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TParamP m_param;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	matchesParam(const TParamP ¶m) : m_param(param) {}
Toshihiro Shimizu 890ddd
	bool operator()(const pair<tparam *,="" string=""> ¶m)</tparam>
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		return m_param.getPointer() == param.first;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::removeParam(const TParamP ¶m)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator it =</pair<tparam>
Toshihiro Shimizu 890ddd
		std::find_if(m_imp->m_params.begin(), m_imp->m_params.end(), matchesParam(param));
Toshihiro Shimizu 890ddd
	if (it != m_imp->m_params.end()) {
Toshihiro Shimizu 890ddd
		param->removeObserver(m_imp);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		//TParamSetParamRemoved psParamRemoved(this, param.getPointer(), it->second, false);
Toshihiro Shimizu 890ddd
		//m_imp->notify(psParamRemoved);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		param->release();
Toshihiro Shimizu 890ddd
		m_imp->m_params.erase(it);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::removeAllParam()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	while (!m_imp->m_params.empty()) {
Toshihiro Shimizu 890ddd
		std::vector<pair<tparam *,="" string="">>::iterator it = m_imp->m_params.begin();</pair<tparam>
Toshihiro Shimizu 890ddd
		TParam *param = it->first;
Toshihiro Shimizu 890ddd
		param->removeObserver(m_imp);
Toshihiro Shimizu 890ddd
		param->release();
Toshihiro Shimizu 890ddd
		m_imp->m_params.erase(it);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int TParamSet::getParamCount() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_imp->m_params.size();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TParamP TParamSet::getParam(int i) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert(i >= 0 && i < (int)m_imp->m_params.size());
Toshihiro Shimizu 890ddd
	return m_imp->m_params[i].first;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
string TParamSet::getParamName(int i) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert(i >= 0 && i < (int)m_imp->m_params.size());
Toshihiro Shimizu 890ddd
	return m_imp->m_params[i].second;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int TParamSet::getParamIdx(const string &name) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int i, paramsCount = m_imp->m_params.size();
Toshihiro Shimizu 890ddd
	for (i = 0; i < paramsCount; ++i)
Toshihiro Shimizu 890ddd
		if (m_imp->m_params[i].second == name)
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	return i;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::getAnimatableParams(vector<tparamp> ¶ms, bool recursive)</tparamp>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator it = m_imp->m_params.begin();</pair<tparam>
Toshihiro Shimizu 890ddd
	for (; it != m_imp->m_params.end(); ++it) {
Toshihiro Shimizu 890ddd
		TParam *param = it->first;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TDoubleParamP dparam = TParamP(param);
Toshihiro Shimizu 890ddd
		if (dparam)
Toshihiro Shimizu 890ddd
			params.push_back(dparam);
Toshihiro Shimizu 890ddd
		else {
Toshihiro Shimizu 890ddd
			TParamSetP paramset = TParamP(param);
Toshihiro Shimizu 890ddd
			if (paramset && recursive)
Toshihiro Shimizu 890ddd
				paramset->getAnimatableParams(params, recursive);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::addObserver(TParamObserver *observer)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	//TParamSetObserver *obs = dynamic_cast<tparamsetobserver *="">(observer);</tparamsetobserver>
Toshihiro Shimizu 890ddd
	//if (obs)
Toshihiro Shimizu 890ddd
	//  m_imp->m_observers.insert(obs);
Toshihiro Shimizu 890ddd
	//else
Toshihiro Shimizu 890ddd
	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>
Toshihiro Shimizu 890ddd
void TParamSetImp::notify(const T &change)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (m_notificationEnabled) {
Toshihiro Shimizu 890ddd
		//  for (std::set<tparamsetobserver*>::iterator it = m_observers.begin();</tparamsetobserver*>
Toshihiro Shimizu 890ddd
		//                                              it!= m_observers.end();
Toshihiro Shimizu 890ddd
		//                                              ++it)
Toshihiro Shimizu 890ddd
		//    (*it)->onChange(change);
Toshihiro Shimizu 890ddd
		for (std::set<tparamobserver *="">::iterator paramIt = m_paramObservers.begin();</tparamobserver>
Toshihiro Shimizu 890ddd
			 paramIt != m_paramObservers.end();
Toshihiro Shimizu 890ddd
			 ++paramIt)
Toshihiro Shimizu 890ddd
			(*paramIt)->onChange(change);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::removeObserver(TParamObserver *observer)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	//TParamSetObserver *obs = dynamic_cast<tparamsetobserver *="">(observer);</tparamsetobserver>
Toshihiro Shimizu 890ddd
	//if (obs)
Toshihiro Shimizu 890ddd
	//  m_imp->m_observers.erase(obs);
Toshihiro Shimizu 890ddd
	//else
Toshihiro Shimizu 890ddd
	m_imp->m_paramObservers.erase(observer);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::enableDragging(bool on)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator it = m_imp->m_params.begin();</pair<tparam>
Toshihiro Shimizu 890ddd
	for (; it != m_imp->m_params.end(); ++it) {
Toshihiro Shimizu 890ddd
		TDoubleParamP dparam(it->first);
Toshihiro Shimizu 890ddd
		//if (dparam)
Toshihiro Shimizu 890ddd
		//  dparam->enableDragging(on);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_imp->m_draggingEnabled = on;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
namespace {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DoEnableNotification : public std::binary_function {
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
  DoEnableNotification() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  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
Toshihiro Shimizu 890ddd
void TParamSet::enableNotification(bool on)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	//  std::for_each(m_imp->m_params.begin(), m_imp->m_params.end(), std::bind2nd(DoEnableNotification, on));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator it = m_imp->m_params.begin();</pair<tparam>
Toshihiro Shimizu 890ddd
	for (; it != m_imp->m_params.end(); ++it) {
Toshihiro Shimizu 890ddd
		it->first->enableNotification(on);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_imp->m_notificationEnabled = on;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool TParamSet::isNotificationEnabled() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_imp->m_notificationEnabled;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool TParamSet::isKeyframe(double frame) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < getParamCount(); i++)
Toshihiro Shimizu 890ddd
		if (getParam(i)->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 TParamSet::getKeyframes(std::set<double> &frames) const</double>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < getParamCount(); i++)
Toshihiro Shimizu 890ddd
		getParam(i)->getKeyframes(frames);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
double TParamSet::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
int TParamSet::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 TParamSet::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
bool TParamSet::hasKeyframes() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < getParamCount(); i++)
Toshihiro Shimizu 890ddd
		if (getParam(i)->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 TParamSet::getKeyframeCount() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	std::set<double> frames;</double>
Toshihiro Shimizu 890ddd
	getKeyframes(frames);
Toshihiro Shimizu 890ddd
	return frames.size();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::deleteKeyframe(double frame)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < getParamCount(); i++)
Toshihiro Shimizu 890ddd
		getParam(i)->deleteKeyframe(frame);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::clearKeyframes()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < getParamCount(); i++)
Toshihiro Shimizu 890ddd
		getParam(i)->clearKeyframes();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::assignKeyframe(
Toshihiro Shimizu 890ddd
	double frame,
Toshihiro Shimizu 890ddd
	const TParamP &src, double srcFrame,
Toshihiro Shimizu 890ddd
	bool changedOnly)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TParamSetP paramSetSrc = src;
Toshihiro Shimizu 890ddd
	if (!paramSetSrc)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	if (getParamCount() != paramSetSrc->getParamCount())
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	for (int i = 0; i < getParamCount(); i++)
Toshihiro Shimizu 890ddd
		getParam(i)->assignKeyframe(
Toshihiro Shimizu 890ddd
			frame, paramSetSrc->getParam(i), srcFrame, changedOnly);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TParam *TParamSet::clone() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return new TParamSet(*this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::copy(TParam *src)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TParamSet *p = dynamic_cast<tparamset *="">(src);</tparamset>
Toshihiro Shimizu 890ddd
	if (!p)
Toshihiro Shimizu 890ddd
		throw TException("invalid source for copy");
Toshihiro Shimizu 890ddd
	int srcParamCount = p->getParamCount();
Toshihiro Shimizu 890ddd
	removeAllParam();
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
	for (i = 0; i < srcParamCount; i++) {
Toshihiro Shimizu 890ddd
		TParamP param = p->getParam(i);
Toshihiro Shimizu 890ddd
		addParam(param->clone(), param->getName());
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::loadData(TIStream &is)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	string tagName;
Toshihiro Shimizu 890ddd
	is.openChild(tagName);
Toshihiro Shimizu 890ddd
	while (!is.eos()) {
Toshihiro Shimizu 890ddd
		string paramName;
Toshihiro Shimizu 890ddd
		is.openChild(paramName);
Toshihiro Shimizu 890ddd
		TPersist *p = 0;
Toshihiro Shimizu 890ddd
		is >> p;
Toshihiro Shimizu 890ddd
		TParam *param = dynamic_cast<tparam *="">(p);</tparam>
Toshihiro Shimizu 890ddd
		assert(param);
Toshihiro Shimizu 890ddd
		addParam(param, paramName);
Toshihiro Shimizu 890ddd
		is.closeChild();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	is.closeChild();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TParamSet::saveData(TOStream &os)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	os.openChild(getName());
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator it = m_imp->m_params.begin();</pair<tparam>
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator end = m_imp->m_params.end();</pair<tparam>
Toshihiro Shimizu 890ddd
	while (it != end) {
Toshihiro Shimizu 890ddd
		os.openChild(it->second);
Toshihiro Shimizu 890ddd
		//it->first->saveData(os);
Toshihiro Shimizu 890ddd
		os << it->first;
Toshihiro Shimizu 890ddd
		os.closeChild();
Toshihiro Shimizu 890ddd
		++it;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	os.closeChild();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
string TParamSet::getValueAlias(double frame, int precision)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	string alias = "(";
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator end = m_imp->m_params.begin();</pair<tparam>
Toshihiro Shimizu 890ddd
	std::advance(end, m_imp->m_params.size() - 1);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::vector<pair<tparam *,="" string="">>::iterator it = m_imp->m_params.begin();</pair<tparam>
Toshihiro Shimizu 890ddd
	for (; it != end; ++it)
Toshihiro Shimizu 890ddd
		alias += it->first->getValueAlias(frame, precision) + ",";
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	alias += it->first->getValueAlias(frame, precision);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	alias += ")";
Toshihiro Shimizu 890ddd
	return alias;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TPersistDeclarationT<tparamset> TParamSet::m_declaration("TParamSet");</tparamset>