Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/txshlevelhandle.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/txshlevel.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshsimplelevel.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheet.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshcell.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// TXshLevelHandle
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TXshLevelHandle::TXshLevelHandle()
Toshihiro Shimizu 890ddd
	: m_level(0)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TXshLevelHandle::~TXshLevelHandle()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (m_level)
Toshihiro Shimizu 890ddd
		m_level->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TXshLevel *TXshLevelHandle::getLevel() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_level;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TXshSimpleLevel *TXshLevelHandle::getSimpleLevel() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (!m_level)
Toshihiro Shimizu 890ddd
		return 0;
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		return m_level->getSimpleLevel();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TXshLevelHandle::setLevel(TXshLevel *level)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (m_level == level)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TXshLevel *oldLevel = m_level;
Toshihiro Shimizu 890ddd
	m_level = level;
Toshihiro Shimizu 890ddd
	if (level)
Toshihiro Shimizu 890ddd
		level->addRef();
Toshihiro Shimizu 890ddd
	bool levelExists = oldLevel ? oldLevel->getRefCount() > 1 : false;
Toshihiro Shimizu 890ddd
	if (oldLevel)
Toshihiro Shimizu 890ddd
		oldLevel->release();
Toshihiro Shimizu 890ddd
	emit xshLevelSwitched(levelExists ? oldLevel : 0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------