|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshcell.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshleveltypes.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshmeshcolumn.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_IDENTIFIER(TXshMeshColumn, "meshColumn")
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Local namespace
|
|
Toshihiro Shimizu |
890ddd |
//*******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFrameId qstringToFrameId(QString str)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (str.isEmpty() || str == "-1")
|
|
Toshihiro Shimizu |
890ddd |
return TFrameId::EMPTY_FRAME;
|
|
Toshihiro Shimizu |
890ddd |
else if (str == "-" || str == "-2")
|
|
Toshihiro Shimizu |
890ddd |
return TFrameId::NO_FRAME;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString number;
|
|
Toshihiro Shimizu |
890ddd |
char letter(0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int s, strSize = str.size();
|
|
Toshihiro Shimizu |
890ddd |
for (s = 0; s < strSize; ++s) {
|
|
Toshihiro Shimizu |
890ddd |
QChar c = str.at(s);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (c.isNumber())
|
|
Toshihiro Shimizu |
890ddd |
number.append(c);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050500
|
|
Toshihiro Shimizu |
890ddd |
letter = c.toLatin1();
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
letter = c.toAscii();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return TFrameId(number.toInt(), letter);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TXshMeshColumn implementation
|
|
Toshihiro Shimizu |
890ddd |
//*******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshMeshColumn::TXshMeshColumn()
|
|
Toshihiro Shimizu |
890ddd |
: TXshCellColumn() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshColumn *TXshMeshColumn::clone() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TXshMeshColumn *column = new TXshMeshColumn();
|
|
Toshihiro Shimizu |
890ddd |
|
|
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 |
return column;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TXshMeshColumn::canSetCell(const TXshCell &cell) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevel *sl = cell.getSimpleLevel();
|
|
Toshihiro Shimizu |
890ddd |
return cell.isEmpty() || (sl && sl->getType() == MESH_XSHLEVEL);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshMeshColumn::saveData(TOStream &os)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
os.child("status") << getStatusWord();
|
|
Toshihiro Shimizu |
890ddd |
if (getOpacity() < 255)
|
|
Toshihiro Shimizu |
890ddd |
os.child("camerastand_opacity") << (int)getOpacity();
|
|
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 |
{
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = cell.m_frameId;
|
|
Toshihiro Shimizu |
890ddd |
int n = 1, inc = 0, dr = fid.getNumber();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// If fid has no letter save more than one cell and its increment - otherwise save just one cell
|
|
Toshihiro Shimizu |
890ddd |
if (r < r1 && fid.getLetter() == 0) {
|
|
Toshihiro Shimizu |
890ddd |
TXshCell cell2 = getCell(r + 1);
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid2 = cell2.m_frameId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (cell2.m_level.getPointer() == cell.m_level.getPointer() && fid2.getLetter() == 0) {
|
|
Toshihiro Shimizu |
890ddd |
inc = cell2.m_frameId.getNumber() - dr;
|
|
Toshihiro Shimizu |
890ddd |
for (++n;; ++n) {
|
|
Toshihiro Shimizu |
890ddd |
if (r + n > r1)
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
cell2 = getCell(r + n);
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid2 = cell2.m_frameId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (cell2.m_level.getPointer() != cell.m_level.getPointer() || fid2.getLetter() != 0)
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (fid2.getNumber() != dr + n * inc)
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
os.child("cell") << r << n << cell.m_level.getPointer() << fid.expand() << inc;
|
|
Toshihiro Shimizu |
890ddd |
r += n - 1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TXshMeshColumn::loadData(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
string tagName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "status") {
|
|
Toshihiro Shimizu |
890ddd |
int status;
|
|
Toshihiro Shimizu |
890ddd |
is >> status;
|
|
Toshihiro Shimizu |
890ddd |
setStatusWord(status);
|
|
Toshihiro Shimizu |
890ddd |
if (status & eCamstandTransparent43) {
|
|
Toshihiro Shimizu |
890ddd |
setOpacity(128);
|
|
Toshihiro Shimizu |
890ddd |
status = status & ~eCamstandTransparent43;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "camerastand_opacity") {
|
|
Toshihiro Shimizu |
890ddd |
int opacity;
|
|
Toshihiro Shimizu |
890ddd |
is >> opacity;
|
|
Toshihiro Shimizu |
890ddd |
setOpacity((UCHAR)opacity);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
} else 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 |
QString str;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int row = 1, rowCount = 1, increment = 0;
|
|
Toshihiro Shimizu |
890ddd |
TFilePath path;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
is >> row >> rowCount >> p >> str >> increment;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFrameId fid = qstringToFrameId(str);
|
|
Toshihiro Shimizu |
890ddd |
assert((fid.getLetter() == 0 && rowCount >= 0) || (fid.getLetter() != 0 && rowCount == 1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TXshLevel *xshLevel = dynamic_cast<txshlevel *="">(p);</txshlevel>
|
|
Toshihiro Shimizu |
890ddd |
if (xshLevel) {
|
|
Toshihiro Shimizu |
890ddd |
int fidNumber = fid.getNumber();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < rowCount; ++i) {
|
|
Toshihiro Shimizu |
890ddd |
TXshCell cell(xshLevel, fid);
|
|
Toshihiro Shimizu |
890ddd |
setCell(row++, cell);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//rowCount>1 => fid has not letter.
|
|
Toshihiro Shimizu |
890ddd |
fidNumber += increment;
|
|
Toshihiro Shimizu |
890ddd |
fid = TFrameId(fidNumber);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
is.skipCurrentTag();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
is.skipCurrentTag();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|