75
sp_selected_path_union_skip_undo()
77
sp_selected_path_boolop(bool_op_union, SP_VERB_NONE, _("Union"));
70
81
sp_selected_path_intersect()
72
83
sp_selected_path_boolop(bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection"));
178
189
for (GSList *l = il; l != NULL; l = l->next)
180
191
SPItem *item = SP_ITEM(l->data);
181
if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item))
192
if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item) && !SP_IS_FLOWTEXT(item))
183
194
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("One of the objects is <b>not a path</b>, cannot perform boolean operation."));
184
195
g_slist_free(il);
446
457
sp_item_adjust_stroke(item_source, i2root.expansion());
447
458
sp_item_adjust_pattern(item_source, i2root);
448
459
sp_item_adjust_gradient(item_source, i2root);
460
sp_item_adjust_livepatheffect(item_source, i2root);
450
462
Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(source);
474
486
// premultiply by the inverse of parent's repr
475
487
SPItem *parent_item = SP_ITEM(sp_desktop_document(desktop)->getObjectByRepr(parent));
476
488
NR::Matrix local = sp_item_i2doc_affine(parent_item);
478
gchar *transform = NULL;
479
if (!local.test_identity() && sp_svg_transform_write(affinestr, 79, local.inverse())) {
480
transform = affinestr;
489
gchar *transform = sp_svg_transform_write(local.inverse());
483
491
// now that we have the result, add it on the canvas
484
492
if ( bop == bool_op_cut || bop == bool_op_slice ) {
506
514
for (int i=0;i<nbRP;i++) {
507
515
gchar *d = resPath[i]->svg_dump_path();
509
Inkscape::XML::Node *repr = sp_repr_new("svg:path");
517
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
518
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
510
519
repr->setAttribute("style", style);
512
521
repr->setAttribute("mask", mask);
552
561
gchar *d = res->svg_dump_path();
554
Inkscape::XML::Node *repr = sp_repr_new("svg:path");
563
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
564
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
555
565
repr->setAttribute("style", style);
573
583
Inkscape::GC::release(repr);
576
sp_document_done(sp_desktop_document(desktop), verb, description);
588
if (verb != SP_VERB_NONE) {
589
sp_document_done(sp_desktop_document(desktop), verb, description);
770
784
if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether
772
Inkscape::XML::Node *repr = sp_repr_new("svg:path");
786
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
787
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
774
789
// restore old style
775
790
repr->setAttribute("style", style);
791
806
if (SP_IS_SHAPE(item) && sp_shape_has_markers (SP_SHAPE(item))) {
793
Inkscape::XML::Node *g_repr = sp_repr_new("svg:g");
808
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
809
Inkscape::XML::Node *g_repr = xml_doc->createElement("svg:g");
795
811
// add the group to the parent
796
812
parent->appendChild(g_repr);
821
837
tr = marker_item->transform * marker->c2p * tr * transform;
823
839
if (SP_OBJECT_REPR(marker_item)) {
824
Inkscape::XML::Node *m_repr = SP_OBJECT_REPR(marker_item)->duplicate();
840
Inkscape::XML::Node *m_repr = SP_OBJECT_REPR(marker_item)->duplicate(xml_doc);
825
841
g_repr->appendChild(m_repr);
826
842
SPItem *marker_item = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(m_repr);
827
843
sp_item_write_transform(marker_item, m_repr, tr);
1092
1108
tstr[79] = '\0';
1094
repr = sp_repr_new("svg:path");
1110
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
1111
repr = xml_doc->createElement("svg:path");
1095
1112
repr->setAttribute("sodipodi:type", "inkscape:offset");
1096
1113
sp_repr_set_svg_double(repr, "inkscape:radius", ( expand > 0
1357
1374
tstr[79] = '\0';
1359
Inkscape::XML::Node *repr = sp_repr_new("svg:path");
1376
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
1377
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
1361
1379
repr->setAttribute("style", style);
1469
1487
Inkscape::XML::Node *parent = SP_OBJECT_REPR(item)->parent();
1471
1489
char const *id = SP_OBJECT_REPR(item)->attribute("id");
1490
// remember path effect
1491
char const *patheffect = SP_OBJECT_REPR(item)->attribute("inkscape:path-effect");
1473
1493
//If a group was selected, to not change the selection list
1474
1494
if (modifySelection)
1483
1503
orig->Simplify(threshold * size);
1486
Inkscape::XML::Node *repr = sp_repr_new("svg:path");
1506
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
1507
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
1488
1509
// restore style, mask and clip-path
1489
1510
repr->setAttribute("style", style);
1503
1524
gchar *str = orig->svg_dump_path();
1504
repr->setAttribute("d", str);
1526
repr->setAttribute("inkscape:original-d", str);
1528
repr->setAttribute("d", str);
1518
1542
// reapply the transform
1519
1543
sp_item_write_transform(newitem, repr, transform);
1545
// restore path effect
1546
repr->setAttribute("inkscape:path-effect", patheffect);
1521
1548
//If we are not in a selected group
1522
1549
if (modifySelection)
1523
1550
selection->add(repr);
1544
1571
gchar *simplificationType;
1545
1572
if (simplifyIndividualPaths) {
1546
simplificationType = "individual paths";
1573
simplificationType = _("Simplifying paths (separately):");
1548
simplificationType = "as a group";
1575
simplificationType = _("Simplifying paths:");
1551
1578
bool didSomething = false;
1553
NR::Rect selectionBbox = selection->bounds();
1554
gdouble selectionSize = L2(selectionBbox.dimensions());
1580
NR::Maybe<NR::Rect> selectionBbox = selection->bounds();
1581
if (!selectionBbox) {
1584
gdouble selectionSize = L2(selectionBbox->dimensions());
1556
1586
gdouble simplifySize = selectionSize;
1558
1588
int pathsSimplified = 0;
1559
1589
int totalPathCount = g_slist_length(items);
1561
desktop->disableInteraction();
1591
// set "busy" cursor
1592
desktop->setWaitingCursor();
1563
1594
for (; items != NULL; items = items->next) {
1564
1595
SPItem *item = (SPItem *) items->data;
1569
1600
if (simplifyIndividualPaths) {
1570
NR::Rect itemBbox = item->invokeBbox(sp_item_i2d_affine(item));
1571
simplifySize = L2(itemBbox.dimensions());
1601
NR::Maybe<NR::Rect> itemBbox = item->getBounds(sp_item_i2d_affine(item));
1603
simplifySize = L2(itemBbox->dimensions());
1575
1609
pathsSimplified++;
1577
1611
if (pathsSimplified % 20 == 0) {
1578
gchar *message = g_strdup_printf(_("Simplifying %s - <b>%d</b> of <b>%d</b> paths simplified..."), simplificationType, pathsSimplified, totalPathCount);
1579
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, message);
1580
desktop->updateCanvasNow();
1612
gchar *message = g_strdup_printf(_("%s <b>%d</b> of <b>%d</b> paths simplified..."), simplificationType, pathsSimplified, totalPathCount);
1613
desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, message);
1583
1616
didSomething |= sp_selected_path_simplify_item(desktop, selection, item,
1584
1617
threshold, justCoalesce, angleLimit, breakableAngles, simplifySize, modifySelection);
1587
desktop->enableInteraction();
1620
desktop->clearWaitingCursor();
1589
1622
if (pathsSimplified > 20) {
1590
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, g_strdup_printf(_("Done - <b>%d</b> paths simplified."), pathsSimplified));
1623
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, g_strdup_printf(_("<b>%d</b> paths simplified."), pathsSimplified));
1593
1626
return didSomething;
1682
1715
Path_for_item(SPItem *item, bool doTransformation, bool transformFull)
1717
SPCurve *curve = curve_for_item(item);
1718
NArtBpath *bpath = bpath_for_curve(item, curve, doTransformation, transformFull);
1720
if (bpath == NULL) {
1724
Path *dest = bpath_to_Path(bpath);
1726
if (doTransformation) {
1727
g_free(bpath); // see comment in bpath_for_curve
1730
sp_curve_unref(curve);
1736
bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull)
1741
NArtBpath *bpath = SP_CURVE_BPATH(curve);
1742
if (bpath == NULL) {
1746
if (doTransformation) {
1747
NArtBpath *new_bpath; // we will get a duplicate which has to be freed at some point!
1748
if (transformFull) {
1749
new_bpath = nr_artpath_affine(bpath, sp_item_i2doc_affine(item));
1751
new_bpath = nr_artpath_affine(bpath, item->transform);
1759
SPCurve* curve_for_item(SPItem *item)
1689
if (SP_IS_SHAPE(item))
1691
curve = sp_shape_get_curve(SP_SHAPE(item));
1693
else if (SP_IS_TEXT(item))
1695
curve = SP_TEXT(item)->getNormalizedBpath();
1704
NArtBpath *bpath = SP_CURVE_BPATH(curve);
1708
if ( doTransformation ) {
1710
bpath = nr_artpath_affine(SP_CURVE_BPATH(curve), sp_item_i2doc_affine(item));
1712
bpath = nr_artpath_affine(SP_CURVE_BPATH(curve), item->transform);
1713
sp_curve_unref(curve);
1716
bpath=SP_CURVE_BPATH(curve);
1764
SPCurve *curve = NULL;
1766
if (SP_IS_SHAPE(item)) {
1767
if (SP_IS_PATH(item)) {
1768
curve = sp_path_get_curve_for_edit(SP_PATH(item));
1770
curve = sp_shape_get_curve(SP_SHAPE(item));
1773
else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item))
1775
curve = te_get_layout(item)->convertToCurves();
1777
else if (SP_IS_IMAGE(item))
1779
curve = sp_image_get_curve(SP_IMAGE(item));
1782
return curve; // do not forget to unref the curve at some point!
1785
Path *bpath_to_Path(NArtBpath const *bpath) {
1719
1786
Path *dest = new Path;
1720
1787
dest->SetBackData(false);