Merge lp:~inkscape.dev/inkscape/spraytool-no-overlap into lp:~inkscape.dev/inkscape/trunk
- spraytool-no-overlap
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Inkscape Developers | Pending | ||
Review via email: mp+275643@code.launchpad.net |
Commit message
Description of the change
The feature I added is optionaly no overlap with offsets for spray tool.
Mc (mc...) wrote : | # |
- 14434. By jabiertxof<email address hidden>
-
Fixed typos from Mc
Removed unnecesary added headers
Put overlap default to false
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-
Mc (mc...) wrote : | # |
comments inline
Preview Diff
1 | === modified file 'src/ui/dialog/clonetiler.cpp' | |||
2 | --- src/ui/dialog/clonetiler.cpp 2015-10-04 15:42:12 +0000 | |||
3 | +++ src/ui/dialog/clonetiler.cpp 2015-11-08 09:50:32 +0000 | |||
4 | @@ -85,7 +85,7 @@ | |||
5 | 85 | { | 85 | { |
6 | 86 | Gtk::Box *contents = _getContents(); | 86 | Gtk::Box *contents = _getContents(); |
7 | 87 | contents->set_spacing(0); | 87 | contents->set_spacing(0); |
9 | 88 | 88 | ||
10 | 89 | { | 89 | { |
11 | 90 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 90 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
12 | 91 | 91 | ||
13 | @@ -101,7 +101,7 @@ | |||
14 | 101 | 101 | ||
15 | 102 | contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0); | 102 | contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0); |
16 | 103 | 103 | ||
18 | 104 | GtkWidget *nb = gtk_notebook_new (); | 104 | nb = gtk_notebook_new (); |
19 | 105 | gtk_box_pack_start (GTK_BOX (mainbox), nb, FALSE, FALSE, 0); | 105 | gtk_box_pack_start (GTK_BOX (mainbox), nb, FALSE, FALSE, 0); |
20 | 106 | 106 | ||
21 | 107 | 107 | ||
22 | @@ -662,7 +662,7 @@ | |||
23 | 662 | gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); | 662 | gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); |
24 | 663 | 663 | ||
25 | 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); |
27 | 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); |
28 | 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)); |
29 | 667 | 667 | ||
30 | 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); |
31 | @@ -776,8 +776,6 @@ | |||
32 | 776 | // Trace | 776 | // Trace |
33 | 777 | { | 777 | { |
34 | 778 | GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace")); | 778 | GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace")); |
35 | 779 | |||
36 | 780 | |||
37 | 781 | { | 779 | { |
38 | 782 | #if GTK_CHECK_VERSION(3,0,0) | 780 | #if GTK_CHECK_VERSION(3,0,0) |
39 | 783 | GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); | 781 | GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); |
40 | @@ -787,11 +785,11 @@ | |||
41 | 787 | #endif | 785 | #endif |
42 | 788 | gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); | 786 | gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); |
43 | 789 | 787 | ||
45 | 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")); |
46 | 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)); |
47 | 792 | bool old = prefs->getBool(prefs_path + "dotrace"); | 790 | bool old = prefs->getBool(prefs_path + "dotrace"); |
48 | 793 | gtk_toggle_button_set_active ((GtkToggleButton *) b, old); | 791 | gtk_toggle_button_set_active ((GtkToggleButton *) b, old); |
50 | 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")); |
51 | 795 | gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); | 793 | gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); |
52 | 796 | 794 | ||
53 | 797 | g_signal_connect(G_OBJECT(b), "toggled", | 795 | g_signal_connect(G_OBJECT(b), "toggled", |
54 | @@ -1001,6 +999,18 @@ | |||
55 | 1001 | } | 999 | } |
56 | 1002 | } | 1000 | } |
57 | 1003 | 1001 | ||
58 | 1002 | { | ||
59 | 1003 | #if GTK_CHECK_VERSION(3,0,0) | ||
60 | 1004 | GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); | ||
61 | 1005 | gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); | ||
62 | 1006 | #else | ||
63 | 1007 | GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); | ||
64 | 1008 | #endif | ||
65 | 1009 | gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); | ||
66 | 1010 | GtkWidget *l = gtk_label_new(_("")); | ||
67 | 1011 | gtk_label_set_markup (GTK_LABEL(l), _("Apply to tiled clones:")); | ||
68 | 1012 | gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); | ||
69 | 1013 | } | ||
70 | 1004 | // Rows/columns, width/height | 1014 | // Rows/columns, width/height |
71 | 1005 | { | 1015 | { |
72 | 1006 | #if GTK_CHECK_VERSION(3,0,0) | 1016 | #if GTK_CHECK_VERSION(3,0,0) |
73 | @@ -1289,7 +1299,6 @@ | |||
74 | 1289 | } | 1299 | } |
75 | 1290 | 1300 | ||
76 | 1291 | gtk_widget_show_all (mainbox); | 1301 | gtk_widget_show_all (mainbox); |
77 | 1292 | |||
78 | 1293 | } | 1302 | } |
79 | 1294 | 1303 | ||
80 | 1295 | show_all(); | 1304 | show_all(); |
81 | @@ -3005,6 +3014,13 @@ | |||
82 | 3005 | } | 3014 | } |
83 | 3006 | } | 3015 | } |
84 | 3007 | 3016 | ||
85 | 3017 | void CloneTiler::show_page_trace() | ||
86 | 3018 | { | ||
87 | 3019 | gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),6); | ||
88 | 3020 | gtk_toggle_button_set_active ((GtkToggleButton *) b, false); | ||
89 | 3021 | } | ||
90 | 3022 | |||
91 | 3023 | |||
92 | 3008 | } | 3024 | } |
93 | 3009 | } | 3025 | } |
94 | 3010 | } | 3026 | } |
95 | 3011 | 3027 | ||
96 | === modified file 'src/ui/dialog/clonetiler.h' | |||
97 | --- src/ui/dialog/clonetiler.h 2014-10-08 02:22:03 +0000 | |||
98 | +++ src/ui/dialog/clonetiler.h 2015-11-08 09:50:32 +0000 | |||
99 | @@ -31,7 +31,7 @@ | |||
100 | 31 | virtual ~CloneTiler(); | 31 | virtual ~CloneTiler(); |
101 | 32 | 32 | ||
102 | 33 | static CloneTiler &getInstance() { return *new CloneTiler(); } | 33 | static CloneTiler &getInstance() { return *new CloneTiler(); } |
104 | 34 | 34 | void show_page_trace(); | |
105 | 35 | protected: | 35 | protected: |
106 | 36 | 36 | ||
107 | 37 | GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label); | 37 | GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label); |
108 | @@ -113,6 +113,8 @@ | |||
109 | 113 | CloneTiler& operator=(CloneTiler const &d); | 113 | CloneTiler& operator=(CloneTiler const &d); |
110 | 114 | 114 | ||
111 | 115 | GtkWidget *dlg; | 115 | GtkWidget *dlg; |
112 | 116 | GtkWidget *nb; | ||
113 | 117 | GtkWidget *b; | ||
114 | 116 | SPDesktop *desktop; | 118 | SPDesktop *desktop; |
115 | 117 | DesktopTracker deskTrack; | 119 | DesktopTracker deskTrack; |
116 | 118 | Inkscape::UI::Widget::ColorPicker *color_picker; | 120 | Inkscape::UI::Widget::ColorPicker *color_picker; |
117 | 119 | 121 | ||
118 | === modified file 'src/ui/tools/spray-tool.cpp' | |||
119 | --- src/ui/tools/spray-tool.cpp 2015-07-04 16:15:46 +0000 | |||
120 | +++ src/ui/tools/spray-tool.cpp 2015-11-08 09:50:32 +0000 | |||
121 | @@ -12,6 +12,7 @@ | |||
122 | 12 | * Steren GIANNINI (steren.giannini@gmail.com) | 12 | * Steren GIANNINI (steren.giannini@gmail.com) |
123 | 13 | * Jon A. Cruz <jon@joncruz.org> | 13 | * Jon A. Cruz <jon@joncruz.org> |
124 | 14 | * Abhishek Sharma | 14 | * Abhishek Sharma |
125 | 15 | * Jabiertxo Arraiza <jabier.arraiza@marker.es> | ||
126 | 15 | * | 16 | * |
127 | 16 | * Copyright (C) 2009 authors | 17 | * Copyright (C) 2009 authors |
128 | 17 | * | 18 | * |
129 | @@ -48,7 +49,15 @@ | |||
130 | 48 | #include "sp-path.h" | 49 | #include "sp-path.h" |
131 | 49 | #include "path-chemistry.h" | 50 | #include "path-chemistry.h" |
132 | 50 | 51 | ||
133 | 52 | // For color picking | ||
134 | 53 | #include "display/drawing.h" | ||
135 | 54 | #include "display/drawing-context.h" | ||
136 | 55 | #include "display/cairo-utils.h" | ||
137 | 56 | #include "desktop-style.h" | ||
138 | 57 | #include "svg/svg-color.h" | ||
139 | 58 | |||
140 | 51 | #include "sp-text.h" | 59 | #include "sp-text.h" |
141 | 60 | #include "sp-root.h" | ||
142 | 52 | #include "sp-flowtext.h" | 61 | #include "sp-flowtext.h" |
143 | 53 | #include "display/sp-canvas.h" | 62 | #include "display/sp-canvas.h" |
144 | 54 | #include "display/canvas-bpath.h" | 63 | #include "display/canvas-bpath.h" |
145 | @@ -88,6 +97,17 @@ | |||
146 | 88 | namespace UI { | 97 | namespace UI { |
147 | 89 | namespace Tools { | 98 | namespace Tools { |
148 | 90 | 99 | ||
149 | 100 | enum { | ||
150 | 101 | PICK_COLOR, | ||
151 | 102 | PICK_OPACITY, | ||
152 | 103 | PICK_R, | ||
153 | 104 | PICK_G, | ||
154 | 105 | PICK_B, | ||
155 | 106 | PICK_H, | ||
156 | 107 | PICK_S, | ||
157 | 108 | PICK_L | ||
158 | 109 | }; | ||
159 | 110 | |||
160 | 91 | const std::string& SprayTool::getPrefsPath() { | 111 | const std::string& SprayTool::getPrefsPath() { |
161 | 92 | return SprayTool::prefsPath; | 112 | return SprayTool::prefsPath; |
162 | 93 | } | 113 | } |
163 | @@ -133,7 +153,9 @@ | |||
164 | 133 | : ToolBase(cursor_spray_xpm, 4, 4, false) | 153 | : ToolBase(cursor_spray_xpm, 4, 4, false) |
165 | 134 | , pressure(TC_DEFAULT_PRESSURE) | 154 | , pressure(TC_DEFAULT_PRESSURE) |
166 | 135 | , dragging(false) | 155 | , dragging(false) |
168 | 136 | , usepressure(false) | 156 | , usepressurewidth(false) |
169 | 157 | , usepressurepopulation(false) | ||
170 | 158 | , usepressurescale(false) | ||
171 | 137 | , usetilt(false) | 159 | , usetilt(false) |
172 | 138 | , usetext(false) | 160 | , usetext(false) |
173 | 139 | , width(0.2) | 161 | , width(0.2) |
174 | @@ -151,6 +173,13 @@ | |||
175 | 151 | , is_dilating(false) | 173 | , is_dilating(false) |
176 | 152 | , has_dilated(false) | 174 | , has_dilated(false) |
177 | 153 | , dilate_area(NULL) | 175 | , dilate_area(NULL) |
178 | 176 | , nooverlap(false) | ||
179 | 177 | , picker(false) | ||
180 | 178 | , pickinversevalue(false) | ||
181 | 179 | , pickfill(false) | ||
182 | 180 | , pickstroke(false) | ||
183 | 181 | , visible(false) | ||
184 | 182 | , offset(0) | ||
185 | 154 | { | 183 | { |
186 | 155 | } | 184 | } |
187 | 156 | 185 | ||
188 | @@ -221,8 +250,17 @@ | |||
189 | 221 | sp_event_context_read(this, "population"); | 250 | sp_event_context_read(this, "population"); |
190 | 222 | sp_event_context_read(this, "mean"); | 251 | sp_event_context_read(this, "mean"); |
191 | 223 | sp_event_context_read(this, "standard_deviation"); | 252 | sp_event_context_read(this, "standard_deviation"); |
193 | 224 | sp_event_context_read(this, "usepressure"); | 253 | sp_event_context_read(this, "usepressurewidth"); |
194 | 254 | sp_event_context_read(this, "usepressurepopulation"); | ||
195 | 255 | sp_event_context_read(this, "usepressurescale"); | ||
196 | 225 | sp_event_context_read(this, "Scale"); | 256 | sp_event_context_read(this, "Scale"); |
197 | 257 | sp_event_context_read(this, "offset"); | ||
198 | 258 | sp_event_context_read(this, "picker"); | ||
199 | 259 | sp_event_context_read(this, "pickinversevalue"); | ||
200 | 260 | sp_event_context_read(this, "pickfill"); | ||
201 | 261 | sp_event_context_read(this, "pickstroke"); | ||
202 | 262 | sp_event_context_read(this, "visible"); | ||
203 | 263 | sp_event_context_read(this, "nooverlap"); | ||
204 | 226 | 264 | ||
205 | 227 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 265 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
206 | 228 | if (prefs->getBool("/tools/spray/selcue")) { | 266 | if (prefs->getBool("/tools/spray/selcue")) { |
207 | @@ -241,8 +279,12 @@ | |||
208 | 241 | this->update_cursor(false); | 279 | this->update_cursor(false); |
209 | 242 | } else if (path == "width") { | 280 | } else if (path == "width") { |
210 | 243 | this->width = 0.01 * CLAMP(val.getInt(10), 1, 100); | 281 | this->width = 0.01 * CLAMP(val.getInt(10), 1, 100); |
213 | 244 | } else if (path == "usepressure") { | 282 | } else if (path == "usepressurewidth") { |
214 | 245 | this->usepressure = val.getBool(); | 283 | this->usepressurewidth = val.getBool(); |
215 | 284 | } else if (path == "usepressurepopulation") { | ||
216 | 285 | this->usepressurepopulation = val.getBool(); | ||
217 | 286 | } else if (path == "usepressurescale") { | ||
218 | 287 | this->usepressurescale = val.getBool(); | ||
219 | 246 | } else if (path == "population") { | 288 | } else if (path == "population") { |
220 | 247 | this->population = 0.01 * CLAMP(val.getInt(10), 1, 100); | 289 | this->population = 0.01 * CLAMP(val.getInt(10), 1, 100); |
221 | 248 | } else if (path == "rotation_variation") { | 290 | } else if (path == "rotation_variation") { |
222 | @@ -260,6 +302,20 @@ | |||
223 | 260 | this->tilt = CLAMP(val.getDouble(0.1), 0, 1000.0); | 302 | this->tilt = CLAMP(val.getDouble(0.1), 0, 1000.0); |
224 | 261 | } else if (path == "ratio") { | 303 | } else if (path == "ratio") { |
225 | 262 | this->ratio = CLAMP(val.getDouble(), 0.0, 0.9); | 304 | this->ratio = CLAMP(val.getDouble(), 0.0, 0.9); |
226 | 305 | } else if (path == "offset") { | ||
227 | 306 | this->offset = CLAMP(val.getDouble(), -1000.0, 1000.0); | ||
228 | 307 | } else if (path == "picker") { | ||
229 | 308 | this->picker = val.getBool(); | ||
230 | 309 | } else if (path == "pickinversevalue") { | ||
231 | 310 | this->pickinversevalue = val.getBool(); | ||
232 | 311 | } else if (path == "pickfill") { | ||
233 | 312 | this->pickfill = val.getBool(); | ||
234 | 313 | } else if (path == "pickstroke") { | ||
235 | 314 | this->pickstroke = val.getBool(); | ||
236 | 315 | } else if (path == "visible") { | ||
237 | 316 | this->visible = val.getBool(); | ||
238 | 317 | } else if (path == "nooverlap") { | ||
239 | 318 | this->nooverlap = val.getBool(); | ||
240 | 263 | } | 319 | } |
241 | 264 | } | 320 | } |
242 | 265 | 321 | ||
243 | @@ -272,9 +328,15 @@ | |||
244 | 272 | } | 328 | } |
245 | 273 | } | 329 | } |
246 | 274 | 330 | ||
247 | 331 | static double get_width(SprayTool *tc) | ||
248 | 332 | { | ||
249 | 333 | double pressure = (tc->usepressurewidth? tc->pressure / TC_DEFAULT_PRESSURE : 1); | ||
250 | 334 | return pressure * tc->width; | ||
251 | 335 | } | ||
252 | 336 | |||
253 | 275 | static double get_dilate_radius(SprayTool *tc) | 337 | static double get_dilate_radius(SprayTool *tc) |
254 | 276 | { | 338 | { |
256 | 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(); |
257 | 278 | } | 340 | } |
258 | 279 | 341 | ||
259 | 280 | static double get_path_mean(SprayTool *tc) | 342 | static double get_path_mean(SprayTool *tc) |
260 | @@ -289,11 +351,16 @@ | |||
261 | 289 | 351 | ||
262 | 290 | static double get_population(SprayTool *tc) | 352 | static double get_population(SprayTool *tc) |
263 | 291 | { | 353 | { |
266 | 292 | double pressure = (tc->usepressure? tc->pressure / TC_DEFAULT_PRESSURE : 1); | 354 | double pressure = (tc->usepressurepopulation? tc->pressure / TC_DEFAULT_PRESSURE : 1); |
265 | 293 | //g_warning("Pressure, population: %f, %f", pressure, pressure * tc->population); | ||
267 | 294 | return pressure * tc->population; | 355 | return pressure * tc->population; |
268 | 295 | } | 356 | } |
269 | 296 | 357 | ||
270 | 358 | static double get_pressure(SprayTool *tc) | ||
271 | 359 | { | ||
272 | 360 | double pressure = tc->pressure / TC_DEFAULT_PRESSURE; | ||
273 | 361 | return pressure; | ||
274 | 362 | } | ||
275 | 363 | |||
276 | 297 | static double get_move_mean(SprayTool *tc) | 364 | static double get_move_mean(SprayTool *tc) |
277 | 298 | { | 365 | { |
278 | 299 | return tc->mean; | 366 | return tc->mean; |
279 | @@ -332,6 +399,317 @@ | |||
280 | 332 | 399 | ||
281 | 333 | } | 400 | } |
282 | 334 | 401 | ||
283 | 402 | static void sp_spray_transform_path(SPItem * item, Geom::Path &path, Geom::Affine affine, Geom::Point center){ | ||
284 | 403 | path *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse(); | ||
285 | 404 | path *= item->transform.inverse(); | ||
286 | 405 | Geom::Affine dt2p; | ||
287 | 406 | if (item->parent) { | ||
288 | 407 | dt2p = static_cast<SPItem *>(item->parent)->i2dt_affine().inverse(); | ||
289 | 408 | } else { | ||
290 | 409 | SPDesktop *dt = SP_ACTIVE_DESKTOP; | ||
291 | 410 | dt2p = dt->dt2doc(); | ||
292 | 411 | } | ||
293 | 412 | Geom::Affine i2dt = item->i2dt_affine() * Geom::Translate(center).inverse() * affine * Geom::Translate(center); | ||
294 | 413 | path *= i2dt * dt2p; | ||
295 | 414 | path *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL); | ||
296 | 415 | } | ||
297 | 416 | |||
298 | 417 | /** | ||
299 | 418 | Randomizes \a val by \a rand, with 0 < val < 1 and all values (including 0, 1) having the same | ||
300 | 419 | probability of being displaced. | ||
301 | 420 | */ | ||
302 | 421 | double randomize01(double val, double rand) | ||
303 | 422 | { | ||
304 | 423 | double base = MIN (val - rand, 1 - 2*rand); | ||
305 | 424 | if (base < 0) { | ||
306 | 425 | base = 0; | ||
307 | 426 | } | ||
308 | 427 | val = base + g_random_double_range (0, MIN (2 * rand, 1 - base)); | ||
309 | 428 | return CLAMP(val, 0, 1); // this should be unnecessary with the above provisions, but just in case... | ||
310 | 429 | } | ||
311 | 430 | |||
312 | 431 | static bool fit_item(SPDesktop *desktop, | ||
313 | 432 | SPItem *item, | ||
314 | 433 | Geom::OptRect bbox, | ||
315 | 434 | Geom::Point &move, | ||
316 | 435 | Geom::Point center, | ||
317 | 436 | double angle, | ||
318 | 437 | double &_scale, | ||
319 | 438 | double scale, | ||
320 | 439 | bool picker, | ||
321 | 440 | bool pickinversevalue, | ||
322 | 441 | bool pickfill, | ||
323 | 442 | bool pickstroke, | ||
324 | 443 | bool visible, | ||
325 | 444 | bool nooverlap, | ||
326 | 445 | double offset, | ||
327 | 446 | SPCSSAttr *css, | ||
328 | 447 | bool trace_scale) | ||
329 | 448 | { | ||
330 | 449 | SPDocument *doc = item->document; | ||
331 | 450 | double width = bbox->width(); | ||
332 | 451 | double height = bbox->height(); | ||
333 | 452 | double size = std::min(width,height); | ||
334 | 453 | double offset_min = (offset * size)/100.0 - (size); | ||
335 | 454 | if(offset_min < 0 ){ | ||
336 | 455 | offset_min = 0; | ||
337 | 456 | } | ||
338 | 457 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
339 | 458 | bool pick_to_size = prefs->getBool("/dialogs/clonetiler/pick_to_size"); | ||
340 | 459 | bool trace = prefs->getBool("/dialogs/clonetiler/dotrace"); | ||
341 | 460 | if(picker && pick_to_size && !trace_scale && trace){ | ||
342 | 461 | _scale = 0.1; | ||
343 | 462 | } | ||
344 | 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)); | ||
345 | 464 | Geom::Path path; | ||
346 | 465 | path.start(Geom::Point(bbox_procesed->left(), bbox_procesed->top())); | ||
347 | 466 | path.appendNew<Geom::LineSegment>(Geom::Point(bbox_procesed->right(), bbox_procesed->top())); | ||
348 | 467 | path.appendNew<Geom::LineSegment>(Geom::Point(bbox_procesed->right(), bbox_procesed->bottom())); | ||
349 | 468 | path.appendNew<Geom::LineSegment>(Geom::Point(bbox_procesed->left(), bbox_procesed->bottom())); | ||
350 | 469 | path.close(true); | ||
351 | 470 | sp_spray_transform_path(item, path, Geom::Scale(_scale), center); | ||
352 | 471 | sp_spray_transform_path(item, path, Geom::Scale(scale), center); | ||
353 | 472 | sp_spray_transform_path(item, path, Geom::Rotate(angle), center); | ||
354 | 473 | path *= Geom::Translate(move); | ||
355 | 474 | path *= desktop->doc2dt(); | ||
356 | 475 | bbox_procesed = path.boundsFast(); | ||
357 | 476 | double bbox_left_main = bbox_procesed->left(); | ||
358 | 477 | double bbox_top_main = bbox_procesed->top(); | ||
359 | 478 | double width_transformed = bbox_procesed->width(); | ||
360 | 479 | double height_transformed = bbox_procesed->height(); | ||
361 | 480 | Geom::Point mid_point = desktop->d2w(bbox_procesed->midpoint()); | ||
362 | 481 | Geom::IntRect area = Geom::IntRect::from_xywh(floor(mid_point[Geom::X]), floor(mid_point[Geom::Y]), 1, 1); | ||
363 | 482 | double R = 0, G = 0, B = 0, A = 0; | ||
364 | 483 | cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); | ||
365 | 484 | sp_canvas_arena_render_surface(SP_CANVAS_ARENA(desktop->getDrawing()), s, area); | ||
366 | 485 | ink_cairo_surface_average_color(s, R, G, B, A); | ||
367 | 486 | cairo_surface_destroy(s); | ||
368 | 487 | guint32 rgba = SP_RGBA32_F_COMPOSE(R, G, B, A); | ||
369 | 488 | if(nooverlap && visible && (A==0 || A < 1e-6)){ | ||
370 | 489 | return false; | ||
371 | 490 | } | ||
372 | 491 | size = std::min(width_transformed,height_transformed); | ||
373 | 492 | if(offset < 100 ){ | ||
374 | 493 | offset_min = ((99.0 - offset) * size)/100.0 - size; | ||
375 | 494 | } else { | ||
376 | 495 | offset_min = 0; | ||
377 | 496 | } | ||
378 | 497 | std::vector<SPItem*> items_down = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *bbox_procesed); | ||
379 | 498 | Inkscape::Selection *selection = desktop->getSelection(); | ||
380 | 499 | if (selection->isEmpty()) { | ||
381 | 500 | return false; | ||
382 | 501 | } | ||
383 | 502 | std::vector<SPItem*> const items_selected(selection->itemList()); | ||
384 | 503 | for (std::vector<SPItem*>::const_iterator i=items_down.begin(); i!=items_down.end(); i++) { | ||
385 | 504 | SPItem *item_down = *i; | ||
386 | 505 | Geom::OptRect bbox_down = item_down->documentVisualBounds(); | ||
387 | 506 | width = bbox_down->width(); | ||
388 | 507 | height = bbox_down->height(); | ||
389 | 508 | double bbox_left = bbox_down->left(); | ||
390 | 509 | double bbox_top = bbox_down->top(); | ||
391 | 510 | gchar const * item_down_sharp = g_strdup_printf("#%s", item_down->getId()); | ||
392 | 511 | for (std::vector<SPItem*>::const_iterator j=items_selected.begin(); j!=items_selected.end(); j++) { | ||
393 | 512 | SPItem *item_selected = *j; | ||
394 | 513 | gchar const * spray_origin; | ||
395 | 514 | if(!item_selected->getAttribute("inkscape:spray-origin")){ | ||
396 | 515 | spray_origin = g_strdup_printf("#%s", item_selected->getId()); | ||
397 | 516 | } else { | ||
398 | 517 | spray_origin = item_selected->getAttribute("inkscape:spray-origin"); | ||
399 | 518 | } | ||
400 | 519 | if(strcmp(item_down_sharp, spray_origin) == 0 || | ||
401 | 520 | (item_down->getAttribute("inkscape:spray-origin") && | ||
402 | 521 | strcmp(item_down->getAttribute("inkscape:spray-origin"),spray_origin) == 0 )) | ||
403 | 522 | { | ||
404 | 523 | if(nooverlap){ | ||
405 | 524 | if(!(offset_min < 0 && std::abs(bbox_left - bbox_left_main) > std::abs(offset_min) && | ||
406 | 525 | std::abs(bbox_top - bbox_top_main) > std::abs(offset_min))){ | ||
407 | 526 | return false; | ||
408 | 527 | } | ||
409 | 528 | } else if(picker || visible){ | ||
410 | 529 | item_down->setHidden(true); | ||
411 | 530 | item_down->updateRepr(); | ||
412 | 531 | } | ||
413 | 532 | } | ||
414 | 533 | } | ||
415 | 534 | } | ||
416 | 535 | if(picker || visible){ | ||
417 | 536 | if(!nooverlap){ | ||
418 | 537 | doc->ensureUpToDate(); | ||
419 | 538 | } | ||
420 | 539 | int pick = prefs->getInt("/dialogs/clonetiler/pick"); | ||
421 | 540 | bool pick_to_presence = prefs->getBool("/dialogs/clonetiler/pick_to_presence", false); | ||
422 | 541 | bool pick_to_color = prefs->getBool("/dialogs/clonetiler/pick_to_color"); | ||
423 | 542 | bool pick_to_opacity = prefs->getBool("/dialogs/clonetiler/pick_to_opacity"); | ||
424 | 543 | double rand_picked = 0.01 * prefs->getDoubleLimited("/dialogs/clonetiler/rand_picked", 0, 0, 100); | ||
425 | 544 | bool invert_picked = prefs->getBool("/dialogs/clonetiler/invert_picked"); | ||
426 | 545 | double gamma_picked = prefs->getDoubleLimited("/dialogs/clonetiler/gamma_picked", 0, -10, 10); | ||
427 | 546 | double opacity = 1.0; | ||
428 | 547 | gchar color_string[32]; *color_string = 0; | ||
429 | 548 | float r = SP_RGBA32_R_F(rgba); | ||
430 | 549 | float g = SP_RGBA32_G_F(rgba); | ||
431 | 550 | float b = SP_RGBA32_B_F(rgba); | ||
432 | 551 | float a = SP_RGBA32_A_F(rgba); | ||
433 | 552 | //this can fix the bug #1511998 if confirmed | ||
434 | 553 | if( a == 0 || a < 1e-6){ | ||
435 | 554 | r = 1; | ||
436 | 555 | g = 1; | ||
437 | 556 | b = 1; | ||
438 | 557 | } | ||
439 | 558 | if(visible && (a == 0 || a < 1e-6)){ | ||
440 | 559 | return false; | ||
441 | 560 | } | ||
442 | 561 | |||
443 | 562 | if(picker && trace){ | ||
444 | 563 | float hsl[3]; | ||
445 | 564 | sp_color_rgb_to_hsl_floatv (hsl, r, g, b); | ||
446 | 565 | |||
447 | 566 | gdouble val = 0; | ||
448 | 567 | switch (pick) { | ||
449 | 568 | case PICK_COLOR: | ||
450 | 569 | val = 1 - hsl[2]; // inverse lightness; to match other picks where black = max | ||
451 | 570 | break; | ||
452 | 571 | case PICK_OPACITY: | ||
453 | 572 | val = a; | ||
454 | 573 | break; | ||
455 | 574 | case PICK_R: | ||
456 | 575 | val = r; | ||
457 | 576 | break; | ||
458 | 577 | case PICK_G: | ||
459 | 578 | val = g; | ||
460 | 579 | break; | ||
461 | 580 | case PICK_B: | ||
462 | 581 | val = b; | ||
463 | 582 | break; | ||
464 | 583 | case PICK_H: | ||
465 | 584 | val = hsl[0]; | ||
466 | 585 | break; | ||
467 | 586 | case PICK_S: | ||
468 | 587 | val = hsl[1]; | ||
469 | 588 | break; | ||
470 | 589 | case PICK_L: | ||
471 | 590 | val = 1 - hsl[2]; | ||
472 | 591 | break; | ||
473 | 592 | default: | ||
474 | 593 | break; | ||
475 | 594 | } | ||
476 | 595 | |||
477 | 596 | if (rand_picked > 0) { | ||
478 | 597 | val = randomize01 (val, rand_picked); | ||
479 | 598 | r = randomize01 (r, rand_picked); | ||
480 | 599 | g = randomize01 (g, rand_picked); | ||
481 | 600 | b = randomize01 (b, rand_picked); | ||
482 | 601 | } | ||
483 | 602 | |||
484 | 603 | if (gamma_picked != 0) { | ||
485 | 604 | double power; | ||
486 | 605 | if (gamma_picked > 0) | ||
487 | 606 | power = 1/(1 + fabs(gamma_picked)); | ||
488 | 607 | else | ||
489 | 608 | power = 1 + fabs(gamma_picked); | ||
490 | 609 | |||
491 | 610 | val = pow (val, power); | ||
492 | 611 | r = pow ((double)r, (double)power); | ||
493 | 612 | g = pow ((double)g, (double)power); | ||
494 | 613 | b = pow ((double)b, (double)power); | ||
495 | 614 | } | ||
496 | 615 | |||
497 | 616 | if (invert_picked) { | ||
498 | 617 | val = 1 - val; | ||
499 | 618 | r = 1 - r; | ||
500 | 619 | g = 1 - g; | ||
501 | 620 | b = 1 - b; | ||
502 | 621 | } | ||
503 | 622 | |||
504 | 623 | val = CLAMP (val, 0, 1); | ||
505 | 624 | r = CLAMP (r, 0, 1); | ||
506 | 625 | g = CLAMP (g, 0, 1); | ||
507 | 626 | b = CLAMP (b, 0, 1); | ||
508 | 627 | |||
509 | 628 | // recompose tweaked color | ||
510 | 629 | rgba = SP_RGBA32_F_COMPOSE(r, g, b, a); | ||
511 | 630 | if (pick_to_size) { | ||
512 | 631 | if(!trace_scale){ | ||
513 | 632 | if(pickinversevalue) { | ||
514 | 633 | _scale = 1.0 - val; | ||
515 | 634 | } else { | ||
516 | 635 | _scale = val; | ||
517 | 636 | } | ||
518 | 637 | if(_scale == 0.0) { | ||
519 | 638 | return false; | ||
520 | 639 | } | ||
521 | 640 | if(!fit_item(desktop, | ||
522 | 641 | item, | ||
523 | 642 | bbox, | ||
524 | 643 | move, | ||
525 | 644 | center, | ||
526 | 645 | angle, | ||
527 | 646 | _scale, | ||
528 | 647 | scale, | ||
529 | 648 | picker, | ||
530 | 649 | pickinversevalue, | ||
531 | 650 | pickfill, | ||
532 | 651 | pickstroke, | ||
533 | 652 | visible, | ||
534 | 653 | nooverlap, | ||
535 | 654 | offset, | ||
536 | 655 | css, | ||
537 | 656 | true)){ | ||
538 | 657 | return false; | ||
539 | 658 | } | ||
540 | 659 | } | ||
541 | 660 | } | ||
542 | 661 | |||
543 | 662 | if (pick_to_opacity) { | ||
544 | 663 | if(pickinversevalue) { | ||
545 | 664 | opacity *= 1.0 - val; | ||
546 | 665 | } else { | ||
547 | 666 | opacity *= val; | ||
548 | 667 | } | ||
549 | 668 | std::stringstream opacity_str; | ||
550 | 669 | opacity_str.imbue(std::locale::classic()); | ||
551 | 670 | opacity_str << opacity; | ||
552 | 671 | sp_repr_css_set_property(css, "opacity", opacity_str.str().c_str()); | ||
553 | 672 | } | ||
554 | 673 | if (pick_to_presence) { | ||
555 | 674 | if (g_random_double_range (0, 1) > val) { | ||
556 | 675 | //Hidding the element is a way to retain original | ||
557 | 676 | //behaviour of tiled clones for presence option. | ||
558 | 677 | sp_repr_css_set_property(css, "opacity", "0"); | ||
559 | 678 | } | ||
560 | 679 | } | ||
561 | 680 | if (pick_to_color) { | ||
562 | 681 | sp_svg_write_color(color_string, sizeof(color_string), rgba); | ||
563 | 682 | if(pickfill){ | ||
564 | 683 | sp_repr_css_set_property(css, "fill", color_string); | ||
565 | 684 | } | ||
566 | 685 | if(pickstroke){ | ||
567 | 686 | sp_repr_css_set_property(css, "stroke", color_string); | ||
568 | 687 | } | ||
569 | 688 | } | ||
570 | 689 | if (opacity < 1e-6) { // invisibly transparent, skip | ||
571 | 690 | return false; | ||
572 | 691 | } | ||
573 | 692 | } | ||
574 | 693 | if(!trace){ | ||
575 | 694 | sp_svg_write_color(color_string, sizeof(color_string), rgba); | ||
576 | 695 | if(pickfill){ | ||
577 | 696 | sp_repr_css_set_property(css, "fill", color_string); | ||
578 | 697 | } | ||
579 | 698 | if(pickstroke){ | ||
580 | 699 | sp_repr_css_set_property(css, "stroke", color_string); | ||
581 | 700 | } | ||
582 | 701 | } | ||
583 | 702 | if(!nooverlap && (picker || visible)){ | ||
584 | 703 | for (std::vector<SPItem *>::const_iterator k=items_down.begin(); k!=items_down.end(); k++) { | ||
585 | 704 | SPItem *item_hidden = *k; | ||
586 | 705 | item_hidden->setHidden(false); | ||
587 | 706 | item_hidden->updateRepr(); | ||
588 | 707 | } | ||
589 | 708 | } | ||
590 | 709 | } | ||
591 | 710 | return true; | ||
592 | 711 | } | ||
593 | 712 | |||
594 | 335 | static bool sp_spray_recursive(SPDesktop *desktop, | 713 | static bool sp_spray_recursive(SPDesktop *desktop, |
595 | 336 | Inkscape::Selection *selection, | 714 | Inkscape::Selection *selection, |
596 | 337 | SPItem *item, | 715 | SPItem *item, |
597 | @@ -348,7 +726,16 @@ | |||
598 | 348 | double ratio, | 726 | double ratio, |
599 | 349 | double tilt, | 727 | double tilt, |
600 | 350 | double rotation_variation, | 728 | double rotation_variation, |
602 | 351 | gint _distrib) | 729 | gint _distrib, |
603 | 730 | bool nooverlap, | ||
604 | 731 | bool picker, | ||
605 | 732 | bool pickinversevalue, | ||
606 | 733 | bool pickfill, | ||
607 | 734 | bool pickstroke, | ||
608 | 735 | bool visible, | ||
609 | 736 | double offset, | ||
610 | 737 | bool usepressurescale, | ||
611 | 738 | double pressure) | ||
612 | 352 | { | 739 | { |
613 | 353 | bool did = false; | 740 | bool did = false; |
614 | 354 | 741 | ||
615 | @@ -364,6 +751,9 @@ | |||
616 | 364 | double _fid = g_random_double_range(0, 1); | 751 | double _fid = g_random_double_range(0, 1); |
617 | 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 ); |
618 | 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 ); |
619 | 754 | if(usepressurescale){ | ||
620 | 755 | _scale = pressure; | ||
621 | 756 | } | ||
622 | 367 | double dr; double dp; | 757 | double dr; double dp; |
623 | 368 | random_position( dr, dp, mean, standard_deviation, _distrib ); | 758 | random_position( dr, dp, mean, standard_deviation, _distrib ); |
624 | 369 | dr=dr*radius; | 759 | dr=dr*radius; |
625 | @@ -371,27 +761,44 @@ | |||
626 | 371 | if (mode == SPRAY_MODE_COPY) { | 761 | if (mode == SPRAY_MODE_COPY) { |
627 | 372 | Geom::OptRect a = item->documentVisualBounds(); | 762 | Geom::OptRect a = item->documentVisualBounds(); |
628 | 373 | if (a) { | 763 | if (a) { |
629 | 374 | SPItem *item_copied; | ||
630 | 375 | if(_fid <= population) | 764 | if(_fid <= population) |
631 | 376 | { | 765 | { |
632 | 766 | SPDocument *doc = item->document; | ||
633 | 767 | gchar const * spray_origin; | ||
634 | 768 | if(!item->getAttribute("inkscape:spray-origin")){ | ||
635 | 769 | spray_origin = g_strdup_printf("#%s", item->getId()); | ||
636 | 770 | } else { | ||
637 | 771 | spray_origin = item->getAttribute("inkscape:spray-origin"); | ||
638 | 772 | } | ||
639 | 773 | Geom::Point center = item->getCenter(); | ||
640 | 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()); | ||
641 | 775 | SPCSSAttr *css = sp_repr_css_attr_new(); | ||
642 | 776 | if(nooverlap || picker || visible){ | ||
643 | 777 | if(!fit_item(desktop, item, a, move, center, angle, _scale, scale, picker, pickinversevalue, pickfill, pickstroke, visible, nooverlap, offset, css, false)){ | ||
644 | 778 | return false; | ||
645 | 779 | } | ||
646 | 780 | } | ||
647 | 781 | SPItem *item_copied; | ||
648 | 377 | // Duplicate | 782 | // Duplicate |
649 | 378 | SPDocument *doc = item->document; | ||
650 | 379 | Inkscape::XML::Document* xml_doc = doc->getReprDoc(); | 783 | Inkscape::XML::Document* xml_doc = doc->getReprDoc(); |
651 | 380 | Inkscape::XML::Node *old_repr = item->getRepr(); | 784 | Inkscape::XML::Node *old_repr = item->getRepr(); |
652 | 381 | Inkscape::XML::Node *parent = old_repr->parent(); | 785 | Inkscape::XML::Node *parent = old_repr->parent(); |
653 | 382 | Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); | 786 | Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); |
654 | 787 | if(!copy->attribute("inkscape:spray-origin")){ | ||
655 | 788 | copy->setAttribute("inkscape:spray-origin", spray_origin); | ||
656 | 789 | } | ||
657 | 383 | parent->appendChild(copy); | 790 | parent->appendChild(copy); |
658 | 384 | |||
659 | 385 | SPObject *new_obj = doc->getObjectByRepr(copy); | 791 | SPObject *new_obj = doc->getObjectByRepr(copy); |
660 | 386 | item_copied = dynamic_cast<SPItem *>(new_obj); // Conversion object->item | 792 | item_copied = dynamic_cast<SPItem *>(new_obj); // Conversion object->item |
665 | 387 | Geom::Point center=item->getCenter(); | 793 | sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(_scale)); |
666 | 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)); |
663 | 389 | sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale,scale)); | ||
664 | 390 | |||
667 | 391 | sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); | 795 | sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); |
668 | 392 | // Move the cursor p | 796 | // Move the cursor p |
669 | 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()); | ||
670 | 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])); |
671 | 798 | Inkscape::GC::release(copy); | ||
672 | 799 | if(picker){ | ||
673 | 800 | sp_desktop_apply_css_recursive(item_copied, css, true); | ||
674 | 801 | } | ||
675 | 395 | did = true; | 802 | did = true; |
676 | 396 | } | 803 | } |
677 | 397 | } | 804 | } |
678 | @@ -425,6 +832,13 @@ | |||
679 | 425 | if (_fid <= population) { // Rules the population of objects sprayed | 832 | if (_fid <= population) { // Rules the population of objects sprayed |
680 | 426 | // Duplicates the parent item | 833 | // Duplicates the parent item |
681 | 427 | Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); | 834 | Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); |
682 | 835 | gchar const * spray_origin; | ||
683 | 836 | if(!copy->attribute("inkscape:spray-origin")){ | ||
684 | 837 | spray_origin = g_strdup_printf("#%s", old_repr->attribute("id")); | ||
685 | 838 | copy->setAttribute("inkscape:spray-origin", spray_origin); | ||
686 | 839 | } else { | ||
687 | 840 | spray_origin = copy->attribute("inkscape:spray-origin"); | ||
688 | 841 | } | ||
689 | 428 | parent->appendChild(copy); | 842 | parent->appendChild(copy); |
690 | 429 | SPObject *new_obj = doc->getObjectByRepr(copy); | 843 | SPObject *new_obj = doc->getObjectByRepr(copy); |
691 | 430 | item_copied = dynamic_cast<SPItem *>(new_obj); | 844 | item_copied = dynamic_cast<SPItem *>(new_obj); |
692 | @@ -456,8 +870,22 @@ | |||
693 | 456 | Geom::OptRect a = item->documentVisualBounds(); | 870 | Geom::OptRect a = item->documentVisualBounds(); |
694 | 457 | if (a) { | 871 | if (a) { |
695 | 458 | if(_fid <= population) { | 872 | if(_fid <= population) { |
696 | 873 | SPDocument *doc = item->document; | ||
697 | 874 | gchar const * spray_origin; | ||
698 | 875 | if(!item->getAttribute("inkscape:spray-origin")){ | ||
699 | 876 | spray_origin = g_strdup_printf("#%s", item->getId()); | ||
700 | 877 | } else { | ||
701 | 878 | spray_origin = item->getAttribute("inkscape:spray-origin"); | ||
702 | 879 | } | ||
703 | 880 | Geom::Point center=item->getCenter(); | ||
704 | 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()); | ||
705 | 882 | SPCSSAttr *css = sp_repr_css_attr_new(); | ||
706 | 883 | if(nooverlap || picker || visible){ | ||
707 | 884 | if(!fit_item(desktop, item, a, move, center, angle, _scale, scale, picker, pickinversevalue, pickfill, pickstroke, visible, nooverlap, offset, css, false)){ | ||
708 | 885 | return false; | ||
709 | 886 | } | ||
710 | 887 | } | ||
711 | 459 | SPItem *item_copied; | 888 | SPItem *item_copied; |
712 | 460 | SPDocument *doc = item->document; | ||
713 | 461 | Inkscape::XML::Document* xml_doc = doc->getReprDoc(); | 889 | Inkscape::XML::Document* xml_doc = doc->getReprDoc(); |
714 | 462 | Inkscape::XML::Node *old_repr = item->getRepr(); | 890 | Inkscape::XML::Node *old_repr = item->getRepr(); |
715 | 463 | Inkscape::XML::Node *parent = old_repr->parent(); | 891 | Inkscape::XML::Node *parent = old_repr->parent(); |
716 | @@ -467,6 +895,9 @@ | |||
717 | 467 | // Ad the clone to the list of the parent's children | 895 | // Ad the clone to the list of the parent's children |
718 | 468 | parent->appendChild(clone); | 896 | parent->appendChild(clone); |
719 | 469 | // Generates the link between parent and child attributes | 897 | // Generates the link between parent and child attributes |
720 | 898 | if(!clone->attribute("inkscape:spray-origin")){ | ||
721 | 899 | clone->setAttribute("inkscape:spray-origin", spray_origin); | ||
722 | 900 | } | ||
723 | 470 | gchar *href_str = g_strdup_printf("#%s", old_repr->attribute("id")); | 901 | gchar *href_str = g_strdup_printf("#%s", old_repr->attribute("id")); |
724 | 471 | clone->setAttribute("xlink:href", href_str, false); | 902 | clone->setAttribute("xlink:href", href_str, false); |
725 | 472 | g_free(href_str); | 903 | g_free(href_str); |
726 | @@ -474,15 +905,14 @@ | |||
727 | 474 | SPObject *clone_object = doc->getObjectByRepr(clone); | 905 | SPObject *clone_object = doc->getObjectByRepr(clone); |
728 | 475 | // Conversion object->item | 906 | // Conversion object->item |
729 | 476 | item_copied = dynamic_cast<SPItem *>(clone_object); | 907 | item_copied = dynamic_cast<SPItem *>(clone_object); |
730 | 477 | Geom::Point center = item->getCenter(); | ||
731 | 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)); |
732 | 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)); |
733 | 480 | sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle)); | 910 | sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle)); |
734 | 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()); | ||
735 | 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])); |
737 | 483 | 912 | if(picker){ | |
738 | 913 | sp_desktop_apply_css_recursive(item_copied, css, true); | ||
739 | 914 | } | ||
740 | 484 | Inkscape::GC::release(clone); | 915 | Inkscape::GC::release(clone); |
741 | 485 | |||
742 | 486 | did = true; | 916 | did = true; |
743 | 487 | } | 917 | } |
744 | 488 | } | 918 | } |
745 | @@ -529,8 +959,7 @@ | |||
746 | 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++){ |
747 | 530 | SPItem *item = *i; | 960 | SPItem *item = *i; |
748 | 531 | g_assert(item != NULL); | 961 | g_assert(item != NULL); |
751 | 532 | 962 | 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))) { | |
750 | 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)) { | ||
752 | 534 | did = true; | 963 | did = true; |
753 | 535 | } | 964 | } |
754 | 536 | } | 965 | } |
755 | 537 | 966 | ||
756 | === modified file 'src/ui/tools/spray-tool.h' | |||
757 | --- src/ui/tools/spray-tool.h 2015-06-22 19:20:23 +0000 | |||
758 | +++ src/ui/tools/spray-tool.h 2015-11-08 09:50:32 +0000 | |||
759 | @@ -12,6 +12,7 @@ | |||
760 | 12 | * Benoît LAVORATA | 12 | * Benoît LAVORATA |
761 | 13 | * Vincent MONTAGNE | 13 | * Vincent MONTAGNE |
762 | 14 | * Pierre BARBRY-BLOT | 14 | * Pierre BARBRY-BLOT |
763 | 15 | * Jabiertxo ARRAIZA | ||
764 | 15 | * | 16 | * |
765 | 16 | * Copyright (C) 2009 authors | 17 | * Copyright (C) 2009 authors |
766 | 17 | * | 18 | * |
767 | @@ -62,7 +63,9 @@ | |||
768 | 62 | 63 | ||
769 | 63 | /* attributes */ | 64 | /* attributes */ |
770 | 64 | bool dragging; /* mouse state: mouse is dragging */ | 65 | bool dragging; /* mouse state: mouse is dragging */ |
772 | 65 | bool usepressure; | 66 | bool usepressurewidth; |
773 | 67 | bool usepressurepopulation; | ||
774 | 68 | bool usepressurescale; | ||
775 | 66 | bool usetilt; | 69 | bool usetilt; |
776 | 67 | bool usetext; | 70 | bool usetext; |
777 | 68 | 71 | ||
778 | @@ -86,7 +89,13 @@ | |||
779 | 86 | bool has_dilated; | 89 | bool has_dilated; |
780 | 87 | Geom::Point last_push; | 90 | Geom::Point last_push; |
781 | 88 | SPCanvasItem *dilate_area; | 91 | SPCanvasItem *dilate_area; |
783 | 89 | 92 | bool nooverlap; | |
784 | 93 | bool picker; | ||
785 | 94 | bool pickinversevalue; | ||
786 | 95 | bool pickfill; | ||
787 | 96 | bool pickstroke; | ||
788 | 97 | bool visible; | ||
789 | 98 | double offset; | ||
790 | 90 | sigc::connection style_set_connection; | 99 | sigc::connection style_set_connection; |
791 | 91 | 100 | ||
792 | 92 | static const std::string prefsPath; | 101 | static const std::string prefsPath; |
793 | 93 | 102 | ||
794 | === modified file 'src/widgets/spray-toolbar.cpp' | |||
795 | --- src/widgets/spray-toolbar.cpp 2014-10-05 18:14:01 +0000 | |||
796 | +++ src/widgets/spray-toolbar.cpp 2015-11-08 09:50:32 +0000 | |||
797 | @@ -15,10 +15,11 @@ | |||
798 | 15 | * Tavmjong Bah <tavmjong@free.fr> | 15 | * Tavmjong Bah <tavmjong@free.fr> |
799 | 16 | * Abhishek Sharma | 16 | * Abhishek Sharma |
800 | 17 | * Kris De Gussem <Kris.DeGussem@gmail.com> | 17 | * Kris De Gussem <Kris.DeGussem@gmail.com> |
801 | 18 | * Jabiertxo Arraiza <jabier.arraiza@marker.es> | ||
802 | 18 | * | 19 | * |
803 | 19 | * Copyright (C) 2004 David Turner | 20 | * Copyright (C) 2004 David Turner |
804 | 20 | * Copyright (C) 2003 MenTaLguY | 21 | * Copyright (C) 2003 MenTaLguY |
806 | 21 | * Copyright (C) 1999-2011 authors | 22 | * Copyright (C) 1999-2015 authors |
807 | 22 | * Copyright (C) 2001-2002 Ximian, Inc. | 23 | * Copyright (C) 2001-2002 Ximian, Inc. |
808 | 23 | * | 24 | * |
809 | 24 | * Released under GNU GPL, read the file 'COPYING' for more information | 25 | * Released under GNU GPL, read the file 'COPYING' for more information |
810 | @@ -28,18 +29,24 @@ | |||
811 | 28 | # include "config.h" | 29 | # include "config.h" |
812 | 29 | #endif | 30 | #endif |
813 | 30 | 31 | ||
815 | 31 | #include <glibmm/i18n.h> | 32 | #include <gtkmm.h> |
816 | 32 | 33 | ||
817 | 33 | #include "spray-toolbar.h" | 34 | #include "spray-toolbar.h" |
818 | 34 | #include "desktop.h" | 35 | #include "desktop.h" |
819 | 36 | #include "inkscape.h" | ||
820 | 35 | #include "document-undo.h" | 37 | #include "document-undo.h" |
821 | 36 | #include "widgets/ege-adjustment-action.h" | 38 | #include "widgets/ege-adjustment-action.h" |
822 | 37 | #include "widgets/ege-select-one-action.h" | 39 | #include "widgets/ege-select-one-action.h" |
823 | 38 | #include "widgets/ink-action.h" | 40 | #include "widgets/ink-action.h" |
824 | 39 | #include "preferences.h" | 41 | #include "preferences.h" |
825 | 40 | #include "toolbox.h" | 42 | #include "toolbox.h" |
826 | 43 | #include "ui/dialog/clonetiler.h" | ||
827 | 44 | #include "ui/dialog/dialog-manager.h" | ||
828 | 45 | #include "ui/dialog/panel-dialog.h" | ||
829 | 41 | #include "ui/icon-names.h" | 46 | #include "ui/icon-names.h" |
830 | 42 | 47 | ||
831 | 48 | #include <glibmm/i18n.h> | ||
832 | 49 | |||
833 | 43 | using Inkscape::DocumentUndo; | 50 | using Inkscape::DocumentUndo; |
834 | 44 | using Inkscape::UI::ToolboxFactory; | 51 | using Inkscape::UI::ToolboxFactory; |
835 | 45 | using Inkscape::UI::PrefPusher; | 52 | using Inkscape::UI::PrefPusher; |
836 | @@ -53,6 +60,55 @@ | |||
837 | 53 | //## Spray ## | 60 | //## Spray ## |
838 | 54 | //######################## | 61 | //######################## |
839 | 55 | 62 | ||
840 | 63 | static void sp_stb_sensitivize( GObject *tbl ) | ||
841 | 64 | { | ||
842 | 65 | GtkAction* offset = GTK_ACTION( g_object_get_data(tbl, "offset") ); | ||
843 | 66 | GtkAction* spray_scale = GTK_ACTION( g_object_get_data(tbl, "spray_scale") ); | ||
844 | 67 | GtkAdjustment *adj_offset = ege_adjustment_action_get_adjustment( EGE_ADJUSTMENT_ACTION(offset) ); | ||
845 | 68 | GtkAdjustment *adj_scale = ege_adjustment_action_get_adjustment( EGE_ADJUSTMENT_ACTION(spray_scale) ); | ||
846 | 69 | GtkToggleAction *nooverlap = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "nooverlap") ); | ||
847 | 70 | GtkToggleAction *picker = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "picker") ); | ||
848 | 71 | GtkToggleAction *usepressurescale = GTK_TOGGLE_ACTION( g_object_get_data(tbl, "usepressurescale") ); | ||
849 | 72 | GtkAction *pickfill = GTK_ACTION( g_object_get_data(tbl, "pickfill") ); | ||
850 | 73 | GtkAction *pickstroke = GTK_ACTION( g_object_get_data(tbl, "pickstroke") ); | ||
851 | 74 | GtkAction *pickinversevalue = GTK_ACTION( g_object_get_data(tbl, "pickinversevalue") ); | ||
852 | 75 | gtk_adjustment_set_value( adj_offset, 100.0 ); | ||
853 | 76 | if (gtk_toggle_action_get_active(nooverlap)) { | ||
854 | 77 | gtk_action_set_sensitive( offset, TRUE ); | ||
855 | 78 | } else { | ||
856 | 79 | gtk_action_set_sensitive( offset, FALSE ); | ||
857 | 80 | } | ||
858 | 81 | if (gtk_toggle_action_get_active(usepressurescale)) { | ||
859 | 82 | gtk_adjustment_set_value( adj_scale, 0.0 ); | ||
860 | 83 | gtk_action_set_sensitive( spray_scale, FALSE ); | ||
861 | 84 | } else { | ||
862 | 85 | gtk_action_set_sensitive( spray_scale, TRUE ); | ||
863 | 86 | } | ||
864 | 87 | if(gtk_toggle_action_get_active(picker)){ | ||
865 | 88 | gtk_action_set_sensitive( pickfill, TRUE ); | ||
866 | 89 | gtk_action_set_sensitive( pickstroke, TRUE ); | ||
867 | 90 | gtk_action_set_sensitive( pickinversevalue, TRUE ); | ||
868 | 91 | } else { | ||
869 | 92 | gtk_action_set_sensitive( pickfill, FALSE ); | ||
870 | 93 | gtk_action_set_sensitive( pickstroke, FALSE ); | ||
871 | 94 | gtk_action_set_sensitive( pickinversevalue, FALSE ); | ||
872 | 95 | } | ||
873 | 96 | } | ||
874 | 97 | |||
875 | 98 | Inkscape::UI::Dialog::CloneTiler *get_clone_tiler_panel(SPDesktop *desktop) | ||
876 | 99 | { | ||
877 | 100 | if (Inkscape::UI::Dialog::PanelDialogBase *panel_dialog = | ||
878 | 101 | dynamic_cast<Inkscape::UI::Dialog::PanelDialogBase *>(desktop->_dlg_mgr->getDialog("CloneTiler"))) { | ||
879 | 102 | try { | ||
880 | 103 | Inkscape::UI::Dialog::CloneTiler &clone_tiler = | ||
881 | 104 | dynamic_cast<Inkscape::UI::Dialog::CloneTiler &>(panel_dialog->getPanel()); | ||
882 | 105 | return &clone_tiler; | ||
883 | 106 | } catch (std::exception &e) { } | ||
884 | 107 | } | ||
885 | 108 | |||
886 | 109 | return 0; | ||
887 | 110 | } | ||
888 | 111 | |||
889 | 56 | static void sp_spray_width_value_changed( GtkAdjustment *adj, GObject * /*tbl*/ ) | 112 | static void sp_spray_width_value_changed( GtkAdjustment *adj, GObject * /*tbl*/ ) |
890 | 57 | { | 113 | { |
891 | 58 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 114 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
892 | @@ -102,12 +158,83 @@ | |||
893 | 102 | gtk_adjustment_get_value(adj)); | 158 | gtk_adjustment_get_value(adj)); |
894 | 103 | } | 159 | } |
895 | 104 | 160 | ||
896 | 161 | static void sp_spray_offset_value_changed( GtkAdjustment *adj, GObject * /*tbl*/ ) | ||
897 | 162 | { | ||
898 | 163 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
899 | 164 | prefs->setDouble( "/tools/spray/offset", | ||
900 | 165 | gtk_adjustment_get_value(adj)); | ||
901 | 166 | } | ||
902 | 167 | |||
903 | 168 | static void sp_toggle_nooverlap( GtkToggleAction* act, gpointer data) | ||
904 | 169 | { | ||
905 | 170 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
906 | 171 | gboolean active = gtk_toggle_action_get_active(act); | ||
907 | 172 | prefs->setBool("/tools/spray/nooverlap", active); | ||
908 | 173 | GObject *tbl = G_OBJECT(data); | ||
909 | 174 | sp_stb_sensitivize(tbl); | ||
910 | 175 | } | ||
911 | 176 | |||
912 | 177 | static void sp_toggle_pressure_scale( GtkToggleAction* act, gpointer data) | ||
913 | 178 | { | ||
914 | 179 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
915 | 180 | gboolean active = gtk_toggle_action_get_active(act); | ||
916 | 181 | prefs->setBool("/tools/spray/usepressurescale", active); | ||
917 | 182 | if(active == true){ | ||
918 | 183 | prefs->setDouble("/tools/spray/scale_variation", 0); | ||
919 | 184 | } | ||
920 | 185 | GObject *tbl = G_OBJECT(data); | ||
921 | 186 | sp_stb_sensitivize( tbl ); | ||
922 | 187 | } | ||
923 | 188 | |||
924 | 189 | static void sp_toggle_visible( GtkToggleAction* act, gpointer data) | ||
925 | 190 | { | ||
926 | 191 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
927 | 192 | gboolean active = gtk_toggle_action_get_active(act); | ||
928 | 193 | prefs->setBool("/tools/spray/visible", active); | ||
929 | 194 | } | ||
930 | 195 | |||
931 | 196 | static void sp_toggle_picker( GtkToggleAction* act, gpointer data ) | ||
932 | 197 | { | ||
933 | 198 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
934 | 199 | gboolean active = gtk_toggle_action_get_active(act); | ||
935 | 200 | prefs->setBool("/tools/spray/picker", active); | ||
936 | 201 | if(active == true){ | ||
937 | 202 | prefs->setBool("/dialogs/clonetiler/dotrace", true); | ||
938 | 203 | SPDesktop *dt = SP_ACTIVE_DESKTOP; | ||
939 | 204 | if (Inkscape::UI::Dialog::CloneTiler *ct = get_clone_tiler_panel(dt)){ | ||
940 | 205 | dt->_dlg_mgr->showDialog("CloneTiler"); | ||
941 | 206 | ct->show_page_trace(); | ||
942 | 207 | } | ||
943 | 208 | } | ||
944 | 209 | GObject *tbl = G_OBJECT(data); | ||
945 | 210 | sp_stb_sensitivize(tbl); | ||
946 | 211 | } | ||
947 | 212 | |||
948 | 213 | static void sp_toggle_pick_fill( GtkToggleAction* act, gpointer data ) | ||
949 | 214 | { | ||
950 | 215 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
951 | 216 | gboolean active = gtk_toggle_action_get_active(act); | ||
952 | 217 | prefs->setBool("/tools/spray/pickfill", active); | ||
953 | 218 | } | ||
954 | 219 | |||
955 | 220 | static void sp_toggle_pick_inverse_value( GtkToggleAction* act, gpointer data ) | ||
956 | 221 | { | ||
957 | 222 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
958 | 223 | gboolean active = gtk_toggle_action_get_active(act); | ||
959 | 224 | prefs->setBool("/tools/spray/pickinversevalue", active); | ||
960 | 225 | } | ||
961 | 226 | |||
962 | 227 | static void sp_toggle_pick_stroke( GtkToggleAction* act, gpointer data ) | ||
963 | 228 | { | ||
964 | 229 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
965 | 230 | gboolean active = gtk_toggle_action_get_active(act); | ||
966 | 231 | prefs->setBool("/tools/spray/pickstroke", active); | ||
967 | 232 | } | ||
968 | 105 | 233 | ||
969 | 106 | void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) | 234 | void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) |
970 | 107 | { | 235 | { |
971 | 108 | Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); | 236 | Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); |
972 | 109 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 237 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
973 | 110 | |||
974 | 111 | { | 238 | { |
975 | 112 | /* Width */ | 239 | /* Width */ |
976 | 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)")}; |
977 | @@ -123,7 +250,20 @@ | |||
978 | 123 | gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); | 250 | gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); |
979 | 124 | gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); | 251 | gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); |
980 | 125 | } | 252 | } |
981 | 253 | |||
982 | 254 | /* Use Pressure Width button */ | ||
983 | 255 | { | ||
984 | 256 | InkToggleAction* act = ink_toggle_action_new( "SprayPressureWidthAction", | ||
985 | 257 | _("Pressure"), | ||
986 | 258 | _("Use the pressure of the input device to alter the width of spray area"), | ||
987 | 259 | INKSCAPE_ICON("draw-use-pressure"), | ||
988 | 260 | Inkscape::ICON_SIZE_DECORATION ); | ||
989 | 261 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); | ||
990 | 262 | PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressurewidth"); | ||
991 | 263 | g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); | ||
992 | 126 | 264 | ||
993 | 265 | } | ||
994 | 266 | |||
995 | 127 | { | 267 | { |
996 | 128 | /* Mean */ | 268 | /* Mean */ |
997 | 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)")}; |
998 | @@ -218,15 +358,15 @@ | |||
999 | 218 | g_object_set_data( holder, "spray_population", eact ); | 358 | g_object_set_data( holder, "spray_population", eact ); |
1000 | 219 | } | 359 | } |
1001 | 220 | 360 | ||
1003 | 221 | /* Use Pressure button */ | 361 | /* Use Pressure Population button */ |
1004 | 222 | { | 362 | { |
1006 | 223 | InkToggleAction* act = ink_toggle_action_new( "SprayPressureAction", | 363 | InkToggleAction* act = ink_toggle_action_new( "SprayPressurePopulationAction", |
1007 | 224 | _("Pressure"), | 364 | _("Pressure"), |
1008 | 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"), |
1009 | 226 | INKSCAPE_ICON("draw-use-pressure"), | 366 | INKSCAPE_ICON("draw-use-pressure"), |
1010 | 227 | Inkscape::ICON_SIZE_DECORATION ); | 367 | Inkscape::ICON_SIZE_DECORATION ); |
1011 | 228 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); | 368 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); |
1013 | 229 | PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressure"); | 369 | PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/spray/usepressurepopulation"); |
1014 | 230 | g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); | 370 | g_signal_connect(holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); |
1015 | 231 | 371 | ||
1016 | 232 | } | 372 | } |
1017 | @@ -267,8 +407,112 @@ | |||
1018 | 267 | g_object_set_data( holder, "spray_scale", eact ); | 407 | g_object_set_data( holder, "spray_scale", eact ); |
1019 | 268 | } | 408 | } |
1020 | 269 | 409 | ||
1023 | 270 | 410 | /* Use Pressure Scale button */ | |
1024 | 271 | 411 | { | |
1025 | 412 | InkToggleAction* act = ink_toggle_action_new( "SprayPressureScaleAction", | ||
1026 | 413 | _("Pressure"), | ||
1027 | 414 | _("Use the pressure of the input device to alter the scale of new items"), | ||
1028 | 415 | INKSCAPE_ICON("draw-use-pressure"), | ||
1029 | 416 | Inkscape::ICON_SIZE_DECORATION); | ||
1030 | 417 | gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/usepressurescale", false) ); | ||
1031 | 418 | g_object_set_data( holder, "usepressurescale", act ); | ||
1032 | 419 | g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pressure_scale), holder) ; | ||
1033 | 420 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); | ||
1034 | 421 | } | ||
1035 | 422 | |||
1036 | 423 | |||
1037 | 424 | /* Picker */ | ||
1038 | 425 | { | ||
1039 | 426 | InkToggleAction* act = ink_toggle_action_new( "SprayPickColorAction", | ||
1040 | 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."), | ||
1041 | 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."), | ||
1042 | 429 | INKSCAPE_ICON("color-picker"), | ||
1043 | 430 | secondarySize ); | ||
1044 | 431 | gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/picker", false) ); | ||
1045 | 432 | g_object_set_data( holder, "picker", act ); | ||
1046 | 433 | g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_picker), holder) ; | ||
1047 | 434 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); | ||
1048 | 435 | } | ||
1049 | 436 | |||
1050 | 437 | /* Inverse Value Size */ | ||
1051 | 438 | { | ||
1052 | 439 | InkToggleAction* act = ink_toggle_action_new( "SprayOverPickInverseValueAction", | ||
1053 | 440 | _("Inversed pick value retaining color"), | ||
1054 | 441 | _("Inversed pick value retaining color"), | ||
1055 | 442 | INKSCAPE_ICON("object-tweak-shrink"), | ||
1056 | 443 | secondarySize ); | ||
1057 | 444 | gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pickinversevalue", false) ); | ||
1058 | 445 | g_object_set_data( holder, "pickinversevalue", act ); | ||
1059 | 446 | g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_inverse_value), holder) ; | ||
1060 | 447 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); | ||
1061 | 448 | } | ||
1062 | 449 | |||
1063 | 450 | /* Pick Fill */ | ||
1064 | 451 | { | ||
1065 | 452 | InkToggleAction* act = ink_toggle_action_new( "SprayOverPickFillAction", | ||
1066 | 453 | _("Apply picked color to fill"), | ||
1067 | 454 | _("Apply picked color to fill"), | ||
1068 | 455 | INKSCAPE_ICON("paint-solid"), | ||
1069 | 456 | secondarySize ); | ||
1070 | 457 | gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pickfill", false) ); | ||
1071 | 458 | g_object_set_data( holder, "pickfill", act ); | ||
1072 | 459 | g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_fill), holder) ; | ||
1073 | 460 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); | ||
1074 | 461 | } | ||
1075 | 462 | |||
1076 | 463 | /* Pick Stroke */ | ||
1077 | 464 | { | ||
1078 | 465 | InkToggleAction* act = ink_toggle_action_new( "SprayOverPickStrokeAction", | ||
1079 | 466 | _("Apply picked color to stroke"), | ||
1080 | 467 | _("Apply picked color to stroke"), | ||
1081 | 468 | INKSCAPE_ICON("no-marker"), | ||
1082 | 469 | secondarySize ); | ||
1083 | 470 | gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/pickstroke", false) ); | ||
1084 | 471 | g_object_set_data( holder, "pickstroke", act ); | ||
1085 | 472 | g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_pick_stroke), holder) ; | ||
1086 | 473 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); | ||
1087 | 474 | } | ||
1088 | 475 | |||
1089 | 476 | /* Visible */ | ||
1090 | 477 | { | ||
1091 | 478 | InkToggleAction* act = ink_toggle_action_new( "SprayOverVisibleAction", | ||
1092 | 479 | _("Apply only over non transparent areas"), | ||
1093 | 480 | _("Apply only over non transparent areas"), | ||
1094 | 481 | INKSCAPE_ICON("object-visible"), | ||
1095 | 482 | secondarySize ); | ||
1096 | 483 | gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/visible", false) ); | ||
1097 | 484 | g_object_set_data( holder, "visible", act ); | ||
1098 | 485 | g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_visible), holder) ; | ||
1099 | 486 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); | ||
1100 | 487 | } | ||
1101 | 488 | |||
1102 | 489 | /* Overlap */ | ||
1103 | 490 | { | ||
1104 | 491 | InkToggleAction* act = ink_toggle_action_new( "SprayNoOverlapAction", | ||
1105 | 492 | _("Prevent overlapping objects"), | ||
1106 | 493 | _("Prevent overlapping objects"), | ||
1107 | 494 | INKSCAPE_ICON("distribute-randomize"), | ||
1108 | 495 | secondarySize ); | ||
1109 | 496 | gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/nooverlap", false) ); | ||
1110 | 497 | g_object_set_data( holder, "nooverlap", act ); | ||
1111 | 498 | g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_nooverlap), holder) ; | ||
1112 | 499 | gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); | ||
1113 | 500 | } | ||
1114 | 501 | |||
1115 | 502 | /* Offset */ | ||
1116 | 503 | { | ||
1117 | 504 | EgeAdjustmentAction *eact = create_adjustment_action( "SprayToolOffsetAction", | ||
1118 | 505 | _("Offset %"), _("Offset %:"), | ||
1119 | 506 | _("Increase to segregate objects more (value in percent)"), | ||
1120 | 507 | "/tools/spray/offset", 100, | ||
1121 | 508 | GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, | ||
1122 | 509 | 0, 10000, 1, 4, | ||
1123 | 510 | 0, 0, 0, | ||
1124 | 511 | sp_spray_offset_value_changed, NULL, 0 , 0); | ||
1125 | 512 | g_object_set_data( holder, "offset", eact ); | ||
1126 | 513 | gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); | ||
1127 | 514 | } | ||
1128 | 515 | sp_stb_sensitivize(holder); | ||
1129 | 272 | } | 516 | } |
1130 | 273 | 517 | ||
1131 | 274 | 518 | ||
1132 | 275 | 519 | ||
1133 | === modified file 'src/widgets/spray-toolbar.h' | |||
1134 | --- src/widgets/spray-toolbar.h 2014-03-02 22:58:28 +0000 | |||
1135 | +++ src/widgets/spray-toolbar.h 2015-11-08 09:50:32 +0000 | |||
1136 | @@ -21,7 +21,7 @@ | |||
1137 | 21 | * | 21 | * |
1138 | 22 | * Copyright (C) 2004 David Turner | 22 | * Copyright (C) 2004 David Turner |
1139 | 23 | * Copyright (C) 2003 MenTaLguY | 23 | * Copyright (C) 2003 MenTaLguY |
1141 | 24 | * Copyright (C) 1999-2011 authors | 24 | * Copyright (C) 1999-2015 authors |
1142 | 25 | * Copyright (C) 2001-2002 Ximian, Inc. | 25 | * Copyright (C) 2001-2002 Ximian, Inc. |
1143 | 26 | * | 26 | * |
1144 | 27 | * Released under GNU GPL, read the file 'COPYING' for more information | 27 | * Released under GNU GPL, read the file 'COPYING' for more information |
1145 | 28 | 28 | ||
1146 | === modified file 'src/widgets/toolbox.cpp' | |||
1147 | --- src/widgets/toolbox.cpp 2015-10-22 17:29:20 +0000 | |||
1148 | +++ src/widgets/toolbox.cpp 2015-11-08 09:50:32 +0000 | |||
1149 | @@ -16,10 +16,11 @@ | |||
1150 | 16 | * Tavmjong Bah <tavmjong@free.fr> | 16 | * Tavmjong Bah <tavmjong@free.fr> |
1151 | 17 | * Abhishek Sharma | 17 | * Abhishek Sharma |
1152 | 18 | * Kris De Gussem <Kris.DeGussem@gmail.com> | 18 | * Kris De Gussem <Kris.DeGussem@gmail.com> |
1153 | 19 | * Jabiertxo Arraiza <jabier.arraiza@marker.es> | ||
1154 | 19 | * | 20 | * |
1155 | 20 | * Copyright (C) 2004 David Turner | 21 | * Copyright (C) 2004 David Turner |
1156 | 21 | * Copyright (C) 2003 MenTaLguY | 22 | * Copyright (C) 2003 MenTaLguY |
1158 | 22 | * Copyright (C) 1999-2011 authors | 23 | * Copyright (C) 1999-2015 authors |
1159 | 23 | * Copyright (C) 2001-2002 Ximian, Inc. | 24 | * Copyright (C) 2001-2002 Ximian, Inc. |
1160 | 24 | * | 25 | * |
1161 | 25 | * Released under GNU GPL, read the file 'COPYING' for more information | 26 | * Released under GNU GPL, read the file 'COPYING' for more information |
1162 | @@ -309,14 +310,26 @@ | |||
1163 | 309 | " <toolitem action='SprayModeAction' />" | 310 | " <toolitem action='SprayModeAction' />" |
1164 | 310 | " <separator />" | 311 | " <separator />" |
1165 | 311 | " <toolitem action='SprayWidthAction' />" | 312 | " <toolitem action='SprayWidthAction' />" |
1166 | 313 | " <toolitem action='SprayPressureWidthAction' />" | ||
1167 | 312 | " <toolitem action='SprayPopulationAction' />" | 314 | " <toolitem action='SprayPopulationAction' />" |
1169 | 313 | " <toolitem action='SprayPressureAction' />" | 315 | " <toolitem action='SprayPressurePopulationAction' />" |
1170 | 314 | " <separator />" | 316 | " <separator />" |
1171 | 315 | " <toolitem action='SprayRotationAction' />" | 317 | " <toolitem action='SprayRotationAction' />" |
1172 | 316 | " <toolitem action='SprayScaleAction' />" | 318 | " <toolitem action='SprayScaleAction' />" |
1173 | 319 | " <toolitem action='SprayPressureScaleAction' />" | ||
1174 | 317 | " <separator />" | 320 | " <separator />" |
1175 | 318 | " <toolitem action='SprayStandard_deviationAction' />" | 321 | " <toolitem action='SprayStandard_deviationAction' />" |
1176 | 319 | " <toolitem action='SprayMeanAction' />" | 322 | " <toolitem action='SprayMeanAction' />" |
1177 | 323 | " <separator />" | ||
1178 | 324 | " <toolitem action='SprayOverVisibleAction' />" | ||
1179 | 325 | " <toolitem action='SprayNoOverlapAction' />" | ||
1180 | 326 | " <toolitem action='SprayToolOffsetAction' />" | ||
1181 | 327 | " <separator />" | ||
1182 | 328 | " <toolitem action='SprayPickColorAction' />" | ||
1183 | 329 | " <toolitem action='SprayOverPickInverseValueAction' />" | ||
1184 | 330 | " <toolitem action='SprayOverPickFillAction' />" | ||
1185 | 331 | " <toolitem action='SprayOverPickStrokeAction' />" | ||
1186 | 332 | |||
1187 | 320 | " </toolbar>" | 333 | " </toolbar>" |
1188 | 321 | 334 | ||
1189 | 322 | " <toolbar name='ZoomToolbar'>" | 335 | " <toolbar name='ZoomToolbar'>" |
I read it, and just saw two very minor things to change.
I did not test it yet.