Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tsystem.h"
Toshihiro Shimizu 890ddd
#include "tstream.h"
Toshihiro Shimizu 890ddd
#include "tfilepath_io.h"
Toshihiro Shimizu 890ddd
#include "tfunctorinvoker.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzBase incudes
Toshihiro Shimizu 890ddd
#include "tunit.h"
Toshihiro Shimizu 890ddd
#include "tparamcontainer.h"
Toshihiro Shimizu 890ddd
#include "tparamset.h"
Toshihiro Shimizu 890ddd
#include "tmacrofx.h"
Toshihiro Shimizu 890ddd
#include "tparamchange.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzExt includes
Toshihiro Shimizu 890ddd
#include "ext/plasticskeleton.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzLib includes
Toshihiro Shimizu 890ddd
#include "toonz/tstageobjecttree.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheet.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheethandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/fxdag.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshzeraryfxcolumn.h"
Toshihiro Shimizu 890ddd
#include "toonz/tcolumnfx.h"
Toshihiro Shimizu 890ddd
#include "toonz/tfxhandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tobjecthandle.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzQt includes
Toshihiro Shimizu 890ddd
#include "toonzqt/functionviewer.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/dvdialog.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/gutil.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/plasticvertexselection.h"
Toshihiro Shimizu 890ddd
#include "tw/stringtable.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qmenu></qmenu>
Toshihiro Shimizu 890ddd
#include <qaction></qaction>
Toshihiro Shimizu 890ddd
#include <qfiledialog></qfiledialog>
Toshihiro Shimizu 890ddd
#include <qmouseevent></qmouseevent>
Toshihiro Shimizu 890ddd
#include <qmetaobject></qmetaobject>
Toshihiro Shimizu 890ddd
#include <qcolor></qcolor>
Toshihiro Shimizu 890ddd
#include <qapplication> // for drag&drop</qapplication>
Toshihiro Shimizu 890ddd
#include <qdrag></qdrag>
Toshihiro Shimizu 890ddd
#include <qmimedata></qmimedata>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonzqt/functiontreeviewer.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*************************************************************************************
Toshihiro Shimizu 890ddd
//    ChannelGroup specialization  definition
Toshihiro Shimizu 890ddd
//*************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class ParamChannelGroup : public FunctionTreeModel::ParamWrapper, public FunctionTreeModel::ChannelGroup
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 3bfa54
	ParamChannelGroup(TParam *param, const std::wstring &fxId, std::string ¶mName);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void refresh();
Toshihiro Shimizu 890ddd
	void *getInternalPointer() const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class StageObjectChannelGroup : public FunctionTreeModel::ChannelGroup
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TStageObject *m_stageObject;					 //!< (not owned) Referenced stage object
Toshihiro Shimizu 890ddd
	FunctionTreeModel::ChannelGroup *m_plasticGroup; //!< (not owned) Eventual plastic channels group
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	StageObjectChannelGroup(TStageObject *pegbar);
Toshihiro Shimizu 890ddd
	~StageObjectChannelGroup();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QString getShortName() const;
Toshihiro Shimizu 890ddd
	QString getLongName() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QString getIdName() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void *getInternalPointer() const { return static_cast<void *="">(m_stageObject); }</void>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TStageObject *getStageObject() const { return m_stageObject; }
Toshihiro Shimizu 890ddd
	QVariant data(int role) const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class SkVDChannelGroup : public FunctionTreeModel::ChannelGroup
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	StageObjectChannelGroup *m_stageObjectGroup; //!< Parent stage object group
Toshihiro Shimizu 890ddd
	const QString *m_vxName;					 //!< The associated vertex name
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	SkVDChannelGroup(const QString *vxName, StageObjectChannelGroup *stageGroup)
Toshihiro Shimizu 890ddd
		: ChannelGroup(*vxName), m_stageObjectGroup(stageGroup), m_vxName(vxName) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QString getShortName() const { return m_stageObjectGroup->getShortName(); }
Toshihiro Shimizu 890ddd
	QString getLongName() const { return *m_vxName; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void *getInternalPointer() const { return (void *)m_vxName; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static inline bool compareStr(const TreeModel::Item *item, const QString &str)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		const QString &thisStr = static_cast<const *="" skvdchannelgroup="">(item)->getLongName();</const>
Toshihiro Shimizu 890ddd
		return (QString::localeAwareCompare(thisStr, str) < 0);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QVariant data(int role) const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
} // namespace
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// ChannelGroup
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeModel::ChannelGroup::ChannelGroup(const QString &name)
Toshihiro Shimizu 890ddd
	: m_name(name), m_showFilter(ShowAllChannels)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeModel::ChannelGroup::~ChannelGroup()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool FunctionTreeModel::ChannelGroup::isActive() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	// Analyze children. If one is active, this is active too.
Toshihiro Shimizu 890ddd
	int c, childCount = getChildCount();
Toshihiro Shimizu 890ddd
	for (c = 0; c != childCount; ++c)
Toshihiro Shimizu 890ddd
		if (static_cast<item *="">(getChild(c))->isActive())</item>
Toshihiro Shimizu 890ddd
			return true;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	return false;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool FunctionTreeModel::ChannelGroup::isAnimated() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	// Same for the animated feature, this is animate if any of its children is.
Toshihiro Shimizu 890ddd
	int c, childCount = getChildCount();
Toshihiro Shimizu 890ddd
	for (c = 0; c != childCount; ++c)
Toshihiro Shimizu 890ddd
		if (static_cast<item *="">(getChild(c))->isAnimated())</item>
Toshihiro Shimizu 890ddd
			return true;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	return false;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QVariant FunctionTreeModel::ChannelGroup::data(int role) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (role == Qt::DisplayRole)
Toshihiro Shimizu 890ddd
		return getLongName();
Toshihiro Shimizu 890ddd
	else if (role == Qt::DecorationRole) {
Toshihiro Shimizu 890ddd
		bool animated = isAnimated();
Toshihiro Shimizu 890ddd
		bool active = isActive();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		if (active) {
Toshihiro Shimizu 890ddd
			static QIcon folderAnimOpen(":Resources/folderanim_open.png");
Toshihiro Shimizu 890ddd
			static QIcon folderAnimClose(":Resources/folderanim_close.png");
Toshihiro Shimizu 890ddd
			static QIcon folderOpen(":Resources/folder_open.png");
Toshihiro Shimizu 890ddd
			static QIcon folderClose(":Resources/folder_close.png");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			return animated ? isOpen() ? folderAnimOpen : folderAnimClose : isOpen() ? folderOpen : folderClose;
Toshihiro Shimizu 890ddd
		} else {
Toshihiro Shimizu 890ddd
			static QIcon folderAnimOpen(":Resources/folderanim_open_off.png");
Toshihiro Shimizu 890ddd
			static QIcon folderAnimClose(":Resources/folderanim_close_off.png");
Toshihiro Shimizu 890ddd
			static QIcon folderOpen(":Resources/folder_open_off.png");
Toshihiro Shimizu 890ddd
			static QIcon folderClose(":Resources/folder_close_off.png");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			return animated ? isOpen() ? folderAnimOpen : folderAnimClose : isOpen() ? folderOpen : folderClose;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} else
Toshihiro Shimizu 890ddd
		return Item::data(role);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! \todo     This is \a not recursive - I guess it should be...?
Toshihiro Shimizu 890ddd
void FunctionTreeModel::ChannelGroup::applyShowFilter()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int i, itemCount = getChildCount();
Toshihiro Shimizu 890ddd
	for (i = 0; i < itemCount; i++) {
Toshihiro Shimizu 890ddd
		FunctionTreeModel::Channel *channel = dynamic_cast<functiontreemodel::channel *="">(getChild(i));</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
		/*--- ChannelGroupの内部も同じフィルタで更新する ---*/
Toshihiro Shimizu 890ddd
		if (!channel) {
Toshihiro Shimizu 890ddd
			FunctionTreeModel::ChannelGroup *channelGroup =
Toshihiro Shimizu 890ddd
				dynamic_cast<functiontreemodel::channelgroup *="">(getChild(i));</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
			if (!channelGroup)
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			channelGroup->setShowFilter(m_showFilter);
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		bool showItem =
Toshihiro Shimizu 890ddd
			(m_showFilter == ShowAllChannels) || channel->getParam()->hasKeyframes();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		QModelIndex modelIndex = createIndex();
Toshihiro Shimizu 890ddd
		getModel()->setRowHidden(i, modelIndex, !showItem);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		if (!showItem)
Toshihiro Shimizu 890ddd
			channel->setIsActive(false);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::ChannelGroup::setShowFilter(ShowFilter showFilter)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_showFilter = showFilter;
Toshihiro Shimizu 890ddd
	applyShowFilter();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString FunctionTreeModel::ChannelGroup::getIdName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	QString tmpName = QString(m_name);
Toshihiro Shimizu 890ddd
	tmpName.remove(QChar(' '), Qt::CaseInsensitive);
Toshihiro Shimizu 890ddd
	tmpName = tmpName.toLower();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionTreeModel::ChannelGroup *parentGroup =
Toshihiro Shimizu 890ddd
		dynamic_cast<functiontreemodel::channelgroup *="">(getParent());</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
	if (parentGroup) {
Toshihiro Shimizu 890ddd
		return parentGroup->getIdName() + QString(".") + tmpName;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	return tmpName;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::ChannelGroup::setChildrenAllActive(bool active)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < getChildCount(); i++) {
Toshihiro Shimizu 890ddd
		//for Channel
Toshihiro Shimizu 890ddd
		FunctionTreeModel::Channel *channel = dynamic_cast<functiontreemodel::channel *="">(getChild(i));</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
		if (channel) {
Toshihiro Shimizu 890ddd
			channel->setIsActive(active);
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		//for ChannelGroup
Toshihiro Shimizu 890ddd
		else {
Toshihiro Shimizu 890ddd
			FunctionTreeModel::ChannelGroup *channelGroup = dynamic_cast<functiontreemodel::channelgroup *="">(getChild(i));</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
			if (channelGroup) {
Toshihiro Shimizu 890ddd
				channelGroup->setChildrenAllActive(active);
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// StageObjectChannelGroup
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
StageObjectChannelGroup::StageObjectChannelGroup(TStageObject *stageObject)
Toshihiro Shimizu 890ddd
	: m_stageObject(stageObject), m_plasticGroup()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_stageObject->addRef();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
StageObjectChannelGroup::~StageObjectChannelGroup()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_stageObject->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QVariant StageObjectChannelGroup::data(int role) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (role == Qt::DisplayRole) {
Shinya Kitaoka 3bfa54
		std::string name = m_stageObject->getName();
Shinya Kitaoka 3bfa54
		std::string id = m_stageObject->getId().toString();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		return (name == id) ? QString::fromStdString(name) : QString::fromStdString(id + " (" + name + ")");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	} else if (role == Qt::ForegroundRole) {
Toshihiro Shimizu 890ddd
		FunctionTreeModel *model = dynamic_cast<functiontreemodel *="">(getModel());</functiontreemodel>
Toshihiro Shimizu 890ddd
		if (!model)
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050000
Toshihiro Shimizu 890ddd
			return QColor(Qt::black);
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
			return Qt::black;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
		FunctionTreeView *view = dynamic_cast<functiontreeview *="">(model->getView());</functiontreeview>
Toshihiro Shimizu 890ddd
		if (!view || !model->getCurrentStageObject())
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050000
Toshihiro Shimizu 890ddd
			return QColor(Qt::black);
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
			return Qt::black;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
		TStageObjectId currentId = model->getCurrentStageObject()->getId();
Toshihiro Shimizu 890ddd
		return m_stageObject->getId() == currentId ? view->getCurrentTextColor() : view->getTextColor();
Toshihiro Shimizu 890ddd
	} else
Toshihiro Shimizu 890ddd
		return ChannelGroup::data(role);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString StageObjectChannelGroup::getShortName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return QString::fromStdString(m_stageObject->getName());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString StageObjectChannelGroup::getLongName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return QString::fromStdString(m_stageObject->getFullName());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString StageObjectChannelGroup::getIdName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return QString::fromStdString(m_stageObject->getId().toString()).toLower();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// FxChannelGroup
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FxChannelGroup::FxChannelGroup(TFx *fx)
Toshihiro Shimizu 890ddd
	: m_fx(fx)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (m_fx)
Toshihiro Shimizu 890ddd
		m_fx->addRef();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FxChannelGroup::~FxChannelGroup()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (m_fx)
Toshihiro Shimizu 890ddd
		m_fx->release();
Toshihiro Shimizu 890ddd
	m_fx = 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString FxChannelGroup::getShortName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return QString::fromStdWString(m_fx->getFxId());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString FxChannelGroup::getLongName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return QString::fromStdWString(m_fx->getFxId());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QVariant FxChannelGroup::data(int role) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (role == Qt::DecorationRole) {
Toshihiro Shimizu 890ddd
		bool isAnimated = false;
Toshihiro Shimizu 890ddd
		TParamContainer *paramContainer = m_fx->getParams();
Toshihiro Shimizu 890ddd
		int i;
Toshihiro Shimizu 890ddd
		for (i = 0; i < paramContainer->getParamCount(); i++) {
Toshihiro Shimizu 890ddd
			if (!paramContainer->getParam(i)->hasKeyframes())
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
			isAnimated = true;
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		bool isOneChildActive = false;
Toshihiro Shimizu 890ddd
		for (i = 0; i < getChildCount(); i++) {
Toshihiro Shimizu 890ddd
			FunctionTreeModel::Channel *channel = dynamic_cast<functiontreemodel::channel *="">(getChild(i));</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
			if (!channel || !channel->isActive())
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
			isOneChildActive = true;
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		if (isOneChildActive) {
Toshihiro Shimizu 890ddd
			static QIcon folderAnimOpen(":Resources/folderanim_open.png");
Toshihiro Shimizu 890ddd
			static QIcon folderAnimClose(":Resources/folderanim_close.png");
Toshihiro Shimizu 890ddd
			static QIcon folderOpen(":Resources/folder_open.png");
Toshihiro Shimizu 890ddd
			static QIcon folderClose(":Resources/folder_close.png");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			return isAnimated ? isOpen() ? folderAnimOpen : folderAnimClose : isOpen() ? folderOpen : folderClose;
Toshihiro Shimizu 890ddd
		} else {
Toshihiro Shimizu 890ddd
			static QIcon folderAnimOpen(":Resources/folderanim_open_off.png");
Toshihiro Shimizu 890ddd
			static QIcon folderAnimClose(":Resources/folderanim_close_off.png");
Toshihiro Shimizu 890ddd
			static QIcon folderOpen(":Resources/folder_open_off.png");
Toshihiro Shimizu 890ddd
			static QIcon folderClose(":Resources/folder_close_off.png");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			return isAnimated ? isOpen() ? folderAnimOpen : folderAnimClose : isOpen() ? folderOpen : folderClose;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} else if (role == Qt::DisplayRole) {
Shinya Kitaoka 3bfa54
		std::wstring name = m_fx->getName();
Shinya Kitaoka 3bfa54
		std::wstring id = m_fx->getFxId();
Toshihiro Shimizu 890ddd
		if (name == id)
Toshihiro Shimizu 890ddd
			return QString::fromStdWString(name);
Toshihiro Shimizu 890ddd
		else
Toshihiro Shimizu 890ddd
			return QString::fromStdWString(id + L" (" + name + L")");
Toshihiro Shimizu 890ddd
	} else if (role == Qt::ForegroundRole) {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		FunctionTreeModel *model = dynamic_cast<functiontreemodel *="">(getModel());</functiontreemodel>
Toshihiro Shimizu 890ddd
		if (!model)
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050000
Toshihiro Shimizu 890ddd
			return QColor(Qt::black);
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
			return Qt::black;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
		FunctionTreeView *view = dynamic_cast<functiontreeview *="">(model->getView());</functiontreeview>
Toshihiro Shimizu 890ddd
		if (!view)
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050000
Toshihiro Shimizu 890ddd
			return QColor(Qt::black);
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
			return Qt::black;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
		TFx *currentFx = model->getCurrentFx();
Toshihiro Shimizu 890ddd
		return m_fx == currentFx ? view->getCurrentTextColor() : view->getTextColor();
Toshihiro Shimizu 890ddd
	} else
Toshihiro Shimizu 890ddd
		return Item::data(role);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString FxChannelGroup::getIdName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return QString::fromStdWString(m_fx->getFxId()).toLower();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FxChannelGroup::refresh()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TMacroFx *macroFx = dynamic_cast<tmacrofx *="">(m_fx);</tmacrofx>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int i, childrenCount = getChildCount();
Toshihiro Shimizu 890ddd
	for (i = 0; i < childrenCount; ++i) {
Toshihiro Shimizu 890ddd
		FunctionTreeModel::ParamWrapper *wrap =
Toshihiro Shimizu 890ddd
			dynamic_cast<functiontreemodel::paramwrapper *="">(getChild(i));</functiontreemodel::paramwrapper>
Toshihiro Shimizu 890ddd
		assert(wrap);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TParam *param = 0;
Toshihiro Shimizu 890ddd
		{
Toshihiro Shimizu 890ddd
			TParamContainer *paramContainer = 0;
Toshihiro Shimizu 890ddd
			if (macroFx) {
Shinya Kitaoka 3bfa54
				const std::wstring &fxId = wrap->getFxId();
Toshihiro Shimizu 890ddd
				TFx *subFx = macroFx->getFxById(fxId);
Toshihiro Shimizu 890ddd
				if (!subFx)
Toshihiro Shimizu 890ddd
					continue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				paramContainer = subFx->getParams();
Toshihiro Shimizu 890ddd
			} else
Toshihiro Shimizu 890ddd
				paramContainer = m_fx->getParams();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			param = paramContainer->getParam(wrap->getParam()->getName());
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		assert(param);
Toshihiro Shimizu 890ddd
		wrap->setParam(param);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		ParamChannelGroup *paramGroup = dynamic_cast<paramchannelgroup *="">(wrap);</paramchannelgroup>
Toshihiro Shimizu 890ddd
		if (paramGroup)
Toshihiro Shimizu 890ddd
			paramGroup->refresh();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// ParamChannelGroup
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
ParamChannelGroup::ParamChannelGroup(TParam *param, const std::wstring &fxId, std::string ¶mName)
Toshihiro Shimizu 890ddd
	: ParamWrapper(param, fxId), ChannelGroup(param->hasUILabel() ? QString::fromStdString(param->getUILabel()) : QString::fromStdWString(TStringTable::translate(paramName)))
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void *ParamChannelGroup::getInternalPointer() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return this->m_param.getPointer();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void ParamChannelGroup::refresh()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TParamSet *paramSet = dynamic_cast<tparamset *="">(m_param.getPointer());</tparamset>
Toshihiro Shimizu 890ddd
	if (!paramSet)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int c, childrenCount = getChildCount();
Toshihiro Shimizu 890ddd
	for (c = 0; c < childrenCount; ++c) {
Toshihiro Shimizu 890ddd
		FunctionTreeModel::ParamWrapper *wrap =
Toshihiro Shimizu 890ddd
			dynamic_cast<functiontreemodel::paramwrapper *="">(getChild(c));</functiontreemodel::paramwrapper>
Toshihiro Shimizu 890ddd
		assert(wrap);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TParamP currentParam = wrap->getParam();
Toshihiro Shimizu 890ddd
		assert(currentParam);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		int p = paramSet->getParamIdx(wrap->getParam()->getName());
Toshihiro Shimizu 890ddd
		assert(p < paramSet->getParamCount());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TParamP param = paramSet->getParam(p);
Toshihiro Shimizu 890ddd
		wrap->setParam(param);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// SkVDChannelGroup
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QVariant SkVDChannelGroup::data(int role) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (role == Qt::ForegroundRole) {
Toshihiro Shimizu 890ddd
		// Check whether current selection is a PlasticVertex one - in case, paint it red
Toshihiro Shimizu 890ddd
		// if this group refers to current vertex
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		if (PlasticVertexSelection *vxSel = dynamic_cast<plasticvertexselection *="">(TSelection::getCurrent()))</plasticvertexselection>
Toshihiro Shimizu 890ddd
			if (TStageObject *obj = static_cast<functiontreemodel *="">(getModel())->getCurrentStageObject())</functiontreemodel>
Toshihiro Shimizu 890ddd
				if (obj == m_stageObjectGroup->m_stageObject)
Toshihiro Shimizu 890ddd
					if (const SkDP &sd = obj->getPlasticSkeletonDeformation()) {
Toshihiro Shimizu 890ddd
						int vIdx = *vxSel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
						if (vIdx >= 0 && sd->skeleton(vxSel->skeletonId())->vertex(vIdx).name() == getLongName())
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050000
Toshihiro Shimizu 890ddd
							return QColor(Qt::red);
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
							return Qt::red;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
					}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050000
Toshihiro Shimizu 890ddd
		return QColor(Qt::black);
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
		return Qt::black;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
	} else
Toshihiro Shimizu 890ddd
		return ChannelGroup::data(role);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// Channel
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeModel::Channel::Channel(FunctionTreeModel *model, TDoubleParam *param,
Shinya Kitaoka 3bfa54
									std::string paramNamePref, std::wstring fxId)
Toshihiro Shimizu 890ddd
	: ParamWrapper(param, fxId), m_model(model), m_group(0), m_isActive(false), m_paramNamePref(paramNamePref)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeModel::Channel::~Channel()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_model->onChannelDestroyed(this);
Toshihiro Shimizu 890ddd
	if (m_isActive)
Toshihiro Shimizu 890ddd
		getParam()->removeObserver(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void *FunctionTreeModel::Channel::getInternalPointer() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return this->m_param.getPointer();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool FunctionTreeModel::Channel::isAnimated() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_param->hasKeyframes();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QVariant FunctionTreeModel::Channel::data(int role) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (role == Qt::DecorationRole) {
Toshihiro Shimizu 890ddd
		static QIcon paramAnimOn(":Resources/paramanim_on.png");
Toshihiro Shimizu 890ddd
		static QIcon paramAnimOff(":Resources/paramanim_off.png");
Toshihiro Shimizu 890ddd
		static QIcon paramOn(":Resources/param_on.png");
Toshihiro Shimizu 890ddd
		static QIcon paramOff(":Resources/param_off.png");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		return m_param->hasKeyframes() ? isActive() ? paramAnimOn : paramAnimOff : isActive() ? paramOn : paramOff;
Toshihiro Shimizu 890ddd
	} else if (role == Qt::DisplayRole) {
Toshihiro Shimizu 890ddd
		if (m_param->hasUILabel()) {
Toshihiro Shimizu 890ddd
			return QString::fromStdString(m_param->getUILabel());
Toshihiro Shimizu 890ddd
		}
Shinya Kitaoka 3bfa54
		std::string name = m_paramNamePref + m_param->getName();
Shinya Kitaoka 3bfa54
		std::wstring translatedName = TStringTable::translate(name);
Toshihiro Shimizu 890ddd
		if (m_fxId.size() > 0)
Toshihiro Shimizu 890ddd
			return QString::fromStdWString(translatedName + L" (" + m_fxId + L")");
Toshihiro Shimizu 890ddd
		return QString::fromStdWString(translatedName);
Toshihiro Shimizu 890ddd
	} else if (role == Qt::ForegroundRole) {
Toshihiro Shimizu 890ddd
		//130221 iwasawa
Toshihiro Shimizu 890ddd
		FunctionTreeView *view = dynamic_cast<functiontreeview *="">(m_model->m_view);</functiontreeview>
Toshihiro Shimizu 890ddd
		if (!view)
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050000
Toshihiro Shimizu 890ddd
			return QColor(Qt::black);
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
			return Qt::black;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
		return (isCurrent()) ? view->getCurrentTextColor() : view->getTextColor();
Toshihiro Shimizu 890ddd
	} else
Toshihiro Shimizu 890ddd
		return TreeModel::Item::data(role);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString FunctionTreeModel::Channel::getShortName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (m_param->hasUILabel()) {
Toshihiro Shimizu 890ddd
		return QString::fromStdString(m_param->getUILabel());
Toshihiro Shimizu 890ddd
	}
Shinya Kitaoka 3bfa54
	std::string name = m_paramNamePref + m_param->getName();
Shinya Kitaoka 3bfa54
	std::wstring translatedName = TStringTable::translate(name);
Toshihiro Shimizu 890ddd
	return QString::fromStdWString(translatedName);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QString FunctionTreeModel::Channel::getLongName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	QString name = getShortName();
Toshihiro Shimizu 890ddd
	if (getChannelGroup())
Toshihiro Shimizu 890ddd
		name = getChannelGroup()->getLongName() + " " + name;
Toshihiro Shimizu 890ddd
	return name;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::Channel::setParam(const TParamP ¶m)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (param.getPointer() == m_param.getPointer())
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TParamP oldParam = m_param;
Toshihiro Shimizu 890ddd
	m_param = param;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (m_isActive) {
Toshihiro Shimizu 890ddd
		oldParam->removeObserver(this);
Toshihiro Shimizu 890ddd
		param->addObserver(this);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*! in order to show the expression name in the tooltip
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
QString FunctionTreeModel::Channel::getExprRefName() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	QString tmpName =
Toshihiro Shimizu 890ddd
		QString(QString::fromStdWString(
Toshihiro Shimizu 890ddd
			TStringTable::translate(m_paramNamePref + m_param->getName())));
Toshihiro Shimizu 890ddd
	/*--- stage objectパラメータの場合、TableにあわせてtmpNameを代表的なExpression名にする---*/
Toshihiro Shimizu 890ddd
	StageObjectChannelGroup *stageGroup =
Toshihiro Shimizu 890ddd
		dynamic_cast<stageobjectchannelgroup *="">(m_group);</stageobjectchannelgroup>
Toshihiro Shimizu 890ddd
	if (stageGroup) {
Toshihiro Shimizu 890ddd
		if (tmpName == "N/S")
Toshihiro Shimizu 890ddd
			tmpName = "ns";
Toshihiro Shimizu 890ddd
		else if (tmpName == "E/W")
Toshihiro Shimizu 890ddd
			tmpName = "ew";
Toshihiro Shimizu 890ddd
		else if (tmpName == "Z")
Toshihiro Shimizu 890ddd
			tmpName = "z";
Toshihiro Shimizu 890ddd
		else if (tmpName == "Rotation")
Toshihiro Shimizu 890ddd
			tmpName = "rot";
Toshihiro Shimizu 890ddd
		else if (tmpName == "Scale H")
Toshihiro Shimizu 890ddd
			tmpName = "sx";
Toshihiro Shimizu 890ddd
		else if (tmpName == "Scale V")
Toshihiro Shimizu 890ddd
			tmpName = "sy";
Toshihiro Shimizu 890ddd
		else if (tmpName == "Shear H")
Toshihiro Shimizu 890ddd
			tmpName = "shx";
Toshihiro Shimizu 890ddd
		else if (tmpName == "Shear V")
Toshihiro Shimizu 890ddd
			tmpName = "shy";
Toshihiro Shimizu 890ddd
		else if (tmpName == "posPath")
Toshihiro Shimizu 890ddd
			tmpName = "path";
Toshihiro Shimizu 890ddd
		else if (tmpName == "Scale")
Toshihiro Shimizu 890ddd
			tmpName = "sc";
Toshihiro Shimizu 890ddd
		else
Toshihiro Shimizu 890ddd
			tmpName = tmpName.toLower();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		return stageGroup->getIdName() + QString(".") + tmpName;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*--- Fxパラメータの場合 ---*/
Toshihiro Shimizu 890ddd
	tmpName.remove(QChar(' '), Qt::CaseInsensitive);
Toshihiro Shimizu 890ddd
	tmpName.remove(QChar('/'));
Toshihiro Shimizu 890ddd
	tmpName = tmpName.toLower();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionTreeModel::ChannelGroup *parentGroup =
Toshihiro Shimizu 890ddd
		dynamic_cast<functiontreemodel::channelgroup *="">(getParent());</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
	if (parentGroup) {
Toshihiro Shimizu 890ddd
		return QString("fx.") + parentGroup->getIdName() + QString(".") + tmpName;
Toshihiro Shimizu 890ddd
	} else
Toshihiro Shimizu 890ddd
		return "";
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::Channel::setIsActive(bool active)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (active == m_isActive)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_isActive = active;
Toshihiro Shimizu 890ddd
	m_model->refreshActiveChannels();
Toshihiro Shimizu 890ddd
	if (m_isActive) {
Toshihiro Shimizu 890ddd
		getParam()->addObserver(this);
Toshihiro Shimizu 890ddd
		/*--- これが最初にVisibleにしたChannelの場合 ---*/
Toshihiro Shimizu 890ddd
		if (!m_model->m_currentChannel) {
Toshihiro Shimizu 890ddd
			setIsCurrent(true);
Toshihiro Shimizu 890ddd
			m_model->emitCurveSelected(getParam());
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} else {
Toshihiro Shimizu 890ddd
		getParam()->removeObserver(this);
Toshihiro Shimizu 890ddd
		if (isCurrent()) {
Toshihiro Shimizu 890ddd
			setIsCurrent(false);
Toshihiro Shimizu 890ddd
			m_model->emitCurveSelected(0);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_model->emitDataChanged(this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool FunctionTreeModel::Channel::isCurrent() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_model->m_currentChannel == this;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::Channel::setIsCurrent(bool current)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Channel *oldCurrent = m_model->m_currentChannel;
Toshihiro Shimizu 890ddd
	if (current) {
Toshihiro Shimizu 890ddd
		// this channel must become the current
Toshihiro Shimizu 890ddd
		if (oldCurrent == this)
Toshihiro Shimizu 890ddd
			return; // already it is: nothing to do
Toshihiro Shimizu 890ddd
		m_model->m_currentChannel = this;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		//change the current fx if the FxChannelGroup is clicked
Toshihiro Shimizu 890ddd
		FxChannelGroup *fxGroup = dynamic_cast<fxchannelgroup *="">(m_group);</fxchannelgroup>
Toshihiro Shimizu 890ddd
		if (fxGroup && m_model->getFxHandle()) {
Toshihiro Shimizu 890ddd
			m_model->getFxHandle()->setFx(fxGroup->getFx());
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		//or, change the current object if the stageObjectChannelGroup is clicked
Toshihiro Shimizu 890ddd
		else {
Toshihiro Shimizu 890ddd
			StageObjectChannelGroup *stageObjectGroup = dynamic_cast<stageobjectchannelgroup *="">(m_group);</stageobjectchannelgroup>
Toshihiro Shimizu 890ddd
			if (stageObjectGroup && m_model->getObjectHandle()) {
Toshihiro Shimizu 890ddd
				m_model->getObjectHandle()->setObjectId(stageObjectGroup->getStageObject()->getId());
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		// the current channel must be active
Toshihiro Shimizu 890ddd
		if (!m_isActive) {
Toshihiro Shimizu 890ddd
			m_isActive = true;
Toshihiro Shimizu 890ddd
			m_model->refreshActiveChannels();
Toshihiro Shimizu 890ddd
			getParam()->addObserver(this);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		// refresh the old current (if !=0) and the new one
Toshihiro Shimizu 890ddd
		if (oldCurrent)
Toshihiro Shimizu 890ddd
			m_model->emitDataChanged(oldCurrent);
Toshihiro Shimizu 890ddd
		m_model->emitDataChanged(this);
Toshihiro Shimizu 890ddd
		m_model->emitCurveSelected(getParam());
Toshihiro Shimizu 890ddd
		//scroll the column to ensure visible the current channel
Toshihiro Shimizu 890ddd
		m_model->emitCurrentChannelChanged(this);
Toshihiro Shimizu 890ddd
	} else {
Toshihiro Shimizu 890ddd
		// this channel is not the current anymore
Toshihiro Shimizu 890ddd
		if (oldCurrent != this)
Toshihiro Shimizu 890ddd
			return; // it was not: nothing to do
Toshihiro Shimizu 890ddd
		m_model->m_currentChannel = 0;
Toshihiro Shimizu 890ddd
		// refresh the channel
Toshihiro Shimizu 890ddd
		m_model->emitDataChanged(this);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool FunctionTreeModel::Channel::isHidden() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return getChannelGroup()->getShowFilter() == ChannelGroup::ShowAnimatedChannels &&
Toshihiro Shimizu 890ddd
		   !getParam()->hasKeyframes();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::Channel::onChange(const TParamChange &ch)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_model->onChange(ch);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// FunctionTreeModel
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeModel::FunctionTreeModel(FunctionTreeView *parent)
Toshihiro Shimizu 890ddd
	: TreeModel(parent), m_currentChannel(0), m_stageObjects(0), m_fxs(0), m_currentStageObject(0), m_currentFx(0), m_paramsChanged(false)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeModel::~FunctionTreeModel()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	// I must delete items here (not in TreeModel::~TreeModel()).
Toshihiro Shimizu 890ddd
	// Channel::~Channel() refers to the model, which should be alive.
Toshihiro Shimizu 890ddd
	setRootItem(0);
Toshihiro Shimizu 890ddd
	if (m_currentFx)
Toshihiro Shimizu 890ddd
		m_currentFx->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::refreshData(TXsheet *xsh)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_activeChannels.clear();
Toshihiro Shimizu 890ddd
	Channel *currentChannel = m_currentChannel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	beginRefresh();
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		if (!getRootItem()) {
Toshihiro Shimizu 890ddd
			setRootItem(new ChannelGroup("Root"));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			if (xsh) {
Toshihiro Shimizu 890ddd
				getRootItem()->appendChild(m_stageObjects = new ChannelGroup("Stage"));
Toshihiro Shimizu 890ddd
				getRootItem()->appendChild(m_fxs = new ChannelGroup("FX"));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				assert(getRootItem()->getChildCount() == 2);
Toshihiro Shimizu 890ddd
				assert(getRootItem()->getChild(0) == m_stageObjects);
Toshihiro Shimizu 890ddd
				assert(getRootItem()->getChild(1) == m_fxs);
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		if (xsh) {
Toshihiro Shimizu 890ddd
			refreshStageObjects(xsh);
Toshihiro Shimizu 890ddd
			refreshFxs(xsh);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		refreshActiveChannels();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	endRefresh();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (m_currentChannel != currentChannel)
Toshihiro Shimizu 890ddd
		emit curveSelected(0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::refreshStageObjects(TXsheet *xsh)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	static const int channelIds[TStageObject::T_ChannelCount] = {
Toshihiro Shimizu 890ddd
		TStageObject::T_X,
Toshihiro Shimizu 890ddd
		TStageObject::T_Y,
Toshihiro Shimizu 890ddd
		TStageObject::T_Z,
Toshihiro Shimizu 890ddd
		TStageObject::T_SO,
Toshihiro Shimizu 890ddd
		TStageObject::T_Path,
Toshihiro Shimizu 890ddd
		TStageObject::T_Angle,
Toshihiro Shimizu 890ddd
		TStageObject::T_ScaleX,
Toshihiro Shimizu 890ddd
		TStageObject::T_ScaleY,
Toshihiro Shimizu 890ddd
		TStageObject::T_Scale,
Toshihiro Shimizu 890ddd
		TStageObject::T_ShearX,
Toshihiro Shimizu 890ddd
		TStageObject::T_ShearY}; // Explicitly ordered channels
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Retrieve all (not-empty) root stage objects, and add them in the tree model
Toshihiro Shimizu 890ddd
	QList<treemodel::item *=""> newItems;</treemodel::item>
Toshihiro Shimizu 890ddd
	TStageObjectTree *ptree = xsh->getStageObjectTree();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int i, iCount = ptree->getStageObjectCount();
Toshihiro Shimizu 890ddd
	for (i = 0; i < iCount; ++i) {
Toshihiro Shimizu 890ddd
		TStageObject *pegbar = ptree->getStageObject(i);
Toshihiro Shimizu 890ddd
		TStageObjectId id = pegbar->getId();
Toshihiro Shimizu 890ddd
		if (id.isColumn() && xsh->isColumnEmpty(id.getIndex()))
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		newItems.push_back(new StageObjectChannelGroup(pegbar));
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*--- newItemsの中で、これまでのChildrenに無いものだけ
Toshihiro Shimizu 890ddd
        m_stageObjectsの子に追加。既に有るものはnewChildrenから除外---*/
Toshihiro Shimizu 890ddd
	m_stageObjects->setChildren(newItems);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Add channels to the NEW stage entries (see the above call to setChildren())
Toshihiro Shimizu 890ddd
	iCount = newItems.size();
Toshihiro Shimizu 890ddd
	for (i = 0; i < iCount; ++i) {
Toshihiro Shimizu 890ddd
		StageObjectChannelGroup *pegbarItem =
Toshihiro Shimizu 890ddd
			dynamic_cast<stageobjectchannelgroup *="">(newItems[i]);</stageobjectchannelgroup>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TStageObject *stageObject = pegbarItem->getStageObject();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		// Add the standard stage object channels
Toshihiro Shimizu 890ddd
		int j, jCount = TStageObject::T_ChannelCount;
Toshihiro Shimizu 890ddd
		// making each channel of pegbar
Toshihiro Shimizu 890ddd
		for (j = 0; j < jCount; ++j) {
Toshihiro Shimizu 890ddd
			TDoubleParam *param = stageObject->getParam((TStageObject::Channel)channelIds[j]);
Toshihiro Shimizu 890ddd
			Channel *channel = new Channel(this, param);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			pegbarItem->appendChild(channel);
Toshihiro Shimizu 890ddd
			channel->setChannelGroup(pegbarItem);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		pegbarItem->applyShowFilter();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// As plastic deformations are stored in stage objects, refresh them if necessary
Toshihiro Shimizu 890ddd
	refreshPlasticDeformations();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::refreshFxs(TXsheet *xsh)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	std::vector<tfx *=""> fxs;</tfx>
Toshihiro Shimizu 890ddd
	xsh->getFxDag()->getFxs(fxs);
Toshihiro Shimizu 890ddd
	for (int i = 0; i < xsh->getColumnCount(); i++) {
Toshihiro Shimizu 890ddd
		TXshZeraryFxColumn *zc =
Toshihiro Shimizu 890ddd
			dynamic_cast<txshzeraryfxcolumn *="">(xsh->getColumn(i));</txshzeraryfxcolumn>
Toshihiro Shimizu 890ddd
		if (!zc)
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
		fxs.push_back(zc->getZeraryColumnFx()->getZeraryFx());
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//sort items by fxId
Toshihiro Shimizu 890ddd
	for (int j = 1; j < (int)fxs.size(); j++) {
Toshihiro Shimizu 890ddd
		int index = j;
Toshihiro Shimizu 890ddd
		while (index > 0 && QString::localeAwareCompare(QString::fromStdWString(fxs[index - 1]->getFxId()), QString::fromStdWString(fxs[index]->getFxId())) > 0) {
Toshihiro Shimizu 890ddd
			std::swap(fxs[index - 1], fxs[index]);
Toshihiro Shimizu 890ddd
			index = index - 1;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QList<treemodel::item *=""> newItems;</treemodel::item>
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
	for (i = 0; i < (int)fxs.size(); i++) {
Toshihiro Shimizu 890ddd
		TFx *fx = fxs[i];
Toshihiro Shimizu 890ddd
		if (!fx)
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
		TParamContainer *params = fx->getParams();
Toshihiro Shimizu 890ddd
		bool hasChannel = false;
Toshihiro Shimizu 890ddd
		int j;
Toshihiro Shimizu 890ddd
		for (j = 0; j < params->getParamCount(); j++)
Toshihiro Shimizu 890ddd
			if (0 != dynamic_cast<tdoubleparam *="">(params->getParam(j)) ||</tdoubleparam>
Toshihiro Shimizu 890ddd
				0 != dynamic_cast<tpointparam *="">(params->getParam(j)) ||</tpointparam>
Toshihiro Shimizu 890ddd
				0 != dynamic_cast<trangeparam *="">(params->getParam(j)) ||</trangeparam>
Toshihiro Shimizu 890ddd
				0 != dynamic_cast<tpixelparam *="">(params->getParam(j))) {</tpixelparam>
Toshihiro Shimizu 890ddd
				hasChannel = true;
Toshihiro Shimizu 890ddd
				break;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
		if (hasChannel)
Toshihiro Shimizu 890ddd
			newItems.push_back(new FxChannelGroup(fxs[i]));
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	m_fxs->setChildren(newItems);
Toshihiro Shimizu 890ddd
	// Add channels to new fxs (only for those actually added: see setChildren())
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	for (i = 0; i < (int)newItems.size(); i++) {
Toshihiro Shimizu 890ddd
		TreeModel::Item *item = newItems[i];
Toshihiro Shimizu 890ddd
		FxChannelGroup *fxItem = dynamic_cast<fxchannelgroup *="">(item);</fxchannelgroup>
Toshihiro Shimizu 890ddd
		assert(fxItem);
Toshihiro Shimizu 890ddd
		if (!fxItem)
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
		TFx *fx = fxItem->getFx();
Toshihiro Shimizu 890ddd
		assert(fx);
Toshihiro Shimizu 890ddd
		if (!fx)
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
		TMacroFx *macroFx = dynamic_cast<tmacrofx *="">(fx);</tmacrofx>
Toshihiro Shimizu 890ddd
		if (macroFx) {
Shinya Kitaoka 3bfa54
			const std::vector<tfxp> ¯oFxs = macroFx->getFxs();</tfxp>
Toshihiro Shimizu 890ddd
			int j;
Toshihiro Shimizu 890ddd
			for (j = 0; j < (int)macroFxs.size(); j++) {
Toshihiro Shimizu 890ddd
				TParamContainer *params = macroFxs[j]->getParams();
Toshihiro Shimizu 890ddd
				addChannels(macroFxs[j].getPointer(), fxItem, params);
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
		} else {
Toshihiro Shimizu 890ddd
			TParamContainer *params = fx->getParams();
Toshihiro Shimizu 890ddd
			addChannels(fx, fxItem, params);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		fxItem->applyShowFilter();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::refreshPlasticDeformations()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	// Refresh ALL stage object items (including OLD ones)
Toshihiro Shimizu 890ddd
	int i, iCount = m_stageObjects->getChildCount();
Toshihiro Shimizu 890ddd
	for (i = 0; i < iCount; ++i) {
Toshihiro Shimizu 890ddd
		// Add the eventual Plastic channels group
Toshihiro Shimizu 890ddd
		StageObjectChannelGroup *stageItem =
Toshihiro Shimizu 890ddd
			static_cast<stageobjectchannelgroup *="">(m_stageObjects->getChild(i));</stageobjectchannelgroup>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TStageObject *stageObject = stageItem->getStageObject();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		const PlasticSkeletonDeformationP &sd = stageObject->getPlasticSkeletonDeformation();
Toshihiro Shimizu 890ddd
		FunctionTreeModel::ChannelGroup *&plasticGroup = stageItem->m_plasticGroup;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		if (sd || plasticGroup) {
Toshihiro Shimizu 890ddd
			if (!plasticGroup) {
Toshihiro Shimizu 890ddd
				// Add a group
Toshihiro Shimizu 890ddd
				plasticGroup = new ChannelGroup("Plastic Skeleton");
Toshihiro Shimizu 890ddd
				stageItem->appendChild(plasticGroup);
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			// Prepare each vertex deformation
Toshihiro Shimizu 890ddd
			QList<treemodel::item *=""> plasticItems;</treemodel::item>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			if (sd) {
Toshihiro Shimizu 890ddd
				SkD::vd_iterator vdt, vdEnd;
Toshihiro Shimizu 890ddd
				sd->vertexDeformations(vdt, vdEnd);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				for (; vdt != vdEnd; ++vdt) {
Toshihiro Shimizu 890ddd
					const QString *str = (*vdt).first;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
					QList<treemodel::item *="">::iterator it = std::lower_bound(</treemodel::item>
Toshihiro Shimizu 890ddd
						plasticItems.begin(), plasticItems.end(),
Toshihiro Shimizu 890ddd
						*str, SkVDChannelGroup::compareStr);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
					plasticItems.insert(it, new SkVDChannelGroup(str, stageItem));
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				// Add the channel corresponding to the skeleton id
Toshihiro Shimizu 890ddd
				{
Toshihiro Shimizu 890ddd
					Channel *skelIdsChannel = new Channel(this, sd->skeletonIdsParam().getPointer());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
					plasticItems.insert(plasticItems.begin(), skelIdsChannel);
Toshihiro Shimizu 890ddd
					skelIdsChannel->setChannelGroup(plasticGroup);
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			if (plasticItems.empty())
Toshihiro Shimizu 890ddd
				plasticGroup->setIsOpen(false);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			// Add the vertex deformations group (this needs to be done BEFORE adding the actual
Toshihiro Shimizu 890ddd
			// channels, seemingly due to a limitation in the TreeModel implementation)
Toshihiro Shimizu 890ddd
			plasticGroup->setChildren(plasticItems);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			int pi, piCount = plasticItems.size(); // NOTE: plasticItems now stores only PART
Toshihiro Shimizu 890ddd
			for (pi = 0; pi != piCount; ++pi)	  // of the specified items - those considered
Toshihiro Shimizu 890ddd
			{									   // 'new' by internal pointer comparison...
Toshihiro Shimizu 890ddd
				SkVDChannelGroup *vxGroup = dynamic_cast<skvdchannelgroup *="">(plasticItems[pi]);</skvdchannelgroup>
Toshihiro Shimizu 890ddd
				if (!vxGroup)
Toshihiro Shimizu 890ddd
					continue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				SkVD *skvd = sd->vertexDeformation(vxGroup->ChannelGroup::getShortName());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				for (int k = 0; k < SkVD::PARAMS_COUNT; ++k) {
Toshihiro Shimizu 890ddd
					// Add channel in the vertex deformation
Toshihiro Shimizu 890ddd
					Channel *channel = new Channel(this, skvd->m_params[k].getPointer());
Toshihiro Shimizu 890ddd
					channel->setChannelGroup(vxGroup);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
					vxGroup->appendChild(channel);
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				vxGroup->applyShowFilter();
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			plasticGroup->applyShowFilter();
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::addParameter(
Toshihiro Shimizu 890ddd
	ChannelGroup *group,
Toshihiro Shimizu 890ddd
	const std::string &prefixString,
Toshihiro Shimizu 890ddd
	const std::wstring &fxId,
Toshihiro Shimizu 890ddd
	TParam *param)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (TDoubleParam *dp = dynamic_cast<tdoubleparam *="">(param)) {</tdoubleparam>
Toshihiro Shimizu 890ddd
		Channel *channel = new Channel(this, dp, prefixString, fxId);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		group->appendChild(channel);
Toshihiro Shimizu 890ddd
		channel->setChannelGroup(group);
Toshihiro Shimizu 890ddd
	} else if (dynamic_cast<tpointparam *="">(param) ||</tpointparam>
Toshihiro Shimizu 890ddd
			   dynamic_cast<trangeparam *="">(param) ||</trangeparam>
Toshihiro Shimizu 890ddd
			   dynamic_cast<tpixelparam *="">(param)) {</tpixelparam>
Toshihiro Shimizu 890ddd
		TParamSet *paramSet = dynamic_cast<tparamset *="">(param);</tparamset>
Toshihiro Shimizu 890ddd
		assert(paramSet);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		std::string paramName = prefixString + param->getName();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		ChannelGroup *paramChannel = new ParamChannelGroup(param, fxId, paramName);
Toshihiro Shimizu 890ddd
		group->appendChild(paramChannel);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TPixelParam *pixParam = dynamic_cast<tpixelparam *="">(param);</tpixelparam>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		int p, paramCount = paramSet->getParamCount();
Toshihiro Shimizu 890ddd
		for (p = 0; p != paramCount; ++p) {
Toshihiro Shimizu 890ddd
			TDoubleParam *dp = dynamic_cast<tdoubleparam *="">(paramSet->getParam(p).getPointer());</tdoubleparam>
Toshihiro Shimizu 890ddd
			if (!dp || (pixParam && !pixParam->isMatteEnabled() && p == paramCount - 1))
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			Channel *channel = new Channel(this, dp, "", fxId);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			paramChannel->appendChild(channel);
Toshihiro Shimizu 890ddd
			channel->setChannelGroup(group);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::addChannels(TFx *fx, ChannelGroup *groupItem, TParamContainer *params)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FxChannelGroup *fxItem = static_cast<fxchannelgroup *="">(groupItem);</fxchannelgroup>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
	std::wstring fxId = L"";
Toshihiro Shimizu 890ddd
	TMacroFx *macro = dynamic_cast<tmacrofx *="">(fxItem->getFx());</tmacrofx>
Toshihiro Shimizu 890ddd
	if (macro)
Toshihiro Shimizu 890ddd
		fxId = fx->getFxId();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
	const std::string ¶mNamePref = fx->getFxType() + ".";
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int p, pCount = params->getParamCount();
Toshihiro Shimizu 890ddd
	for (p = 0; p != pCount; ++p)
Toshihiro Shimizu 890ddd
		addParameter(fxItem, paramNamePref, fxId, params->getParam(p));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::addActiveChannels(TreeModel::Item *item)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert(item);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (Channel *channel = dynamic_cast<channel *="">(item)) {</channel>
Toshihiro Shimizu 890ddd
		if (channel->isActive())
Toshihiro Shimizu 890ddd
			m_activeChannels.push_back(channel);
Toshihiro Shimizu 890ddd
	} else
Toshihiro Shimizu 890ddd
		for (int i = 0; i < item->getChildCount(); i++)
Toshihiro Shimizu 890ddd
			addActiveChannels(item->getChild(i));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::refreshActiveChannels()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_activeChannels.clear();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (m_stageObjects)
Toshihiro Shimizu 890ddd
		addActiveChannels(m_stageObjects);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (m_fxs)
Toshihiro Shimizu 890ddd
		addActiveChannels(m_fxs);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::onChannelDestroyed(Channel *channel)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (channel == m_currentChannel)
Toshihiro Shimizu 890ddd
		m_currentChannel = 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeModel::Channel *FunctionTreeModel::getActiveChannel(int index) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (index < 0 || index >= (int)m_activeChannels.size())
Toshihiro Shimizu 890ddd
		return 0;
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		return m_activeChannels[index];
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int FunctionTreeModel::getColumnIndexByCurve(TDoubleParam *param) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	for (int i = 0; i < (int)m_activeChannels.size(); i++) {
Toshihiro Shimizu 890ddd
		if (m_activeChannels[i]->getParam() == param)
Toshihiro Shimizu 890ddd
			return i;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	return -1;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeModel::ChannelGroup *FunctionTreeModel::getStageObjectChannel(int index) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (index < 0 || index >= (int)m_stageObjects->getChildCount())
Toshihiro Shimizu 890ddd
		return 0;
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		return dynamic_cast<functiontreemodel::channelgroup *="">(m_stageObjects->getChild(index));</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeModel::ChannelGroup *FunctionTreeModel::getFxChannel(int index) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (index < 0 || index >= (int)m_fxs->getChildCount())
Toshihiro Shimizu 890ddd
		return 0;
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		return dynamic_cast<functiontreemodel::channelgroup *="">(m_fxs->getChild(index));</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::onChange(const TParamChange &tpc)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (!m_paramsChanged) {
Toshihiro Shimizu 890ddd
		m_paramsChanged = true;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		struct Func : public TFunctorInvoker::BaseFunctor {
Toshihiro Shimizu 890ddd
			FunctionTreeModel *m_obj;
Toshihiro Shimizu 890ddd
			const TParamChange *m_tpc;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			Func(FunctionTreeModel *obj, const TParamChange *tpc) : m_obj(obj), m_tpc(tpc) {}
Toshihiro Shimizu 890ddd
			void operator()() { m_obj->onParamChange(m_tpc->m_dragging); }
Toshihiro Shimizu 890ddd
		};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		QMetaObject::invokeMethod(TFunctorInvoker::instance(), "invoke", Qt::QueuedConnection,
Toshihiro Shimizu 890ddd
								  Q_ARG(void *, new Func(this, &tpc)));
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::onParamChange(bool isDragging)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_paramsChanged = false;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	emit curveChanged(isDragging);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::resetAll()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050000
Toshihiro Shimizu 890ddd
	beginResetModel();
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
	m_activeChannels.clear();
Toshihiro Shimizu 890ddd
	setRootItem(0);
Toshihiro Shimizu 890ddd
	m_stageObjects = 0;
Toshihiro Shimizu 890ddd
	m_fxs = 0;
Toshihiro Shimizu 890ddd
#if QT_VERSION < 0x050000
Toshihiro Shimizu 890ddd
	reset();
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	beginRefresh();
Toshihiro Shimizu 890ddd
	refreshActiveChannels();
Toshihiro Shimizu 890ddd
	endRefresh();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_currentChannel = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050000
Toshihiro Shimizu 890ddd
	endResetModel();
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::setCurrentFx(TFx *fx)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TZeraryColumnFx *zcfx = dynamic_cast<tzerarycolumnfx *="">(fx);</tzerarycolumnfx>
Toshihiro Shimizu 890ddd
	if (zcfx)
Toshihiro Shimizu 890ddd
		fx = zcfx->getZeraryFx();
Toshihiro Shimizu 890ddd
	if (fx != m_currentFx) {
Toshihiro Shimizu 890ddd
		if (fx)
Toshihiro Shimizu 890ddd
			fx->addRef();
Toshihiro Shimizu 890ddd
		if (m_currentFx)
Toshihiro Shimizu 890ddd
			m_currentFx->release();
Toshihiro Shimizu 890ddd
		m_currentFx = fx;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::applyShowFilters()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	// WARNING: This is implemented BAD - notice that the get*() functions below
Toshihiro Shimizu 890ddd
	//          DO NOT ACTUALLY RETURN CHANNELS, but rather the child ChannelGROUPS!
Toshihiro Shimizu 890ddd
	//
Toshihiro Shimizu 890ddd
	//          This means that these show filters are presumably applied only to
Toshihiro Shimizu 890ddd
	//          the FIRST LEVEL OF PARAMETERS...!
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (m_stageObjects) {
Toshihiro Shimizu 890ddd
		int so, soCount = m_stageObjects->getChildCount();
Toshihiro Shimizu 890ddd
		for (so = 0; so != soCount; ++so)
Toshihiro Shimizu 890ddd
			getStageObjectChannel(so)->applyShowFilter();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (m_fxs) {
Toshihiro Shimizu 890ddd
		int fx, fxCount = m_fxs->getChildCount();
Toshihiro Shimizu 890ddd
		for (fx = 0; fx != fxCount; ++fx)
Toshihiro Shimizu 890ddd
			getFxChannel(fx)->applyShowFilter();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeModel::addParameter(
Toshihiro Shimizu 890ddd
	TParam *parameter, const TFilePath &folder)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	struct locals {
Toshihiro Shimizu 890ddd
		static void locateExistingRoot(ChannelGroup *&root, TFilePath &fp)
Toshihiro Shimizu 890ddd
		{
Toshihiro Shimizu 890ddd
			std::wstring firstName;
Toshihiro Shimizu 890ddd
			TFilePath tempFp;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			while (!fp.isEmpty()) {
Toshihiro Shimizu 890ddd
				// Get the path's first name
Toshihiro Shimizu 890ddd
				fp.split(firstName, tempFp);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				// Search a matching channel group in root's children
Toshihiro Shimizu 890ddd
				int c, cCount = root->getChildCount();
Toshihiro Shimizu 890ddd
				for (c = 0; c != cCount; ++c) {
Toshihiro Shimizu 890ddd
					if (ChannelGroup *group = dynamic_cast<channelgroup *="">(root->getChild(c))) {</channelgroup>
Toshihiro Shimizu 890ddd
						if (group->getShortName().toStdWString() == firstName) {
Toshihiro Shimizu 890ddd
							root = group, fp = tempFp;
Toshihiro Shimizu 890ddd
							break;
Toshihiro Shimizu 890ddd
						}
Toshihiro Shimizu 890ddd
					}
Toshihiro Shimizu 890ddd
				}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				if (c == cCount)
Toshihiro Shimizu 890ddd
					break;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		static void addFolders(ChannelGroup *&group, TFilePath &fp)
Toshihiro Shimizu 890ddd
		{
Toshihiro Shimizu 890ddd
			std::wstring firstName;
Toshihiro Shimizu 890ddd
			TFilePath tempFp;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			while (!fp.isEmpty()) {
Toshihiro Shimizu 890ddd
				fp.split(firstName, tempFp);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				ChannelGroup *newGroup = new ChannelGroup(QString::fromStdWString(firstName));
Toshihiro Shimizu 890ddd
				group->appendChild(newGroup);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				group = newGroup, fp = tempFp;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}; // locals
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Search for the furthest existing channel group chain leading to our folder
Toshihiro Shimizu 890ddd
	ChannelGroup *group = static_cast<channelgroup *="">(getRootItem());</channelgroup>
Toshihiro Shimizu 890ddd
	assert(group);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TFilePath path = folder;
Toshihiro Shimizu 890ddd
	locals::locateExistingRoot(group, path);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// If the chain interrupts prematurely, create new groups up to the required folder
Toshihiro Shimizu 890ddd
	if (!path.isEmpty())
Toshihiro Shimizu 890ddd
		locals::addFolders(group, path);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	assert(path.isEmpty());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Add the parameter to the last group
Toshihiro Shimizu 890ddd
	addParameter(group, "", L"", parameter);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// FunctionTreeView
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
FunctionTreeView::FunctionTreeView(FunctionViewer *parent)
Toshihiro Shimizu 890ddd
	: TreeView(parent), m_scenePath(), m_clickedItem(0), m_draggingChannel(0)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert(parent);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	setModel(new FunctionTreeModel(this));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	setObjectName("FunctionEditorTree");
Toshihiro Shimizu 890ddd
	setSelectionMode(QAbstractItemView::NoSelection);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	connect(
Toshihiro Shimizu 890ddd
		this, SIGNAL(pressed(const QModelIndex &)),
Toshihiro Shimizu 890ddd
		this, SLOT(onActivated(const QModelIndex &)));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	setFocusPolicy(Qt::NoFocus);
Toshihiro Shimizu 890ddd
	setIndentation(14);
Toshihiro Shimizu 890ddd
	setAlternatingRowColors(true);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeView::onActivated(const QModelIndex &index)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	enum {
Toshihiro Shimizu 890ddd
		NO_CHANNELS = 0x0,
Toshihiro Shimizu 890ddd
		ACTIVE_CHANNELS = 0x1,
Toshihiro Shimizu 890ddd
		INACTIVE_CHANNELS = 0x2,
Toshihiro Shimizu 890ddd
		HAS_CHANNELS = ACTIVE_CHANNELS | INACTIVE_CHANNELS
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (!index.isValid())
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionTreeModel *ftModel = (FunctionTreeModel *)model();
Toshihiro Shimizu 890ddd
	if (!ftModel)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::vector<functiontreemodel::channel *=""> childChannels;</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
	std::vector<functiontreemodel::channelgroup *=""> channelGroups;</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Scan for already active children - to decide whether to activate or deactivate them
Toshihiro Shimizu 890ddd
	int activeFlag = NO_CHANNELS;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TreeModel::Item *item = static_cast<treemodel::item *="">(index.internalPointer());</treemodel::item>
Toshihiro Shimizu 890ddd
	if (item) {
Toshihiro Shimizu 890ddd
		int c, cCount = item->getChildCount();
Toshihiro Shimizu 890ddd
		for (c = 0; c != cCount; ++c) {
Toshihiro Shimizu 890ddd
			FunctionTreeModel::Channel *channel =
Toshihiro Shimizu 890ddd
				dynamic_cast<functiontreemodel::channel *="">(item->getChild(c));</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			if (!channel) {
Toshihiro Shimizu 890ddd
				FunctionTreeModel::ChannelGroup *channelGroup =
Toshihiro Shimizu 890ddd
					dynamic_cast<functiontreemodel::channelgroup *="">(item->getChild(c));</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
				if (!channelGroup)
Toshihiro Shimizu 890ddd
					continue;
Toshihiro Shimizu 890ddd
				channelGroups.push_back(channelGroup);
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
			if (channel->isHidden())
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			childChannels.push_back(channel);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			activeFlag |= (channel->isActive() ? ACTIVE_CHANNELS : INACTIVE_CHANNELS);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Open the item (ie show children) if it was closed AND not all its children were active
Toshihiro Shimizu 890ddd
	bool someInactiveChannels = (activeFlag != ACTIVE_CHANNELS);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (someInactiveChannels && !isExpanded(index)) {
Toshihiro Shimizu 890ddd
		setExpanded(index, true);
Toshihiro Shimizu 890ddd
		ftModel->onExpanded(index);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (item) {
Toshihiro Shimizu 890ddd
		if (!childChannels.empty()) {
Toshihiro Shimizu 890ddd
			// Activate child channels if there is some inactive channel - deactivate otherwise
Toshihiro Shimizu 890ddd
			int c, cCount = childChannels.size();
Toshihiro Shimizu 890ddd
			for (c = 0; c != cCount; ++c)
Toshihiro Shimizu 890ddd
				childChannels[c]->setIsActive(someInactiveChannels);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			for (int i = 0; i < (int)channelGroups.size(); i++)
Toshihiro Shimizu 890ddd
				channelGroups[i]->setChildrenAllActive(someInactiveChannels);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			update();
Toshihiro Shimizu 890ddd
		} else {
Toshihiro Shimizu 890ddd
			// There was no child channel. Try to activate children groups.
Toshihiro Shimizu 890ddd
			int c, cCount = item->getChildCount();
Toshihiro Shimizu 890ddd
			for (c = 0; c != cCount; ++c)
Toshihiro Shimizu 890ddd
				onActivated(item->getChild(c)->createIndex());
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeView::onClick(TreeModel::Item *item, const QPoint &itemPos, QMouseEvent *e)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_draggingChannel = 0;
Toshihiro Shimizu 890ddd
	FunctionTreeModel::Channel *channel = dynamic_cast<functiontreemodel::channel *="">(item);</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
	FxChannelGroup *fxChannelGroup = dynamic_cast<fxchannelgroup *="">(item);</fxchannelgroup>
Toshihiro Shimizu 890ddd
	StageObjectChannelGroup *stageObjectChannelGroup = dynamic_cast<stageobjectchannelgroup *="">(item);</stageobjectchannelgroup>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_clickedItem = channel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (channel) {
Toshihiro Shimizu 890ddd
		fxChannelGroup = dynamic_cast<fxchannelgroup *="">(channel->getParent());</fxchannelgroup>
Toshihiro Shimizu 890ddd
		stageObjectChannelGroup = dynamic_cast<stageobjectchannelgroup *="">(channel->getParent());</stageobjectchannelgroup>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		int x = itemPos.x();
Toshihiro Shimizu 890ddd
		if (x >= 20)
Toshihiro Shimizu 890ddd
			channel->setIsCurrent(true);
Toshihiro Shimizu 890ddd
		else if (0 <= x && x < 20) {
Toshihiro Shimizu 890ddd
			channel->setIsActive((e->button() == Qt::RightButton) ? true : !channel->isActive());
Toshihiro Shimizu 890ddd
			update();
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (fxChannelGroup) {
Toshihiro Shimizu 890ddd
		TFx *fx = fxChannelGroup->getFx();
Toshihiro Shimizu 890ddd
		emit switchCurrentFx(fx);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (stageObjectChannelGroup) {
Toshihiro Shimizu 890ddd
		TStageObject *obj = stageObjectChannelGroup->getStageObject();
Toshihiro Shimizu 890ddd
		emit switchCurrentObject(obj);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeView::onMidClick(TreeModel::Item *item, const QPoint &itemPos, QMouseEvent *e)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FunctionTreeModel::Channel *channel =
Toshihiro Shimizu 890ddd
		dynamic_cast<functiontreemodel::channel *="">(item);</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
	if (channel && e->button() == Qt::MidButton) {
Toshihiro Shimizu 890ddd
		m_draggingChannel = channel;
Toshihiro Shimizu 890ddd
		m_dragStartPosition = e->pos();
Toshihiro Shimizu 890ddd
	} else
Toshihiro Shimizu 890ddd
		m_draggingChannel = 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeView::onDrag(TreeModel::Item *item, const QPoint &itemPos, QMouseEvent *e)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	//middle drag of the channel item can retrieve expression name
Toshihiro Shimizu 890ddd
	if ((e->buttons() & Qt::MidButton) &&
Toshihiro Shimizu 890ddd
		m_draggingChannel &&
Toshihiro Shimizu 890ddd
		(e->pos() - m_dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) {
Toshihiro Shimizu 890ddd
		QDrag *drag = new QDrag(this);
Toshihiro Shimizu 890ddd
		QMimeData *mimeData = new QMimeData;
Toshihiro Shimizu 890ddd
		mimeData->setText(m_draggingChannel->getExprRefName());
Toshihiro Shimizu 890ddd
		drag->setMimeData(mimeData);
Toshihiro Shimizu 890ddd
		static const QPixmap cursorPixmap(":Resources/dragcursor_exp_text.png");
Toshihiro Shimizu 890ddd
		drag->setDragCursor(cursorPixmap, Qt::MoveAction);
Toshihiro Shimizu 890ddd
		Qt::DropAction dropAction = drag->exec();
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionTreeModel::Channel *channel = dynamic_cast<functiontreemodel::channel *="">(item);</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
	if (!channel || !m_clickedItem)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// i0: item under the current cursor position
Toshihiro Shimizu 890ddd
	// i1: clicked item
Toshihiro Shimizu 890ddd
	QModelIndex i0 = channel->createIndex(), i1 = m_clickedItem->createIndex();
Toshihiro Shimizu 890ddd
	if (!i0.isValid() || !i1.isValid() || i0.parent() != i1.parent())
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (i0.row() > i1.row())
Toshihiro Shimizu 890ddd
		tswap(i0, i1);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionTreeModel *md = static_cast<functiontreemodel *="">(model());</functiontreemodel>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool active = m_clickedItem->isActive();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	for (int row = i0.row(); row <= i1.row(); ++row) {
Toshihiro Shimizu 890ddd
		if (isRowHidden(row, i0.parent()))
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		QModelIndex index = md->index(row, 0, i0.parent());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		TreeModel::Item *chItem = static_cast<treemodel::item *="">(index.internalPointer());</treemodel::item>
Toshihiro Shimizu 890ddd
		FunctionTreeModel::Channel *ch = dynamic_cast<functiontreemodel::channel *="">(chItem);</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		if (ch && ch->isActive() != active) {
Toshihiro Shimizu 890ddd
			ch->setIsActive(active);
Toshihiro Shimizu 890ddd
			update();
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeView::onRelease()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_clickedItem = 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeView::openContextMenu(TreeModel::Item *item, const QPoint &globalPos)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (FunctionTreeModel::Channel *channel = dynamic_cast<functiontreemodel::channel *="">(item))</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
		openContextMenu(channel, globalPos);
Toshihiro Shimizu 890ddd
	else if (FunctionTreeModel::ChannelGroup *group = dynamic_cast<functiontreemodel::channelgroup *="">(item))</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
		openContextMenu(group, globalPos);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeView::openContextMenu(FunctionTreeModel::Channel *channel, const QPoint &globalPos)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert(channel);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QWidget *pw = dynamic_cast<qwidget *="">(parentWidget());</qwidget>
Toshihiro Shimizu 890ddd
	if (!pw)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionViewer *fv = dynamic_cast<functionviewer *="">(pw->parentWidget());</functionviewer>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (!fv) {
Toshihiro Shimizu 890ddd
		assert(fv);
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QMenu menu;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QAction saveCurveAction(tr("Save Curve"), 0);
Toshihiro Shimizu 890ddd
	QAction loadCurveAction(tr("Load Curve"), 0);
Toshihiro Shimizu 890ddd
	QAction exportDataAction(tr("Export Data"), 0);
Toshihiro Shimizu 890ddd
	menu.addAction(&saveCurveAction);
Toshihiro Shimizu 890ddd
	menu.addAction(&loadCurveAction);
Toshihiro Shimizu 890ddd
	menu.addAction(&exportDataAction);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QAction *action = menu.exec(globalPos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDoubleParam *curve = channel->getParam();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (action == &saveCurveAction)
Toshihiro Shimizu 890ddd
		fv->emitIoCurve((int)FunctionViewer::eSaveCurve, curve, "");
Toshihiro Shimizu 890ddd
	else if (action == &loadCurveAction)
Toshihiro Shimizu 890ddd
		fv->emitIoCurve((int)FunctionViewer::eLoadCurve, curve, "");
Toshihiro Shimizu 890ddd
	else if (action == &exportDataAction)
Toshihiro Shimizu 890ddd
		fv->emitIoCurve((int)FunctionViewer::eExportCurve, curve, channel->getLongName().toStdString());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeView::openContextMenu(FunctionTreeModel::ChannelGroup *group, const QPoint &globalPos)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert(group);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QMenu menu;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QAction showAnimateOnly(tr("Show Animated Only"), 0);
Toshihiro Shimizu 890ddd
	QAction showAll(tr("Show All"), 0);
Toshihiro Shimizu 890ddd
	menu.addAction(&showAnimateOnly);
Toshihiro Shimizu 890ddd
	menu.addAction(&showAll);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// execute menu
Toshihiro Shimizu 890ddd
	QAction *action = menu.exec(globalPos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (action != &showAll && action != &showAnimateOnly)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionTreeModel::ChannelGroup::ShowFilter showFilter =
Toshihiro Shimizu 890ddd
		(action == &showAll) ? FunctionTreeModel::ChannelGroup::ShowAllChannels : FunctionTreeModel::ChannelGroup::ShowAnimatedChannels;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	expand(group->createIndex());
Toshihiro Shimizu 890ddd
	group->setShowFilter(showFilter);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void FunctionTreeView::updateAll()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FunctionTreeModel *functionTreeModel = dynamic_cast<functiontreemodel *="">(model());</functiontreemodel>
Toshihiro Shimizu 890ddd
	assert(functionTreeModel);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	functionTreeModel->applyShowFilters();
Toshihiro Shimizu 890ddd
	update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*! show all the animated channels when the scene switched
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
void FunctionTreeView::displayAnimatedChannels()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FunctionTreeModel *functionTreeModel = dynamic_cast<functiontreemodel *="">(model());</functiontreemodel>
Toshihiro Shimizu 890ddd
	assert(functionTreeModel);
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
	for (i = 0; i < functionTreeModel->getStageObjectsChannelCount(); i++)
Toshihiro Shimizu 890ddd
		functionTreeModel->getStageObjectChannel(i)->displayAnimatedChannels();
Toshihiro Shimizu 890ddd
	for (i = 0; i < functionTreeModel->getFxsChannelCount(); i++)
Toshihiro Shimizu 890ddd
		functionTreeModel->getFxChannel(i)->displayAnimatedChannels();
Toshihiro Shimizu 890ddd
	update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*! show all the animated channels when the scene switched
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
void FunctionTreeModel::ChannelGroup::displayAnimatedChannels()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int itemCount = getChildCount();
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	for (i = 0; i < itemCount; i++) {
Toshihiro Shimizu 890ddd
		FunctionTreeModel::Channel *channel = dynamic_cast<functiontreemodel::channel *="">(getChild(i));</functiontreemodel::channel>
Toshihiro Shimizu 890ddd
		if (!channel) {
Toshihiro Shimizu 890ddd
			FunctionTreeModel::ChannelGroup *channelGroup =
Toshihiro Shimizu 890ddd
				dynamic_cast<functiontreemodel::channelgroup *="">(getChild(i));</functiontreemodel::channelgroup>
Toshihiro Shimizu 890ddd
			if (!channelGroup)
Toshihiro Shimizu 890ddd
				continue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			channelGroup->displayAnimatedChannels();
Toshihiro Shimizu 890ddd
			continue;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		channel->setIsActive(channel->getParam()->hasKeyframes());
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}