|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tconst.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamcontainer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxattributes.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texternfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpassivecachemanager.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// STD includes
|
|
Toshihiro Shimizu |
890ddd |
#include <set></set>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tfx.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TIStream &operator>>(TIStream &in, TFxP &p)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPersist *tmp = 0;
|
|
Toshihiro Shimizu |
890ddd |
in >> tmp;
|
|
Toshihiro Shimizu |
890ddd |
p = TFxP(dynamic_cast<tfx *="">(tmp));</tfx>
|
|
Toshihiro Shimizu |
890ddd |
return in;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// namespace {}
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
typedef std::pair<std::string, *="" tfxport=""> NamePort;</std::string,>
|
|
Shinya Kitaoka |
3bfa54 |
typedef std::map<std::string, *="" tfxport=""> PortTable;</std::string,>
|
|
Shinya Kitaoka |
3bfa54 |
typedef std::vector<nameport> PortArray;</nameport>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class PortNameEq
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
3bfa54 |
std::string m_name;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
3bfa54 |
PortNameEq(const std::string &name) : m_name(name) {}
|
|
Toshihiro Shimizu |
890ddd |
~PortNameEq() {}
|
|
Toshihiro Shimizu |
890ddd |
bool operator()(const NamePort &np) { return np.first == m_name; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void skipChild(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
while (!is.eos()) {
|
|
Shinya Kitaoka |
3bfa54 |
std::string dummy = is.getString();
|
|
Shinya Kitaoka |
3bfa54 |
std::string tagName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
skipChild(is);
|
|
Toshihiro Shimizu |
890ddd |
if (is.isBeginEndTag())
|
|
Toshihiro Shimizu |
890ddd |
is.matchTag(tagName);
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD updateDagPosition(const TPointD &pos, const VersionNumber &tnzVersion)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (tnzVersion < VersionNumber(1, 16))
|
|
Toshihiro Shimizu |
890ddd |
return TConst::nowhere;
|
|
Toshihiro Shimizu |
890ddd |
return pos;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// TFxParamChange
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxParamChange::TFxParamChange(TFx *fx, double firstAffectedFrame, double lastAffectedFrame, bool dragging)
|
|
Toshihiro Shimizu |
890ddd |
: TFxChange(fx, firstAffectedFrame, lastAffectedFrame, dragging)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxParamChange::TFxParamChange(TFx *fx, const TParamChange &src)
|
|
Toshihiro Shimizu |
890ddd |
: TFxChange(fx, src.m_firstAffectedFrame, src.m_lastAffectedFrame, src.m_dragging)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// TFxChange
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double TFxChange::m_minFrame = -(std::numeric_limits<double>::max)();</double>
|
|
Toshihiro Shimizu |
890ddd |
double TFxChange::m_maxFrame = +(std::numeric_limits<double>::max)();</double>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// TFxPortDynamicGroup
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPortDynamicGroup::TFxPortDynamicGroup(const std::string &prefix, int minSize)
|
|
Toshihiro Shimizu |
890ddd |
: m_portsPrefix(prefix), m_minPortsCount(minSize)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPortDynamicGroup::~TFxPortDynamicGroup()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFxPortDynamicGroup::addPort(TFxPort *port)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_ports.push_back(port);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFxPortDynamicGroup::removePort(TFxPort *port)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_ports.resize(std::remove(m_ports.begin(), m_ports.end(), port) - m_ports.begin());
|
|
Toshihiro Shimizu |
890ddd |
delete port;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFxPortDynamicGroup::clear()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::for_each(m_ports.begin(), m_ports.end(), TDeleteObjectFunctor());
|
|
Toshihiro Shimizu |
890ddd |
m_ports.clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// TFxImp
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFxImp
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TFx *m_fx; //!< Fx back-pointer
|
|
Toshihiro Shimizu |
890ddd |
TFxImp *m_prev, *m_next; //!< Linked fxs
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring m_name;
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring m_fxId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PortTable m_portTable; //!< Name -> port map
|
|
Toshihiro Shimizu |
890ddd |
PortArray m_portArray; //!< Ports container
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TParamContainer m_paramContainer;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfxport *=""> m_outputPort;</tfxport>
|
|
Toshihiro Shimizu |
890ddd |
TFxTimeRegion m_activeTimeRegion;
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfxobserver *=""> m_observers;</tfxobserver>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxAttributes m_attributes;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static unsigned long m_nextId;
|
|
Toshihiro Shimizu |
890ddd |
unsigned long m_id; //!< Unique fx identifier, per Toonz session.
|
|
Toshihiro Shimizu |
890ddd |
//!< It is intended to be used \b solely to build
|
|
Toshihiro Shimizu |
890ddd |
//!< an internal string description of the fx.
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TFxImp(TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
: m_fx(fx), m_activeTimeRegion(TFxTimeRegion::createUnlimited()), m_id()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_prev = m_next = this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~TFxImp()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_prev->m_next = m_next;
|
|
Toshihiro Shimizu |
890ddd |
m_next->m_prev = m_prev;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool checkLinks() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(m_prev);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_next);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_prev->m_next == this);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_next->m_prev == this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
// not copyable
|
|
Toshihiro Shimizu |
890ddd |
TFxImp(const TFxImp &);
|
|
Toshihiro Shimizu |
890ddd |
TFxImp &operator=(const TFxImp &);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
unsigned long TFxImp::m_nextId = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// TFxFactory
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFxFactory // singleton
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
typedef std::map
|
|
Toshihiro Shimizu |
890ddd |
std::pair<tfxinfo, *="" tfxdeclaration="">> Table;</tfxinfo,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Table m_table;
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<std::string> m_map;</std::string>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxFactory() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
static TFxFactory *instance()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static TFxFactory _instance;
|
|
Toshihiro Shimizu |
890ddd |
return &_instance;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void add(const TFxInfo &info, TFxDeclaration *decl)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// check for dups ???
|
|
Toshihiro Shimizu |
890ddd |
std::pair<tfxinfo, *="" tfxdeclaration=""> p(info, decl);</tfxinfo,>
|
|
Toshihiro Shimizu |
890ddd |
m_table[info.m_name] = p;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *create(std::string name)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Table::iterator it = m_table.find(name);
|
|
Toshihiro Shimizu |
890ddd |
if (it != m_table.end()) {
|
|
Toshihiro Shimizu |
890ddd |
TFxDeclaration *decl = it->second.second;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPersist *obj = decl->create();
|
|
Toshihiro Shimizu |
890ddd |
assert(obj);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return dynamic_cast<tfx *="">(obj);</tfx>
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
return TExternFx::create(name);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void getFxInfos(std::vector<tfxinfo> &info) const</tfxinfo>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (Table::const_iterator it = m_table.begin(); it != m_table.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
info.push_back(it->second.first);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxInfo getFxInfo(const std::string &fxIdentifier) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Table::const_iterator it = m_table.find(fxIdentifier);
|
|
Toshihiro Shimizu |
890ddd |
return (it != m_table.end()) ? it->second.first : TFxInfo();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// TFxDeclaration
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxDeclaration::TFxDeclaration(const TFxInfo &info)
|
|
Toshihiro Shimizu |
890ddd |
: TPersistDeclaration(info.m_name)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxFactory::instance()->add(info, this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// TFx
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DEFINE_CLASS_CODE(TFx, 3)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx::TFx()
|
|
Toshihiro Shimizu |
890ddd |
: TSmartObject(m_classCode) // TPersist(TFxImp::m_instances)
|
|
Shinya Kitaoka |
262a92 |
, m_imp(new TFxImp(this))
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx::~TFx()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (std::set<tfxport *="">::iterator it = m_imp->m_outputPort.begin();</tfxport>
|
|
Toshihiro Shimizu |
890ddd |
it != m_imp->m_outputPort.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = *it;
|
|
Toshihiro Shimizu |
890ddd |
port->setFx(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
delete m_imp;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring TFx::getName() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_name;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
void TFx::setName(std::wstring name)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_name = name;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring TFx::getFxId() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_fxId;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
void TFx::setFxId(std::wstring id)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_fxId = id;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxAttributes *TFx::getAttributes() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return &m_imp->m_attributes;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const TParamContainer *TFx::getParams() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return &m_imp->m_paramContainer;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TParamContainer *TFx::getParams()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return &m_imp->m_paramContainer;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *TFx::clone(bool recursive) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = TFx::create(getFxType());
|
|
Toshihiro Shimizu |
890ddd |
assert(fx);
|
|
Toshihiro Shimizu |
890ddd |
return this->clone(fx, recursive);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *TFx::clone(TFx *fx, bool recursive) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// Copy misc stuff
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
fx->m_imp->m_activeTimeRegion = m_imp->m_activeTimeRegion;
|
|
Toshihiro Shimizu |
890ddd |
fx->setIdentifier(getIdentifier());
|
|
Toshihiro Shimizu |
890ddd |
fx->getParams()->copy(getParams());
|
|
Toshihiro Shimizu |
890ddd |
fx->setFxId(getFxId());
|
|
Toshihiro Shimizu |
890ddd |
fx->setName(getName());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Copy attributes
|
|
Toshihiro Shimizu |
890ddd |
*fx->getAttributes() = *getAttributes();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Clone the dynamic ports pool
|
|
Toshihiro Shimizu |
890ddd |
if (hasDynamicPortGroups()) {
|
|
Toshihiro Shimizu |
890ddd |
int p, pCount = m_imp->m_portArray.size();
|
|
Toshihiro Shimizu |
890ddd |
for (p = 0; p != pCount; ++p) {
|
|
Toshihiro Shimizu |
890ddd |
const NamePort &namedPort = m_imp->m_portArray[p];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int groupIdx = namedPort.second->getGroupIndex();
|
|
Toshihiro Shimizu |
890ddd |
if (groupIdx >= 0 && !fx->getInputPort(namedPort.first))
|
|
Toshihiro Shimizu |
890ddd |
fx->addInputPort(namedPort.first, new TRasterFxPort, groupIdx);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(pCount == fx->getInputPortCount());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// copia ricorsiva sulle porte
|
|
Toshihiro Shimizu |
890ddd |
if (recursive) {
|
|
Toshihiro Shimizu |
890ddd |
int p, pCount = getInputPortCount();
|
|
Toshihiro Shimizu |
890ddd |
for (p = 0; p != pCount; ++p) {
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = getInputPort(p);
|
|
Toshihiro Shimizu |
890ddd |
if (port->getFx())
|
|
Toshihiro Shimizu |
890ddd |
fx->connect(getInputPortName(p), port->getFx()->clone(true));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::linkParams(TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (this == fx)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
getParams()->link(fx->getParams());
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_activeTimeRegion = fx->m_imp->m_activeTimeRegion;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// aggiorno i link
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->checkLinks());
|
|
Toshihiro Shimizu |
890ddd |
assert(fx->m_imp->checkLinks());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tswap(m_imp->m_next, fx->m_imp->m_next);
|
|
Toshihiro Shimizu |
890ddd |
tswap(m_imp->m_next->m_prev, fx->m_imp->m_next->m_prev);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->checkLinks());
|
|
Toshihiro Shimizu |
890ddd |
assert(fx->m_imp->checkLinks());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::unlinkParams()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// clone dei parametri
|
|
Toshihiro Shimizu |
890ddd |
getParams()->unlink();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->m_prev);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->m_next);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->m_prev->m_next == m_imp);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->m_next->m_prev == m_imp);
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_prev->m_next = m_imp->m_next;
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_next->m_prev = m_imp->m_prev;
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_next = m_imp->m_prev = m_imp;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
notify(TFxParamsUnlinked(this));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFx::addInputPort(const std::string &name, TFxPort &port)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
PortTable::iterator it = m_imp->m_portTable.find(name);
|
|
Toshihiro Shimizu |
890ddd |
if (it != m_imp->m_portTable.end())
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_portTable[name] = &port;
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_portArray.push_back(NamePort(name, &port));
|
|
Toshihiro Shimizu |
890ddd |
port.setOwnerFx(this); // back pointer to the owner...
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFx::addInputPort(const std::string &name, TFxPort *port, int groupIndex)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!port) {
|
|
Toshihiro Shimizu |
890ddd |
assert(port);
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (groupIndex >= dynamicPortGroupsCount()) {
|
|
Toshihiro Shimizu |
890ddd |
assert(groupIndex < dynamicPortGroupsCount());
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!addInputPort(name, *port))
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Assign the port to the associated group
|
|
Toshihiro Shimizu |
890ddd |
port->m_groupIdx = groupIndex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPortDG *group = const_cast<tfxportdg *="">(dynamicPortGroup(groupIndex));</tfxportdg>
|
|
Toshihiro Shimizu |
890ddd |
group->addPort(port);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(name.find(group->m_portsPrefix) == 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFx::removeInputPort(const std::string &name)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_portTable.erase(name);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PortArray::iterator it = std::find_if(m_imp->m_portArray.begin(), m_imp->m_portArray.end(), PortNameEq(name));
|
|
Toshihiro Shimizu |
890ddd |
if (it == m_imp->m_portArray.end())
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = it->second;
|
|
Toshihiro Shimizu |
890ddd |
port->setOwnerFx(0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (port->m_groupIdx >= 0) {
|
|
Toshihiro Shimizu |
890ddd |
TFxPortDG *group = const_cast<tfxportdg *="">(this->dynamicPortGroup(port->m_groupIdx));</tfxportdg>
|
|
Toshihiro Shimizu |
890ddd |
group->removePort(port); // The port is DELETED here
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_portArray.erase(it);
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
struct IsPrefix {
|
|
Toshihiro Shimizu |
890ddd |
const std::string &m_prefix;
|
|
Toshihiro Shimizu |
890ddd |
bool operator()(const NamePort &nameport)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (strncmp(m_prefix.c_str(), nameport.first.c_str(), m_prefix.size()) == 0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::clearDynamicPortGroup(int g)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxPortDG *dg = const_cast<tfxportdg *="">(this->dynamicPortGroup(g));</tfxportdg>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const std::string &prefix = dg->portsPrefix();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::string prefixEnd = prefix;
|
|
Toshihiro Shimizu |
890ddd |
++prefixEnd[prefixEnd.size() - 1];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// Delete all associated ports from the ports table
|
|
Toshihiro Shimizu |
890ddd |
PortTable::iterator pBegin(m_imp->m_portTable.lower_bound(prefix));
|
|
Toshihiro Shimizu |
890ddd |
PortTable::iterator pEnd(m_imp->m_portTable.lower_bound(prefixEnd));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_portTable.erase(pBegin, pEnd);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Traverse the ports array and remove all ports in the group
|
|
Toshihiro Shimizu |
890ddd |
IsPrefix func = {prefix};
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_portArray.resize(std::remove_if(m_imp->m_portArray.begin(), m_imp->m_portArray.end(), func) - m_imp->m_portArray.begin());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dg->clear(); // Has ports ownership, so deletes them
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFx::addOutputConnection(TFxPort *port)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(port->getFx() == this);
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_outputPort.insert(port).second;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFx::removeOutputConnection(TFxPort *port)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfxport *="">::iterator it = m_imp->m_outputPort.find(port);</tfxport>
|
|
Toshihiro Shimizu |
890ddd |
if (it == m_imp->m_outputPort.end())
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_outputPort.erase(it);
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TFx::getOutputConnectionCount() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_outputPort.size();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *TFx::getOutputConnection(int i) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(0 <= i && i <= (int)m_imp->m_outputPort.size());
|
|
Toshihiro Shimizu |
890ddd |
std::set<tfxport *="">::iterator it = m_imp->m_outputPort.begin();</tfxport>
|
|
Toshihiro Shimizu |
890ddd |
std::advance(it, i);
|
|
Toshihiro Shimizu |
890ddd |
if (it == m_imp->m_outputPort.end())
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
return *it;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFx::disconnect(const std::string &name)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = getInputPort(name);
|
|
Toshihiro Shimizu |
890ddd |
if (!port)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
port->setFx(0);
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFx::connect(const std::string &name, TFx *fx)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = getInputPort(name);
|
|
Toshihiro Shimizu |
890ddd |
if (!port)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
port->setFx(fx);
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TFx::getInputPortCount() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_portArray.size();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *TFx::getInputPort(int index) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(0 <= index && index < (int)m_imp->m_portArray.size());
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_portArray[index].second;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::string TFx::getInputPortName(int index) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(0 <= index && index < (int)(m_imp->m_portArray.size()));
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_portArray[index].first;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
bool TFx::renamePort(const std::string &oldName, const std::string &newName)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
PortTable::iterator it = m_imp->m_portTable.find(oldName);
|
|
Toshihiro Shimizu |
890ddd |
if (it == m_imp->m_portTable.end())
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = it->second;
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_portTable.erase(it);
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_portTable[newName] = port;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PortArray::iterator it2;
|
|
Toshihiro Shimizu |
890ddd |
for (it2 = m_imp->m_portArray.begin(); it2 != m_imp->m_portArray.end(); ++it2) {
|
|
Toshihiro Shimizu |
890ddd |
if (it2->first != oldName)
|
|
Toshihiro Shimizu |
890ddd |
continue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
it2->first = newName;
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *TFx::getInputPort(const std::string &name) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
PortTable::iterator it = m_imp->m_portTable.find(name);
|
|
Toshihiro Shimizu |
890ddd |
if (it == m_imp->m_portTable.end())
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_portTable[name];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TFx::getReferenceColumnIndex() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_imp->m_portArray.empty()) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = m_imp->m_portArray[0].second->getFx();
|
|
Toshihiro Shimizu |
890ddd |
if (fx)
|
|
Toshihiro Shimizu |
890ddd |
return fx->getReferenceColumnIndex();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return -1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxTimeRegion TFx::getTimeRegion() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_imp->m_portTable.empty())
|
|
Toshihiro Shimizu |
890ddd |
return TFxTimeRegion::createUnlimited();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxTimeRegion tr((std::numeric_limits<double>::max)(), -(std::numeric_limits<double>::max)());</double></double>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PortTable::iterator it = m_imp->m_portTable.begin();
|
|
Toshihiro Shimizu |
890ddd |
for (; it != m_imp->m_portTable.end(); ++it) {
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = it->second;
|
|
Toshihiro Shimizu |
890ddd |
if (port && port->isConnected() && !port->isaControlPort()) {
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = port->getFx();
|
|
Toshihiro Shimizu |
890ddd |
assert(fx);
|
|
Toshihiro Shimizu |
890ddd |
tr += fx->getTimeRegion();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return tr;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::setActiveTimeRegion(const TFxTimeRegion &tr)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_activeTimeRegion = tr;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxTimeRegion TFx::getActiveTimeRegion() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_activeTimeRegion;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::onChange(const TParamChange &c)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxParamChange change(this, c);
|
|
Toshihiro Shimizu |
890ddd |
notify(change);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::addObserver(TFxObserver *obs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_observers.insert(obs);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::removeObserver(TFxObserver *obs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_observers.erase(obs);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::notify(const TFxChange &change)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (std::set<tfxobserver *="">::iterator it = m_imp->m_observers.begin();</tfxobserver>
|
|
Toshihiro Shimizu |
890ddd |
it != m_imp->m_observers.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
(*it)->onChange(change);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::notify(const TFxPortAdded &change)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (std::set<tfxobserver *="">::iterator it = m_imp->m_observers.begin();</tfxobserver>
|
|
Toshihiro Shimizu |
890ddd |
it != m_imp->m_observers.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
(*it)->onChange(change);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::notify(const TFxPortRemoved &change)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (std::set<tfxobserver *="">::iterator it = m_imp->m_observers.begin();</tfxobserver>
|
|
Toshihiro Shimizu |
890ddd |
it != m_imp->m_observers.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
(*it)->onChange(change);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::notify(const TFxParamAdded &change)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (std::set<tfxobserver *="">::iterator it = m_imp->m_observers.begin();</tfxobserver>
|
|
Toshihiro Shimizu |
890ddd |
it != m_imp->m_observers.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
(*it)->onChange(change);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::notify(const TFxParamRemoved &change)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (std::set<tfxobserver *="">::iterator it = m_imp->m_observers.begin();</tfxobserver>
|
|
Toshihiro Shimizu |
890ddd |
it != m_imp->m_observers.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
(*it)->onChange(change);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
unsigned long TFx::getIdentifier() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_id;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::setIdentifier(unsigned long id)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_id = id;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::setNewIdentifier()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_id = ++m_imp->m_nextId;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::loadData(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
3bfa54 |
std::string tagName;
|
|
Toshihiro Shimizu |
890ddd |
VersionNumber tnzVersion = is.getVersion();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QList<int> groupIds;</int>
|
|
Shinya Kitaoka |
3bfa54 |
QList<std::wstring> groupNames;</std::wstring>
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "params") {
|
|
Toshihiro Shimizu |
890ddd |
while (!is.eos()) {
|
|
Shinya Kitaoka |
3bfa54 |
std::string paramName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(paramName)) {
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = getParams()->getParam(paramName);
|
|
Toshihiro Shimizu |
890ddd |
if (param)
|
|
Toshihiro Shimizu |
890ddd |
param->loadData(is);
|
|
Toshihiro Shimizu |
890ddd |
else // il parametro non e' presente -> skip
|
|
Toshihiro Shimizu |
890ddd |
skipChild(is);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "paramsLinkedTo") {
|
|
Toshihiro Shimizu |
890ddd |
TPersist *p = 0;
|
|
Toshihiro Shimizu |
890ddd |
is >> p;
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = dynamic_cast<tfx *="">(p);</tfx>
|
|
Toshihiro Shimizu |
890ddd |
if (fx == 0)
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Missing linkedSetRoot");
|
|
Toshihiro Shimizu |
890ddd |
linkParams(fx);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "ports") {
|
|
Shinya Kitaoka |
3bfa54 |
std::string portName;
|
|
Toshihiro Shimizu |
890ddd |
while (!is.eos()) {
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(portName)) {
|
|
Toshihiro Shimizu |
890ddd |
VersionNumber version = is.getVersion();
|
|
Toshihiro Shimizu |
890ddd |
compatibilityTranslatePort(version.first, version.second, portName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Try to find the specified port
|
|
Toshihiro Shimizu |
890ddd |
TFxPort *port = getInputPort(portName);
|
|
Toshihiro Shimizu |
890ddd |
if (!port) {
|
|
Toshihiro Shimizu |
890ddd |
// Scan dynamic port groups for a containing one - add a port there if found
|
|
Toshihiro Shimizu |
890ddd |
int g, gCount = dynamicPortGroupsCount();
|
|
Toshihiro Shimizu |
890ddd |
for (g = 0; g != gCount; ++g) {
|
|
Toshihiro Shimizu |
890ddd |
TFxPortDG *group = const_cast<tfxportdg *="">(dynamicPortGroup(g));</tfxportdg>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (group->contains(portName)) {
|
|
Toshihiro Shimizu |
890ddd |
addInputPort(portName, port = new TRasterFxPort, g);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Could not find (or add) a port with the corresponding name - throw
|
|
Toshihiro Shimizu |
890ddd |
if (!port)
|
|
Shinya Kitaoka |
3bfa54 |
throw TException(std::string("port '") + portName + "' is not present");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!is.eos()) {
|
|
Toshihiro Shimizu |
890ddd |
TPersist *p = 0;
|
|
Toshihiro Shimizu |
890ddd |
is >> p;
|
|
Toshihiro Shimizu |
890ddd |
TFx *fx = dynamic_cast<tfx *="">(p);</tfx>
|
|
Toshihiro Shimizu |
890ddd |
port->setFx(fx);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "dagNodePos") {
|
|
Toshihiro Shimizu |
890ddd |
TPointD p;
|
|
Toshihiro Shimizu |
890ddd |
is >> p.x >> p.y;
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_attributes.setDagNodePos(updateDagPosition(p, tnzVersion));
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "numberId") {
|
|
Toshihiro Shimizu |
890ddd |
int numberId = 0;
|
|
Toshihiro Shimizu |
890ddd |
is >> numberId;
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_attributes.setId(numberId);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "passiveCacheId") {
|
|
Toshihiro Shimizu |
890ddd |
int passiveCacheId = 0;
|
|
Toshihiro Shimizu |
890ddd |
is >> passiveCacheId;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(passiveCacheId > 0);
|
|
Toshihiro Shimizu |
890ddd |
TPassiveCacheManager::instance()->declareCached(this, passiveCacheId);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "name") {
|
|
Toshihiro Shimizu |
890ddd |
// passo attraverso un filepath solo per evitare i problemi di blank
|
|
Toshihiro Shimizu |
890ddd |
// o caratteri strani dentro il nome (sospetto che tfilepath sia gestito
|
|
Toshihiro Shimizu |
890ddd |
// correttamente mentre wstring no
|
|
Toshihiro Shimizu |
890ddd |
TFilePath tmp;
|
|
Toshihiro Shimizu |
890ddd |
is >> tmp;
|
|
Toshihiro Shimizu |
890ddd |
setName(tmp.getWideName());
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "fxId") {
|
|
Toshihiro Shimizu |
890ddd |
TFilePath tmp;
|
|
Toshihiro Shimizu |
890ddd |
is >> tmp;
|
|
Toshihiro Shimizu |
890ddd |
setFxId(tmp.getWideName());
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "enabled") {
|
|
Toshihiro Shimizu |
890ddd |
int flag = 1;
|
|
Toshihiro Shimizu |
890ddd |
is >> flag;
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_attributes.enable(flag != 0);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "opened") {
|
|
Toshihiro Shimizu |
890ddd |
int opened = 1;
|
|
Toshihiro Shimizu |
890ddd |
is >> opened;
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_attributes.setIsOpened(opened);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "groupIds") {
|
|
Toshihiro Shimizu |
890ddd |
int groupId;
|
|
Toshihiro Shimizu |
890ddd |
while (!is.eos()) {
|
|
Toshihiro Shimizu |
890ddd |
is >> groupId;
|
|
Toshihiro Shimizu |
890ddd |
groupIds.append(groupId);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "groupNames") {
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring groupName;
|
|
Toshihiro Shimizu |
890ddd |
while (!is.eos()) {
|
|
Toshihiro Shimizu |
890ddd |
is >> groupName;
|
|
Toshihiro Shimizu |
890ddd |
groupNames.append(groupName);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Unknown tag!");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (!groupIds.isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
assert(groupIds.size() == groupNames.size());
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < groupIds.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_attributes.setGroupId(groupIds[i]);
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_attributes.setGroupName(groupNames[i]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::saveData(TOStream &os)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFx *linkedSetRoot = this;
|
|
Toshihiro Shimizu |
890ddd |
if (m_imp->m_next != m_imp) {
|
|
Toshihiro Shimizu |
890ddd |
TFxImp *imp = m_imp->m_next;
|
|
Toshihiro Shimizu |
890ddd |
int guard = 0;
|
|
Toshihiro Shimizu |
890ddd |
while (guard++ < 1000 && imp != m_imp) {
|
|
Toshihiro Shimizu |
890ddd |
if (imp->m_fx < linkedSetRoot)
|
|
Toshihiro Shimizu |
890ddd |
linkedSetRoot = imp->m_fx;
|
|
Toshihiro Shimizu |
890ddd |
imp = imp->m_next;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
assert(imp == m_imp);
|
|
Toshihiro Shimizu |
890ddd |
assert(linkedSetRoot);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (linkedSetRoot == this) {
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("params");
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < getParams()->getParamCount(); i++) {
|
|
Shinya Kitaoka |
3bfa54 |
std::string paramName = getParams()->getParamName(i);
|
|
Toshihiro Shimizu |
890ddd |
TParam *param = getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
os.openChild(paramName);
|
|
Toshihiro Shimizu |
890ddd |
param->saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("paramsLinkedTo");
|
|
Toshihiro Shimizu |
890ddd |
os << linkedSetRoot;
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("ports");
|
|
Toshihiro Shimizu |
890ddd |
for (PortTable::iterator pit = m_imp->m_portTable.begin();
|
|
Toshihiro Shimizu |
890ddd |
pit != m_imp->m_portTable.end(); ++pit) {
|
|
Toshihiro Shimizu |
890ddd |
os.openChild(pit->first);
|
|
Toshihiro Shimizu |
890ddd |
if (pit->second->isConnected())
|
|
Toshihiro Shimizu |
890ddd |
os << TFxP(pit->second->getFx()).getPointer();
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPointD p = m_imp->m_attributes.getDagNodePos();
|
|
Toshihiro Shimizu |
890ddd |
if (p != TConst::nowhere)
|
|
Toshihiro Shimizu |
890ddd |
os.child("dagNodePos") << p.x << p.y;
|
|
Toshihiro Shimizu |
890ddd |
int numberId = m_imp->m_attributes.getId();
|
|
Toshihiro Shimizu |
890ddd |
os.child("numberId") << numberId;
|
|
Toshihiro Shimizu |
890ddd |
bool cacheEnabled = TPassiveCacheManager::instance()->cacheEnabled(this);
|
|
Toshihiro Shimizu |
890ddd |
if (cacheEnabled)
|
|
Toshihiro Shimizu |
890ddd |
os.child("passiveCacheId") << TPassiveCacheManager::instance()->getPassiveCacheId(this);
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring name = getName();
|
|
Toshihiro Shimizu |
890ddd |
if (name != L"")
|
|
Toshihiro Shimizu |
890ddd |
os.child("name") << TFilePath(name);
|
|
Shinya Kitaoka |
3bfa54 |
std::wstring fxId = getFxId();
|
|
Toshihiro Shimizu |
890ddd |
os.child("fxId") << fxId;
|
|
Toshihiro Shimizu |
890ddd |
if (!m_imp->m_attributes.isEnabled())
|
|
Toshihiro Shimizu |
890ddd |
os.child("enabled") << 0;
|
|
Toshihiro Shimizu |
890ddd |
os.child("opened") << (int)m_imp->m_attributes.isOpened();
|
|
Toshihiro Shimizu |
890ddd |
if (m_imp->m_attributes.isGrouped()) {
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("groupIds");
|
|
Toshihiro Shimizu |
890ddd |
QStack<int> groupIdStack = m_imp->m_attributes.getGroupIdStack();</int>
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < groupIdStack.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
os << groupIdStack[i];
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("groupNames");
|
|
Shinya Kitaoka |
3bfa54 |
QStack<std::wstring> groupNameStack = m_imp->m_attributes.getGroupNameStack();</std::wstring>
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < groupNameStack.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
os << groupNameStack[i];
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::loadPreset(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
3bfa54 |
std::string tagName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "dvpreset") {
|
|
Shinya Kitaoka |
3bfa54 |
std::string fxId = is.getTagAttribute("fxId");
|
|
Toshihiro Shimizu |
890ddd |
if (fxId != getFxType())
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Preset doesn't match the fx type");
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "params") {
|
|
Toshihiro Shimizu |
890ddd |
while (!is.eos()) {
|
|
Shinya Kitaoka |
3bfa54 |
std::string paramName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.openChild(paramName)) {
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
TParamP param = getParams()->getParam(paramName);
|
|
Toshihiro Shimizu |
890ddd |
param->loadData(is);
|
|
Toshihiro Shimizu |
890ddd |
} catch (TException &) { /*skip*/
|
|
Toshihiro Shimizu |
890ddd |
} // il parametro non e' presente
|
|
Toshihiro Shimizu |
890ddd |
is.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Fx preset unknown tag!");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::savePreset(TOStream &os)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
3bfa54 |
std::map<std::string, std::string=""> attributes;</std::string,>
|
|
Shinya Kitaoka |
3bfa54 |
attributes.insert(std::make_pair(std::string("ver"), std::string("1.0")));
|
|
Shinya Kitaoka |
3bfa54 |
attributes.insert(std::make_pair(std::string("fxId"), getFxType()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("dvpreset", attributes);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("params");
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < getParams()->getParamCount(); i++) {
|
|
Shinya Kitaoka |
3bfa54 |
std::string paramName = getParams()->getParamName(i);
|
|
Toshihiro Shimizu |
890ddd |
TParam *param = getParams()->getParam(i);
|
|
Toshihiro Shimizu |
890ddd |
os.openChild(paramName);
|
|
Toshihiro Shimizu |
890ddd |
param->saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::disconnectAll()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int p, pCount = getInputPortCount();
|
|
Toshihiro Shimizu |
890ddd |
for (p = 0; p != pCount; ++p)
|
|
Toshihiro Shimizu |
890ddd |
getInputPort(p)->setFx(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
TFx *TFx::create(std::string name)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TFxFactory::instance()->create(name);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFx::listFxs(std::vector<tfxinfo> &info)</tfxinfo>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFxFactory::instance()->getFxInfos(info);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxInfo TFx::getFxInfo(const std::string &fxIdentifier)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TFxFactory::instance()->getFxInfo(fxIdentifier);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *TFx::getLinkedFx() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->m_next);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->m_next->m_prev == m_imp);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_imp->m_next->m_fx != 0);
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_next->m_fx;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// TFxTimeRegion
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Creates an unlimited time region.
|
|
Toshihiro Shimizu |
890ddd |
TFxTimeRegion::TFxTimeRegion()
|
|
Toshihiro Shimizu |
890ddd |
: m_start((std::numeric_limits<double>::max)()), m_end(-(std::numeric_limits<double>::max)())</double></double>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Creates a time region with specified start (included) and end (\b excluded).
|
|
Toshihiro Shimizu |
890ddd |
TFxTimeRegion::TFxTimeRegion(double start, double end)
|
|
Toshihiro Shimizu |
890ddd |
: m_start(start), m_end(end)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFxTimeRegion TFxTimeRegion::createUnlimited()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TFxTimeRegion(
|
|
Toshihiro Shimizu |
890ddd |
-(std::numeric_limits<double>::max)(),</double>
|
|
Toshihiro Shimizu |
890ddd |
(std::numeric_limits<double>::max)());</double>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFxTimeRegion::contains(double time) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (m_start <= time && time < m_end);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFxTimeRegion::isUnlimited() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (m_start == -(std::numeric_limits<double>::max)() ||</double>
|
|
Toshihiro Shimizu |
890ddd |
m_end == (std::numeric_limits<double>::max)());</double>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFxTimeRegion::isEmpty() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (m_end <= m_start);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFxTimeRegion::getFrameCount(int &count) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (isUnlimited())
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
count = tfloor(m_end) - tceil(m_start);
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TFxTimeRegion::getFirstFrame() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return tceil(m_start);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TFxTimeRegion::getLastFrame() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_end == (std::numeric_limits<double>::max)())</double>
|
|
Toshihiro Shimizu |
890ddd |
return (std::numeric_limits<int>::max)();</int>
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
return tceil(m_end) - 1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================
|