From 35a96bde514a8897f6f0fcc41c5833bf63df2e2a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:29:01 +0200 Subject: Adding upstream version 1.0.2. Signed-off-by: Daniel Baumann --- src/object/sp-item-update-cns.cpp | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/object/sp-item-update-cns.cpp (limited to 'src/object/sp-item-update-cns.cpp') diff --git a/src/object/sp-item-update-cns.cpp b/src/object/sp-item-update-cns.cpp new file mode 100644 index 0000000..516fb67 --- /dev/null +++ b/src/object/sp-item-update-cns.cpp @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * TODO: insert short description here + *//* + * Authors: see git history + * + * Copyright (C) 2018 Authors + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include +#include "satisfied-guide-cns.h" + +#include "sp-item-update-cns.h" +#include "sp-guide.h" + +void sp_item_update_cns(SPItem &item, SPDesktop const &desktop) +{ + std::vector snappoints; + item.getSnappoints(snappoints, nullptr); + /* TODO: Implement the ordering. */ + std::vector found_cns; + satisfied_guide_cns(desktop, snappoints, found_cns); + /* effic: It might be nice to avoid an n^2 algorithm, but in practice n will be + small enough that it's still usually more efficient. */ + + for (auto cn : found_cns) + { + if ( std::find(item.constraints.begin(), + item.constraints.end(), + cn) + == item.constraints.end() ) + { + item.constraints.push_back(cn); + cn.g->attached_items.emplace_back(&item, cn.snappoint_ix); + } + } +} + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3