/*
9 * Copyright (C) 2022 Authors
10 * Released under GNU GPL v2+, read the file
'COPYING' for more information.
37static constexpr std::array<uint32_t, 6>
fill_lite = {0x00000055, 0x0291ffff, 0x8eceffff, 0x0291ffff, 0xf299d6ff, 0xff0db3ff};
38static constexpr std::array<uint32_t, 6>
fill_dark = {0xffffff55, 0x0291ffff, 0x8eceffff, 0x0291ffff, 0xf299d6ff, 0xff0db3ff};
48 _group = make_canvasitem<CanvasItemGroup>(
root);
52 if (!subitem->is_image())
72 int i = (int)task * 2 + (
int)selected;
76 fill = (fill | 0xff) - 0xcc;
98 auto bpath = make_canvasitem<Inkscape::CanvasItemBpath>(
_group.get(), subitem->get_pathv(),
false);
100 _screen_items.push_back({ subitem, std::move(bpath),
true });
110 if (pair.vis->contains(point, 2.0))
126 bool hover = !done && si.
vis->contains(point, 2.0);
129 si.vis->raise_to_top();
130 done = done || hover;
141 if (subitem->get_root() ==
root && subitem->is_image()) {
157 _work_task = std::make_shared<SubItem>(*si->work);
161 si->vis->set_visible(
false);
176 si->vis->set_visible(
false);
191 si.vis->set_visible(
true);
228 std::vector<SPObject *> ret;
229 std::map<SPItem *, SPItem *> used_images;
232 auto defs = doc->getDefs();
233 auto xml_doc = doc->getReprDoc();
237 ret.insert(ret.begin(),
items.begin(),
items.end());
244 selected += (int)subitem->getSelected();
249 if (!subitem->getSelected() && selected)
251 auto root = subitem->get_root();
252 auto item = subitem->get_item();
253 auto style = subitem->getStyle();
260 g_warning(
"Can't generate itemless object in boolean-builder.");
265 g_warning(
"Can't generate top-most object in boolean-builder.");
275 if (is<SPImage>(
item)) {
281 if (!used_images.contains(
item)) {
285 item = cast<SPItem>(defs->appendChildRepr(copy_repr));
297 std::vector<Inkscape::XML::Node *>
paths = {repr};
299 std::string href_id = std::string(
"#") +
item->
getId();
301 if (is<SPUse>(
item)) {
308 repr = xml_doc->createElement(
"svg:use");
312 repr->
setAttribute(
"clip-path", std::string(
"url(#") + clip_id +
")");
316 parent->getRepr()->addChild(repr,
root->getRepr());
317 ret.emplace_back(doc->getObjectByRepr(repr));
321 for (
auto &[
orig,
item] : used_images) {
326 defs->getRepr()->appendChild(img_repr);
333 if (!used_images.contains(
item)) {
338 if (!used_images.contains(
item)) {
void enable_undo_actions(SPDocument *document, bool undo, bool redo)
Actions for Undo/Redo tied to document.
3x3 matrix representing an affine transformation.
Affine inverse() const
Compute the inverse matrix.
Two-dimensional point that doubles as a vector.
CanvasItemPtr< CanvasItemGroup > _group
bool task_select(const Geom::Point &point, bool add_task=true)
Select the shape under the cursor.
std::vector< ItemPair > _screen_items
bool task_add(const Geom::Point &point)
void redraw_item(CanvasItemBpath &bpath, bool selected, TaskType task, bool image)
Control the visual appearence of this particular bpath.
std::vector< std::vector< WorkItem > > _redo
ItemPair * get_item(const Geom::Point &point)
sigc::scoped_connection desk_modified_connection
BooleanBuilder(ObjectSet *obj, bool flatten=false)
void redraw_items()
Update to visuals with the latest subitem list.
std::vector< WorkItem > _work_items
bool contains_image(SPItem *root) const
Returns true if this root item contains an image work item.
std::vector< std::vector< WorkItem > > _undo
std::vector< SPObject * > shape_commit(bool all=false, bool replace=true)
Commit the changes to the document (finish)
bool highlight(const Geom::Point &point, bool add_task=true)
Highlight any shape under the mouse at this point.
void set_fill(uint32_t rgba, SPWindRule fill_rule)
Set the fill color and fill rule.
virtual void set_stroke(uint32_t rgba)
void set_stroke_width(double width)
Set the stroke width.
SPDesktop * desktop()
Returns the desktop the selection is bound to.
SPDocument * document()
Returns the document the selection is bound to.
std::vector< SPItem * > items_vector()
static WorkItems build_flatten(std::vector< SPItem * > &&items)
Take a list of items and flatten into a list of SubItems.
static WorkItems build_mosaic(std::vector< SPItem * > &&items)
Take a list of items and fracture into a list of SubItems ready for use inside the booleans interacti...
Interface for refcounted XML nodes.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual Node * duplicate(Document *doc) const =0
Create a duplicate of this node.
static char const * create(std::vector< Inkscape::XML::Node * > &reprs, SPDocument *document)
Inkscape::UI::Widget::Canvas * getCanvas() const
SPNamedView * getNamedView() const
Base class for visual SVG elements.
Colors::Color getDeskColor() const
SPObject is an abstract base class of all of the document nodes at the SVG document level.
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
char const * getId() const
Returns the objects current ID string.
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
void deleteObject(bool propagate, bool propagate_descendants)
Deletes an object, unparenting it from its parent.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
char const * getAttribute(char const *name) const
sigc::connection connectModified(sigc::slot< void(SPObject *, unsigned int)> slot)
Connects to the modification notification signal.
Editable view implementation.
static char const *const parent
std::unique_ptr< Magick::Image > image
vector< vector< Point > > paths
Affine identity()
Create an identity matrix.
double get_perceptual_lightness(Color const &color)
Return a value for how the light the color appears to be using HSLUV.
Helper class to stream background task notifications as a series of messages.
static constexpr std::array< uint32_t, 6 > fill_lite
static constexpr std::array< uint32_t, 6 > fill_dark
void flatten(Geom::PathVector &pathv, FillRule fill_rule)
void sp_repr_unparent(Inkscape::XML::Node *repr)
Remove repr from children of its parent node.
SVG <image> implementation.
Geom::Affine i2anc_affine(SPObject const *object, SPObject const *ancestor)
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
SPObject * sp_object_unref(SPObject *object, SPObject *owner)
Decrease reference count of object, with possible debugging and finalization.
SPObject * sp_object_ref(SPObject *object, SPObject *owner)
Increase reference count of object, with possible debugging.
SPRoot: SVG <svg> implementation.
SPStyle - a style object for SPItem objects.
std::string sp_svg_transform_write(Geom::Affine const &transform)
static void sp_svg_write_path(Inkscape::SVG::PathString &str, Geom::Path const &p, bool normalize=false)