Merge lp:~caldoria+inkscape.dev/inkscape/clonetiler-absolute-units into lp:~inkscape.dev/inkscape/trunk

Proposed by Mark
Status: Needs review
Proposed branch: lp:~caldoria+inkscape.dev/inkscape/clonetiler-absolute-units
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 864 lines (+411/-277)
3 files modified
src/ui/dialog/clonetiler.cpp (+355/-276)
src/ui/dialog/clonetiler.h (+52/-0)
src/ui/widget/labelled.cpp (+4/-1)
To merge this branch: bzr merge lp:~caldoria+inkscape.dev/inkscape/clonetiler-absolute-units
Reviewer Review Type Date Requested Status
Inkscape Developers Pending
Review via email: mp+276948@code.launchpad.net

Description of the change

I've changed the clonetiler dialog so that absolute units can be used for both shifting and scaling. So far only dimensionless units (percent) could be used for this.

Absolute units help when trying to place irregular objects on a regular grid, where it is inconvenient to specify the grid spacing as a multiple of the object size.

Note that this is my first contribution to Inkscape, so I am not sure if this is the avenue you guys prefer for contributions. I find the various wiki pages and instructions a little unclear, using the procedure detailed on http://wiki.inkscape.org/wiki/index.php/Working_with_Bazaar#Publishing_your_work_on_Launchpad.

To post a comment you must log in.
14453. By jabiertxof<email address hidden>

Spray Tool: Change hide invisibe by over visible and over invisible, sugested by Ivan Louette

14454. By Jabiertxof <email address hidden>

Improvements to the over visible/invisible to minimize the colisions, sprayed items fit on background whith overlap visible or invisible areas
Add option in picker mode to compute the center/or average area of sprayed item
Now reverse work without adbanced trace dialog inverting the color. By this all buttons have a utility in advanced and in normal mode

14455. By Jabiertxof <email address hidden>

Add option to spray tool to no overlap between colors

14456. By Jabiertxof <email address hidden>

Remove unused functions

14457. By jabiertxof<email address hidden>

Improve offseting calculation
Improve no picoverlap feature

14458. By jabiertxof<email address hidden>

Refactor of code, minor bugs fixed.

14459. By jabiertxof<email address hidden>

Add erase mode to spray. Bugfixes.

14460. By jabiertxof<email address hidden>

Fix a warn on launch

14461. By jabiertxof<email address hidden>

Fix crashes in erase mode of spray

14462. By jabiertxof<email address hidden>

Fix a bug on bspline, duplicating end nodes

14463. By Kris

static code analysis

14464. By Kris

static code analysis

14465. By Alexandre Prokoudine

Update Russian translation

14466. By Alexandre Prokoudine

Update Russian translation

14467. By Alexandre Prokoudine

Some sane defaults for spray offset, subject to further tweaking

14468. By Alexandre Prokoudine

Update Russian translation

14469. By Jabiertxof <email address hidden>

Fix erase mode in no overlap mode, pointed by Ivan Louette

14470. By Hasan Kiran

Translation. Turkish translation update.

14471. By Jabiertxof <email address hidden>

Fixed roughen LPE

14472. By Janis Eisaks

Latvian translation update

14473. By Firas Hanife

Translations. Italian translation update.

14474. By Kris

static code analysis

14475. By Mc

removes warnings when compiling with c++11 using uniqueptr instead of autoptr

14476. By Kris

Fix potentential null pointer dereference

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

Hi,

there are a lot of conflicts with current trunk since jabier's work, could you update to trunk and fix these ?

Also, can you roughly explain what you changed in the code (a high-level explanation) ?

Thanks.

Mc

14477. By Hasan Kiran

Translations. Turkish translation update.

14478. By Mc

fix for bug 1517740 (crash in some cases in selection sets)

14479. By insaner

window/task bar icon missing when installed in non-standard location

14480. By Alex Valavanis

Compile against external libpotrace

14481. By Alex Valavanis

src/Makefile.am: Rm notes about tests that have been fixed

14482. By su_v

packaging/macosx: update scripts for potrace switch to external dependency

14483. By caldoria <email address hidden>

Enabled absolute units for clonetiler shift and scale functions. Addressed first reviewer comments, removed some dead code.

Revision history for this message
Mark (caldoria) wrote :

Hi,

Thanks for reviewing the code. I've tried to address your comments. There seem to be no conflicts at the moment.

As to what I did in the code, I changed the widgets in the clonetiler dialog to be able to deal with units. Before one could only input dimensionless quantities via that dialog. I have only changed the "Shift" and "Scale" pages, as these seem to me to be the only ones that would reasonably benefit from unit quantities. This mainly meant replacing the relevant input widgets with UI::Widget::ScalarUnit and adding corresponding UI::Widget::UnitMenu widgets. I've based my changes on the code for the Transformation dialog. I've added appropriate signal handling functions that make use of the existing model of storing all quantities within the preferences subsystem before calculating the required transforms. I also made some changes to the code actually calculating the transforms so that the units are respected.

I also made a small change to the "Labelled" widget. Before a label would be placed into the layout manager even if no label (empty string) is specified, which could yield an unsightly space. I've made this conditional on non-empty strings. I've done this because the ScalarUnit widget is a Labelled, and while I don't want to label the widget, I do want to make use of the unit capabilities.

Thanks,
Mark

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

I tested the branch, and got into those problems:

-> by default, there is no unit selected, not even "%" (blank choice)
-> "reset" does not work as expected (or at all in some tabs, and does not reset units to %)
-> default % setting set 100% randomness...
-> Not sure the unit choice is ideally placed (since you have to choose the unit before the values)

Unmerged revisions

14483. By caldoria <email address hidden>

Enabled absolute units for clonetiler shift and scale functions. Addressed first reviewer comments, removed some dead code.

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-11-08 09:49:26 +0000
+++ src/ui/dialog/clonetiler.cpp 2015-11-21 20:12:56 +0000
@@ -81,7 +81,48 @@
81 dlg(NULL),81 dlg(NULL),
82 desktop(NULL),82 desktop(NULL),
83 deskTrack(),83 deskTrack(),
84 table_row_labels(NULL)84 table_row_labels(NULL),
85
86 // Shift page
87 _scalar_shift_x_row ("", _("Shift in x coordinate per row"), UNIT_TYPE_LINEAR, "", "", &_units_shift),
88 _scalar_shift_x_column ("", _("Shift in x coordinate per column"), UNIT_TYPE_LINEAR, "", "", &_units_shift),
89 _scalar_shift_x_randomize ("", _("Randomization of x coordinate per shift"), UNIT_TYPE_LINEAR, "", "", &_units_shift),
90
91 _scalar_shift_y_row ("", _("Shift in y coordinate per row"), UNIT_TYPE_LINEAR, "", "", &_units_shift),
92 _scalar_shift_y_column ("", _("Shift in y coordinate per column"), UNIT_TYPE_LINEAR, "", "", &_units_shift),
93 _scalar_shift_y_randomize ("", _("Randomization of y coordinate per shift"), UNIT_TYPE_LINEAR, "", "", &_units_shift),
94
95 _scalar_shift_exponent_row ("", _("Whether rows are spaced evenly (1), diverge (> 1) or converge (< 1)"), UNIT_TYPE_DIMENSIONLESS, "", ""),
96 _scalar_shift_exponent_column ("", _("Whether columns are spaced evenly (1), diverge (> 1) or converge (< 1)"), UNIT_TYPE_DIMENSIONLESS, "", ""),
97
98 _check_shift_alternate_row ("", _("Alternate sign of shifts for each row")),
99 _check_shift_alternate_column ("", _("Alternate sign of shifts for each column")),
100 _check_shift_cumulate_row ("", _("Combine shifts cumulatively for each row")),
101 _check_shift_cumulate_column ("", _("Combine shifts cumulatively for each column")),
102 _check_shift_exclude_row ("", _("Exclude tile width from row shifts")),
103 _check_shift_exclude_column ("", _("Exclude tile height from column shifts")),
104
105
106 // Scale page
107 _scalar_scale_x_row ("", _("Horizontal scale per row"), UNIT_TYPE_LINEAR, "", "", &_units_scale),
108 _scalar_scale_x_column ("", _("Horizontal scale per column"), UNIT_TYPE_LINEAR, "", "", &_units_scale),
109 _scalar_scale_x_randomize ("", _("Randomize the horizontal scale"), UNIT_TYPE_LINEAR, "", "", &_units_scale),
110
111 _scalar_scale_y_row ("", _("Vertical scale per row"), UNIT_TYPE_LINEAR, "", "", &_units_scale),
112 _scalar_scale_y_column ("", _("Vertical scale per column"), UNIT_TYPE_LINEAR, "", "", &_units_scale),
113 _scalar_scale_y_randomize ("", _("Randomize the vertical scale"), UNIT_TYPE_LINEAR, "", "", &_units_scale),
114
115 _scalar_scale_exponent_row ("", _("Whether row scaling is uniform (1), converges (< 1) or diverges (> 1)"), UNIT_TYPE_DIMENSIONLESS, "", ""),
116 _scalar_scale_exponent_column ("", _("Whether column scaling is uniform (1), converges (< 1) or diverges (> 1)"), UNIT_TYPE_DIMENSIONLESS, "", ""),
117
118 _scalar_scale_base_row ("", _("Base for a logarithmic spiral: not used (0), convergent (< 1) or divergent (> 1)"), UNIT_TYPE_DIMENSIONLESS, "", ""),
119 _scalar_scale_base_column ("", _("Base for a logarithmic spiral: not used (0), convergent (< 1) or divergent (> 1)"), UNIT_TYPE_DIMENSIONLESS, "", ""),
120
121 _check_scale_alternate_row ("", _("Alternate sign of scales across rows")),
122 _check_scale_alternate_column ("", _("Alternate sign of scales across columns")),
123 _check_scale_cumulate_row ("", _("Cumulate scales across rows")),
124 _check_scale_cumulate_column ("", _("Cumulate scales across columns"))
125
85{126{
86 Gtk::Box *contents = _getContents();127 Gtk::Box *contents = _getContents();
87 contents->set_spacing(0);128 contents->set_spacing(0);
@@ -173,14 +214,15 @@
173214
174 table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);215 table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
175216
176 // Shift217 // Shift page
177 {218 {
178 GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift"));219 GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift"));
179220
180 GtkWidget *table = clonetiler_table_x_y_rand (3);221 GtkWidget *table = clonetiler_table_x_y_rand (3);
181 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);222 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
182223 prepareUnitMenu(_units_shift, "shiftx_per_j", "px");
183 // X224
225 // X Label
184 {226 {
185 GtkWidget *l = gtk_label_new ("");227 GtkWidget *l = gtk_label_new ("");
186 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount228 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount
@@ -190,59 +232,40 @@
190 clonetiler_table_attach (table, l, 1, 2, 1);232 clonetiler_table_attach (table, l, 1, 2, 1);
191 }233 }
192234
193 {235 // Y Label
194 GtkWidget *l = clonetiler_spinbox (
195 // xgettext:no-c-format
196 _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j",
197 -10000, 10000, "%");
198 clonetiler_table_attach (table, l, 0, 2, 2);
199 }
200
201 {
202 GtkWidget *l = clonetiler_spinbox (
203 // xgettext:no-c-format
204 _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i",
205 -10000, 10000, "%");
206 clonetiler_table_attach (table, l, 0, 2, 3);
207 }
208
209 {
210 GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand",
211 0, 1000, "%");
212 clonetiler_table_attach (table, l, 0, 2, 4);
213 }
214
215 // Y
216 {236 {
217 GtkWidget *l = gtk_label_new ("");237 GtkWidget *l = gtk_label_new ("");
218 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) vertically by this amount238 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount
219 // xgettext:no-c-format239 // xgettext:no-c-format
220 gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift Y:</b>"));240 gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift Y:</b>"));
221 gtk_size_group_add_widget(table_row_labels, l);241 gtk_size_group_add_widget(table_row_labels, l);
222 clonetiler_table_attach (table, l, 1, 3, 1);242 clonetiler_table_attach (table, l, 1, 3, 1);
223 }243 }
224244
225 {245 // X and Y Shifts
226 GtkWidget *l = clonetiler_spinbox (246 {
227 // xgettext:no-c-format247 prepareScalarUnit(_scalar_shift_x_row, "shiftx_per_j", 0);
228 _("Vertical shift per row (in % of tile height)"), "shifty_per_j",248 prepareScalarUnit(_scalar_shift_x_column, "shiftx_per_i", 0);
229 -10000, 10000, "%");249 prepareScalarUnit(_scalar_shift_x_randomize, "shiftx_rand", 0);
230 clonetiler_table_attach (table, l, 0, 3, 2);250 prepareScalarUnit(_scalar_shift_y_row, "shifty_per_j", 0);
231 }251 prepareScalarUnit(_scalar_shift_y_column, "shifty_per_i", 0);
232252 prepareScalarUnit(_scalar_shift_y_randomize, "shifty_rand", 0);
233 {253
234 GtkWidget *l = clonetiler_spinbox (254 clonetiler_table_attach(table, (GtkWidget*)_scalar_shift_x_row.gobj(), 0, 2, 2);
235 // xgettext:no-c-format255 clonetiler_table_attach(table, (GtkWidget*)_scalar_shift_x_column.gobj(), 0, 2, 3);
236 _("Vertical shift per column (in % of tile height)"), "shifty_per_i",256 clonetiler_table_attach(table, (GtkWidget*)_scalar_shift_x_randomize.gobj(), 0, 2, 4);
237 -10000, 10000, "%");257 clonetiler_table_attach(table, (GtkWidget*)_scalar_shift_y_row.gobj(), 0, 3, 2);
238 clonetiler_table_attach (table, l, 0, 3, 3);258 clonetiler_table_attach(table, (GtkWidget*)_scalar_shift_y_column.gobj(), 0, 3, 3);
239 }259 clonetiler_table_attach(table, (GtkWidget*)_scalar_shift_y_randomize.gobj(), 0, 3, 4);
240260 }
241 {261
242 GtkWidget *l = clonetiler_spinbox (262 // UnitMenu
243 _("Randomize the vertical shift by this percentage"), "shifty_rand",263 {
244 0, 1000, "%");264 GtkWidget *l = gtk_label_new("");
245 clonetiler_table_attach (table, l, 0, 3, 4);265 gtk_label_set_markup(GTK_LABEL(l), _("<b>Units:</b>"));
266 gtk_size_group_add_widget(table_row_labels, l);
267 clonetiler_table_attach(table, l, 1, 4, 1);
268 clonetiler_table_attach(table, (GtkWidget*)_units_shift.gobj(), 0, 4, 2);
246 }269 }
247270
248 // Exponent271 // Exponent
@@ -250,86 +273,72 @@
250 GtkWidget *l = gtk_label_new ("");273 GtkWidget *l = gtk_label_new ("");
251 gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));274 gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));
252 gtk_size_group_add_widget(table_row_labels, l);275 gtk_size_group_add_widget(table_row_labels, l);
253 clonetiler_table_attach (table, l, 1, 4, 1);276 clonetiler_table_attach (table, l, 1, 5, 1);
254 }277 }
255278
256 {279 {
257 GtkWidget *l = clonetiler_spinbox (280 prepareScalar(_scalar_shift_exponent_row, "shifty_exp", 1);
258 _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp",281 prepareScalar(_scalar_shift_exponent_column, "shiftx_exp", 1);
259 0, 10, "", true);282 clonetiler_table_attach(table, (GtkWidget*)_scalar_shift_exponent_row.gobj(), 0, 5, 2);
260 clonetiler_table_attach (table, l, 0, 4, 2);283 clonetiler_table_attach(table, (GtkWidget*)_scalar_shift_exponent_column.gobj(), 0, 5, 3);
261 }284 }
262285
263 {286 // Alternate
264 GtkWidget *l = clonetiler_spinbox (287 {
265 _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp",
266 0, 10, "", true);
267 clonetiler_table_attach (table, l, 0, 4, 3);
268 }
269
270 { // alternates
271 GtkWidget *l = gtk_label_new ("");288 GtkWidget *l = gtk_label_new ("");
272 // TRANSLATORS: "Alternate" is a verb here289 // TRANSLATORS: "Alternate" is a verb here
273 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));290 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
274 gtk_size_group_add_widget(table_row_labels, l);291 gtk_size_group_add_widget(table_row_labels, l);
275 clonetiler_table_attach (table, l, 1, 5, 1);292 clonetiler_table_attach (table, l, 1, 6, 1);
276 }293 }
277294
278 {295 {
279 GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate");296 prepareCheckButton(_check_shift_alternate_row, "shifty_alternate");
280 clonetiler_table_attach (table, l, 0, 5, 2);297 prepareCheckButton(_check_shift_alternate_column, "shiftx_alternate");
281 }298 clonetiler_table_attach (table, (GtkWidget*)_check_shift_alternate_row.gobj(), 0.5, 6, 2);
282299 clonetiler_table_attach (table, (GtkWidget*)_check_shift_alternate_column.gobj(), 0.5, 6, 3);
283 {300 }
284 GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate");301
285 clonetiler_table_attach (table, l, 0, 5, 3);302 // Cumulate
286 }303 {
287
288 { // Cumulate
289 GtkWidget *l = gtk_label_new ("");304 GtkWidget *l = gtk_label_new ("");
290 // TRANSLATORS: "Cumulate" is a verb here305 // TRANSLATORS: "Cumulate" is a verb here
291 gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));306 gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));
292 gtk_size_group_add_widget(table_row_labels, l);307 gtk_size_group_add_widget(table_row_labels, l);
293 clonetiler_table_attach (table, l, 1, 6, 1);308 clonetiler_table_attach (table, l, 1, 7, 1);
294 }309 }
295310
296 {311 {
297 GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate");312 prepareCheckButton(_check_shift_cumulate_row, "shifty_cumulate");
298 clonetiler_table_attach (table, l, 0, 6, 2);313 prepareCheckButton(_check_shift_cumulate_column, "shiftx_cumulate");
299 }314 clonetiler_table_attach (table, (GtkWidget*)_check_shift_cumulate_row.gobj(), 0.5, 7, 2);
300315 clonetiler_table_attach (table, (GtkWidget*)_check_shift_cumulate_column.gobj(), 0.5, 7, 3);
301 {316 }
302 GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate");317
303 clonetiler_table_attach (table, l, 0, 6, 3);318 // Exclude
304 }319 {
305
306 { // Exclude tile width and height in shift
307 GtkWidget *l = gtk_label_new ("");320 GtkWidget *l = gtk_label_new ("");
308 // TRANSLATORS: "Cumulate" is a verb here
309 gtk_label_set_markup (GTK_LABEL(l), _("<small>Exclude tile:</small>"));321 gtk_label_set_markup (GTK_LABEL(l), _("<small>Exclude tile:</small>"));
310 gtk_size_group_add_widget(table_row_labels, l);322 gtk_size_group_add_widget(table_row_labels, l);
311 clonetiler_table_attach (table, l, 1, 7, 1);323 clonetiler_table_attach (table, l, 1, 8, 1);
312 }324 }
313325
314 {326 {
315 GtkWidget *l = clonetiler_checkbox (_("Exclude tile height in shift"), "shifty_excludeh");327 prepareCheckButton(_check_shift_exclude_row, "shifty_excludeh");
316 clonetiler_table_attach (table, l, 0, 7, 2);328 prepareCheckButton(_check_shift_exclude_column, "shiftx_excludew");
317 }329 clonetiler_table_attach (table, (GtkWidget*)_check_shift_exclude_row.gobj(), 0.5, 8, 2);
318330 clonetiler_table_attach (table, (GtkWidget*)_check_shift_exclude_column.gobj(), 0.5, 8, 3);
319 {
320 GtkWidget *l = clonetiler_checkbox (_("Exclude tile width in shift"), "shiftx_excludew");
321 clonetiler_table_attach (table, l, 0, 7, 3);
322 }331 }
323332
324 }333 }
325334
326335 // Scale page
327 // Scale
328 {336 {
329 GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale"));337 GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale"));
330338
331 GtkWidget *table = clonetiler_table_x_y_rand (2);339 GtkWidget *table = clonetiler_table_x_y_rand (2);
332 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);340 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
341 prepareUnitMenu(_units_scale, "scalex_per_j", "px");
333342
334 // X343 // X
335 {344 {
@@ -339,28 +348,6 @@
339 clonetiler_table_attach (table, l, 1, 2, 1);348 clonetiler_table_attach (table, l, 1, 2, 1);
340 }349 }
341350
342 {
343 GtkWidget *l = clonetiler_spinbox (
344 // xgettext:no-c-format
345 _("Horizontal scale per row (in % of tile width)"), "scalex_per_j",
346 -100, 1000, "%");
347 clonetiler_table_attach (table, l, 0, 2, 2);
348 }
349
350 {
351 GtkWidget *l = clonetiler_spinbox (
352 // xgettext:no-c-format
353 _("Horizontal scale per column (in % of tile width)"), "scalex_per_i",
354 -100, 1000, "%");
355 clonetiler_table_attach (table, l, 0, 2, 3);
356 }
357
358 {
359 GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand",
360 0, 1000, "%");
361 clonetiler_table_attach (table, l, 0, 2, 4);
362 }
363
364 // Y351 // Y
365 {352 {
366 GtkWidget *l = gtk_label_new ("");353 GtkWidget *l = gtk_label_new ("");
@@ -368,47 +355,45 @@
368 gtk_size_group_add_widget(table_row_labels, l);355 gtk_size_group_add_widget(table_row_labels, l);
369 clonetiler_table_attach (table, l, 1, 3, 1);356 clonetiler_table_attach (table, l, 1, 3, 1);
370 }357 }
371358
372 {359 {
373 GtkWidget *l = clonetiler_spinbox (360 prepareScalarUnit(_scalar_scale_x_row, "scalex_per_j", 0);
374 // xgettext:no-c-format361 prepareScalarUnit(_scalar_scale_x_column, "scalex_per_i", 0);
375 _("Vertical scale per row (in % of tile height)"), "scaley_per_j",362 prepareScalarUnit(_scalar_scale_x_randomize, "scalex_rand", 0);
376 -100, 1000, "%");363 prepareScalarUnit(_scalar_scale_y_row, "scaley_per_j", 0);
377 clonetiler_table_attach (table, l, 0, 3, 2);364 prepareScalarUnit(_scalar_scale_y_column, "scaley_per_i", 0);
378 }365 prepareScalarUnit(_scalar_scale_y_randomize, "scaley_rand", 0);
379366
380 {367 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_x_row.gobj(), 0, 2, 2);
381 GtkWidget *l = clonetiler_spinbox (368 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_x_column.gobj(), 0, 2, 3);
382 // xgettext:no-c-format369 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_x_randomize.gobj(), 0, 2, 4);
383 _("Vertical scale per column (in % of tile height)"), "scaley_per_i",370 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_y_row.gobj(), 0, 3, 2);
384 -100, 1000, "%");371 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_y_column.gobj(), 0, 3, 3);
385 clonetiler_table_attach (table, l, 0, 3, 3);372 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_y_randomize.gobj(), 0, 3, 4);
386 }373 }
387374
388 {375 // UnitMenu
389 GtkWidget *l = clonetiler_spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand",376 {
390 0, 1000, "%");377 GtkWidget *l = gtk_label_new("");
391 clonetiler_table_attach (table, l, 0, 3, 4);378 gtk_label_set_markup(GTK_LABEL(l), _("<b>Units:</b>"));
392 }379 gtk_size_group_add_widget(table_row_labels, l);
393380 clonetiler_table_attach(table, l, 1, 4, 1);
381 clonetiler_table_attach(table, (GtkWidget*)_units_scale.gobj(), 0, 4, 2);
382 }
383
394 // Exponent384 // Exponent
395 {385 {
396 GtkWidget *l = gtk_label_new ("");386 GtkWidget *l = gtk_label_new ("");
397 gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));387 gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));
398 gtk_size_group_add_widget(table_row_labels, l);388 gtk_size_group_add_widget(table_row_labels, l);
399 clonetiler_table_attach (table, l, 1, 4, 1);389 clonetiler_table_attach (table, l, 1, 5, 1);
400 }390 }
401391
402 {392 {
403 GtkWidget *l = clonetiler_spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp",393 prepareScalar(_scalar_scale_exponent_row, "scaley_exp", 1);
404 0, 10, "", true);394 prepareScalar(_scalar_scale_exponent_column, "scalex_exp", 1);
405 clonetiler_table_attach (table, l, 0, 4, 2);395 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_exponent_row.gobj(), 0, 5, 2);
406 }396 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_exponent_column.gobj(), 0, 5, 3);
407
408 {
409 GtkWidget *l = clonetiler_spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp",
410 0, 10, "", true);
411 clonetiler_table_attach (table, l, 0, 4, 3);
412 }397 }
413398
414 // Logarithmic (as in logarithmic spiral)399 // Logarithmic (as in logarithmic spiral)
@@ -416,19 +401,14 @@
416 GtkWidget *l = gtk_label_new ("");401 GtkWidget *l = gtk_label_new ("");
417 gtk_label_set_markup (GTK_LABEL(l), _("<b>Base:</b>"));402 gtk_label_set_markup (GTK_LABEL(l), _("<b>Base:</b>"));
418 gtk_size_group_add_widget(table_row_labels, l);403 gtk_size_group_add_widget(table_row_labels, l);
419 clonetiler_table_attach (table, l, 1, 5, 1);404 clonetiler_table_attach (table, l, 1, 6, 1);
420 }405 }
421406
422 {407 {
423 GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log",408 prepareScalar(_scalar_scale_base_row, "scaley_log", 0);
424 0, 10, "", false);409 prepareScalar(_scalar_scale_base_column, "scalex_log", 0);
425 clonetiler_table_attach (table, l, 0, 5, 2);410 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_base_row.gobj(), 0, 6, 2);
426 }411 clonetiler_table_attach(table, (GtkWidget*)_scalar_scale_base_column.gobj(), 0, 6, 3);
427
428 {
429 GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log",
430 0, 10, "", false);
431 clonetiler_table_attach (table, l, 0, 5, 3);
432 }412 }
433413
434 { // alternates414 { // alternates
@@ -436,17 +416,14 @@
436 // TRANSLATORS: "Alternate" is a verb here416 // TRANSLATORS: "Alternate" is a verb here
437 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));417 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
438 gtk_size_group_add_widget(table_row_labels, l);418 gtk_size_group_add_widget(table_row_labels, l);
439 clonetiler_table_attach (table, l, 1, 6, 1);419 clonetiler_table_attach (table, l, 1, 7, 1);
440 }420 }
441421
442 {422 {
443 GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate");423 prepareCheckButton(_check_scale_alternate_row, "scaley_alternate");
444 clonetiler_table_attach (table, l, 0, 6, 2);424 prepareCheckButton(_check_scale_alternate_column, "scalex_alternate");
445 }425 clonetiler_table_attach(table, (GtkWidget*)_check_scale_alternate_row.gobj(), 0.5, 7, 2);
446426 clonetiler_table_attach(table, (GtkWidget*)_check_scale_alternate_column.gobj(), 0.5, 7, 3);
447 {
448 GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate");
449 clonetiler_table_attach (table, l, 0, 6, 3);
450 }427 }
451428
452 { // Cumulate429 { // Cumulate
@@ -454,22 +431,17 @@
454 // TRANSLATORS: "Cumulate" is a verb here431 // TRANSLATORS: "Cumulate" is a verb here
455 gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));432 gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>"));
456 gtk_size_group_add_widget(table_row_labels, l);433 gtk_size_group_add_widget(table_row_labels, l);
457 clonetiler_table_attach (table, l, 1, 7, 1);434 clonetiler_table_attach (table, l, 1, 8, 1);
458 }435 }
459436
460 {437 {
461 GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each row"), "scaley_cumulate");438 prepareCheckButton(_check_scale_cumulate_row, "scaley_cumulate");
462 clonetiler_table_attach (table, l, 0, 7, 2);439 prepareCheckButton(_check_scale_cumulate_column, "scalex_cumulate");
463 }440 clonetiler_table_attach(table, (GtkWidget*)_check_scale_cumulate_row.gobj(), 0.5, 8, 2);
464441 clonetiler_table_attach(table, (GtkWidget*)_check_scale_cumulate_column.gobj(), 0.5, 8, 3);
465 {442 }
466 GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each column"), "scalex_cumulate");
467 clonetiler_table_attach (table, l, 0, 7, 3);
468 }
469
470 }443 }
471444
472
473 // Rotation445 // Rotation
474 {446 {
475 GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation"));447 GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation"));
@@ -1324,6 +1296,68 @@
1324 deskTrack.setBase(desktop);1296 deskTrack.setBase(desktop);
1325}1297}
13261298
1299void CloneTiler::prepareScalarUnit(UI::Widget::ScalarUnit &item, const char* attr, double def) {
1300 item.initScalar(-1e5, 1e5);
1301 item.setDigits(3);
1302
1303 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
1304 double number = prefs->getDouble(prefs_path + attr, def);
1305 Glib::ustring unit = prefs->getUnit(prefs_path + attr);
1306
1307 item.setValue(number, unit);
1308 item.signal_value_changed().connect(
1309 sigc::bind(sigc::mem_fun(*this, &CloneTiler::onUnitValueChanged), sigc::ref(item), attr)
1310 );
1311}
1312
1313void CloneTiler::prepareScalar(UI::Widget::Scalar &item, const char* attr, double def) {
1314 item.setRange(-1e5, 1e5);
1315 item.setDigits(3);
1316 item.setIncrements(0.01, 1);
1317
1318 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
1319 double number = prefs->getDouble(prefs_path + attr, def);
1320
1321 item.setValue(number);
1322 item.signal_value_changed().connect(
1323 sigc::bind(&CloneTiler::clonetiler_value_changed,
1324 (GtkAdjustment*)((Gtk::SpinButton*)item.getWidget())->get_adjustment()->gobj(),
1325 (gpointer)attr)
1326 );
1327}
1328
1329void CloneTiler::prepareCheckButton(UI::Widget::CheckButton &item, const char* attr) {
1330
1331 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
1332 bool state = prefs->getBool(prefs_path + attr);
1333
1334 item.set_active(state);
1335
1336 item.signal_toggled().connect(
1337 sigc::bind(&CloneTiler::clonetiler_checkbox_toggled,
1338 (GtkToggleButton*)item.gobj(),
1339 (gpointer*)attr)
1340 );
1341}
1342
1343void CloneTiler::prepareUnitMenu(UI::Widget::UnitMenu &item, const char* attr, Glib::ustring def) {
1344 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
1345 Glib::ustring unit = prefs->getUnit(prefs_path + attr);
1346
1347 if (unit == "") unit = def;
1348
1349 item.setUnitType(UNIT_TYPE_DIMENSIONLESS);
1350 item.setUnitType(UNIT_TYPE_LINEAR);
1351 item.setUnit(unit);
1352}
1353
1354void CloneTiler::onUnitValueChanged(UI::Widget::ScalarUnit &item, const char* attr) {
1355 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
1356 Glib::ustring unit_abbr = item.getUnit()->abbr;
1357 double number = item.getValue(unit_abbr);
1358 prefs->setDoubleUnit(prefs_path + attr, number, unit_abbr);
1359}
1360
1327void CloneTiler::setTargetDesktop(SPDesktop *desktop)1361void CloneTiler::setTargetDesktop(SPDesktop *desktop)
1328{1362{
1329 if (this->desktop != desktop) {1363 if (this->desktop != desktop) {
@@ -2258,14 +2292,97 @@
22582292
2259 clonetiler_remove (NULL, dlg, false);2293 clonetiler_remove (NULL, dlg, false);
22602294
2261 double scale_units = Inkscape::Util::Quantity::convert(1, "px", &desktop->getDocument()->getSVGUnit());2295 bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true);
22622296 bool dotrace = prefs->getBool(prefs_path + "dotrace");
2263 double shiftx_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_i", 0, -10000, 10000);2297
2264 double shifty_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_i", 0, -10000, 10000);2298 SPItem *item = dynamic_cast<SPItem *>(obj);
2265 double shiftx_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_j", 0, -10000, 10000);2299 if (dotrace) {
2266 double shifty_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_j", 0, -10000, 10000);2300 clonetiler_trace_setup (desktop->getDocument(), 1.0, item);
2267 double shiftx_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_rand", 0, 0, 1000);2301 }
2268 double shifty_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_rand", 0, 0, 1000);2302
2303 Geom::Point center;
2304 double w = 0;
2305 double h = 0;
2306 double x0 = 0;
2307 double y0 = 0;
2308
2309 Util::Unit svg_unit = desktop->getDocument()->getSVGUnit();
2310 double scale_units = Inkscape::Util::Quantity::convert(1, "px", &svg_unit);
2311
2312 if (keepbbox &&
2313 obj_repr->attribute("inkscape:tile-w") &&
2314 obj_repr->attribute("inkscape:tile-h") &&
2315 obj_repr->attribute("inkscape:tile-x0") &&
2316 obj_repr->attribute("inkscape:tile-y0") &&
2317 obj_repr->attribute("inkscape:tile-cx") &&
2318 obj_repr->attribute("inkscape:tile-cy")) {
2319
2320 double cx = 0;
2321 double cy = 0;
2322 sp_repr_get_double (obj_repr, "inkscape:tile-cx", &cx);
2323 sp_repr_get_double (obj_repr, "inkscape:tile-cy", &cy);
2324 center = Geom::Point (cx, cy);
2325
2326 sp_repr_get_double (obj_repr, "inkscape:tile-w", &w);
2327 sp_repr_get_double (obj_repr, "inkscape:tile-h", &h);
2328 sp_repr_get_double (obj_repr, "inkscape:tile-x0", &x0);
2329 sp_repr_get_double (obj_repr, "inkscape:tile-y0", &y0);
2330 } else {
2331 bool prefs_bbox = prefs->getBool("/tools/bounding_box", false);
2332 SPItem::BBoxType bbox_type = ( !prefs_bbox ?
2333 SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX );
2334 Geom::OptRect r = item->documentBounds(bbox_type);
2335 if (r) {
2336 w = scale_units*r->dimensions()[Geom::X];
2337 h = scale_units*r->dimensions()[Geom::Y];
2338 x0 = scale_units*r->min()[Geom::X];
2339 y0 = scale_units*r->min()[Geom::Y];
2340 center = scale_units*desktop->dt2doc(item->getCenter());
2341
2342 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", center[Geom::X]);
2343 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", center[Geom::Y]);
2344 sp_repr_set_svg_double(obj_repr, "inkscape:tile-w", w);
2345 sp_repr_set_svg_double(obj_repr, "inkscape:tile-h", h);
2346 sp_repr_set_svg_double(obj_repr, "inkscape:tile-x0", x0);
2347 sp_repr_set_svg_double(obj_repr, "inkscape:tile-y0", y0);
2348 } else {
2349 center = Geom::Point(0, 0);
2350 w = h = 0;
2351 x0 = y0 = 0;
2352 }
2353 }
2354
2355 /* Now we have w and h in SVG units. */
2356
2357 Glib::ustring svg_unit_abbr = svg_unit.abbr;
2358 double prefactor_w = 1.0/w;
2359 double prefactor_h = 1.0/h;
2360
2361 const Util::Unit *shift_unit = unit_table.getUnit(prefs->getUnit(prefs_path + "shiftx_per_i"));
2362 if (!shift_unit->isAbsolute()) {
2363 // Deal with dimensionless (percentage) shift.
2364 svg_unit_abbr = "%";
2365 prefactor_w = prefactor_h = 0.01;
2366 }
2367
2368 // double scale_units = Inkscape::Util::Quantity::convert(1, "px", &desktop->getDocument()->getSVGUnit());
2369
2370 // double shiftx_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_i", 0, -10000, 10000);
2371 // double shifty_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_i", 0, -10000, 10000);
2372 // double shiftx_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_j", 0, -10000, 10000);
2373 // double shifty_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_j", 0, -10000, 10000);
2374 // double shiftx_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_rand", 0, 0, 1000);
2375 // double shifty_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_rand", 0, 0, 1000);
2376
2377 /* Get quantities in px since width and height will be sent in px. */
2378 double shiftx_per_i = prefactor_w * prefs->getDouble(prefs_path + "shiftx_per_i", 0, svg_unit_abbr);
2379 double shifty_per_i = prefactor_h * prefs->getDouble(prefs_path + "shifty_per_i", 0, svg_unit_abbr);
2380 double shiftx_per_j = prefactor_w * prefs->getDouble(prefs_path + "shiftx_per_j", 0, svg_unit_abbr);
2381 double shifty_per_j = prefactor_h * prefs->getDouble(prefs_path + "shifty_per_j", 0, svg_unit_abbr);
2382
2383 double shiftx_rand = prefactor_w * prefs->getDouble(prefs_path + "shiftx_rand", 0, svg_unit_abbr);
2384 double shifty_rand = prefactor_h * prefs->getDouble(prefs_path + "shifty_rand", 0, svg_unit_abbr);
2385
2269 double shiftx_exp = prefs->getDoubleLimited(prefs_path + "shiftx_exp", 1, 0, 10);2386 double shiftx_exp = prefs->getDoubleLimited(prefs_path + "shiftx_exp", 1, 0, 10);
2270 double shifty_exp = prefs->getDoubleLimited(prefs_path + "shifty_exp", 1, 0, 10);2387 double shifty_exp = prefs->getDoubleLimited(prefs_path + "shifty_exp", 1, 0, 10);
2271 bool shiftx_alternate = prefs->getBool(prefs_path + "shiftx_alternate");2388 bool shiftx_alternate = prefs->getBool(prefs_path + "shiftx_alternate");
@@ -2275,12 +2392,30 @@
2275 bool shiftx_excludew = prefs->getBool(prefs_path + "shiftx_excludew");2392 bool shiftx_excludew = prefs->getBool(prefs_path + "shiftx_excludew");
2276 bool shifty_excludeh = prefs->getBool(prefs_path + "shifty_excludeh");2393 bool shifty_excludeh = prefs->getBool(prefs_path + "shifty_excludeh");
22772394
2278 double scalex_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_per_i", 0, -100, 1000);2395 const Util::Unit *scale_unit = unit_table.getUnit(prefs->getUnit(prefs_path + "scalex_per_i"));
2279 double scaley_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_per_i", 0, -100, 1000);2396 if (scale_unit->isAbsolute()) {
2280 double scalex_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_per_j", 0, -100, 1000);2397 svg_unit_abbr = svg_unit.abbr;
2281 double scaley_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_per_j", 0, -100, 1000);2398 prefactor_w = 1.0/w;
2282 double scalex_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_rand", 0, 0, 1000);2399 prefactor_h = 1.0/h;
2283 double scaley_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_rand", 0, 0, 1000);2400 } else {
2401 prefactor_w = prefactor_h = 0.01;
2402 svg_unit_abbr = "%";
2403 }
2404
2405 // double scalex_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_per_i", 0, -100, 1000);
2406 // double scaley_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_per_i", 0, -100, 1000);
2407 // double scalex_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_per_j", 0, -100, 1000);
2408 // double scaley_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_per_j", 0, -100, 1000);
2409 // double scalex_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "scalex_rand", 0, 0, 1000);
2410 // double scaley_rand = 0.01 * prefs->getDoubleLimited(prefs_path + "scaley_rand", 0, 0, 1000);
2411
2412 double scalex_per_i = prefactor_w * prefs->getDouble(prefs_path + "scalex_per_i", 0, svg_unit_abbr);
2413 double scaley_per_i = prefactor_h * prefs->getDouble(prefs_path + "scaley_per_i", 0, svg_unit_abbr);
2414 double scalex_per_j = prefactor_w * prefs->getDouble(prefs_path + "scalex_per_j", 0, svg_unit_abbr);
2415 double scaley_per_j = prefactor_h * prefs->getDouble(prefs_path + "scaley_per_j", 0, svg_unit_abbr);
2416 double scalex_rand = prefactor_w * prefs->getDouble(prefs_path + "scalex_rand", 0, svg_unit_abbr);
2417 double scaley_rand = prefactor_h * prefs->getDouble(prefs_path + "scaley_rand", 0, svg_unit_abbr);
2418
2284 double scalex_exp = prefs->getDoubleLimited(prefs_path + "scalex_exp", 1, 0, 10);2419 double scalex_exp = prefs->getDoubleLimited(prefs_path + "scalex_exp", 1, 0, 10);
2285 double scaley_exp = prefs->getDoubleLimited(prefs_path + "scaley_exp", 1, 0, 10);2420 double scaley_exp = prefs->getDoubleLimited(prefs_path + "scaley_exp", 1, 0, 10);
2286 double scalex_log = prefs->getDoubleLimited(prefs_path + "scalex_log", 0, 0, 10);2421 double scalex_log = prefs->getDoubleLimited(prefs_path + "scalex_log", 0, 0, 10);
@@ -2324,7 +2459,6 @@
2324 bool color_alternatei = prefs->getBool(prefs_path + "color_alternatei");2459 bool color_alternatei = prefs->getBool(prefs_path + "color_alternatei");
23252460
2326 int type = prefs->getInt(prefs_path + "symmetrygroup", 0);2461 int type = prefs->getInt(prefs_path + "symmetrygroup", 0);
2327 bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true);
2328 int imax = prefs->getInt(prefs_path + "imax", 2);2462 int imax = prefs->getInt(prefs_path + "imax", 2);
2329 int jmax = prefs->getInt(prefs_path + "jmax", 2);2463 int jmax = prefs->getInt(prefs_path + "jmax", 2);
23302464
@@ -2332,7 +2466,6 @@
2332 double fillwidth = scale_units*prefs->getDoubleLimited(prefs_path + "fillwidth", 50, 0, 1e6);2466 double fillwidth = scale_units*prefs->getDoubleLimited(prefs_path + "fillwidth", 50, 0, 1e6);
2333 double fillheight = scale_units*prefs->getDoubleLimited(prefs_path + "fillheight", 50, 0, 1e6);2467 double fillheight = scale_units*prefs->getDoubleLimited(prefs_path + "fillheight", 50, 0, 1e6);
23342468
2335 bool dotrace = prefs->getBool(prefs_path + "dotrace");
2336 int pick = prefs->getInt(prefs_path + "pick");2469 int pick = prefs->getInt(prefs_path + "pick");
2337 bool pick_to_presence = prefs->getBool(prefs_path + "pick_to_presence");2470 bool pick_to_presence = prefs->getBool(prefs_path + "pick_to_presence");
2338 bool pick_to_size = prefs->getBool(prefs_path + "pick_to_size");2471 bool pick_to_size = prefs->getBool(prefs_path + "pick_to_size");
@@ -2342,60 +2475,6 @@
2342 bool invert_picked = prefs->getBool(prefs_path + "invert_picked");2475 bool invert_picked = prefs->getBool(prefs_path + "invert_picked");
2343 double gamma_picked = prefs->getDoubleLimited(prefs_path + "gamma_picked", 0, -10, 10);2476 double gamma_picked = prefs->getDoubleLimited(prefs_path + "gamma_picked", 0, -10, 10);
23442477
2345 SPItem *item = dynamic_cast<SPItem *>(obj);
2346 if (dotrace) {
2347 clonetiler_trace_setup (desktop->getDocument(), 1.0, item);
2348 }
2349
2350 Geom::Point center;
2351 double w = 0;
2352 double h = 0;
2353 double x0 = 0;
2354 double y0 = 0;
2355
2356 if (keepbbox &&
2357 obj_repr->attribute("inkscape:tile-w") &&
2358 obj_repr->attribute("inkscape:tile-h") &&
2359 obj_repr->attribute("inkscape:tile-x0") &&
2360 obj_repr->attribute("inkscape:tile-y0") &&
2361 obj_repr->attribute("inkscape:tile-cx") &&
2362 obj_repr->attribute("inkscape:tile-cy")) {
2363
2364 double cx = 0;
2365 double cy = 0;
2366 sp_repr_get_double (obj_repr, "inkscape:tile-cx", &cx);
2367 sp_repr_get_double (obj_repr, "inkscape:tile-cy", &cy);
2368 center = Geom::Point (cx, cy);
2369
2370 sp_repr_get_double (obj_repr, "inkscape:tile-w", &w);
2371 sp_repr_get_double (obj_repr, "inkscape:tile-h", &h);
2372 sp_repr_get_double (obj_repr, "inkscape:tile-x0", &x0);
2373 sp_repr_get_double (obj_repr, "inkscape:tile-y0", &y0);
2374 } else {
2375 bool prefs_bbox = prefs->getBool("/tools/bounding_box", false);
2376 SPItem::BBoxType bbox_type = ( !prefs_bbox ?
2377 SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX );
2378 Geom::OptRect r = item->documentBounds(bbox_type);
2379 if (r) {
2380 w = scale_units*r->dimensions()[Geom::X];
2381 h = scale_units*r->dimensions()[Geom::Y];
2382 x0 = scale_units*r->min()[Geom::X];
2383 y0 = scale_units*r->min()[Geom::Y];
2384 center = scale_units*desktop->dt2doc(item->getCenter());
2385
2386 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", center[Geom::X]);
2387 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", center[Geom::Y]);
2388 sp_repr_set_svg_double(obj_repr, "inkscape:tile-w", w);
2389 sp_repr_set_svg_double(obj_repr, "inkscape:tile-h", h);
2390 sp_repr_set_svg_double(obj_repr, "inkscape:tile-x0", x0);
2391 sp_repr_set_svg_double(obj_repr, "inkscape:tile-y0", y0);
2392 } else {
2393 center = Geom::Point(0, 0);
2394 w = h = 0;
2395 x0 = y0 = 0;
2396 }
2397 }
2398
2399 Geom::Point cur(0, 0);2478 Geom::Point cur(0, 0);
2400 Geom::Rect bbox_original (Geom::Point (x0, y0), Geom::Point (x0 + w, y0 + h));2479 Geom::Rect bbox_original (Geom::Point (x0, y0), Geom::Point (x0 + w, y0 + h));
2401 double perimeter_original = (w + h)/4;2480 double perimeter_original = (w + h)/4;
24022481
=== modified file 'src/ui/dialog/clonetiler.h'
--- src/ui/dialog/clonetiler.h 2015-10-30 16:45:39 +0000
+++ src/ui/dialog/clonetiler.h 2015-11-21 20:12:56 +0000
@@ -15,6 +15,8 @@
15#include "ui/dialog/desktop-tracker.h"15#include "ui/dialog/desktop-tracker.h"
16#include "ui/widget/color-picker.h"16#include "ui/widget/color-picker.h"
17#include "sp-root.h"17#include "sp-root.h"
18#include "ui/widget/scalar-unit.h"
19#include "ui/widget/button.h"
1820
19namespace Inkscape {21namespace Inkscape {
20namespace UI {22namespace UI {
@@ -108,6 +110,56 @@
108 );110 );
109111
110112
113 // Shift page
114 UI::Widget::UnitMenu _units_shift;
115
116 UI::Widget::ScalarUnit _scalar_shift_x_row;
117 UI::Widget::ScalarUnit _scalar_shift_x_column;
118 UI::Widget::ScalarUnit _scalar_shift_x_randomize;
119
120 UI::Widget::ScalarUnit _scalar_shift_y_row;
121 UI::Widget::ScalarUnit _scalar_shift_y_column;
122 UI::Widget::ScalarUnit _scalar_shift_y_randomize;
123
124 UI::Widget::Scalar _scalar_shift_exponent_row;
125 UI::Widget::Scalar _scalar_shift_exponent_column;
126
127 UI::Widget::CheckButton _check_shift_alternate_row;
128 UI::Widget::CheckButton _check_shift_alternate_column;
129 UI::Widget::CheckButton _check_shift_cumulate_row;
130 UI::Widget::CheckButton _check_shift_cumulate_column;
131 UI::Widget::CheckButton _check_shift_exclude_row;
132 UI::Widget::CheckButton _check_shift_exclude_column;
133
134 // Scale page
135 UI::Widget::UnitMenu _units_scale;
136
137 UI::Widget::ScalarUnit _scalar_scale_x_row;
138 UI::Widget::ScalarUnit _scalar_scale_x_column;
139 UI::Widget::ScalarUnit _scalar_scale_x_randomize;
140
141 UI::Widget::ScalarUnit _scalar_scale_y_row;
142 UI::Widget::ScalarUnit _scalar_scale_y_column;
143 UI::Widget::ScalarUnit _scalar_scale_y_randomize;
144
145 UI::Widget::Scalar _scalar_scale_exponent_row;
146 UI::Widget::Scalar _scalar_scale_exponent_column;
147 UI::Widget::Scalar _scalar_scale_base_row;
148 UI::Widget::Scalar _scalar_scale_base_column;
149
150 UI::Widget::CheckButton _check_scale_alternate_row;
151 UI::Widget::CheckButton _check_scale_alternate_column;
152 UI::Widget::CheckButton _check_scale_cumulate_row;
153 UI::Widget::CheckButton _check_scale_cumulate_column;
154
155 void prepareScalarUnit(UI::Widget::ScalarUnit &item, const char* attr, double def);
156 void prepareScalar(UI::Widget::Scalar &item, const char* attr, double def);
157 void prepareCheckButton(UI::Widget::CheckButton &item, const char* attr);
158 void prepareUnitMenu(UI::Widget::UnitMenu &item, const char* attr, Glib::ustring def);
159
160 // Signal handlers
161 void onUnitValueChanged(UI::Widget::ScalarUnit& item, const char* attr);
162
111private:163private:
112 CloneTiler(CloneTiler const &d);164 CloneTiler(CloneTiler const &d);
113 CloneTiler& operator=(CloneTiler const &d);165 CloneTiler& operator=(CloneTiler const &d);
114166
=== modified file 'src/ui/widget/labelled.cpp'
--- src/ui/widget/labelled.cpp 2014-03-27 01:33:44 +0000
+++ src/ui/widget/labelled.cpp 2015-11-21 20:12:56 +0000
@@ -36,7 +36,10 @@
36 _icon = sp_icon_get_icon(icon.c_str(), Inkscape::ICON_SIZE_LARGE_TOOLBAR);36 _icon = sp_icon_get_icon(icon.c_str(), Inkscape::ICON_SIZE_LARGE_TOOLBAR);
37 pack_start(*Gtk::manage(_icon), Gtk::PACK_SHRINK);37 pack_start(*Gtk::manage(_icon), Gtk::PACK_SHRINK);
38 }38 }
39 pack_start(*Gtk::manage(_label), Gtk::PACK_EXPAND_WIDGET, 6);39 if (label != "") {
40 // The label takes up some space otherwise.
41 pack_start(*Gtk::manage(_label), Gtk::PACK_EXPAND_WIDGET, 6);
42 }
40 pack_start(*Gtk::manage(_widget), Gtk::PACK_SHRINK, 6);43 pack_start(*Gtk::manage(_widget), Gtk::PACK_SHRINK, 6);
41 if (mnemonic) {44 if (mnemonic) {
42 _label->set_mnemonic_widget(*_widget);45 _label->set_mnemonic_widget(*_widget);