|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshpalettecolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshcell.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshPaletteColumn::TXshPaletteColumn()
|
|
Toshihiro Shimizu |
890ddd |
: TXshCellColumn(), m_fx(new TPaletteColumnFx())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_fx->addRef();
|
|
Toshihiro Shimizu |
890ddd |
m_fx->setColumn(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshPaletteColumn::~TXshPaletteColumn()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_fx->setColumn(0);
|
|
Toshihiro Shimizu |
890ddd |
m_fx->release();
|
|
Toshihiro Shimizu |
890ddd |
m_fx = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshColumn::ColumnType TXshPaletteColumn::getColumnType() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return ePaletteType;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshColumn *TXshPaletteColumn::clone() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TXshPaletteColumn *column = new TXshPaletteColumn();
|
|
Toshihiro Shimizu |
890ddd |
column->setStatusWord(getStatusWord());
|
|
Toshihiro Shimizu |
890ddd |
column->m_cells = m_cells;
|
|
Toshihiro Shimizu |
890ddd |
column->m_first = m_first;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//column->updateIcon();
|
|
Toshihiro Shimizu |
890ddd |
return column;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *TXshPaletteColumn::getFx() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshPaletteColumn::setFx(TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPaletteColumnFx *pfx = dynamic_cast<tpalettecolumnfx *="">(fx);</tpalettecolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
assert(pfx);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_fx);
|
|
Toshihiro Shimizu |
890ddd |
if (m_fx == pfx)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
pfx->addRef();
|
|
Toshihiro Shimizu |
890ddd |
m_fx->release();
|
|
Toshihiro Shimizu |
890ddd |
m_fx = pfx;
|
|
Toshihiro Shimizu |
890ddd |
pfx->setColumn(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TXshPaletteColumn::canSetCell(const TXshCell &cell) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return cell.isEmpty() || cell.m_level->getPaletteLevel() != 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshPaletteColumn::loadData(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
string tagName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "cells") {
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "cell") {
|
|
Toshihiro Shimizu |
890ddd |
TPersist *p = 0;
|
|
Toshihiro Shimizu |
890ddd |
int row = 1, rowCount = 1, drawing = 1, increment = 0;
|
|
Toshihiro Shimizu |
890ddd |
is >> row >> rowCount >> p >> drawing >> increment;
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xshLevel = dynamic_cast<txshlevel *="">(p);</txshlevel>
|
|
Toshihiro Shimizu |
890ddd |
if (xshLevel) {
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < rowCount; i++) {
|
|
Toshihiro Shimizu |
890ddd |
TXshCell cell(xshLevel, drawing);
|
|
Toshihiro Shimizu |
890ddd |
setCell(row++, cell);
|
|
Toshihiro Shimizu |
890ddd |
drawing += increment;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
throw TException("TXshPaletteColumn, unknown tag(2): " + tagName);
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "fx") {
|
|
Toshihiro Shimizu |
890ddd |
TPersist *p = 0;
|
|
Toshihiro Shimizu |
890ddd |
is >> p;
|
|
Toshihiro Shimizu |
890ddd |
if (TFx *fx = dynamic_cast<tfx *="">(p))</tfx>
|
|
Toshihiro Shimizu |
890ddd |
setFx(fx);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
throw TException("TXshLevelColumn, unknown tag: " + tagName);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void TXshPaletteColumn::saveData(TOStream &os)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int r0, r1;
|
|
Toshihiro Shimizu |
890ddd |
if (getRange(r0, r1)) {
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("cells");
|
|
Toshihiro Shimizu |
890ddd |
for (int r = r0; r <= r1; r++) {
|
|
Toshihiro Shimizu |
890ddd |
TXshCell cell = getCell(r);
|
|
Toshihiro Shimizu |
890ddd |
if (cell.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
int n = 1, inc = 0, dr = cell.m_frameId.getNumber();
|
|
Toshihiro Shimizu |
890ddd |
if (r < r1) {
|
|
Toshihiro Shimizu |
890ddd |
TXshCell cell2 = getCell(r + 1);
|
|
Toshihiro Shimizu |
890ddd |
if (cell2.m_level.getPointer() == cell.m_level.getPointer()) {
|
|
Toshihiro Shimizu |
890ddd |
inc = cell2.m_frameId.getNumber() - dr;
|
|
Toshihiro Shimizu |
890ddd |
n++;
|
|
Toshihiro Shimizu |
890ddd |
for (;;) {
|
|
Toshihiro Shimizu |
890ddd |
if (r + n > r1)
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
cell2 = getCell(r + n);
|
|
Toshihiro Shimizu |
890ddd |
if (cell2.m_level.getPointer() != cell.m_level.getPointer())
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
if (cell2.m_frameId.getNumber() != dr + n * inc)
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
n++;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.child("cell") << r << n << cell.m_level.getPointer() << dr << inc;
|
|
Toshihiro Shimizu |
890ddd |
r += n - 1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.child("fx") << m_fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_IDENTIFIER(TXshPaletteColumn, "paletteColumn")
|