Merge lp:~inkscape.dev/inkscape/spraytool-no-overlap into lp:~inkscape.dev/inkscape/trunk

Proposed by Jabiertxof
Status: Merged
Merged at revision: 14452
Proposed branch: lp:~inkscape.dev/inkscape/spraytool-no-overlap
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 1189 lines (+758/-45)
7 files modified
src/ui/dialog/clonetiler.cpp (+24/-8)
src/ui/dialog/clonetiler.h (+3/-1)
src/ui/tools/spray-tool.cpp (+452/-23)
src/ui/tools/spray-tool.h (+11/-2)
src/widgets/spray-toolbar.cpp (+252/-8)
src/widgets/spray-toolbar.h (+1/-1)
src/widgets/toolbox.cpp (+15/-2)
To merge this branch: bzr merge lp:~inkscape.dev/inkscape/spraytool-no-overlap
Reviewer Review Type Date Requested Status
Inkscape Developers Pending
Review via email: mp+275643@code.launchpad.net

Description of the change

The feature I added is optionaly no overlap with offsets for spray tool.

To post a comment you must log in.
Revision history for this message
Mc (mc...) wrote :

I read it, and just saw two very minor things to change.

I did not test it yet.

14434. By jabiertxof<email address hidden>

Fixed typos from Mc
Removed unnecesary added headers
Put overlap default to false

Revision history for this message
Jabiertxof (jabiertxof) wrote :

Thanks Mc for the review! I hope you can test it soon.

14435. By jabiertxof<email address hidden>

Add option to not overlap if multiple elements are selected to spray

14436. By Jabiertxof <email address hidden>

Added a option to pick down color

14437. By Jabiertxof <email address hidden>

update to trunk

14438. By Jabiertxof <email address hidden>

removed dead code

14439. By Jabiertxof <email address hidden>

Fixed some typos pointed by Mc

14440. By jabiertxof<email address hidden>

Now the picker work with alphas and also in no overlap mode
Offset dropdown disabled if no overlap
Changed offset to percent based

14441. By jabiertxof<email address hidden>

little tweak

14442. By jabiertxof<email address hidden>

Fix the problems on transformed layers

14443. By jabiertxof<email address hidden>

add a ignore transparent areas option

14444. By jabiertxof<email address hidden>

Improvement to the css stored on change colors

14445. By jabiertxof<email address hidden>

Increase recursion levels

14446. By Jabiertxof <email address hidden>

Fix a regression updating CSS data

14447. By Jabiertxof <email address hidden>

Removed recursion from code because no speed improvements
Added swith to 100 on toogle no overlap button pointed by Mc.
Fixed crash pointed by Mc selecting all+no overlap+click

14448. By Jabiertxof <email address hidden>

update to trunk

14449. By Jabiertxof <email address hidden>

Add optional presure to width and to size
Start showing trace dialog

14450. By Jabiertxof <email address hidden>

update to trunk

14451. By jabiertxof<email address hidden>

Some fixes to new pressure options

14452. By jabiertxof<email address hidden>

Open trace dialog on click on pick toogle

14453. By jabiertxof<email address hidden>

Now picker use all features of trace clones

14454. By Jabiertxof <email address hidden>

Fix a bug compiling on pow

14455. By Jabiertxof <email address hidden>

Working on picker

14456. By Jabiertxof <email address hidden>

update to trunk

14457. By Jabiertxof <email address hidden>

'End' of picker work

14458. By Jabiertxof <email address hidden>

update to trunk

14459. By Jabiertxof <email address hidden>

Order disposition of icons
Add inverse also to opacity

14460. By Jabiertxof <email address hidden>

improve apply value to clones in scale mode

14461. By Jabiertxof <email address hidden>

update to trunk

14462. By Jabiertxof <email address hidden>

update to trunk

14463. By Jabiertxof <email address hidden>

update to trunk

14464. By Jabiertxof <email address hidden>

update to trunk

14465. By Jabiertxof <email address hidden>

Use color if trace dialog is disabled

14466. By Jabiertxof <email address hidden>

update to trunk

14467. By Jabiertxof <email address hidden>

Fix for scale bug pointed by Mc-

Revision history for this message
Mc (mc...) wrote :

comments inline

14468. By Jabiertxof <email address hidden>

Fixes from review form Mc-

14469. By Jabiertxof <email address hidden>

Fix a typo

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ui/dialog/clonetiler.cpp'
--- src/ui/dialog/clonetiler.cpp 2015-10-04 15:42:12 +0000
+++ src/ui/dialog/clonetiler.cpp 2015-11-08 09:50:32 +0000
@@ -85,7 +85,7 @@
85{85{
86 Gtk::Box *contents = _getContents();86 Gtk::Box *contents = _getContents();
87 contents->set_spacing(0);87 contents->set_spacing(0);
8888
89 {89 {
90 Inkscape::Preferences *prefs = Inkscape::Preferences::get();90 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
9191
@@ -101,7 +101,7 @@
101101
102 contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0);102 contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0);
103103
104 GtkWidget *nb = gtk_notebook_new ();104 nb = gtk_notebook_new ();
105 gtk_box_pack_start (GTK_BOX (mainbox), nb, FALSE, FALSE, 0);105 gtk_box_pack_start (GTK_BOX (mainbox), nb, FALSE, FALSE, 0);
106106
107107
@@ -662,7 +662,7 @@
662 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);662 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
663663
664 guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff);664 guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff);
665 color_picker = new Inkscape::UI::Widget::ColorPicker (*new Glib::ustring(_("Initial color of tiled clones")), *new Glib::ustring(_("Initial color for clones (works only if the original has unset fill or stroke)")), rgba, false);665 color_picker = new Inkscape::UI::Widget::ColorPicker (*new Glib::ustring(_("Initial color of tiled clones")), *new Glib::ustring(_("Initial color for clones (works only if the original has unset fill or stroke or on spray tool in copy mode)")), rgba, false);
666 color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed));666 color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed));
667667
668 gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0);668 gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0);
@@ -776,8 +776,6 @@
776 // Trace776 // Trace
777 {777 {
778 GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace"));778 GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace"));
779
780
781 {779 {
782#if GTK_CHECK_VERSION(3,0,0)780#if GTK_CHECK_VERSION(3,0,0)
783 GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);781 GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
@@ -787,11 +785,11 @@
787#endif785#endif
788 gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);786 gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);
789787
790 GtkWidget *b = gtk_check_button_new_with_label (_("Trace the drawing under the tiles"));788 b = gtk_check_button_new_with_label (_("Trace the drawing under the clones/sprayed items"));
791 g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));789 g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
792 bool old = prefs->getBool(prefs_path + "dotrace");790 bool old = prefs->getBool(prefs_path + "dotrace");
793 gtk_toggle_button_set_active ((GtkToggleButton *) b, old);791 gtk_toggle_button_set_active ((GtkToggleButton *) b, old);
794 gtk_widget_set_tooltip_text (b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone"));792 gtk_widget_set_tooltip_text (b, _("For each clone/sprayed item, pick a value from the drawing in its location and apply it"));
795 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);793 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
796794
797 g_signal_connect(G_OBJECT(b), "toggled",795 g_signal_connect(G_OBJECT(b), "toggled",
@@ -1001,6 +999,18 @@
1001 }999 }
1002 }1000 }
10031001
1002 {
1003#if GTK_CHECK_VERSION(3,0,0)
1004 GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN);
1005 gtk_box_set_homogeneous(GTK_BOX(hb), FALSE);
1006#else
1007 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
1008#endif
1009 gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
1010 GtkWidget *l = gtk_label_new(_(""));
1011 gtk_label_set_markup (GTK_LABEL(l), _("Apply to tiled clones:"));
1012 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
1013 }
1004 // Rows/columns, width/height1014 // Rows/columns, width/height
1005 {1015 {
1006#if GTK_CHECK_VERSION(3,0,0)1016#if GTK_CHECK_VERSION(3,0,0)
@@ -1289,7 +1299,6 @@
1289 }1299 }
12901300
1291 gtk_widget_show_all (mainbox);1301 gtk_widget_show_all (mainbox);
1292
1293 }1302 }
12941303
1295 show_all();1304 show_all();
@@ -3005,6 +3014,13 @@
3005 }3014 }
3006}3015}
30073016
3017void CloneTiler::show_page_trace()
3018{
3019 gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),6);
3020 gtk_toggle_button_set_active ((GtkToggleButton *) b, false);
3021}
3022
3023
3008}3024}
3009}3025}
3010}3026}
30113027
=== modified file 'src/ui/dialog/clonetiler.h'
--- src/ui/dialog/clonetiler.h 2014-10-08 02:22:03 +0000
+++ src/ui/dialog/clonetiler.h 2015-11-08 09:50:32 +0000
@@ -31,7 +31,7 @@
31 virtual ~CloneTiler();31 virtual ~CloneTiler();
3232
33 static CloneTiler &getInstance() { return *new CloneTiler(); }33 static CloneTiler &getInstance() { return *new CloneTiler(); }
3434 void show_page_trace();
35protected:35protected:
3636
37 GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label);37 GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label);
@@ -113,6 +113,8 @@
113 CloneTiler& operator=(CloneTiler const &d);113 CloneTiler& operator=(CloneTiler const &d);
114114
115 GtkWidget *dlg;115 GtkWidget *dlg;
116 GtkWidget *nb;
117 GtkWidget *b;
116 SPDesktop *desktop;118 SPDesktop *desktop;
117 DesktopTracker deskTrack;119 DesktopTracker deskTrack;
118 Inkscape::UI::Widget::ColorPicker *color_picker;120 Inkscape::UI::Widget::ColorPicker *color_picker;
119121
=== modified file 'src/ui/tools/spray-tool.cpp'
--- src/ui/tools/spray-tool.cpp 2015-07-04 16:15:46 +0000
+++ src/ui/tools/spray-tool.cpp 2015-11-08 09:50:32 +0000
@@ -12,6 +12,7 @@
12 * Steren GIANNINI (steren.giannini@gmail.com)12 * Steren GIANNINI (steren.giannini@gmail.com)
13 * Jon A. Cruz <jon@joncruz.org>13 * Jon A. Cruz <jon@joncruz.org>
14 * Abhishek Sharma14 * Abhishek Sharma
15 * Jabiertxo Arraiza <jabier.arraiza@marker.es>
15 *16 *
16 * Copyright (C) 2009 authors17 * Copyright (C) 2009 authors
17 *18 *
@@ -48,7 +49,15 @@
48#include "sp-path.h"49#include "sp-path.h"
49#include "path-chemistry.h"50#include "path-chemistry.h"
5051
52// For color picking
53#include "display/drawing.h"
54#include "display/drawing-context.h"
55#include "display/cairo-utils.h"
56#include "desktop-style.h"
57#include "svg/svg-color.h"
58
51#include "sp-text.h"59#include "sp-text.h"
60#include "sp-root.h"
52#include "sp-flowtext.h"61#include "sp-flowtext.h"
53#include "display/sp-canvas.h"62#include "display/sp-canvas.h"
54#include "display/canvas-bpath.h"63#include "display/canvas-bpath.h"
@@ -88,6 +97,17 @@
88namespace UI {97namespace UI {
89namespace Tools {98namespace Tools {
9099
100enum {
101 PICK_COLOR,
102 PICK_OPACITY,
103 PICK_R,
104 PICK_G,
105 PICK_B,
106 PICK_H,
107 PICK_S,
108 PICK_L
109};
110
91const std::string& SprayTool::getPrefsPath() {111const std::string& SprayTool::getPrefsPath() {
92 return SprayTool::prefsPath;112 return SprayTool::prefsPath;
93}113}
@@ -133,7 +153,9 @@
133 : ToolBase(cursor_spray_xpm, 4, 4, false)153 : ToolBase(cursor_spray_xpm, 4, 4, false)
134 , pressure(TC_DEFAULT_PRESSURE)154 , pressure(TC_DEFAULT_PRESSURE)
135 , dragging(false)155 , dragging(false)
136 , usepressure(false)156 , usepressurewidth(false)
157 , usepressurepopulation(false)
158 , usepressurescale(false)
137 , usetilt(false)159 , usetilt(false)
138 , usetext(false)160 , usetext(false)
139 , width(0.2)161 , width(0.2)
@@ -151,6 +173,13 @@
151 , is_dilating(false)173 , is_dilating(false)
152 , has_dilated(false)174 , has_dilated(false)
153 , dilate_area(NULL)175 , dilate_area(NULL)
176 , nooverlap(false)
177 , picker(false)
178 , pickinversevalue(false)
179 , pickfill(false)
180 , pickstroke(false)
181 , visible(false)
182 , offset(0)
154{183{
155}184}
156185
@@ -221,8 +250,17 @@
221 sp_event_context_read(this, "population");250 sp_event_context_read(this, "population");
222 sp_event_context_read(this, "mean");251 sp_event_context_read(this, "mean");
223 sp_event_context_read(this, "standard_deviation");252 sp_event_context_read(this, "standard_deviation");
224 sp_event_context_read(this, "usepressure");253 sp_event_context_read(this, "usepressurewidth");
254 sp_event_context_read(this, "usepressurepopulation");
255 sp_event_context_read(this, "usepressurescale");
225 sp_event_context_read(this, "Scale");256 sp_event_context_read(this, "Scale");
257 sp_event_context_read(this, "offset");
258 sp_event_context_read(this, "picker");
259 sp_event_context_read(this, "pickinversevalue");
260 sp_event_context_read(this, "pickfill");
261 sp_event_context_read(this, "pickstroke");
262 sp_event_context_read(this, "visible");
263 sp_event_context_read(this, "nooverlap");
226264
227 Inkscape::Preferences *prefs = Inkscape::Preferences::get();265 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
228 if (prefs->getBool("/tools/spray/selcue")) {266 if (prefs->getBool("/tools/spray/selcue")) {
@@ -241,8 +279,12 @@
241 this->update_cursor(false);279 this->update_cursor(false);
242 } else if (path == "width") {280 } else if (path == "width") {
243 this->width = 0.01 * CLAMP(val.getInt(10), 1, 100);281 this->width = 0.01 * CLAMP(val.getInt(10), 1, 100);
244 } else if (path == "usepressure") {282 } else if (path == "usepressurewidth") {
245 this->usepressure = val.getBool();283 this->usepressurewidth = val.getBool();
284 } else if (path == "usepressurepopulation") {
285 this->usepressurepopulation = val.getBool();
286 } else if (path == "usepressurescale") {
287 this->usepressurescale = val.getBool();
246 } else if (path == "population") {288 } else if (path == "population") {
247 this->population = 0.01 * CLAMP(val.getInt(10), 1, 100);289 this->population = 0.01 * CLAMP(val.getInt(10), 1, 100);
248 } else if (path == "rotation_variation") {290 } else if (path == "rotation_variation") {
@@ -260,6 +302,20 @@
260 this->tilt = CLAMP(val.getDouble(0.1), 0, 1000.0);302 this->tilt = CLAMP(val.getDouble(0.1), 0, 1000.0);
261 } else if (path == "ratio") {303 } else if (path == "ratio") {
262 this->ratio = CLAMP(val.getDouble(), 0.0, 0.9);304 this->ratio = CLAMP(val.getDouble(), 0.0, 0.9);
305 } else if (path == "offset") {
306 this->offset = CLAMP(val.getDouble(), -1000.0, 1000.0);
307 } else if (path == "picker") {
308 this->picker = val.getBool();
309 } else if (path == "pickinversevalue") {
310 this->pickinversevalue = val.getBool();
311 } else if (path == "pickfill") {
312 this->pickfill = val.getBool();
313 } else if (path == "pickstroke") {
314 this->pickstroke = val.getBool();
315 } else if (path == "visible") {
316 this->visible = val.getBool();
317 } else if (path == "nooverlap") {
318 this->nooverlap = val.getBool();
263 }319 }
264}320}
265321
@@ -272,9 +328,15 @@
272 }328 }
273}329}
274330
331static double get_width(SprayTool *tc)
332{
333 double pressure = (tc->usepressurewidth? tc->pressure / TC_DEFAULT_PRESSURE : 1);
334 return pressure * tc->width;
335}
336
275static double get_dilate_radius(SprayTool *tc)337static double get_dilate_radius(SprayTool *tc)
276{338{
277 return 250 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom();339 return 250 * get_width(tc)/SP_EVENT_CONTEXT(tc)->desktop->current_zoom();
278}340}
279341
280static double get_path_mean(SprayTool *tc)342static double get_path_mean(SprayTool *tc)
@@ -289,11 +351,16 @@
289351
290static double get_population(SprayTool *tc)352static double get_population(SprayTool *tc)
291{353{
292 double pressure = (tc->usepressure? tc->pressure / TC_DEFAULT_PRESSURE : 1);354 double pressure = (tc->usepressurepopulation? tc->pressure / TC_DEFAULT_PRESSURE : 1);
293 //g_warning("Pressure, population: %f, %f", pressure, pressure * tc->population);
294 return pressure * tc->population;355 return pressure * tc->population;
295}356}
296357
358static double get_pressure(SprayTool *tc)
359{
360 double pressure = tc->pressure / TC_DEFAULT_PRESSURE;
361 return pressure;
362}
363
297static double get_move_mean(SprayTool *tc)364static double get_move_mean(SprayTool *tc)
298{365{
299 return tc->mean;366 return tc->mean;
@@ -332,6 +399,317 @@
332399
333}400}
334401
402static void sp_spray_transform_path(SPItem * item, Geom::Path &path, Geom::Affine affine, Geom::Point center){
403 path *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
404 path *= item->transform.inverse();
405 Geom::Affine dt2p;
406 if (item->parent) {
407 dt2p = static_cast<SPItem *>(item->parent)->i2dt_affine().inverse();
408 } else {
409 SPDesktop *dt = SP_ACTIVE_DESKTOP;
410 dt2p = dt->dt2doc();
411 }
412 Geom::Affine i2dt = item->i2dt_affine() * Geom::Translate(center).inverse() * affine * Geom::Translate(center);
413 path *= i2dt * dt2p;
414 path *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL);
415}
416
417/**
418Randomizes \a val by \a rand, with 0 < val < 1 and all values (including 0, 1) having the same
419probability of being displaced.
420 */
421double randomize01(double val, double rand)
422{
423 double base = MIN (val - rand, 1 - 2*rand);
424 if (base < 0) {
425 base = 0;
426 }
427 val = base + g_random_double_range (0, MIN (2 * rand, 1 - base));
428 return CLAMP(val, 0, 1); // this should be unnecessary with the above provisions, but just in case...
429}
430
431static bool fit_item(SPDesktop *desktop,
432 SPItem *item,
433 Geom::OptRect bbox,
434 Geom::Point &move,
435 Geom::Point center,
436 double angle,
437 double &_scale,
438 double scale,
439 bool picker,
440 bool pickinversevalue,
441 bool pickfill,
442 bool pickstroke,
443 bool visible,
444 bool nooverlap,
445 double offset,
446 SPCSSAttr *css,
447 bool trace_scale)
448{
449 SPDocument *doc = item->document;
450 double width = bbox->width();
451 double height = bbox->height();
452 double size = std::min(width,height);
453 double offset_min = (offset * size)/100.0 - (size);
454 if(offset_min < 0 ){
455 offset_min = 0;
456 }
457 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
458 bool pick_to_size = prefs->getBool("/dialogs/clonetiler/pick_to_size");
459 bool trace = prefs->getBool("/dialogs/clonetiler/dotrace");
460 if(picker && pick_to_size && !trace_scale && trace){
461 _scale = 0.1;
462 }
463 Geom::OptRect bbox_procesed = Geom::Rect(Geom::Point(bbox->left() - offset_min, bbox->top() - offset_min),Geom::Point(bbox->right() + offset_min, bbox->bottom() + offset_min));
464 Geom::Path path;
465 path.start(Geom::Point(bbox_procesed->left(), bbox_procesed->top()));
466 path.appendNew<Geom::LineSegment>(Geom::Point(bbox_procesed->right(), bbox_procesed->top()));
467 path.appendNew<Geom::LineSegment>(Geom::Point(bbox_procesed->right(), bbox_procesed->bottom()));
468 path.appendNew<Geom::LineSegment>(Geom::Point(bbox_procesed->left(), bbox_procesed->bottom()));
469 path.close(true);
470 sp_spray_transform_path(item, path, Geom::Scale(_scale), center);
471 sp_spray_transform_path(item, path, Geom::Scale(scale), center);
472 sp_spray_transform_path(item, path, Geom::Rotate(angle), center);
473 path *= Geom::Translate(move);
474 path *= desktop->doc2dt();
475 bbox_procesed = path.boundsFast();
476 double bbox_left_main = bbox_procesed->left();
477 double bbox_top_main = bbox_procesed->top();
478 double width_transformed = bbox_procesed->width();
479 double height_transformed = bbox_procesed->height();
480 Geom::Point mid_point = desktop->d2w(bbox_procesed->midpoint());
481 Geom::IntRect area = Geom::IntRect::from_xywh(floor(mid_point[Geom::X]), floor(mid_point[Geom::Y]), 1, 1);
482 double R = 0, G = 0, B = 0, A = 0;
483 cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
484 sp_canvas_arena_render_surface(SP_CANVAS_ARENA(desktop->getDrawing()), s, area);
485 ink_cairo_surface_average_color(s, R, G, B, A);
486 cairo_surface_destroy(s);
487 guint32 rgba = SP_RGBA32_F_COMPOSE(R, G, B, A);
488 if(nooverlap && visible && (A==0 || A < 1e-6)){
489 return false;
490 }
491 size = std::min(width_transformed,height_transformed);
492 if(offset < 100 ){
493 offset_min = ((99.0 - offset) * size)/100.0 - size;
494 } else {
495 offset_min = 0;
496 }
497 std::vector<SPItem*> items_down = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *bbox_procesed);
498 Inkscape::Selection *selection = desktop->getSelection();
499 if (selection->isEmpty()) {
500 return false;
501 }
502 std::vector<SPItem*> const items_selected(selection->itemList());
503 for (std::vector<SPItem*>::const_iterator i=items_down.begin(); i!=items_down.end(); i++) {
504 SPItem *item_down = *i;
505 Geom::OptRect bbox_down = item_down->documentVisualBounds();
506 width = bbox_down->width();
507 height = bbox_down->height();
508 double bbox_left = bbox_down->left();
509 double bbox_top = bbox_down->top();
510 gchar const * item_down_sharp = g_strdup_printf("#%s", item_down->getId());
511 for (std::vector<SPItem*>::const_iterator j=items_selected.begin(); j!=items_selected.end(); j++) {
512 SPItem *item_selected = *j;
513 gchar const * spray_origin;
514 if(!item_selected->getAttribute("inkscape:spray-origin")){
515 spray_origin = g_strdup_printf("#%s", item_selected->getId());
516 } else {
517 spray_origin = item_selected->getAttribute("inkscape:spray-origin");
518 }
519 if(strcmp(item_down_sharp, spray_origin) == 0 ||
520 (item_down->getAttribute("inkscape:spray-origin") &&
521 strcmp(item_down->getAttribute("inkscape:spray-origin"),spray_origin) == 0 ))
522 {
523 if(nooverlap){
524 if(!(offset_min < 0 && std::abs(bbox_left - bbox_left_main) > std::abs(offset_min) &&
525 std::abs(bbox_top - bbox_top_main) > std::abs(offset_min))){
526 return false;
527 }
528 } else if(picker || visible){
529 item_down->setHidden(true);
530 item_down->updateRepr();
531 }
532 }
533 }
534 }
535 if(picker || visible){
536 if(!nooverlap){
537 doc->ensureUpToDate();
538 }
539 int pick = prefs->getInt("/dialogs/clonetiler/pick");
540 bool pick_to_presence = prefs->getBool("/dialogs/clonetiler/pick_to_presence", false);
541 bool pick_to_color = prefs->getBool("/dialogs/clonetiler/pick_to_color");
542 bool pick_to_opacity = prefs->getBool("/dialogs/clonetiler/pick_to_opacity");
543 double rand_picked = 0.01 * prefs->getDoubleLimited("/dialogs/clonetiler/rand_picked", 0, 0, 100);
544 bool invert_picked = prefs->getBool("/dialogs/clonetiler/invert_picked");
545 double gamma_picked = prefs->getDoubleLimited("/dialogs/clonetiler/gamma_picked", 0, -10, 10);
546 double opacity = 1.0;
547 gchar color_string[32]; *color_string = 0;
548 float r = SP_RGBA32_R_F(rgba);
549 float g = SP_RGBA32_G_F(rgba);
550 float b = SP_RGBA32_B_F(rgba);
551 float a = SP_RGBA32_A_F(rgba);
552 //this can fix the bug #1511998 if confirmed
553 if( a == 0 || a < 1e-6){
554 r = 1;
555 g = 1;
556 b = 1;
557 }
558 if(visible && (a == 0 || a < 1e-6)){
559 return false;
560 }
561
562 if(picker && trace){
563 float hsl[3];
564 sp_color_rgb_to_hsl_floatv (hsl, r, g, b);
565
566 gdouble val = 0;
567 switch (pick) {
568 case PICK_COLOR:
569 val = 1 - hsl[2]; // inverse lightness; to match other picks where black = max
570 break;
571 case PICK_OPACITY:
572 val = a;
573 break;
574 case PICK_R:
575 val = r;
576 break;
577 case PICK_G:
578 val = g;
579 break;
580 case PICK_B:
581 val = b;
582 break;
583 case PICK_H:
584 val = hsl[0];
585 break;
586 case PICK_S:
587 val = hsl[1];
588 break;
589 case PICK_L:
590 val = 1 - hsl[2];
591 break;
592 default:
593 break;
594 }
595
596 if (rand_picked > 0) {
597 val = randomize01 (val, rand_picked);
598 r = randomize01 (r, rand_picked);
599 g = randomize01 (g, rand_picked);
600 b = randomize01 (b, rand_picked);
601 }
602
603 if (gamma_picked != 0) {
604 double power;
605 if (gamma_picked > 0)
606 power = 1/(1 + fabs(gamma_picked));
607 else
608 power = 1 + fabs(gamma_picked);
609
610 val = pow (val, power);
611 r = pow ((double)r, (double)power);
612 g = pow ((double)g, (double)power);
613 b = pow ((double)b, (double)power);
614 }
615
616 if (invert_picked) {
617 val = 1 - val;
618 r = 1 - r;
619 g = 1 - g;
620 b = 1 - b;
621 }
622
623 val = CLAMP (val, 0, 1);
624 r = CLAMP (r, 0, 1);
625 g = CLAMP (g, 0, 1);
626 b = CLAMP (b, 0, 1);
627
628 // recompose tweaked color
629 rgba = SP_RGBA32_F_COMPOSE(r, g, b, a);
630 if (pick_to_size) {
631 if(!trace_scale){
632 if(pickinversevalue) {
633 _scale = 1.0 - val;
634 } else {
635 _scale = val;
636 }
637 if(_scale == 0.0) {
638 return false;
639 }
640 if(!fit_item(desktop,
641 item,
642 bbox,
643 move,
644 center,
645 angle,
646 _scale,
647 scale,
648 picker,
649 pickinversevalue,
650 pickfill,
651 pickstroke,
652 visible,
653 nooverlap,
654 offset,
655 css,
656 true)){
657 return false;
658 }
659 }
660 }
661
662 if (pick_to_opacity) {
663 if(pickinversevalue) {
664 opacity *= 1.0 - val;
665 } else {
666 opacity *= val;
667 }
668 std::stringstream opacity_str;
669 opacity_str.imbue(std::locale::classic());
670 opacity_str << opacity;
671 sp_repr_css_set_property(css, "opacity", opacity_str.str().c_str());
672 }
673 if (pick_to_presence) {
674 if (g_random_double_range (0, 1) > val) {
675 //Hidding the element is a way to retain original
676 //behaviour of tiled clones for presence option.
677 sp_repr_css_set_property(css, "opacity", "0");
678 }
679 }
680 if (pick_to_color) {
681 sp_svg_write_color(color_string, sizeof(color_string), rgba);
682 if(pickfill){
683 sp_repr_css_set_property(css, "fill", color_string);
684 }
685 if(pickstroke){
686 sp_repr_css_set_property(css, "stroke", color_string);
687 }
688 }
689 if (opacity < 1e-6) { // invisibly transparent, skip
690 return false;
691 }
692 }
693 if(!trace){
694 sp_svg_write_color(color_string, sizeof(color_string), rgba);
695 if(pickfill){
696 sp_repr_css_set_property(css, "fill", color_string);
697 }
698 if(pickstroke){
699 sp_repr_css_set_property(css, "stroke", color_string);
700 }
701 }
702 if(!nooverlap && (picker || visible)){
703 for (std::vector<SPItem *>::const_iterator k=items_down.begin(); k!=items_down.end(); k++) {
704 SPItem *item_hidden = *k;
705 item_hidden->setHidden(false);
706 item_hidden->updateRepr();
707 }
708 }
709 }
710 return true;
711}
712
335static bool sp_spray_recursive(SPDesktop *desktop,713static bool sp_spray_recursive(SPDesktop *desktop,
336 Inkscape::Selection *selection,714 Inkscape::Selection *selection,
337 SPItem *item,715 SPItem *item,
@@ -348,7 +726,16 @@
348 double ratio,726 double ratio,
349 double tilt,727 double tilt,
350 double rotation_variation,728 double rotation_variation,
351 gint _distrib)729 gint _distrib,
730 bool nooverlap,
731 bool picker,
732 bool pickinversevalue,
733 bool pickfill,
734 bool pickstroke,
735 bool visible,
736 double offset,
737 bool usepressurescale,
738 double pressure)
352{739{
353 bool did = false;740 bool did = false;
354741
@@ -364,6 +751,9 @@
364 double _fid = g_random_double_range(0, 1);751 double _fid = g_random_double_range(0, 1);
365 double angle = g_random_double_range( - rotation_variation / 100.0 * M_PI , rotation_variation / 100.0 * M_PI );752 double angle = g_random_double_range( - rotation_variation / 100.0 * M_PI , rotation_variation / 100.0 * M_PI );
366 double _scale = g_random_double_range( 1.0 - scale_variation / 100.0, 1.0 + scale_variation / 100.0 );753 double _scale = g_random_double_range( 1.0 - scale_variation / 100.0, 1.0 + scale_variation / 100.0 );
754 if(usepressurescale){
755 _scale = pressure;
756 }
367 double dr; double dp;757 double dr; double dp;
368 random_position( dr, dp, mean, standard_deviation, _distrib );758 random_position( dr, dp, mean, standard_deviation, _distrib );
369 dr=dr*radius;759 dr=dr*radius;
@@ -371,27 +761,44 @@
371 if (mode == SPRAY_MODE_COPY) {761 if (mode == SPRAY_MODE_COPY) {
372 Geom::OptRect a = item->documentVisualBounds();762 Geom::OptRect a = item->documentVisualBounds();
373 if (a) {763 if (a) {
374 SPItem *item_copied;
375 if(_fid <= population)764 if(_fid <= population)
376 {765 {
766 SPDocument *doc = item->document;
767 gchar const * spray_origin;
768 if(!item->getAttribute("inkscape:spray-origin")){
769 spray_origin = g_strdup_printf("#%s", item->getId());
770 } else {
771 spray_origin = item->getAttribute("inkscape:spray-origin");
772 }
773 Geom::Point center = item->getCenter();
774 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());
775 SPCSSAttr *css = sp_repr_css_attr_new();
776 if(nooverlap || picker || visible){
777 if(!fit_item(desktop, item, a, move, center, angle, _scale, scale, picker, pickinversevalue, pickfill, pickstroke, visible, nooverlap, offset, css, false)){
778 return false;
779 }
780 }
781 SPItem *item_copied;
377 // Duplicate782 // Duplicate
378 SPDocument *doc = item->document;
379 Inkscape::XML::Document* xml_doc = doc->getReprDoc();783 Inkscape::XML::Document* xml_doc = doc->getReprDoc();
380 Inkscape::XML::Node *old_repr = item->getRepr();784 Inkscape::XML::Node *old_repr = item->getRepr();
381 Inkscape::XML::Node *parent = old_repr->parent();785 Inkscape::XML::Node *parent = old_repr->parent();
382 Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);786 Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
787 if(!copy->attribute("inkscape:spray-origin")){
788 copy->setAttribute("inkscape:spray-origin", spray_origin);
789 }
383 parent->appendChild(copy);790 parent->appendChild(copy);
384
385 SPObject *new_obj = doc->getObjectByRepr(copy);791 SPObject *new_obj = doc->getObjectByRepr(copy);
386 item_copied = dynamic_cast<SPItem *>(new_obj); // Conversion object->item792 item_copied = dynamic_cast<SPItem *>(new_obj); // Conversion object->item
387 Geom::Point center=item->getCenter();793 sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(_scale));
388 sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(_scale,_scale));794 sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale));
389 sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale,scale));
390
391 sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));795 sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle));
392 // Move the cursor p796 // Move the cursor p
393 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());
394 sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));797 sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
798 Inkscape::GC::release(copy);
799 if(picker){
800 sp_desktop_apply_css_recursive(item_copied, css, true);
801 }
395 did = true;802 did = true;
396 }803 }
397 }804 }
@@ -425,6 +832,13 @@
425 if (_fid <= population) { // Rules the population of objects sprayed832 if (_fid <= population) { // Rules the population of objects sprayed
426 // Duplicates the parent item833 // Duplicates the parent item
427 Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);834 Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
835 gchar const * spray_origin;
836 if(!copy->attribute("inkscape:spray-origin")){
837 spray_origin = g_strdup_printf("#%s", old_repr->attribute("id"));
838 copy->setAttribute("inkscape:spray-origin", spray_origin);
839 } else {
840 spray_origin = copy->attribute("inkscape:spray-origin");
841 }
428 parent->appendChild(copy);842 parent->appendChild(copy);
429 SPObject *new_obj = doc->getObjectByRepr(copy);843 SPObject *new_obj = doc->getObjectByRepr(copy);
430 item_copied = dynamic_cast<SPItem *>(new_obj);844 item_copied = dynamic_cast<SPItem *>(new_obj);
@@ -456,8 +870,22 @@
456 Geom::OptRect a = item->documentVisualBounds();870 Geom::OptRect a = item->documentVisualBounds();
457 if (a) {871 if (a) {
458 if(_fid <= population) {872 if(_fid <= population) {
873 SPDocument *doc = item->document;
874 gchar const * spray_origin;
875 if(!item->getAttribute("inkscape:spray-origin")){
876 spray_origin = g_strdup_printf("#%s", item->getId());
877 } else {
878 spray_origin = item->getAttribute("inkscape:spray-origin");
879 }
880 Geom::Point center=item->getCenter();
881 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());
882 SPCSSAttr *css = sp_repr_css_attr_new();
883 if(nooverlap || picker || visible){
884 if(!fit_item(desktop, item, a, move, center, angle, _scale, scale, picker, pickinversevalue, pickfill, pickstroke, visible, nooverlap, offset, css, false)){
885 return false;
886 }
887 }
459 SPItem *item_copied;888 SPItem *item_copied;
460 SPDocument *doc = item->document;
461 Inkscape::XML::Document* xml_doc = doc->getReprDoc();889 Inkscape::XML::Document* xml_doc = doc->getReprDoc();
462 Inkscape::XML::Node *old_repr = item->getRepr();890 Inkscape::XML::Node *old_repr = item->getRepr();
463 Inkscape::XML::Node *parent = old_repr->parent();891 Inkscape::XML::Node *parent = old_repr->parent();
@@ -467,6 +895,9 @@
467 // Ad the clone to the list of the parent's children895 // Ad the clone to the list of the parent's children
468 parent->appendChild(clone);896 parent->appendChild(clone);
469 // Generates the link between parent and child attributes897 // Generates the link between parent and child attributes
898 if(!clone->attribute("inkscape:spray-origin")){
899 clone->setAttribute("inkscape:spray-origin", spray_origin);
900 }
470 gchar *href_str = g_strdup_printf("#%s", old_repr->attribute("id"));901 gchar *href_str = g_strdup_printf("#%s", old_repr->attribute("id"));
471 clone->setAttribute("xlink:href", href_str, false); 902 clone->setAttribute("xlink:href", href_str, false);
472 g_free(href_str);903 g_free(href_str);
@@ -474,15 +905,14 @@
474 SPObject *clone_object = doc->getObjectByRepr(clone);905 SPObject *clone_object = doc->getObjectByRepr(clone);
475 // Conversion object->item906 // Conversion object->item
476 item_copied = dynamic_cast<SPItem *>(clone_object);907 item_copied = dynamic_cast<SPItem *>(clone_object);
477 Geom::Point center = item->getCenter();
478 sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));908 sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale));
479 sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));909 sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale));
480 sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));910 sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle));
481 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());
482 sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));911 sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
483912 if(picker){
913 sp_desktop_apply_css_recursive(item_copied, css, true);
914 }
484 Inkscape::GC::release(clone);915 Inkscape::GC::release(clone);
485
486 did = true;916 did = true;
487 }917 }
488 }918 }
@@ -529,8 +959,7 @@
529 for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){959 for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
530 SPItem *item = *i;960 SPItem *item = *i;
531 g_assert(item != NULL);961 g_assert(item != NULL);
532962 if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib, tc->nooverlap, tc->picker, tc->pickinversevalue, tc->pickfill, tc->pickstroke, tc->visible, tc->offset, tc->usepressurescale, get_pressure(tc))) {
533 if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib)) {
534 did = true;963 did = true;
535 }964 }
536 }965 }
537966
=== modified file 'src/ui/tools/spray-tool.h'
--- src/ui/tools/spray-tool.h 2015-06-22 19:20:23 +0000
+++ src/ui/tools/spray-tool.h 2015-11-08 09:50:32 +0000
@@ -12,6 +12,7 @@
12 * Benoît LAVORATA12 * Benoît LAVORATA
13 * Vincent MONTAGNE13 * Vincent MONTAGNE
14 * Pierre BARBRY-BLOT14 * Pierre BARBRY-BLOT
15 * Jabiertxo ARRAIZA
15 *16 *
16 * Copyright (C) 2009 authors17 * Copyright (C) 2009 authors
17 *18 *
@@ -62,7 +63,9 @@
6263
63 /* attributes */64 /* attributes */
64 bool dragging; /* mouse state: mouse is dragging */65 bool dragging; /* mouse state: mouse is dragging */
65 bool usepressure;66 bool usepressurewidth;
67 bool usepressurepopulation;
68 bool usepressurescale;
66 bool usetilt;69 bool usetilt;
67 bool usetext;70 bool usetext;
6871
@@ -86,7 +89,13 @@
86 bool has_dilated;89 bool has_dilated;
87 Geom::Point last_push;90 Geom::Point last_push;
88 SPCanvasItem *dilate_area;91 SPCanvasItem *dilate_area;
8992 bool nooverlap;
93 bool picker;
94 bool pickinversevalue;
95 bool pickfill;
96 bool pickstroke;
97 bool visible;
98 double offset;
90 sigc::connection style_set_connection;99 sigc::connection style_set_connection;
91100
92 static const std::string prefsPath;101 static const std::string prefsPath;
93102
=== modified file 'src/widgets/spray-toolbar.cpp'
--- src/widgets/spray-toolbar.cpp 2014-10-05 18:14:01 +0000
+++ src/widgets/spray-toolbar.cpp 2015-11-08 09:50:32 +0000
@@ -15,10 +15,11 @@
15 * Tavmjong Bah <tavmjong@free.fr>15 * Tavmjong Bah <tavmjong@free.fr>
16 * Abhishek Sharma16 * Abhishek Sharma
17 * Kris De Gussem <Kris.DeGussem@gmail.com>17 * Kris De Gussem <Kris.DeGussem@gmail.com>
18 * Jabiertxo Arraiza <jabier.arraiza@marker.es>
18 *19 *
19 * Copyright (C) 2004 David Turner20 * Copyright (C) 2004 David Turner
20 * Copyright (C) 2003 MenTaLguY21 * Copyright (C) 2003 MenTaLguY
21 * Copyright (C) 1999-2011 authors22 * Copyright (C) 1999-2015 authors
22 * Copyright (C) 2001-2002 Ximian, Inc.23 * Copyright (C) 2001-2002 Ximian, Inc.
23 *24 *
24 * Released under GNU GPL, read the file 'COPYING' for more information25 * Released under GNU GPL, read the file 'COPYING' for more information
@@ -28,18 +29,24 @@
28# include "config.h"29# include "config.h"
29#endif30#endif
3031
31#include <glibmm/i18n.h>32#include <gtkmm.h>
3233
33#include "spray-toolbar.h"34#include "spray-toolbar.h"
34#include "desktop.h"35#include "desktop.h"
36#include "inkscape.h"
35#include "document-undo.h"37#include "document-undo.h"
36#include "widgets/ege-adjustment-action.h"38#include "widgets/ege-adjustment-action.h"
37#include "widgets/ege-select-one-action.h"39#include "widgets/ege-select-one-action.h"
38#include "widgets/ink-action.h"40#include "widgets/ink-action.h"
39#include "preferences.h"41#include "preferences.h"
40#include "toolbox.h"42#include "toolbox.h"
43#include "ui/dialog/clonetiler.h"
44#include "ui/dialog/dialog-manager.h"
45#include "ui/dialog/panel-dialog.h"
41#include "ui/icon-names.h"46#include "ui/icon-names.h"
4247
48#include <glibmm/i18n.h>
49
43using Inkscape::DocumentUndo;50using Inkscape::DocumentUndo;
44using Inkscape::UI::ToolboxFactory;51using Inkscape::UI::ToolboxFactory;
45using Inkscape::UI::PrefPusher;52using Inkscape::UI::PrefPusher;
@@ -53,6 +60,55 @@
53//## Spray ##60//## Spray ##
54//########################61//########################
5562
63static void sp_stb_sensitivize( GObject *tbl )
64{
65 GtkAction* offset = GTK_ACTION( g_object_get_data(tbl, "offset") );
66 GtkAction* spray_scale = GTK_ACTION( g_object_get_data(tbl, "spray_scale") );
67 GtkAdjustment *adj_offset = ege_adjustment_action_get_adjustment( EGE_ADJUSTMENT_ACTION(offset) );
68 GtkAdjustment *adj_scale = ege_adjustment_action_get_adjustment( EGE_ADJUSTMENT_ACTION(spray_scale) );
69 GtkToggleAction *nooverlap = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "nooverlap") );
70 GtkToggleAction *picker = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "picker") );
71 GtkToggleAction *usepressurescale = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "usepressurescale") );
72 GtkAction *pickfill = GTK_ACTION( g_object_get_data(tbl, "pickfill") );
73 GtkAction *pickstroke = GTK_ACTION( g_object_get_data(tbl, "pickstroke") );
74 GtkAction *pickinversevalue = GTK_ACTION( g_object_get_data(tbl, "pickinversevalue") );
75 gtk_adjustment_set_value( adj_offset, 100.0 );
76 if (gtk_toggle_action_get_active(nooverlap)) {
77 gtk_action_set_sensitive( offset, TRUE );
78 } else {
79 gtk_action_set_sensitive( offset, FALSE );
80 }
81 if (gtk_toggle_action_get_active(usepressurescale)) {
82 gtk_adjustment_set_value( adj_scale, 0.0 );
83 gtk_action_set_sensitive( spray_scale, FALSE );
84 } else {
85 gtk_action_set_sensitive( spray_scale, TRUE );
86 }
87 if(gtk_toggle_action_get_active(picker)){
88 gtk_action_set_sensitive( pickfill, TRUE );
89 gtk_action_set_sensitive( pickstroke, TRUE );
90 gtk_action_set_sensitive( pickinversevalue, TRUE );
91 } else {
92 gtk_action_set_sensitive( pickfill, FALSE );
93 gtk_action_set_sensitive( pickstroke, FALSE );
94 gtk_action_set_sensitive( pickinversevalue, FALSE );
95 }
96}
97
98Inkscape::UI::Dialog::CloneTiler *get_clone_tiler_panel(SPDesktop *desktop)
99{
100 if (Inkscape::UI::Dialog::PanelDialogBase *panel_dialog =
101 dynamic_cast<Inkscape::UI::Dialog::PanelDialogBase *>(desktop->_dlg_mgr->getDialog("CloneTiler"))) {
102 try {
103 Inkscape::UI::Dialog::CloneTiler &clone_tiler =
104 dynamic_cast<Inkscape::UI::Dialog::CloneTiler &>(panel_dialog->getPanel());
105 return &clone_tiler;
106 } catch (std::exception &e) { }
107 }
108
109 return 0;
110}
111
56static void sp_spray_width_value_changed( GtkAdjustment *adj, GObject * /*tbl*/ )112static void sp_spray_width_value_changed( GtkAdjustment *adj, GObject * /*tbl*/ )
57{113{
58 Inkscape::Preferences *prefs = Inkscape::Preferences::get();114 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -102,12 +158,83 @@
102 gtk_adjustment_get_value(adj));158 gtk_adjustment_get_value(adj));
103}159}
104160
161static void sp_spray_offset_value_changed( GtkAdjustment *adj, GObject * /*tbl*/ )
162{
163 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
164 prefs->setDouble( "/tools/spray/offset",
165 gtk_adjustment_get_value(adj));
166}
167
168static void sp_toggle_nooverlap( GtkToggleAction* act, gpointer data)
169{
170 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
171 gboolean active = gtk_toggle_action_get_active(act);
172 prefs->setBool("/tools/spray/nooverlap", active);
173 GObject *tbl = G_OBJECT(data);
174 sp_stb_sensitivize(tbl);
175}
176
177static void sp_toggle_pressure_scale( GtkToggleAction* act, gpointer data)
178{
179 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
180 gboolean active = gtk_toggle_action_get_active(act);
181 prefs->setBool("/tools/spray/usepressurescale", active);
182 if(active == true){
183 prefs->setDouble("/tools/spray/scale_variation", 0);
184 }
185 GObject *tbl = G_OBJECT(data);
186 sp_stb_sensitivize( tbl );
187}
188
189static void sp_toggle_visible( GtkToggleAction* act, gpointer data)
190{
191 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
192 gboolean active = gtk_toggle_action_get_active(act);
193 prefs->setBool("/tools/spray/visible", active);
194}
195
196static void sp_toggle_picker( GtkToggleAction* act, gpointer data )
197{
198 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
199 gboolean active = gtk_toggle_action_get_active(act);
200 prefs->setBool("/tools/spray/picker", active);
201 if(active == true){
202 prefs->setBool("/dialogs/clonetiler/dotrace", true);
203 SPDesktop *dt = SP_ACTIVE_DESKTOP;
204 if (Inkscape::UI::Dialog::CloneTiler *ct = get_clone_tiler_panel(dt)){
205 dt->_dlg_mgr->showDialog("CloneTiler");
206 ct->show_page_trace();
207 }
208 }
209 GObject *tbl = G_OBJECT(data);
210 sp_stb_sensitivize(tbl);
211}
212
213static void sp_toggle_pick_fill( GtkToggleAction* act, gpointer data )
214{
215 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
216 gboolean active = gtk_toggle_action_get_active(act);
217 prefs->setBool("/tools/spray/pickfill", active);
218}
219
220static void sp_toggle_pick_inverse_value( GtkToggleAction* act, gpointer data )
221{
222 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
223 gboolean active = gtk_toggle_action_get_active(act);
224 prefs->setBool("/tools/spray/pickinversevalue", active);
225}
226
227static void sp_toggle_pick_stroke( GtkToggleAction* act, gpointer data )
228{
229 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
230 gboolean active = gtk_toggle_action_get_active(act);
231 prefs->setBool("/tools/spray/pickstroke", active);
232}
105233
106void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)234void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
107{235{
108 Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);236 Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
109 Inkscape::Preferences *prefs = Inkscape::Preferences::get();237 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
110
111 {238 {
112 /* Width */239 /* Width */
113 gchar const* labels[] = {_("(narrow spray)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad spray)")};240 gchar const* labels[] = {_("(narrow spray)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad spray)")};
@@ -123,7 +250,20 @@
123 gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );250 gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
124 gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );251 gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
125 }252 }
253
254 /* Use Pressure Width button */
255 {
256 InkToggleAction* act = ink_toggle_action_new( "SprayPressureWidthAction",
257 _("Pressure"),
258 _("Use the pressure of the input device to alter the width of spray area"),
259 INKSCAPE_ICON("draw-use-pressure"),
260 Inkscape::ICON_SIZE_DECORATION );
261 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
262 PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressurewidth");
263 g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
126264
265 }
266
127 {267 {
128 /* Mean */268 /* Mean */
129 gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(maximum mean)")};269 gchar const* labels[] = {_("(default)"), 0, 0, 0, 0, 0, 0, _("(maximum mean)")};
@@ -218,15 +358,15 @@
218 g_object_set_data( holder, "spray_population", eact );358 g_object_set_data( holder, "spray_population", eact );
219 }359 }
220360
221 /* Use Pressure button */361 /* Use Pressure Population button */
222 {362 {
223 InkToggleAction* act = ink_toggle_action_new( "SprayPressureAction",363 InkToggleAction* act = ink_toggle_action_new( "SprayPressurePopulationAction",
224 _("Pressure"),364 _("Pressure"),
225 _("Use the pressure of the input device to alter the amount of sprayed objects"),365 _("Use the pressure of the input device to alter the amount of sprayed objects"),
226 INKSCAPE_ICON("draw-use-pressure"),366 INKSCAPE_ICON("draw-use-pressure"),
227 Inkscape::ICON_SIZE_DECORATION );367 Inkscape::ICON_SIZE_DECORATION );
228 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );368 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
229 PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressure");369 PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressurepopulation");
230 g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);370 g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
231371
232 }372 }
@@ -267,8 +407,112 @@
267 g_object_set_data( holder, "spray_scale", eact );407 g_object_set_data( holder, "spray_scale", eact );
268 }408 }
269409
270410 /* Use Pressure Scale button */
271411 {
412 InkToggleAction* act = ink_toggle_action_new( "SprayPressureScaleAction",
413 _("Pressure"),
414 _("Use the pressure of the input device to alter the scale of new items"),
415 INKSCAPE_ICON("draw-use-pressure"),
416 Inkscape::ICON_SIZE_DECORATION);
417 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/usepressurescale", false) );
418 g_object_set_data( holder, "usepressurescale", act );
419 g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pressure_scale), holder) ;
420 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
421 }
422
423
424 /* Picker */
425 {
426 InkToggleAction* act = ink_toggle_action_new( "SprayPickColorAction",
427 _("Pick color from the drawing. You can use clonetiler trace dialog for avanced effects. In clone mode original fill or stroke colors must be unset."),
428 _("Pick color from the drawing. You can use clonetiler trace dialog for avanced effects. In clone mode original fill or stroke colors must be unset."),
429 INKSCAPE_ICON("color-picker"),
430 secondarySize );
431 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/picker", false) );
432 g_object_set_data( holder, "picker", act );
433 g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_picker), holder) ;
434 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
435 }
436
437 /* Inverse Value Size */
438 {
439 InkToggleAction* act = ink_toggle_action_new( "SprayOverPickInverseValueAction",
440 _("Inversed pick value retaining color"),
441 _("Inversed pick value retaining color"),
442 INKSCAPE_ICON("object-tweak-shrink"),
443 secondarySize );
444 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pickinversevalue", false) );
445 g_object_set_data( holder, "pickinversevalue", act );
446 g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_inverse_value), holder) ;
447 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
448 }
449
450 /* Pick Fill */
451 {
452 InkToggleAction* act = ink_toggle_action_new( "SprayOverPickFillAction",
453 _("Apply picked color to fill"),
454 _("Apply picked color to fill"),
455 INKSCAPE_ICON("paint-solid"),
456 secondarySize );
457 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pickfill", false) );
458 g_object_set_data( holder, "pickfill", act );
459 g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_fill), holder) ;
460 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
461 }
462
463 /* Pick Stroke */
464 {
465 InkToggleAction* act = ink_toggle_action_new( "SprayOverPickStrokeAction",
466 _("Apply picked color to stroke"),
467 _("Apply picked color to stroke"),
468 INKSCAPE_ICON("no-marker"),
469 secondarySize );
470 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pickstroke", false) );
471 g_object_set_data( holder, "pickstroke", act );
472 g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_stroke), holder) ;
473 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
474 }
475
476 /* Visible */
477 {
478 InkToggleAction* act = ink_toggle_action_new( "SprayOverVisibleAction",
479 _("Apply only over non transparent areas"),
480 _("Apply only over non transparent areas"),
481 INKSCAPE_ICON("object-visible"),
482 secondarySize );
483 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/visible", false) );
484 g_object_set_data( holder, "visible", act );
485 g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_visible), holder) ;
486 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
487 }
488
489 /* Overlap */
490 {
491 InkToggleAction* act = ink_toggle_action_new( "SprayNoOverlapAction",
492 _("Prevent overlapping objects"),
493 _("Prevent overlapping objects"),
494 INKSCAPE_ICON("distribute-randomize"),
495 secondarySize );
496 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/nooverlap", false) );
497 g_object_set_data( holder, "nooverlap", act );
498 g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_nooverlap), holder) ;
499 gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
500 }
501
502 /* Offset */
503 {
504 EgeAdjustmentAction *eact = create_adjustment_action( "SprayToolOffsetAction",
505 _("Offset %"), _("Offset %:"),
506 _("Increase to segregate objects more (value in percent)"),
507 "/tools/spray/offset", 100,
508 GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
509 0, 10000, 1, 4,
510 0, 0, 0,
511 sp_spray_offset_value_changed, NULL, 0 , 0);
512 g_object_set_data( holder, "offset", eact );
513 gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
514 }
515 sp_stb_sensitivize(holder);
272}516}
273517
274518
275519
=== modified file 'src/widgets/spray-toolbar.h'
--- src/widgets/spray-toolbar.h 2014-03-02 22:58:28 +0000
+++ src/widgets/spray-toolbar.h 2015-11-08 09:50:32 +0000
@@ -21,7 +21,7 @@
21 *21 *
22 * Copyright (C) 2004 David Turner22 * Copyright (C) 2004 David Turner
23 * Copyright (C) 2003 MenTaLguY23 * Copyright (C) 2003 MenTaLguY
24 * Copyright (C) 1999-2011 authors24 * Copyright (C) 1999-2015 authors
25 * Copyright (C) 2001-2002 Ximian, Inc.25 * Copyright (C) 2001-2002 Ximian, Inc.
26 *26 *
27 * Released under GNU GPL, read the file 'COPYING' for more information27 * Released under GNU GPL, read the file 'COPYING' for more information
2828
=== modified file 'src/widgets/toolbox.cpp'
--- src/widgets/toolbox.cpp 2015-10-22 17:29:20 +0000
+++ src/widgets/toolbox.cpp 2015-11-08 09:50:32 +0000
@@ -16,10 +16,11 @@
16 * Tavmjong Bah <tavmjong@free.fr>16 * Tavmjong Bah <tavmjong@free.fr>
17 * Abhishek Sharma17 * Abhishek Sharma
18 * Kris De Gussem <Kris.DeGussem@gmail.com>18 * Kris De Gussem <Kris.DeGussem@gmail.com>
19 * Jabiertxo Arraiza <jabier.arraiza@marker.es>
19 *20 *
20 * Copyright (C) 2004 David Turner21 * Copyright (C) 2004 David Turner
21 * Copyright (C) 2003 MenTaLguY22 * Copyright (C) 2003 MenTaLguY
22 * Copyright (C) 1999-2011 authors23 * Copyright (C) 1999-2015 authors
23 * Copyright (C) 2001-2002 Ximian, Inc.24 * Copyright (C) 2001-2002 Ximian, Inc.
24 *25 *
25 * Released under GNU GPL, read the file 'COPYING' for more information26 * Released under GNU GPL, read the file 'COPYING' for more information
@@ -309,14 +310,26 @@
309 " <toolitem action='SprayModeAction' />"310 " <toolitem action='SprayModeAction' />"
310 " <separator />"311 " <separator />"
311 " <toolitem action='SprayWidthAction' />"312 " <toolitem action='SprayWidthAction' />"
313 " <toolitem action='SprayPressureWidthAction' />"
312 " <toolitem action='SprayPopulationAction' />"314 " <toolitem action='SprayPopulationAction' />"
313 " <toolitem action='SprayPressureAction' />"315 " <toolitem action='SprayPressurePopulationAction' />"
314 " <separator />"316 " <separator />"
315 " <toolitem action='SprayRotationAction' />"317 " <toolitem action='SprayRotationAction' />"
316 " <toolitem action='SprayScaleAction' />"318 " <toolitem action='SprayScaleAction' />"
319 " <toolitem action='SprayPressureScaleAction' />"
317 " <separator />"320 " <separator />"
318 " <toolitem action='SprayStandard_deviationAction' />"321 " <toolitem action='SprayStandard_deviationAction' />"
319 " <toolitem action='SprayMeanAction' />"322 " <toolitem action='SprayMeanAction' />"
323 " <separator />"
324 " <toolitem action='SprayOverVisibleAction' />"
325 " <toolitem action='SprayNoOverlapAction' />"
326 " <toolitem action='SprayToolOffsetAction' />"
327 " <separator />"
328 " <toolitem action='SprayPickColorAction' />"
329 " <toolitem action='SprayOverPickInverseValueAction' />"
330 " <toolitem action='SprayOverPickFillAction' />"
331 " <toolitem action='SprayOverPickStrokeAction' />"
332
320 " </toolbar>"333 " </toolbar>"
321334
322 " <toolbar name='ZoomToolbar'>"335 " <toolbar name='ZoomToolbar'>"