Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/txshchildlevel.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshleveltypes.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheet.h"
Toshihiro Shimizu 890ddd
#include "toonz/imagemanager.h"
Toshihiro Shimizu 890ddd
#include "toonz/toonzscene.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshcolumn.h"
Toshihiro Shimizu 890ddd
#include "tconvert.h"
Toshihiro Shimizu 890ddd
#include "trasterimage.h"
Toshihiro Shimizu 890ddd
#include "timagecache.h"
Toshihiro Shimizu 890ddd
#include "tstream.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DEFINE_CLASS_CODE(TXshChildLevel, 50)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
PERSIST_IDENTIFIER(TXshChildLevel, "childLevel")
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// TXshChildLevel
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
TXshChildLevel::TXshChildLevel(std::wstring name)
Shinya Kitaoka 120a6e
    : TXshLevel(m_classCode, name), m_xsheet(new TXsheet()), m_iconId() {
Shinya Kitaoka 120a6e
  m_xsheet->addRef();
Shinya Kitaoka 120a6e
  m_type = CHILD_XSHLEVEL;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshChildLevel::~TXshChildLevel() {
Shinya Kitaoka 120a6e
  m_xsheet->release();
Shinya Kitaoka 120a6e
  if (m_iconId != "") {
Shinya Kitaoka 120a6e
    ImageManager::instance()->bind(m_iconId, 0);
Shinya Kitaoka 120a6e
    TImageCache::instance()->remove(m_iconId);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshChildLevel::loadData(TIStream &is) {
Shinya Kitaoka 120a6e
  if (m_xsheet) m_xsheet->release();
Shinya Kitaoka 120a6e
  m_xsheet = 0;
Shinya Kitaoka 120a6e
  is >> m_xsheet;
Shinya Kitaoka 120a6e
  m_xsheet->addRef();
Shinya Kitaoka 120a6e
  std::string tagName;
Shinya Kitaoka 120a6e
  if (is.matchTag(tagName)) {
Shinya Kitaoka 120a6e
    if (tagName == "name") {
Shinya Kitaoka 120a6e
      std::wstring name;
Shinya Kitaoka 120a6e
      is >> name;
Shinya Kitaoka 120a6e
      setName(name);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    is.closeChild();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshChildLevel::saveData(TOStream &os) {
Shinya Kitaoka 120a6e
  os << m_xsheet;
Shinya Kitaoka 120a6e
  os.child("name") << getName();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshChildLevel::setXsheet(TXsheet *xsheet) {
Shinya Kitaoka 120a6e
  xsheet->addRef();
Shinya Kitaoka 120a6e
  m_xsheet->release();
Shinya Kitaoka 120a6e
  m_xsheet = xsheet;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshChildLevel::setScene(ToonzScene *scene) {
Shinya Kitaoka 120a6e
  TXshLevel::setScene(scene);
Shinya Kitaoka 120a6e
  assert(m_xsheet);
Shinya Kitaoka 120a6e
  if (!m_xsheet) return;
Shinya Kitaoka 120a6e
  m_xsheet->setScene(scene);
Shinya Kitaoka 120a6e
  int i, columnCount = m_xsheet->getColumnCount();
Shinya Kitaoka 120a6e
  for (i = 0; i < columnCount; i++)
Shinya Kitaoka 120a6e
    if (m_xsheet->getColumn(i)) m_xsheet->getColumn(i)->setXsheet(m_xsheet);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int TXshChildLevel::getFrameCount() const {
Shinya Kitaoka 120a6e
  if (m_xsheet)
Shinya Kitaoka 120a6e
    return m_xsheet->getFrameCount();
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    return 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshChildLevel::getFids(std::vector<tframeid> &fids) const {</tframeid>
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 1; i <= getFrameCount(); i++) fids.push_back(TFrameId(i));
Toshihiro Shimizu 890ddd
}