Remove make_cast_it (#2594)
This commit is contained in:
parent
55ca6bddd5
commit
e347adcb20
7 changed files with 48 additions and 274 deletions
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
// tcg includes
|
// tcg includes
|
||||||
#include "tcg/tcg_misc.h"
|
#include "tcg/tcg_misc.h"
|
||||||
#include "tcg/tcg_iterator_ops.h"
|
|
||||||
|
|
||||||
#define INCLUDE_HPP
|
#define INCLUDE_HPP
|
||||||
#include "tmeshimage.h"
|
#include "tmeshimage.h"
|
||||||
|
@ -24,10 +23,6 @@ typedef tcg::TriMesh<TTextureVertex, tcg::Edge, tcg::FaceN<3>> TriMesh_base;
|
||||||
DEFINE_CLASS_CODE(TTextureMesh, 120)
|
DEFINE_CLASS_CODE(TTextureMesh, 120)
|
||||||
PERSIST_IDENTIFIER(TTextureMesh, "mesh")
|
PERSIST_IDENTIFIER(TTextureMesh, "mesh")
|
||||||
|
|
||||||
static TTextureMeshP cloneMesh_(const TTextureMeshP &other) {
|
|
||||||
return TTextureMeshP(new TTextureMesh(*other));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void static_check() {
|
static void static_check() {
|
||||||
/* input iterator */
|
/* input iterator */
|
||||||
static_assert(
|
static_assert(
|
||||||
|
@ -56,35 +51,6 @@ static void static_check() {
|
||||||
TTextureMeshP>::iterator>::reference>::value ==
|
TTextureMeshP>::iterator>::reference>::value ==
|
||||||
true,
|
true,
|
||||||
"akan");
|
"akan");
|
||||||
|
|
||||||
/* converted iterator */
|
|
||||||
std::vector<TTextureMeshP> vec;
|
|
||||||
auto it = vec.end();
|
|
||||||
auto c = tcg::make_cast_it(it, cloneMesh_);
|
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::is_same<std::iterator_traits<decltype(c)>::iterator_category,
|
|
||||||
std::random_access_iterator_tag>::value == true,
|
|
||||||
"random");
|
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::is_base_of<
|
|
||||||
std::input_iterator_tag,
|
|
||||||
std::iterator_traits<decltype(c)>::iterator_category>::value == true,
|
|
||||||
"input");
|
|
||||||
|
|
||||||
static_assert(
|
|
||||||
std::is_base_of<
|
|
||||||
std::forward_iterator_tag,
|
|
||||||
std::iterator_traits<decltype(c)>::iterator_category>::value == true,
|
|
||||||
"forward");
|
|
||||||
|
|
||||||
// TTextureMeshP p(std::iterator_traits< decltype(c) >::reference);
|
|
||||||
static_assert(
|
|
||||||
std::is_constructible<
|
|
||||||
TTextureMeshP, std::iterator_traits<decltype(c)>::reference>::value ==
|
|
||||||
true,
|
|
||||||
"akan");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -310,11 +276,11 @@ public:
|
||||||
|
|
||||||
Imp() : m_dpiX(), m_dpiY() {}
|
Imp() : m_dpiX(), m_dpiY() {}
|
||||||
|
|
||||||
Imp(const Imp &other)
|
Imp(const Imp &other) : m_dpiX(other.m_dpiX), m_dpiY(other.m_dpiY) {
|
||||||
: m_meshes(tcg::make_cast_it(other.m_meshes.begin(), cloneMesh),
|
for (auto const &e : other.m_meshes) {
|
||||||
tcg::make_cast_it(other.m_meshes.end(), cloneMesh))
|
m_meshes.push_back(cloneMesh(e));
|
||||||
, m_dpiX(other.m_dpiX)
|
}
|
||||||
, m_dpiY(other.m_dpiY) {}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static TTextureMeshP cloneMesh(const TTextureMeshP &other) {
|
static TTextureMeshP cloneMesh(const TTextureMeshP &other) {
|
||||||
|
|
|
@ -26,159 +26,6 @@ struct iterator_traits<T *> : public std::iterator_traits<T *> {
|
||||||
typedef ptr<T> inheritable_iterator_type;
|
typedef ptr<T> inheritable_iterator_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
//****************************************************************************
|
|
||||||
// Derived Iterator definition
|
|
||||||
//****************************************************************************
|
|
||||||
|
|
||||||
template <typename It, typename Der,
|
|
||||||
typename iterator_tag =
|
|
||||||
typename std::iterator_traits<It>::iterator_category>
|
|
||||||
struct derived_iterator
|
|
||||||
: public tcg::iterator_traits<It>::inheritable_iterator_type {
|
|
||||||
typedef typename tcg::iterator_traits<It>::inheritable_iterator_type
|
|
||||||
base_iterator;
|
|
||||||
|
|
||||||
public:
|
|
||||||
derived_iterator() : base_iterator() {}
|
|
||||||
derived_iterator(const base_iterator &it) : base_iterator(it) {}
|
|
||||||
|
|
||||||
Der &operator++() {
|
|
||||||
base_iterator::operator++();
|
|
||||||
return static_cast<Der &>(*this);
|
|
||||||
}
|
|
||||||
Der operator++(int) {
|
|
||||||
return Der(base_iterator::operator++(0), static_cast<Der &>(*this));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename It, typename Der>
|
|
||||||
struct derived_iterator<It, Der, std::bidirectional_iterator_tag>
|
|
||||||
: public derived_iterator<It, Der, std::forward_iterator_tag> {
|
|
||||||
typedef typename tcg::iterator_traits<It>::inheritable_iterator_type
|
|
||||||
base_iterator;
|
|
||||||
|
|
||||||
public:
|
|
||||||
derived_iterator() : _iter() {}
|
|
||||||
derived_iterator(const base_iterator &it) : _iter(it) {}
|
|
||||||
|
|
||||||
Der &operator--() {
|
|
||||||
base_iterator::operator--();
|
|
||||||
return static_cast<Der &>(*this);
|
|
||||||
}
|
|
||||||
Der operator--(int) {
|
|
||||||
return Der(base_iterator::operator--(0), static_cast<Der &>(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef derived_iterator<It, Der, std::forward_iterator_tag> _iter;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename It, typename Der>
|
|
||||||
struct derived_iterator<It, Der, std::random_access_iterator_tag>
|
|
||||||
: public derived_iterator<It, Der, std::bidirectional_iterator_tag> {
|
|
||||||
typedef typename tcg::iterator_traits<It>::inheritable_iterator_type
|
|
||||||
base_iterator;
|
|
||||||
typedef typename base_iterator::difference_type difference_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
derived_iterator() : _iter() {}
|
|
||||||
derived_iterator(const base_iterator &it) : _iter(it) {}
|
|
||||||
|
|
||||||
Der operator+(difference_type d) const {
|
|
||||||
return Der(static_cast<const base_iterator &>(*this) + d,
|
|
||||||
static_cast<const Der &>(*this));
|
|
||||||
}
|
|
||||||
Der &operator+=(difference_type d) {
|
|
||||||
static_cast<base_iterator &>(*this) += d;
|
|
||||||
return static_cast<Der &>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Der operator-(difference_type d) const {
|
|
||||||
return Der(static_cast<const base_iterator &>(*this) - d,
|
|
||||||
static_cast<const Der &>(*this));
|
|
||||||
}
|
|
||||||
Der &operator-=(difference_type d) {
|
|
||||||
static_cast<base_iterator &>(*this) -= d;
|
|
||||||
return static_cast<Der &>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
difference_type operator-(const Der &other) const {
|
|
||||||
return static_cast<const base_iterator &>(*this) -
|
|
||||||
static_cast<const base_iterator &>(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef derived_iterator<It, Der, std::bidirectional_iterator_tag> _iter;
|
|
||||||
};
|
|
||||||
|
|
||||||
//****************************************************************************
|
|
||||||
// Cast Iterator definition
|
|
||||||
//****************************************************************************
|
|
||||||
|
|
||||||
/*!
|
|
||||||
A cast iterator is a utility iterator wrapper that can be used to access
|
|
||||||
an iterator's data through a supplied functor intermediary, proving to be
|
|
||||||
especially useful when converting data from a container to another with
|
|
||||||
minimal effort.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <typename It, typename Func,
|
|
||||||
typename Val = typename traits<
|
|
||||||
typename function_traits<Func>::ret_type>::referenced_type,
|
|
||||||
typename Ref = typename choose_if_match<
|
|
||||||
typename function_traits<Func>::ret_type &,
|
|
||||||
typename traits<Val>::reference_type>::type,
|
|
||||||
typename Ptr = typename choose_if_match<
|
|
||||||
Ref, void, typename traits<Val>::pointer_type>::type>
|
|
||||||
class cast_iterator
|
|
||||||
: public derived_iterator<It, cast_iterator<It, Func, Val, Ref, Ptr>> {
|
|
||||||
typedef derived_iterator<It, cast_iterator> iterator;
|
|
||||||
typedef typename iterator::base_iterator base_iterator;
|
|
||||||
typedef Func function;
|
|
||||||
typedef typename function_traits<Func>::ret_type ret_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef Ref reference;
|
|
||||||
typedef Ptr pointer;
|
|
||||||
typedef Val value_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
cast_iterator() : iterator(), m_func() {}
|
|
||||||
cast_iterator(const Func &func) : iterator(), m_func(func) {}
|
|
||||||
|
|
||||||
cast_iterator(const base_iterator &it) : iterator(it), m_func() {}
|
|
||||||
cast_iterator(const base_iterator &it, const Func &func)
|
|
||||||
: iterator(it), m_func(func) {}
|
|
||||||
|
|
||||||
cast_iterator(const base_iterator &it, const cast_iterator &other)
|
|
||||||
: iterator(it), m_func(other.m_func) {}
|
|
||||||
|
|
||||||
ret_type operator*() { return m_func(iterator::operator*()); }
|
|
||||||
pointer operator->() { return ptr(0); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Func m_func;
|
|
||||||
|
|
||||||
private:
|
|
||||||
template <typename T>
|
|
||||||
pointer ptr(T,
|
|
||||||
typename tcg::enable_if<tcg::type_mismatch<pointer, void>::value,
|
|
||||||
T>::type = 0) const {
|
|
||||||
return &operator*();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ptr(char) const {}
|
|
||||||
};
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
// Utility maker function
|
|
||||||
|
|
||||||
template <typename It, typename Func>
|
|
||||||
inline cast_iterator<It, Func> make_cast_it(const It &it, Func func) {
|
|
||||||
return cast_iterator<It, Func>(it, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
//***********************************************************************
|
//***********************************************************************
|
||||||
// Step Iterator class
|
// Step Iterator class
|
||||||
//***********************************************************************
|
//***********************************************************************
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "tcg/tcg_misc.h"
|
#include "tcg/tcg_misc.h"
|
||||||
#include "tcg/tcg_pool.h"
|
#include "tcg/tcg_pool.h"
|
||||||
#include "tcg/tcg_function_types.h"
|
#include "tcg/tcg_function_types.h"
|
||||||
#include "tcg/tcg_iterator_ops.h"
|
|
||||||
|
|
||||||
#include "ext/plasticskeleton.h"
|
#include "ext/plasticskeleton.h"
|
||||||
|
|
||||||
|
@ -573,16 +572,9 @@ int PlasticSkeleton::closestEdge(const TPointD &pos, double *dist) const {
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
|
||||||
std::vector<PlasticHandle> PlasticSkeleton::verticesToHandles() const {
|
std::vector<PlasticHandle> PlasticSkeleton::verticesToHandles() const {
|
||||||
// Someway, PlasticHandle's EXPLICIT unary constructors are not enough
|
std::vector<PlasticHandle> v;
|
||||||
// to disambiguate the direct construction of a vector of PlasticHandles
|
for (auto const &e : m_vertices) {
|
||||||
// from m_vertices, at least with *gcc*. I guess it could be a compiler bug.
|
v.push_back(e);
|
||||||
|
}
|
||||||
// So, we'll convert them using an explicit casting iterator...
|
return v;
|
||||||
|
|
||||||
typedef tcg::function < PlasticHandle (PlasticSkeletonVertex::*)() const,
|
|
||||||
&PlasticSkeletonVertex::operator PlasticHandle> Func;
|
|
||||||
|
|
||||||
return std::vector<PlasticHandle>(
|
|
||||||
tcg::make_cast_it(m_vertices.begin(), Func()),
|
|
||||||
tcg::make_cast_it(m_vertices.end(), Func()));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
// tcg includes
|
// tcg includes
|
||||||
#include "tcg/tcg_point_ops.h"
|
#include "tcg/tcg_point_ops.h"
|
||||||
#include "tcg/tcg_function_types.h"
|
#include "tcg/tcg_function_types.h"
|
||||||
#include "tcg/tcg_iterator_ops.h"
|
|
||||||
|
|
||||||
#include "plastictool.h"
|
#include "plastictool.h"
|
||||||
|
|
||||||
|
@ -562,12 +561,6 @@ void PlasticTool::leftButtonDown_build(const TPointD &pos,
|
||||||
|
|
||||||
// Start move vertex operation
|
// Start move vertex operation
|
||||||
if (!m_svSel.isEmpty()) {
|
if (!m_svSel.isEmpty()) {
|
||||||
struct locals {
|
|
||||||
static TPointD vertexPos(const PlasticSkeleton &skel, int v) {
|
|
||||||
return skel.vertex(v).P();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const PlasticSkeletonP &skel = skeleton();
|
const PlasticSkeletonP &skel = skeleton();
|
||||||
assert(skel);
|
assert(skel);
|
||||||
|
|
||||||
|
@ -575,11 +568,11 @@ void PlasticTool::leftButtonDown_build(const TPointD &pos,
|
||||||
if (m_svSel.hasSingleObject()) m_pressedPos = skel->vertex(m_svSel).P();
|
if (m_svSel.hasSingleObject()) m_pressedPos = skel->vertex(m_svSel).P();
|
||||||
|
|
||||||
// Store original vertex positions
|
// Store original vertex positions
|
||||||
m_pressedVxsPos = std::vector<TPointD>(
|
std::vector<TPointD> v;
|
||||||
tcg::make_cast_it(m_svSel.objects().begin(),
|
for (auto const &e : m_svSel.objects()) {
|
||||||
tcg::bind1st(&locals::vertexPos, *skel)),
|
v.push_back(skel->vertex(e).P());
|
||||||
tcg::make_cast_it(m_svSel.objects().end(),
|
}
|
||||||
tcg::bind1st(&locals::vertexPos, *skel)));
|
m_pressedVxsPos = std::move(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
// tcg includes
|
// tcg includes
|
||||||
#include "tcg/tcg_macros.h"
|
#include "tcg/tcg_macros.h"
|
||||||
#include "tcg/tcg_point_ops.h"
|
#include "tcg/tcg_point_ops.h"
|
||||||
#include "tcg/tcg_iterator_ops.h"
|
|
||||||
#include "tcg/tcg_function_types.h"
|
#include "tcg/tcg_function_types.h"
|
||||||
|
|
||||||
// boost includes
|
// boost includes
|
||||||
|
@ -1052,11 +1051,6 @@ void PlasticTool::leftButtonDown_mesh(const TPointD &pos,
|
||||||
} else
|
} else
|
||||||
m_this->setMeshSelection(sel, MeshSelection());
|
m_this->setMeshSelection(sel, MeshSelection());
|
||||||
}
|
}
|
||||||
|
|
||||||
static TPointD vertexPos(const TMeshImage &mi, const MeshIndex &meshIdx) {
|
|
||||||
return mi.meshes()[meshIdx.m_meshIdx]->vertex(meshIdx.m_idx).P();
|
|
||||||
}
|
|
||||||
|
|
||||||
} locals = {this};
|
} locals = {this};
|
||||||
|
|
||||||
// Track mouse position
|
// Track mouse position
|
||||||
|
@ -1068,11 +1062,11 @@ void PlasticTool::leftButtonDown_mesh(const TPointD &pos,
|
||||||
|
|
||||||
// Store original vertex positions
|
// Store original vertex positions
|
||||||
if (!m_mvSel.isEmpty()) {
|
if (!m_mvSel.isEmpty()) {
|
||||||
m_pressedVxsPos = std::vector<TPointD>(
|
std::vector<TPointD> v;
|
||||||
tcg::make_cast_it(m_mvSel.objects().begin(),
|
for (auto const &e : m_mvSel.objects()) {
|
||||||
tcg::bind1st(&Locals::vertexPos, *m_mi)),
|
v.push_back(m_mi->meshes()[e.m_meshIdx]->vertex(e.m_idx).P());
|
||||||
tcg::make_cast_it(m_mvSel.objects().end(),
|
}
|
||||||
tcg::bind1st(&Locals::vertexPos, *m_mi)));
|
m_pressedVxsPos = std::move(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redraw selections
|
// Redraw selections
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
// tcg includes
|
// tcg includes
|
||||||
#include "tcg/tcg_numeric_ops.h"
|
#include "tcg/tcg_numeric_ops.h"
|
||||||
#include "tcg/tcg_function_types.h"
|
#include "tcg/tcg_function_types.h"
|
||||||
#include "tcg/tcg_iterator_ops.h"
|
|
||||||
|
|
||||||
// boost includes
|
// boost includes
|
||||||
#include <boost/iterator/counting_iterator.hpp>
|
#include <boost/iterator/counting_iterator.hpp>
|
||||||
|
@ -298,10 +297,6 @@ AdjustThicknessPopup::SelectionData::SelectionData(const TSelection *sel)
|
||||||
struct Locals {
|
struct Locals {
|
||||||
SelectionData *m_this;
|
SelectionData *m_this;
|
||||||
|
|
||||||
typedef tcg::function<int (TXshSimpleLevel::*)(const TFrameId &) const,
|
|
||||||
&TXshSimpleLevel::fid2index>
|
|
||||||
Fid2Index;
|
|
||||||
|
|
||||||
void resetIfInvalid() // Resets to empty if thickness adjustment is
|
void resetIfInvalid() // Resets to empty if thickness adjustment is
|
||||||
{ // not applicable:
|
{ // not applicable:
|
||||||
if (!m_this->m_sl) // 1. The level is not a VECTOR level
|
if (!m_this->m_sl) // 1. The level is not a VECTOR level
|
||||||
|
@ -349,11 +344,11 @@ AdjustThicknessPopup::SelectionData::SelectionData(const TSelection *sel)
|
||||||
|
|
||||||
const std::set<TFrameId> &fids = selection.getSelectedFids();
|
const std::set<TFrameId> &fids = selection.getSelectedFids();
|
||||||
|
|
||||||
m_this->m_frameIdxs = std::set<int>(
|
std::set<int> s;
|
||||||
tcg::make_cast_it(fids.begin(),
|
for (auto const &e : fids) {
|
||||||
tcg::bind1st(Fid2Index(), *m_this->m_sl)),
|
s.insert(m_this->m_sl->fid2index(e));
|
||||||
tcg::make_cast_it(fids.end(),
|
}
|
||||||
tcg::bind1st(Fid2Index(), *m_this->m_sl)));
|
m_this->m_frameIdxs = std::move(s);
|
||||||
|
|
||||||
resetIfInvalid();
|
resetIfInvalid();
|
||||||
}
|
}
|
||||||
|
@ -484,11 +479,11 @@ AdjustThicknessPopup::SelectionData::SelectionData(const TSelection *sel)
|
||||||
|
|
||||||
const std::set<TFrameId> &fids = TTool::getSelectedFrames();
|
const std::set<TFrameId> &fids = TTool::getSelectedFrames();
|
||||||
|
|
||||||
m_this->m_frameIdxs = std::set<int>(
|
std::set<int> s;
|
||||||
tcg::make_cast_it(fids.begin(),
|
for (auto const &e : fids) {
|
||||||
tcg::bind1st(Fid2Index(), *m_this->m_sl)),
|
s.insert(m_this->m_sl->fid2index(e));
|
||||||
tcg::make_cast_it(fids.end(),
|
}
|
||||||
tcg::bind1st(Fid2Index(), *m_this->m_sl)));
|
m_this->m_frameIdxs = std::move(s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#include "tcg/tcg_macros.h"
|
#include "tcg/tcg_macros.h"
|
||||||
#include "tcg/tcg_base.h"
|
#include "tcg/tcg_base.h"
|
||||||
#include "tcg/tcg_function_types.h"
|
#include "tcg/tcg_function_types.h"
|
||||||
#include "tcg/tcg_iterator_ops.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -2366,12 +2365,10 @@ static void deleteColumns(const std::list<int> &columns,
|
||||||
// columns directly, and then their (updated) column index.
|
// columns directly, and then their (updated) column index.
|
||||||
TXsheet *xsh = xshHandle->getXsheet();
|
TXsheet *xsh = xshHandle->getXsheet();
|
||||||
|
|
||||||
typedef tcg::function<TXshColumn *(TXsheet::*)(int)const, &TXsheet::getColumn>
|
std::vector<TXshColumn *> cols;
|
||||||
getColumn_fun;
|
for (auto const &c : columns) {
|
||||||
tcg::binder1st<getColumn_fun> getCol(getColumn_fun(), *xsh);
|
cols.push_back(xsh->getColumn(c));
|
||||||
|
}
|
||||||
std::vector<TXshColumn *> cols(tcg::make_cast_it(columns.begin(), getCol),
|
|
||||||
tcg::make_cast_it(columns.end(), getCol));
|
|
||||||
|
|
||||||
size_t c, cCount = cols.size();
|
size_t c, cCount = cols.size();
|
||||||
for (c = 0; c != cCount; ++c) {
|
for (c = 0; c != cCount; ++c) {
|
||||||
|
@ -3107,20 +3104,6 @@ private:
|
||||||
//======================================================
|
//======================================================
|
||||||
|
|
||||||
void UndoDisconnectFxs::initialize() {
|
void UndoDisconnectFxs::initialize() {
|
||||||
struct locals {
|
|
||||||
static QPair<TFxP, TPointD> originalPos(const QPair<TFxP, TPointD> &pair) {
|
|
||||||
return QPair<TFxP, TPointD>(pair.first,
|
|
||||||
pair.first->getAttributes()->getDagNodePos());
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool contains(const std::list<TFxP> &fxs, TFx *fx) {
|
|
||||||
tcg::function<TFx *(TFxP::*)() const, &TFxP::getPointer> getPointer_fun;
|
|
||||||
|
|
||||||
return (std::count(tcg::make_cast_it(fxs.begin(), getPointer_fun),
|
|
||||||
tcg::make_cast_it(fxs.end(), getPointer_fun), fx) > 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TXsheet *xsh = m_xshHandle->getXsheet();
|
TXsheet *xsh = m_xshHandle->getXsheet();
|
||||||
FxDag *fxDag = xsh->getFxDag();
|
FxDag *fxDag = xsh->getFxDag();
|
||||||
|
|
||||||
|
@ -3132,13 +3115,15 @@ void UndoDisconnectFxs::initialize() {
|
||||||
if (m_fxs.empty()) return;
|
if (m_fxs.empty()) return;
|
||||||
|
|
||||||
// Build fxs data
|
// Build fxs data
|
||||||
tcg::binder1st<bool (*)(const std::list<TFxP> &, TFx *)> contains_fun(
|
auto const contains = [this](TFx const *fx) -> bool {
|
||||||
&locals::contains, m_fxs);
|
return std::count_if(this->m_fxs.begin(), this->m_fxs.end(),
|
||||||
|
[fx](TFxP &f) { return f.getPointer() == fx; }) > 0;
|
||||||
|
};
|
||||||
|
|
||||||
m_leftFx = FxCommandUndo::leftmostConnectedFx(m_fxs.front().getPointer(),
|
m_leftFx =
|
||||||
contains_fun);
|
FxCommandUndo::leftmostConnectedFx(m_fxs.front().getPointer(), contains);
|
||||||
m_rightFx = FxCommandUndo::rightmostConnectedFx(m_fxs.front().getPointer(),
|
m_rightFx =
|
||||||
contains_fun);
|
FxCommandUndo::rightmostConnectedFx(m_fxs.front().getPointer(), contains);
|
||||||
|
|
||||||
// Store sensible original data for the undo
|
// Store sensible original data for the undo
|
||||||
m_undoLinksIn = FxCommandUndo::inputLinks(xsh, m_leftFx);
|
m_undoLinksIn = FxCommandUndo::inputLinks(xsh, m_leftFx);
|
||||||
|
@ -3150,10 +3135,12 @@ void UndoDisconnectFxs::initialize() {
|
||||||
m_undoTerminalLinks.push_back(TFxCommand::Link(lt->m_inputFx.getPointer(),
|
m_undoTerminalLinks.push_back(TFxCommand::Link(lt->m_inputFx.getPointer(),
|
||||||
fxDag->getXsheetFx(), -1));
|
fxDag->getXsheetFx(), -1));
|
||||||
|
|
||||||
std::vector<QPair<TFxP, TPointD>>(
|
std::vector<QPair<TFxP, TPointD>> v;
|
||||||
tcg::make_cast_it(m_undoDagPos.begin(), &locals::originalPos),
|
for (auto const &e : m_undoDagPos) {
|
||||||
tcg::make_cast_it(m_undoDagPos.end(), &locals::originalPos))
|
v.emplace_back(e.first, e.first->getAttributes()->getDagNodePos());
|
||||||
.swap(m_redoDagPos);
|
}
|
||||||
|
m_redoDagPos = std::move(v);
|
||||||
|
m_redoDagPos.shrink_to_fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue