240
238
num = g_slist_length((GSList *) desktop->selection->itemList());
241
239
sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
243
sel_message = g_strdup_printf(_("<b>Nothing</b> selected"));
241
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
508
506
} else if (mode == SPRAY_MODE_SINGLE_PATH) {
510
SPItem *father; //initial Object
511
SPItem *item_copied; //Projected Object
512
SPItem *unionResult; //previous union
513
SPItem *son; //father copy
508
SPItem *parent_item = NULL; //initial Object
509
SPItem *item_copied = NULL; //Projected Object
510
SPItem *union_result = NULL; //previous union
516
513
for (GSList *items = g_slist_copy((GSList *) selection->itemList());
520
517
SPItem *item1 = (SPItem *) items->data;
522
union_result = item1;
529
SPDocument *doc = SP_OBJECT_DOCUMENT(father);
526
SPDocument *doc = SP_OBJECT_DOCUMENT(parent_item);
530
527
Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc);
531
Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(father);
528
Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(parent_item);
532
529
Inkscape::XML::Node *parent = old_repr->parent();
534
Geom::OptRect a = father->getBounds(sp_item_i2doc_affine(father));
531
Geom::OptRect a = parent_item->getBounds(sp_item_i2doc_affine(parent_item));
537
Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc);
538
parent->appendChild(copy1);
539
SPObject *new_obj1 = doc->getObjectByRepr(copy1);
540
son = (SPItem *) new_obj1; // conversion object->item
542
Inkscape::GC::release(copy1);
545
533
if (_fid<=population) { // Rules the population of objects sprayed
546
// duplicates the father
547
Inkscape::XML::Node *copy2 = old_repr->duplicate(xml_doc);
548
parent->appendChild(copy2);
549
SPObject *new_obj2 = doc->getObjectByRepr(copy2);
550
item_copied = (SPItem *) new_obj2;
534
// duplicates the parent_item
535
Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
536
parent->appendChild(copy);
537
SPObject *new_obj = doc->getObjectByRepr(copy);
538
item_copied = SP_ITEM(new_obj);
552
540
// Move around the cursor
553
541
Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio),-sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());
555
Geom::Point center=father->getCenter();
543
Geom::Point center = parent_item->getCenter();
556
544
sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(_scale,_scale));
557
545
sp_spray_scale_rel(center,desktop,item_copied, Geom::Scale(scale,scale));
558
546
sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
561
549
// union and duplication
562
550
selection->clear();
563
551
selection->add(item_copied);
564
selection->add(unionResult);
553
selection->add(union_result);
565
555
sp_selected_path_union_skip_undo(selection->desktop());
566
selection->add(father);
567
Inkscape::GC::release(copy2);
556
selection->add(parent_item);
557
Inkscape::GC::release(copy);
581
571
// Creation of the clone
582
572
Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
583
// Ad the clone to the list of the father's sons
573
// Add the clone to the list of the parent_item's children
584
574
parent->appendChild(clone);
585
// Generates the link between father and son attributes
575
// Generates the link between parent_item and child attributes
586
576
clone->setAttribute("xlink:href", g_strdup_printf("#%s", old_repr->attribute("id")), false);
588
578
SPObject *clone_object = doc->getObjectByRepr(clone);