Remove tcg_function_types.h (#2772)
This commit is contained in:
parent
dd5fb60491
commit
91a93e2575
16 changed files with 123 additions and 375 deletions
|
@ -3,9 +3,6 @@
|
|||
// TnzCore includes
|
||||
#include "tstream.h"
|
||||
|
||||
// tcg includes
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
// STD includes
|
||||
#include <typeinfo>
|
||||
|
||||
|
@ -26,16 +23,13 @@ TPersistSet::~TPersistSet() {
|
|||
//------------------------------------------------------------------
|
||||
|
||||
void TPersistSet::insert(std::unique_ptr<TPersist> object) {
|
||||
struct locals {
|
||||
inline static bool sameType(TPersist *a, TPersist *b) {
|
||||
return (typeid(*a) == typeid(*b));
|
||||
}
|
||||
auto const sameType = [&object](TPersist *x) {
|
||||
return typeid(*object.get()) == typeid(*x);
|
||||
};
|
||||
|
||||
// Remove any object with the same type id
|
||||
std::vector<TPersist *>::iterator pt =
|
||||
std::remove_if(m_objects.begin(), m_objects.end(),
|
||||
tcg::bind1st(&locals::sameType, object.get()));
|
||||
std::remove_if(m_objects.begin(), m_objects.end(), sameType);
|
||||
|
||||
std::for_each(pt, m_objects.end(), std::default_delete<TPersist>());
|
||||
m_objects.erase(pt, m_objects.end());
|
||||
|
|
|
@ -1,183 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef TCG_FUNCTION_TYPES_H
|
||||
#define TCG_FUNCTION_TYPES_H
|
||||
|
||||
// tcg includes
|
||||
#include "traits.h"
|
||||
|
||||
// STD includes
|
||||
#include <functional>
|
||||
|
||||
/*!
|
||||
\file function_types.h
|
||||
|
||||
\brief This file contains some template class types useful to convert
|
||||
functions
|
||||
into functors <I> at compile-time <\I>, with minimal memory
|
||||
overhead.
|
||||
*/
|
||||
|
||||
namespace tcg {
|
||||
|
||||
//************************************************************************************
|
||||
// Function Objects definition
|
||||
//************************************************************************************
|
||||
|
||||
template <typename Func, Func f>
|
||||
struct function;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
template <typename Ret, Ret (*f)()>
|
||||
struct function<Ret (*)(), f> : public std::unary_function<void, Ret> {
|
||||
Ret operator()() const { return f(); }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
template <typename Ret, typename Arg, Ret (*f)(Arg)>
|
||||
struct function<Ret (*)(Arg), f> : public std::unary_function<Arg, Ret> {
|
||||
Ret operator()(Arg arg) const { return f(arg); }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
template <typename Ret, typename Arg1, typename Arg2, Ret (*f)(Arg1, Arg2)>
|
||||
struct function<Ret (*)(Arg1, Arg2), f>
|
||||
: public std::binary_function<Arg1, Arg2, Ret> {
|
||||
Ret operator()(Arg1 arg1, Arg2 arg2) const { return f(arg1, arg2); }
|
||||
};
|
||||
|
||||
//************************************************************************************
|
||||
// Member Function Objects definition
|
||||
//************************************************************************************
|
||||
|
||||
template <typename C, typename Ret, Ret (C::*f)()>
|
||||
struct function<Ret (C::*)(), f> : public std::unary_function<C &, Ret> {
|
||||
Ret operator()(C &c) const { return (c.*f)(); }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
template <typename C, typename Ret, Ret (C::*f)() const>
|
||||
struct function<Ret (C::*)() const, f>
|
||||
: public std::unary_function<const C &, Ret> {
|
||||
Ret operator()(const C &c) const { return (c.*f)(); }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
template <typename C, typename Ret, typename Arg, Ret (C::*f)(Arg)>
|
||||
struct function<Ret (C::*)(Arg), f>
|
||||
: public std::binary_function<C &, Arg, Ret> {
|
||||
Ret operator()(C &c, Arg arg) const { return (c.*f)(arg); }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
template <typename C, typename Ret, typename Arg, Ret (C::*f)(Arg) const>
|
||||
struct function<Ret (C::*)(Arg) const, f>
|
||||
: public std::binary_function<const C &, Arg, Ret> {
|
||||
Ret operator()(const C &c, Arg arg) const { return (c.*f)(arg); }
|
||||
};
|
||||
|
||||
//************************************************************************************
|
||||
// Binder functors
|
||||
//************************************************************************************
|
||||
|
||||
/*!
|
||||
\brief Binary function object binder generalizing \p std::binder1st with
|
||||
an explicitly specifiable bound type.
|
||||
|
||||
\note Unlike std::binder1st, this binder accepts functors whose arguments
|
||||
are reference types.
|
||||
|
||||
\sa Helper function tcg::bind1st().
|
||||
|
||||
\remark This class currently <I>adds an additional arguments copy</I>.
|
||||
Be warned of this when using heavyweight argument types.
|
||||
*/
|
||||
|
||||
template <class Func, typename Arg = typename function_traits<Func>::arg1_type>
|
||||
class binder1st
|
||||
: public std::unary_function<
|
||||
typename function_traits<Func>::arg2_type, // Forward function types
|
||||
typename function_traits<Func>::ret_type> //
|
||||
{
|
||||
public:
|
||||
binder1st(const Func &func, Arg arg1) : m_func(func), m_arg1(arg1) {}
|
||||
|
||||
typename function_traits<Func>::ret_type operator()(
|
||||
typename function_traits<Func>::arg2_type arg2)
|
||||
const // NOTE: Double copy
|
||||
{
|
||||
return m_func(m_arg1, arg2);
|
||||
}
|
||||
|
||||
protected:
|
||||
Func m_func;
|
||||
Arg m_arg1;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
template <class Func, typename Arg = typename function_traits<Func>::arg2_type>
|
||||
class binder2nd
|
||||
: public std::unary_function<typename function_traits<Func>::arg1_type,
|
||||
typename function_traits<Func>::ret_type> {
|
||||
public:
|
||||
binder2nd(const Func &func, Arg arg2) : m_func(func), m_arg2(arg2) {}
|
||||
|
||||
typename function_traits<Func>::ret_type operator()(
|
||||
typename function_traits<Func>::arg1_type arg1) const {
|
||||
return m_func(arg1, m_arg2);
|
||||
}
|
||||
|
||||
protected:
|
||||
Func m_func;
|
||||
Arg m_arg2;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*!
|
||||
\brief Helper function for the creation of binder objects with automatic
|
||||
type deduction.
|
||||
|
||||
\warning Unlike std::bind1st, the bound argument type is the one <I>declared
|
||||
by the function object</I>. This is typically a commodity, but
|
||||
be aware of the subtle implications:
|
||||
|
||||
\li Only parameters copied by value result in a copied
|
||||
bound argument.
|
||||
\li Avoid temporaries as bound reference arguments.
|
||||
|
||||
\sa Class tcg::binder1st.
|
||||
*/
|
||||
|
||||
template <typename Func, typename Arg>
|
||||
inline binder1st<Func> bind1st(const Func &func, const Arg &arg1) {
|
||||
return binder1st<Func>(func, arg1);
|
||||
}
|
||||
|
||||
template <typename Func, typename Arg>
|
||||
inline binder1st<Func> bind1st(const Func &func, Arg &arg1) {
|
||||
return binder1st<Func>(func, arg1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
template <typename Func, typename Arg>
|
||||
inline binder2nd<Func> bind2nd(const Func &func, const Arg &arg2) {
|
||||
return binder2nd<Func>(func, arg2);
|
||||
}
|
||||
|
||||
template <typename Func, typename Arg>
|
||||
inline binder2nd<Func> bind2nd(const Func &func, Arg &arg2) {
|
||||
return binder2nd<Func>(func, arg2);
|
||||
}
|
||||
|
||||
} // namespace tcg
|
||||
|
||||
#endif // TCG_FUNCTION_TYPES_H
|
|
@ -1,3 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "function_types.h"
|
|
@ -29,9 +29,6 @@
|
|||
// Glew include
|
||||
#include <GL/glew.h>
|
||||
|
||||
// tcg includes
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
// Boost includes
|
||||
#include <boost/any.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
@ -953,12 +950,9 @@ void ShaderFx::doCompute(TTile &tile, double frame,
|
|||
}
|
||||
|
||||
~TexturesStorage() {
|
||||
typedef tcg::function<void (ShadingContext::*)(GLuint),
|
||||
&ShadingContext::unloadTexture>
|
||||
UnloadFunc;
|
||||
|
||||
std::for_each(m_texIds.begin(), m_texIds.end(),
|
||||
tcg::bind1st(UnloadFunc(), m_ctx));
|
||||
for (auto const &texId : m_texIds) {
|
||||
m_ctx.unloadTexture(texId);
|
||||
}
|
||||
}
|
||||
|
||||
void load(const TRasterP &ras, GLuint texUnit) {
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
// tcg includes
|
||||
#include "tcg/tcg_misc.h"
|
||||
#include "tcg/tcg_pool.h"
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
#include "ext/plasticskeleton.h"
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
// tcg includes
|
||||
#include "tcg/tcg_misc.h"
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
// STL includes
|
||||
#include <memory>
|
||||
|
@ -645,24 +644,14 @@ int PlasticSkeletonDeformation::skeletonsCount() const {
|
|||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
namespace skeletonIds {
|
||||
typedef boost::bimap<int, PlasticSkeletonP>::left_map::const_iterator iter_type;
|
||||
typedef iter_type::value_type value_type;
|
||||
|
||||
inline int func_(const value_type &val) { return val.first; }
|
||||
}
|
||||
} // namespace ::skeletonIds
|
||||
|
||||
void PlasticSkeletonDeformation::skeletonIds(skelId_iterator &begin,
|
||||
skelId_iterator &end) const {
|
||||
using namespace ::skeletonIds;
|
||||
auto const f = [](const SkeletonSet::left_map::value_type &val) {
|
||||
return val.first;
|
||||
};
|
||||
|
||||
typedef tcg::function<int (*)(const value_type &), func_> func;
|
||||
typedef boost::transform_iterator<func, iter_type> adapt_it;
|
||||
|
||||
begin = adapt_it(m_imp->m_skeletons.left.begin());
|
||||
end = adapt_it(m_imp->m_skeletons.left.end());
|
||||
begin = boost::make_transform_iterator(m_imp->m_skeletons.left.begin(), f);
|
||||
end = boost::make_transform_iterator(m_imp->m_skeletons.left.end(), f);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -744,54 +733,34 @@ SkVD *PlasticSkeletonDeformation::vertexDeformation(int skelId, int v) const {
|
|||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
namespace vertexDeformations {
|
||||
inline std::pair<const QString *, SkVD *> func_(const VDKey &vdKey) {
|
||||
return std::make_pair(&vdKey.m_name, &vdKey.m_vd);
|
||||
}
|
||||
}
|
||||
} // namespace ::vertexDeformations
|
||||
|
||||
void PlasticSkeletonDeformation::vertexDeformations(vd_iterator &begin,
|
||||
vd_iterator &end) const {
|
||||
using namespace ::vertexDeformations;
|
||||
auto const f = [](const VDKey &vdKey) {
|
||||
return std::make_pair(&vdKey.m_name, &vdKey.m_vd);
|
||||
};
|
||||
|
||||
typedef std::pair<const QString *, SkVD *> (*func_type)(const VDKey &vdKey);
|
||||
typedef tcg::function<func_type, func_> func;
|
||||
typedef boost::transform_iterator<func, SkVDSet::const_iterator> adapt_it;
|
||||
|
||||
begin = adapt_it(m_imp->m_vds.begin());
|
||||
end = adapt_it(m_imp->m_vds.end());
|
||||
begin = boost::make_transform_iterator(m_imp->m_vds.begin(), f);
|
||||
end = boost::make_transform_iterator(m_imp->m_vds.end(), f);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
namespace vdSkeletonVertices {
|
||||
inline std::pair<int, int> func_(const std::map<int, int>::value_type &val) {
|
||||
return std::make_pair(val.first, val.second);
|
||||
}
|
||||
}
|
||||
} // namespace ::vdSkeletonVertices
|
||||
|
||||
void PlasticSkeletonDeformation::vdSkeletonVertices(const QString &vertexName,
|
||||
vx_iterator &begin,
|
||||
vx_iterator &end) const {
|
||||
using namespace ::vdSkeletonVertices;
|
||||
|
||||
typedef std::pair<int, int> (*func_type)(
|
||||
const std::map<int, int>::value_type &);
|
||||
typedef tcg::function<func_type, func_> func;
|
||||
typedef boost::transform_iterator<func, std::map<int, int>::const_iterator>
|
||||
adapt_it;
|
||||
auto const f = [](const std::map<int, int>::value_type &val) {
|
||||
return std::make_pair(val.first, val.second);
|
||||
};
|
||||
|
||||
SkVDSet::const_iterator nt(m_imp->m_vds.find(vertexName));
|
||||
|
||||
if (nt == m_imp->m_vds.end())
|
||||
begin = adapt_it(), end = adapt_it();
|
||||
else
|
||||
begin = adapt_it(nt->m_vIndices.begin()),
|
||||
end = adapt_it(nt->m_vIndices.end());
|
||||
if (nt == m_imp->m_vds.end()) {
|
||||
begin = vx_iterator();
|
||||
end = vx_iterator();
|
||||
} else {
|
||||
begin = boost::make_transform_iterator(nt->m_vIndices.begin(), f);
|
||||
end = boost::make_transform_iterator(nt->m_vIndices.end(), f);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "tcg/tcg_macros.h"
|
||||
#include "tcg/tcg_point_ops.h"
|
||||
#include "tcg/tcg_list.h"
|
||||
#include "tcg/tcg_function_types.h"
|
||||
#include "tcg/tcg_iterator_ops.h"
|
||||
|
||||
//****************************************************************************************
|
||||
|
@ -761,11 +760,9 @@ PlasticSkeletonP PlasticTool::skeleton() const {
|
|||
//------------------------------------------------------------------------
|
||||
|
||||
PlasticSkeleton &PlasticTool::deformedSkeleton() {
|
||||
typedef tcg::function<void (PlasticTool::*)(PlasticSkeleton &),
|
||||
&PlasticTool::updateDeformedSkeleton>
|
||||
Func;
|
||||
|
||||
return m_deformedSkeleton(tcg::bind1st(Func(), *this));
|
||||
return m_deformedSkeleton([this](PlasticSkeleton &deformedSkeleton) {
|
||||
updateDeformedSkeleton(deformedSkeleton);
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
// tcg includes
|
||||
#include "tcg/tcg_point_ops.h"
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
#include "plastictool.h"
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
// tcg includes
|
||||
#include "tcg/tcg_macros.h"
|
||||
#include "tcg/tcg_point_ops.h"
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
// boost includes
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
@ -257,8 +256,9 @@ bool buildEdgeCuts(const TMeshImage &mi,
|
|||
static int testSingleMesh(const edges_container &edges) {
|
||||
assert(!edges.empty());
|
||||
return (std::find_if(edges.begin(), edges.end(),
|
||||
tcg::bind2nd(&differentMesh, edges.front())) ==
|
||||
edges.end())
|
||||
[&edges](const MeshIndex &x) {
|
||||
return differentMesh(x, edges.front());
|
||||
}) == edges.end())
|
||||
? edges.front().m_meshIdx
|
||||
: -1;
|
||||
}
|
||||
|
@ -318,7 +318,8 @@ bool buildEdgeCuts(const TMeshImage &mi,
|
|||
// one)
|
||||
int *ept, *epEnd = endPoints + 2;
|
||||
|
||||
ept = std::find_if(endPoints, epEnd, tcg::bind1st(&borderVertex, mesh));
|
||||
ept = std::find_if(endPoints, epEnd,
|
||||
[&mesh](int v) { return borderVertex(mesh, v); });
|
||||
if (ept == epEnd) {
|
||||
// There is no boundary endpoint
|
||||
if (edges.size() < 2) // We should not cut the mesh on a
|
||||
|
@ -568,8 +569,9 @@ void splitMesh(TMeshImage &mi, int meshIdx, int lastBoundaryVertex) {
|
|||
{
|
||||
const vertex_type &lbVx = mesh.vertex(lastBoundaryVertex);
|
||||
|
||||
vertex_type::edges_const_iterator et = std::find_if(
|
||||
lbVx.edgesBegin(), lbVx.edgesEnd(), tcg::bind1st(&borderEdge, mesh));
|
||||
vertex_type::edges_const_iterator et =
|
||||
std::find_if(lbVx.edgesBegin(), lbVx.edgesEnd(),
|
||||
[&mesh](int e) { return borderEdge(mesh, e); });
|
||||
assert(et != lbVx.edgesEnd());
|
||||
|
||||
e = *et;
|
||||
|
@ -619,7 +621,9 @@ bool cutMesh(TMeshImage &mi, const PlasticTool::MeshSelection &edgesSelection) {
|
|||
}
|
||||
|
||||
// Cut edges, in the order specified by edgeCuts
|
||||
std::for_each(ecBegin, edgeCuts.end(), tcg::bind1st(&cutEdge, mesh));
|
||||
std::for_each(ecBegin, edgeCuts.end(), [&mesh](const EdgeCut &edgeCut) {
|
||||
return cutEdge(mesh, edgeCut);
|
||||
});
|
||||
|
||||
// Finally, the mesh could have been split in 2 - we need to separate
|
||||
// the pieces if needed
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
|
||||
// tcg includes
|
||||
#include "tcg/tcg_numeric_ops.h"
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
// boost includes
|
||||
#include <boost/iterator/counting_iterator.hpp>
|
||||
|
@ -1013,31 +1012,28 @@ AdjustThicknessUndo::AdjustThicknessUndo(const SelectionData &selData,
|
|||
//--------------------------------------------------------------
|
||||
|
||||
void AdjustThicknessUndo::redo() const {
|
||||
struct locals {
|
||||
static void processFrame(const AdjustThicknessUndo &undo, int frameIdx) {
|
||||
TXshSimpleLevel *sl = undo.m_selData.m_sl.getPointer();
|
||||
assert(sl);
|
||||
auto const processFrame = [this](int frameIdx) {
|
||||
TXshSimpleLevel *sl = m_selData.m_sl.getPointer();
|
||||
assert(sl);
|
||||
|
||||
const TFrameId &fid = sl->index2fid(frameIdx);
|
||||
const TFrameId &fid = sl->index2fid(frameIdx);
|
||||
|
||||
// Backup input frame
|
||||
TVectorImageP viIn = sl->getFullsampledFrame(fid, false);
|
||||
if (!viIn) return;
|
||||
// Backup input frame
|
||||
TVectorImageP viIn = sl->getFullsampledFrame(fid, false);
|
||||
if (!viIn) return;
|
||||
|
||||
undo.m_originalImages.push_back(ImageBackup(fid, viIn));
|
||||
m_originalImages.push_back(ImageBackup(fid, viIn));
|
||||
|
||||
// Process required frame
|
||||
TVectorImageP viOut = ::processFrame(
|
||||
undo.m_selData, frameIdx, undo.m_fromTransform, undo.m_toTransform);
|
||||
// Process required frame
|
||||
TVectorImageP viOut = ::processFrame(
|
||||
m_selData, frameIdx, m_fromTransform, m_toTransform);
|
||||
|
||||
sl->setFrame(fid, viOut);
|
||||
sl->setFrame(fid, viOut);
|
||||
|
||||
// Ensure the level data is invalidated suitably
|
||||
sl->setDirtyFlag(true);
|
||||
IconGenerator::instance()->invalidate(sl, fid);
|
||||
}
|
||||
|
||||
}; // locals
|
||||
// Ensure the level data is invalidated suitably
|
||||
sl->setDirtyFlag(true);
|
||||
IconGenerator::instance()->invalidate(sl, fid);
|
||||
};
|
||||
|
||||
m_originalImages.clear();
|
||||
|
||||
|
@ -1047,11 +1043,11 @@ void AdjustThicknessUndo::redo() const {
|
|||
std::for_each(
|
||||
boost::make_counting_iterator(0),
|
||||
boost::make_counting_iterator(m_selData.m_sl->getFrameCount()),
|
||||
tcg::bind1st(&locals::processFrame, *this));
|
||||
processFrame);
|
||||
break;
|
||||
case SelectionData::SELECTED_FRAMES:
|
||||
std::for_each(m_selData.m_frameIdxs.begin(), m_selData.m_frameIdxs.end(),
|
||||
tcg::bind1st(&locals::processFrame, *this));
|
||||
processFrame);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,9 +52,6 @@
|
|||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
// tcg includes
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
//*************************************************************************
|
||||
|
@ -63,11 +60,6 @@
|
|||
|
||||
namespace {
|
||||
|
||||
bool filterNegatives(int c) { return (c < 0); }
|
||||
typedef tcg::function<bool (*)(int), filterNegatives> filterNegatives_fun;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool canRemoveFx(const std::set<TFx *> &leaves, TFx *fx) {
|
||||
bool removeFx = false;
|
||||
for (int i = 0; i < fx->getInputPortCount(); i++) {
|
||||
|
|
|
@ -30,9 +30,6 @@
|
|||
#include <QButtonGroup>
|
||||
#include <QRadioButton>
|
||||
|
||||
// tcg includes
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
// boost includes
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
|
@ -209,20 +206,16 @@ static const FormatData l_formatDatas[] = {
|
|||
typedef std::pair<Resource::Path, int> RsrcKey;
|
||||
typedef std::map<RsrcKey, Resource::CompSeq> RsrcMap;
|
||||
|
||||
bool differentPath(const RsrcMap::value_type &a, const RsrcMap::value_type &b) {
|
||||
auto const differentPath = [](const RsrcMap::value_type &a,
|
||||
const RsrcMap::value_type &b) -> bool {
|
||||
return (a.first.first < b.first.first) || (b.first.first < a.first.first);
|
||||
}
|
||||
};
|
||||
|
||||
struct buildResources_locals {
|
||||
static bool isValid(const RsrcMap::value_type &rsrcVal) {
|
||||
return (isLoadable(rsrcVal.first.first.m_relFp) && !rsrcVal.second.empty());
|
||||
}
|
||||
|
||||
typedef tcg::function<bool (*)(const RsrcMap::value_type &,
|
||||
const RsrcMap::value_type &),
|
||||
&differentPath>
|
||||
DifferentPath;
|
||||
|
||||
static Resource toResource(const RsrcMap::value_type &rsrcVal) {
|
||||
return Resource(rsrcVal.first.first, rsrcVal.second);
|
||||
}
|
||||
|
@ -334,12 +327,11 @@ void buildResources(std::vector<Resource> &resources, const TFilePath &rootPath,
|
|||
for (rt = rsrcMap.begin(); rt != rEnd; ++rt) locals::mergeInto(rt, rsrcMap);
|
||||
|
||||
// Export valid data into the output resources collection
|
||||
boost::copy(
|
||||
rsrcMap | boost::adaptors::filtered(locals::isValid) |
|
||||
boost::adaptors::adjacent_filtered(
|
||||
locals::DifferentPath()) // E.g. A.xxxx.tga and Axxxx.tga
|
||||
| boost::adaptors::transformed(locals::toResource),
|
||||
std::back_inserter(resources));
|
||||
boost::copy(rsrcMap | boost::adaptors::filtered(locals::isValid) |
|
||||
boost::adaptors::adjacent_filtered(
|
||||
differentPath) // E.g. A.xxxx.tga and Axxxx.tga
|
||||
| boost::adaptors::transformed(locals::toResource),
|
||||
std::back_inserter(resources));
|
||||
}
|
||||
|
||||
// Look for level options associated to each level
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
// tcg includes
|
||||
#include "tcg/tcg_macros.h"
|
||||
#include "tcg/tcg_base.h"
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -742,9 +741,6 @@ namespace {
|
|||
bool containsInputFx(const QList<TFxP> &fxs, const TFxCommand::Link &link) {
|
||||
return fxs.contains(link.m_inputFx);
|
||||
}
|
||||
typedef tcg::function<bool (*)(const QList<TFxP> &, const TFxCommand::Link &),
|
||||
containsInputFx>
|
||||
ContainsInputFx_fun;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -797,7 +793,9 @@ void InsertFxUndo::initialize(const TFxP &newFx, int row, int col) {
|
|||
m_selectedLinks.end());
|
||||
m_selectedLinks.erase(
|
||||
std::remove_if(m_selectedLinks.begin(), m_selectedLinks.end(),
|
||||
tcg::bind1st(::ContainsInputFx_fun(), m_selectedFxs)),
|
||||
[this](const TFxCommand::Link &link) {
|
||||
return containsInputFx(m_selectedFxs, link);
|
||||
}),
|
||||
m_selectedLinks.end());
|
||||
|
||||
// Build an fx for each of the specified inputs
|
||||
|
@ -1864,7 +1862,9 @@ void DeleteLinksUndo::initialize() {
|
|||
|
||||
// Remove invalid links
|
||||
m_links.erase(std::remove_if(m_links.begin(), m_links.end(),
|
||||
tcg::bind1st(&locals::isInvalid, fxDag)),
|
||||
[fxDag](const TFxCommand::Link &link) {
|
||||
return locals::isInvalid(fxDag, link);
|
||||
}),
|
||||
m_links.end());
|
||||
|
||||
std::list<TFxCommand::Link>::iterator lt, lEnd(m_links.end());
|
||||
|
@ -2502,14 +2502,6 @@ void UndoPasteFxs::initialize(const std::map<TFx *, int> &zeraryFxColumnSize,
|
|||
fx->renamePort(qPortName.toStdString(), qNewPortName.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
static bool circularSubxsheet(TXsheet *xsh, const TXshColumnP &col) {
|
||||
return xsh->checkCircularReferences(col.getPointer());
|
||||
}
|
||||
|
||||
static void push_back(std::vector<TFx *> &fxs, TFx *fx) {
|
||||
fxs.push_back(fx);
|
||||
}
|
||||
};
|
||||
|
||||
TXsheet *xsh = m_xshHandle->getXsheet();
|
||||
|
@ -2590,9 +2582,12 @@ void UndoPasteFxs::initialize(const std::map<TFx *, int> &zeraryFxColumnSize,
|
|||
}
|
||||
|
||||
// Filter columns
|
||||
m_columns.erase(std::remove_if(m_columns.begin(), m_columns.end(),
|
||||
tcg::bind1st(&locals::circularSubxsheet, xsh)),
|
||||
m_columns.end());
|
||||
auto const circularSubxsheet = [xsh](const TXshColumnP &col) -> bool {
|
||||
return xsh->checkCircularReferences(col.getPointer());
|
||||
};
|
||||
m_columns.erase(
|
||||
std::remove_if(m_columns.begin(), m_columns.end(), circularSubxsheet),
|
||||
m_columns.end());
|
||||
|
||||
// Initialize columns
|
||||
std::list<TXshColumnP>::const_iterator ct, cEnd(m_columns.end());
|
||||
|
@ -2608,7 +2603,7 @@ void UndoPasteFxs::initialize(const std::map<TFx *, int> &zeraryFxColumnSize,
|
|||
std::vector<TFx *> fxs;
|
||||
fxs.reserve(m_fxs.size() + m_columns.size());
|
||||
|
||||
for_each_fx(tcg::bind1st(&locals::push_back, fxs));
|
||||
for_each_fx([&fxs](TFx *fx) { fxs.push_back(fx); });
|
||||
|
||||
// We need to store input links for these fxs
|
||||
size_t f, fCount = fxs.size();
|
||||
|
@ -2798,9 +2793,9 @@ void UndoAddPasteFxs::initialize(TFx *inFx) {
|
|||
m_linkIn = TFxCommand::Link(inFx, ifx, 0);
|
||||
|
||||
// Furthermore, clone the group stack from inFx into each inserted fx
|
||||
typedef tcg::function<void (*)(TFx *, TFx *), FxCommandUndo::cloneGroupStack>
|
||||
clone_fun;
|
||||
for_each_fx(tcg::bind1st(clone_fun(), inFx));
|
||||
auto const clone_fun = static_cast<void (*)(TFx *, TFx *)>(FxCommandUndo::cloneGroupStack);
|
||||
for_each_fx(
|
||||
[inFx, clone_fun](TFx *toFx) { clone_fun(inFx, toFx); });
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
|
@ -2813,11 +2808,10 @@ void UndoAddPasteFxs::redo() const {
|
|||
FxCommandUndo::attach(xsh, m_linkIn, false);
|
||||
|
||||
// Copiare l'indice di gruppo dell'fx di input
|
||||
typedef tcg::function<void (*)(TFx *, TFx *),
|
||||
FxCommandUndo::copyGroupEditLevel>
|
||||
copy_fun;
|
||||
for_each_fx(
|
||||
tcg::binder1st<copy_fun>(copy_fun(), m_linkIn.m_inputFx.getPointer()));
|
||||
auto const copy_fun = static_cast<void (*)(TFx *, TFx *)>(FxCommandUndo::copyGroupEditLevel);
|
||||
for_each_fx([this, copy_fun](TFx *toFx) {
|
||||
copy_fun(m_linkIn.m_inputFx.getPointer(), toFx);
|
||||
});
|
||||
}
|
||||
|
||||
UndoPasteFxs::redo();
|
||||
|
@ -3182,8 +3176,12 @@ void UndoDisconnectFxs::undo() const {
|
|||
FxDag *fxDag = xsh->getFxDag();
|
||||
|
||||
// Restore the old links
|
||||
tcg::binder1st<LinkFun> attacher(&UndoDisconnectFxs::attach, xsh);
|
||||
tcg::binder1st<LinkFun> xshDetacher(&UndoDisconnectFxs::detachXsh, xsh);
|
||||
auto const attacher = [xsh](const TFxCommand::Link &link) {
|
||||
return UndoDisconnectFxs::attach(xsh, link);
|
||||
};
|
||||
auto const xshDetacher = [xsh](const TFxCommand::Link &link) {
|
||||
return UndoDisconnectFxs::detachXsh(xsh, link);
|
||||
};
|
||||
|
||||
std::for_each(m_undoLinksIn.begin(), m_undoLinksIn.end(), attacher);
|
||||
std::for_each(m_undoLinksOut.begin(), m_undoLinksOut.end(), attacher);
|
||||
|
@ -3328,8 +3326,9 @@ void UndoConnectFxs::undo() const {
|
|||
FxCommandUndo::attach(xsh, m_link, false);
|
||||
|
||||
// Restore the old fxs' group data
|
||||
tcg::function<void (GroupData::*)() const, &GroupData::restore> restore_fun;
|
||||
std::for_each(m_undoGroupDatas.begin(), m_undoGroupDatas.end(), restore_fun);
|
||||
for (auto const &groupData : m_undoGroupDatas) {
|
||||
groupData.restore();
|
||||
}
|
||||
|
||||
UndoDisconnectFxs::undo();
|
||||
}
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
// TnzCore includes
|
||||
#include "tstream.h"
|
||||
|
||||
// tcg includes
|
||||
#include "tcg/function_types.h"
|
||||
|
||||
// STD includes
|
||||
//#include <cwctypes>
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
// tcg includes
|
||||
#include "tcg/tcg_numeric_ops.h"
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
// STD includes
|
||||
#include <cmath>
|
||||
|
@ -1272,9 +1271,7 @@ void VectorizerCore::applyFillColors(TRegion *r, const TRasterP &ras,
|
|||
TPalette *palette,
|
||||
const CenterlineConfiguration &c,
|
||||
int regionCount) {
|
||||
struct locals {
|
||||
static inline bool alwaysTrue(const TPixelCM32 &) { return true; }
|
||||
};
|
||||
auto const alwaysTrue = [](const TPixelCM32 &) { return true; };
|
||||
|
||||
TRasterCM32P rt = ras;
|
||||
TRaster32P rr = ras;
|
||||
|
@ -1306,29 +1303,40 @@ void VectorizerCore::applyFillColors(TRegion *r, const TRasterP &ras,
|
|||
|
||||
bool tookPoint =
|
||||
isBrightRegion
|
||||
? rt
|
||||
? getInternalPoint(
|
||||
rt, tcg::bind2nd(cm_func(isBright), c.m_threshold),
|
||||
inverse, c, r,
|
||||
pd) || // If no bright pixel could be found,
|
||||
getInternalPoint(rt, locals::alwaysTrue, inverse, c, r,
|
||||
pd)
|
||||
: // then any pixel inside the region
|
||||
? rt ? getInternalPoint(
|
||||
rt,
|
||||
std::bind(cm_func(isBright), std::placeholders::_1,
|
||||
c.m_threshold),
|
||||
inverse, c, r, pd) ||
|
||||
// If no bright pixel could be found,
|
||||
getInternalPoint(rt, alwaysTrue, inverse, c, r,
|
||||
pd)
|
||||
: // then any pixel inside the region
|
||||
rr ? getInternalPoint(
|
||||
rr, tcg::bind2nd(rgbm_func(isBright), c.m_threshold),
|
||||
rr,
|
||||
std::bind(rgbm_func(isBright), std::placeholders::_1,
|
||||
c.m_threshold),
|
||||
inverse, c, r, pd)
|
||||
: // must suffice.
|
||||
getInternalPoint(
|
||||
rgr, tcg::bind2nd(gr_func(isBright), c.m_threshold),
|
||||
rgr,
|
||||
std::bind(gr_func(isBright), std::placeholders::_1,
|
||||
c.m_threshold),
|
||||
inverse, c, r, pd)
|
||||
: rt ? getInternalPoint(rt,
|
||||
tcg::bind2nd(cm_func(isDark), c.m_threshold),
|
||||
inverse, c, r, pd)
|
||||
: rt ? getInternalPoint(
|
||||
rt,
|
||||
std::bind(cm_func(isDark), std::placeholders::_1,
|
||||
c.m_threshold),
|
||||
inverse, c, r, pd)
|
||||
: rr ? getInternalPoint(
|
||||
rr, tcg::bind2nd(rgbm_func(isDark), c.m_threshold),
|
||||
rr,
|
||||
std::bind(rgbm_func(isDark), std::placeholders::_1,
|
||||
c.m_threshold),
|
||||
inverse, c, r, pd)
|
||||
: getInternalPoint(
|
||||
rgr, tcg::bind2nd(gr_func(isDark), c.m_threshold),
|
||||
rgr,
|
||||
std::bind(gr_func(isDark), std::placeholders::_1,
|
||||
c.m_threshold),
|
||||
inverse, c, r, pd);
|
||||
|
||||
if (tookPoint) {
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
// Qt includes
|
||||
#include <QMetaObject>
|
||||
|
||||
// tcg includes
|
||||
#include "tcg/tcg_function_types.h"
|
||||
|
||||
// STD includes
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
|
@ -481,10 +478,7 @@ TStageObject::~TStageObject() {
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
const TStageObject::LazyData &TStageObject::lazyData() const {
|
||||
typedef tcg::function<void (TStageObject::*)(LazyData &) const,
|
||||
&TStageObject::update>
|
||||
Func;
|
||||
return m_lazyData(tcg::bind1st(Func(), *this));
|
||||
return m_lazyData([this](LazyData &ld) { this->update(ld); });
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue