Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-item-group.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_SP_ITEM_GROUP_H
3#define SEEN_SP_ITEM_GROUP_H
4
5/*
6 * SVG <g> implementation
7 *
8 * Authors:
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 *
11 * Copyright (C) 1999-2002 authors
12 * Copyright (C) 2000-2001 Ximian, Inc.
13 *
14 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
15 */
16
17#include <map>
18#include "sp-lpe-item.h"
19
20namespace Inkscape {
21
22class Drawing;
23class DrawingItem;
24
25} // namespace Inkscape
26
27class SPGroup : public SPLPEItem {
28public:
29 SPGroup();
30 ~SPGroup() override;
31 int tag() const override { return tag_of<decltype(*this)>; }
32
34
35 bool isLayer() const { return _layer_mode == LAYER; }
36
39 std::map<unsigned int, LayerMode> _display_modes;
40
41 LayerMode layerMode() const { return _layer_mode; }
43
44 bool insertBottom() const { return _insert_bottom; }
45 void setInsertBottom(bool insertbottom);
46
47 LayerMode effectiveLayerMode(unsigned int display_key) const {
48 if ( _layer_mode == LAYER ) {
49 return LAYER;
50 } else {
51 return layerDisplayMode(display_key);
52 }
53 }
54
55 LayerMode layerDisplayMode(unsigned int display_key) const;
56 void setLayerDisplayMode(unsigned int display_key, LayerMode mode);
58 void scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse);
59
60 int getItemCount() const;
61 virtual void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags);
62
63 std::vector<SPItem*> item_list();
64
65private:
66 void _updateLayerMode(unsigned int display_key=0);
67
68public:
70 void release() override;
71
75
76 void update(SPCtx *ctx, unsigned int flags) override;
77 void modified(unsigned int flags) override;
78 void set(SPAttr key, char const* value) override;
79
80 Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override;
81
82 Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const override;
83 void print(SPPrintContext *ctx) override;
84 const char* typeName() const override;
85 const char* displayName() const override;
86 char *description() const override;
87 Inkscape::DrawingItem *show (Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override;
88 void hide (unsigned int key) override;
89
90 void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const override;
91
92 void update_patheffect(bool write) override;
93
95
96 void removeTransformsRecursively(SPObject const *root) override;
97
101 static std::vector<SPItem*> get_expanded(std::vector<SPItem*> const &items);
102};
103
113
114void sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children);
115
117
118
119inline bool SP_IS_LAYER(SPObject const *obj)
120{
121 auto group = cast<SPGroup>(obj);
122 return group && group->layerMode() == SPGroup::LAYER;
123}
124
125void set_default_highlight_colors(std::vector<guint32> colors);
126
127#endif
128
129/*
130 Local Variables:
131 mode:c++
132 c-file-style:"stroustrup"
133 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
134 indent-tabs-mode:nil
135 fill-column:99
136 End:
137*/
138// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Two-dimensional point that doubles as a vector.
Definition point.h:66
Scaling from the origin.
Definition transforms.h:150
Translation by a vector.
Definition transforms.h:115
SVG drawing item for display.
Storing of snapping preferences.
Interface for refcounted XML nodes.
Definition node.h:80
Typed SVG document implementation.
Definition document.h:101
bool isLayer() const
void release() override
void setLayerMode(LayerMode mode)
void setInsertBottom(bool insertbottom)
void scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse)
void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) override
int getItemCount() const
void removeTransformsRecursively(SPObject const *root) override
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override
~SPGroup() override
void remove_child(Inkscape::XML::Node *child) override
void print(SPPrintContext *ctx) override
LayerMode layerMode() const
Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const override
bool insertBottom() const
LayerMode layerDisplayMode(unsigned int display_key) const
char * description() const override
void setLayerDisplayMode(unsigned int display_key, LayerMode mode)
LayerMode _layer_mode
std::map< unsigned int, LayerMode > _display_modes
void translateChildItems(Geom::Translate const &tr)
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
const char * typeName() const override
The item's type name, not node tag name.
static std::vector< SPItem * > get_expanded(std::vector< SPItem * > const &items)
Return the result of recursively ungrouping all groups in items.
void build(SPDocument *document, Inkscape::XML::Node *repr) override
Inkscape::Colors::Color highlight_color() const override
Generate a highlight colour if one isn't set and return it.
void _updateLayerMode(unsigned int display_key=0)
std::vector< SPItem * > item_list()
int tag() const override
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
void update_patheffect(bool write) override
void modified(unsigned int flags) override
bool _insert_bottom
const char * displayName() const override
The item's type name as a translated human string.
LayerMode effectiveLayerMode(unsigned int display_key) const
void hide(unsigned int key) override
void update(SPCtx *ctx, unsigned int flags) override
virtual void _showChildren(Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags)
Base class for visual SVG elements.
Definition sp-item.h:109
Geom::Affine transform
Definition sp-item.h:138
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
Inkscape::XML::Node * repr
Definition sp-object.h:193
SPDocument * document
Definition sp-object.h:188
RootCluster root
static char const *const parent
Definition dir-util.cpp:70
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
int mode
Ocnode * child[8]
Definition quantize.cpp:33
Ocnode ** ref
Definition quantize.cpp:32
GList * items
bool SP_IS_LAYER(SPObject const *obj)
SPObject * sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const char *name)
void set_default_highlight_colors(std::vector< guint32 > colors)
void sp_item_group_ungroup_handle_clones(SPItem *parent, Geom::Affine const g)
finds clones of a child of the group going out of the group; and inverse the group transform on its c...
void sp_item_group_ungroup(SPGroup *group, std::vector< SPItem * > &children)
Base class for live path effect items.
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94
Glib::ustring name
Definition toolbars.cpp:55