8#include <glibmm/i18n.h>
30namespace LivePathEffect {
34 , hide_clip(_(
"Hide clip"), _(
"Hide clip"),
"hide_clip", &wr, this, false)
35 ,
inverse(_(
"Inverse clip"), _(
"Inverse clip"),
"inverse", &wr, this, true)
36 ,
flatten(_(
"Flatten clip"), _(
"Flatten clip, see fill rule once convert to paths"),
"flatten", &wr, this, false)
38 _(
"Info Box"), _(
"Important messages"),
"message", &wr, this,
39 _(
"Use fill-rule evenodd on <b>fill and stroke</b> dialog if no flatten result after convert clip to paths."))
50 if (this->
getRepr()->attribute(
"is_inverse")) {
70 auto group = cast<SPGroup>(
item);
72 std::vector<SPItem *> item_list = group->item_list();
73 for (
auto child : item_list) {
75 auto childitem = cast<SPLPEItem>(
child);
82 auto shape = cast<SPShape>(
item);
83 if (shape && shape->curve()) {
84 for (
auto path : *shape->curve()) {
87 if (pathdir == dir &&
inverse) {
88 path = path.reversed();
107 std::vector<SPObject*> clip_path_list = clip_path->
childList(
true);
108 clip_path_list.pop_back();
109 if (clip_path_list.size()) {
110 for (
auto clip : clip_path_list) {
111 auto childitem = cast<SPLPEItem>(
clip);
117 if (!childitem->style || !childitem->style->display.set ||
119 childitem->style->display.set = TRUE;
121 childitem->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT);
138 for (
auto path : res_hlp) {
155 auto childitems = clip_path->
childList(
true);
156 auto childitem = cast<SPLPEItem>(childitems.empty() ?
nullptr : childitems.back());
158 if (
const gchar *powerclip = childitem->getRepr()->attribute(
"class")) {
159 if (!strcmp(powerclip,
"powerclip")) {
160 Glib::ustring newclip = Glib::ustring(
"clipath_") +
getId();
161 Glib::ustring uri = Glib::ustring(
"url(#") + newclip + Glib::ustring(
")");
167 auto childitems2 = clip_path->
childList(
true);
168 if (
auto childitemdel = cast<SPLPEItem>(childitems2.empty() ?
nullptr : childitems2.back())) {
169 childitemdel->setAttribute(
"id",
getId());
181 elemref->
setAttribute(
"style", childitem->getAttribute(
"style"));
207 elemref->
updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT);
232 auto childitem = cast<SPLPEItem>(clip_path->
childList(
true).front());
233 childitem->deleteObject();
244 std::vector<SPObject *> clip_path_list = clip_path->
childList(
true);
245 for (
auto clip : clip_path_list) {
246 auto childitem = cast<SPLPEItem>(
clip);
248 if (!childitem->style || childitem->style->display.set ||
250 childitem->style->display.set = TRUE;
252 childitem->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT);
265 if (pig && !c_pv.
empty() && !path_out.
empty()) {
266 path_out = pig->getIntersection();
277 auto selList = sel->
items();
278 for (
auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) {
279 auto lpeitem = cast<SPLPEItem>(*i);
281 if (lpeitem->hasPathEffect() && lpeitem->pathEffectsEnabled()) {
283 for (
auto &lperef : path_effect_list) {
290 g_warning(
"SPLPEItem::performPathEffect - NULL lpeobj in list!");
294 lpeitem->setCurrentPathEffect(lperef);
295 lpeitem->removeCurrentPathEffect(
false);
307 auto selList = sel->
items();
308 for(
auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) {
309 auto lpeitem = cast<SPLPEItem>(*i);
311 SPClipPath *clip_path = lpeitem->getClipObject();
313 std::vector<SPObject*> clip_path_list = clip_path->
childList(
true);
314 for (
auto iter : clip_path_list) {
315 auto use = cast<SPUse>(iter);
317 g_warning(
"We can`t add inverse clip on clones");
322 Effect* lpe = lpeitem->getCurrentLPE();
Axis-aligned rectangle that can be empty.
Intermediate data for computing Boolean operations on paths.
void push_back(Path const &path)
Append a path at the end.
bool empty() const
Check whether the vector contains any paths.
Sequence of contiguous curves, aka spline.
void registerParameter(Parameter *param)
static void createAndApply(const char *name, SPDocument *doc, SPItem *item)
Inkscape::XML::Node * getRepr()
LivePathEffectObject * getLPEObj()
Geom::PathVector doEffect_path(Geom::PathVector const &path_in) override
Geom::PathVector getClipPathvector()
void doOnRemove(SPLPEItem const *) override
LPEPowerClip(LivePathEffectObject *lpeobject)
void doBeforeEffect(SPLPEItem const *lpeitem) override
Is performed each time before the effect is updated.
void doOnVisibilityToggled(SPLPEItem const *lpeitem) override
void param_set_min_height(int height)
SPItemRange items()
Returns a range of selected SPItems.
bool isEmpty()
Returns true if no items are selected.
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
The set of selected SPObjects for a given document and layer model.
Interface for refcounted XML nodes.
virtual void appendChild(Node *child)=0
Append a node as the last child of this node.
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.
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
Inkscape::LivePathEffect::EffectType effecttype
Typed SVG document implementation.
SPObject * getObjectById(std::string const &id) const
SPDefs * getDefs()
Return the main defs object for the document.
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
Geom::OptRect visualBounds(Geom::Affine const &transform=Geom::identity(), bool wfilter=true, bool wclip=true, bool wmask=true) const
Get item's visual bounding box in this item's coordinate system.
SPClipPath * getClipObject() const
SPLPEItem * removeCurrentPathEffect(bool keep_paths)
If keep_path is true, the item should not be updated, effectively 'flattening' the LPE.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
std::vector< SPObject * > childList(bool add_ref, Action action=ActionGeneral)
Retrieves the children as a std vector object, optionally ref'ing the children in the process,...
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
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.
SPObject * appendChildRepr(Inkscape::XML::Node *repr)
Append repr as child of this object.
static char const *const parent
SBasisN< n > inverse(SBasisN< n > a, int k)
bool path_direction(Path const &p)
This function should only be applied to simple paths (regions), as otherwise a boolean winding direct...
Affine identity()
Create an identity matrix.
bool clip(std::vector< RatQuad > &rq, const xAx &cs, const Rect &R)
static R & release(R &r)
Decrements the reference count of a anchored object.
void sp_remove_powerclip(Inkscape::Selection *sel)
const EnumEffectDataConverter< EffectType > LPETypeConverter
defined in effect.cpp
void sp_inverse_powerclip(Inkscape::Selection *sel)
Geom::Path sp_bbox_without_clip(SPLPEItem *lpeitem)
Geom::PathVector sp_get_recursive_pathvector(SPLPEItem *item, Geom::PathVector res, bool dir, bool inverse)
Helper class to stream background task notifications as a series of messages.
void flatten(Geom::PathVector &pathv, FillRule fill_rule)
Singleton class to access the preferences file in a convenient way.
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
std::list< PathEffectSharedPtr > PathEffectList
Interface for XML documents.
virtual Node * createElement(char const *name)=0
SPStyle - a style object for SPItem objects.
static void sp_svg_write_path(Inkscape::SVG::PathString &str, Geom::Path const &p, bool normalize=false)