From c853ffb5b2f75f5a889ed2e3ef89b818a736e87a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:50:49 +0200 Subject: Adding upstream version 1.3+ds. Signed-off-by: Daniel Baumann --- src/ui/tools/booleans-subitems.h | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/ui/tools/booleans-subitems.h (limited to 'src/ui/tools/booleans-subitems.h') diff --git a/src/ui/tools/booleans-subitems.h b/src/ui/tools/booleans-subitems.h new file mode 100644 index 0000000..bbb12f2 --- /dev/null +++ b/src/ui/tools/booleans-subitems.h @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * + *//* + * Authors: + * Martin Owens + * + * Copyright (C) 2022 Authors + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_TOOLS_BOOLEANS_SUBITEMS_H +#define INKSCAPE_UI_TOOLS_BOOLEANS_SUBITEMS_H + +#include <2geom/pathvector.h> +#include +#include + +class SPItem; +class SPStyle; + +namespace Inkscape { + +class SubItem; +using WorkItem = std::shared_ptr; +using WorkItems = std::vector; + +/** + * When an item is broken, each broken part is represented by + * the SubItem class. This class hold information such as the + * original items it originated from and the paths that it + * consists of. + **/ +class SubItem +{ +public: + + SubItem(Geom::PathVector paths, SPItem *item, SPStyle *style) + : _paths(std::move(paths)) + , _item(item) + , _style(style) + {} + + SubItem(const SubItem ©) + : SubItem(copy._paths, copy._item, copy._style) + {} + + SubItem &operator+=(const SubItem &other); + + bool contains(const Geom::Point &pt) const; + + const Geom::PathVector &get_pathv() const { return _paths; } + SPItem *get_item() const { return _item; } + SPStyle *getStyle() const { return _style; } + + static WorkItems build_mosaic(std::vector &&items); + static WorkItems build_flatten(std::vector &&items); + + bool getSelected() const { return _selected; } + void setSelected(bool selected) { _selected = selected; } + +private: + Geom::PathVector _paths; + SPItem *_item; + SPStyle *_style; + bool _selected = false; +}; + +} // namespace Inkscape + +#endif // INKSCAPE_UI_TOOLS_BOOLEANS_SUBITEMS_H -- cgit v1.2.3