|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfxset.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tcolumnfx.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tfx.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxSet::TFxSet()
|
|
Toshihiro Shimizu |
890ddd |
//: m_xsheetFx(0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxSet::~TFxSet()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// delete m_xsheetFx;
|
|
Toshihiro Shimizu |
890ddd |
clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFxSet::addFx(TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfx *="">::iterator it = m_fxs.find(fx);</tfx>
|
|
Toshihiro Shimizu |
890ddd |
if (it == m_fxs.end()) {
|
|
Toshihiro Shimizu |
890ddd |
fx->addRef();
|
|
Toshihiro Shimizu |
890ddd |
m_fxs.insert(fx);
|
|
Toshihiro Shimizu |
890ddd |
fx->setNewIdentifier();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFxSet::getFxs(std::set<tfx *=""> &fxs)</tfx>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
fxs.insert(m_fxs.begin(), m_fxs.end());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFxSet::saveData(TOStream &os, int occupiedColumnCount)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfx *="">::iterator it;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_fxs.begin(); it != m_fxs.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
TRasterFx *rasterFx = dynamic_cast<trasterfx *="">(*it);</trasterfx>
|
|
Toshihiro Shimizu |
890ddd |
if (rasterFx) {
|
|
Toshihiro Shimizu |
890ddd |
TColumnFx *columnFx = dynamic_cast<tcolumnfx *="">(rasterFx);</tcolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
if (columnFx &&
|
|
Toshihiro Shimizu |
890ddd |
(columnFx->getColumnIndex() == -1 ||
|
|
Toshihiro Shimizu |
890ddd |
columnFx->getColumnIndex() >= occupiedColumnCount))
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("fxnode");
|
|
Toshihiro Shimizu |
890ddd |
os << (*it);
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TFxSet::getFxCount() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_fxs.size();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFxSet::removeFx(TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfx *="">::iterator it = m_fxs.find(fx);</tfx>
|
|
Toshihiro Shimizu |
890ddd |
if (it != m_fxs.end()) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = *it;
|
|
Toshihiro Shimizu |
890ddd |
fx->release();
|
|
Toshihiro Shimizu |
890ddd |
m_fxs.erase(fx);
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *TFxSet::getFx(int index) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(0 <= index && index < getFxCount());
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfx *="">::const_iterator it = m_fxs.begin();</tfx>
|
|
Toshihiro Shimizu |
890ddd |
std::advance(it, index);
|
|
Toshihiro Shimizu |
890ddd |
return *it;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *TFxSet::getFx(const std::string &id) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfx *="">::const_iterator it;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_fxs.begin(); it != m_fxs.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
// TFx *fx = *it;
|
|
Toshihiro Shimizu |
890ddd |
//if (fx->getId() == id)
|
|
Toshihiro Shimizu |
890ddd |
// return fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFxSet::clear()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfx *="">::iterator it;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = m_fxs.begin(); it != m_fxs.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = *it;
|
|
Toshihiro Shimizu |
890ddd |
fx->release();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_fxs.clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFxSet::loadData(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
clear();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
string tagName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "fxnode") {
|
|
Toshihiro Shimizu |
890ddd |
TPersist *p = 0;
|
|
Toshihiro Shimizu |
890ddd |
is >> p;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// NOTE: In current implementation p is sharedly owned by is - it's automatically
|
|
Toshihiro Shimizu |
890ddd |
// released upon stream destruction if the below assignment fails
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (TFx *fx = dynamic_cast<tfx *="">(p)) {</tfx>
|
|
Toshihiro Shimizu |
890ddd |
addFx(fx);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
throw TException("TFxSet, unknown tag: " + tagName);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *getActualFx(TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// Zerary fxs and zerary COLUMN fxs are separate, and fx port connections
|
|
Toshihiro Shimizu |
890ddd |
// are stored in the actual zerary fx.
|
|
Toshihiro Shimizu |
890ddd |
// It's sad - couldn't we do something about it?
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TZeraryColumnFx *zeraryColumnFx = dynamic_cast<tzerarycolumnfx *="">(fx);</tzerarycolumnfx>
|
|
Toshihiro Shimizu |
890ddd |
return zeraryColumnFx ? zeraryColumnFx->getZeraryFx() : fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *searchFx(const std::map<tfx *="" *,="" tfx=""> &table, TFx *fx)</tfx>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::map<tfx *="" *,="" tfx="">::const_iterator it = table.find(fx);</tfx>
|
|
Toshihiro Shimizu |
890ddd |
return it == table.end() ? 0 : it->second;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void updateFxLinks(const std::map<tfx *="" *,="" tfx=""> &table)</tfx>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// The input table is made of (original, cloned) couples.
|
|
Toshihiro Shimizu |
890ddd |
// The purpose of this function is that of replicating the hierarchycal
|
|
Toshihiro Shimizu |
890ddd |
// structure from the first fxs to the seconds.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::map<tfx *="" *,="" tfx="">::const_iterator it;</tfx>
|
|
Toshihiro Shimizu |
890ddd |
for (it = table.begin(); it != table.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = getActualFx(it->first), *fx2 = getActualFx(it->second);
|
|
Toshihiro Shimizu |
890ddd |
if (!fx || !fx2)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < fx->getInputPortCount(); ++i) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *inputFx = fx->getInputPort(i)->getFx();
|
|
Toshihiro Shimizu |
890ddd |
TFx *inputFx2 = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (inputFx) {
|
|
Toshihiro Shimizu |
890ddd |
inputFx2 = searchFx(table, inputFx);
|
|
Toshihiro Shimizu |
890ddd |
inputFx = getActualFx(inputFx);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Normally, the above should be enough. However, it seems that
|
|
Toshihiro Shimizu |
890ddd |
// the possibility of the input table being 'incomplete' must be dealt with
|
|
Toshihiro Shimizu |
890ddd |
// (why is it not asserted >_< !)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
while (inputFx && !inputFx2 && (inputFx->getInputPortCount() > 0)) {
|
|
Toshihiro Shimizu |
890ddd |
// So, well... this block tries to delve deeper in the hierarchy
|
|
Toshihiro Shimizu |
890ddd |
// until a suitable mapped children is found... Yeah, sure...
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = inputFx->getInputPort(0);
|
|
Toshihiro Shimizu |
890ddd |
inputFx = port->getFx();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inputFx2 = searchFx(table, inputFx);
|
|
Toshihiro Shimizu |
890ddd |
inputFx = getActualFx(inputFx);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (inputFx2)
|
|
Toshihiro Shimizu |
890ddd |
fx2->getInputPort(i)->setFx(inputFx2);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|