1 #define __SP_CLONE_TILER_C__
3 /*
4 * Clone tiling dialog
5 *
6 * Authors:
7 * bulia byak <buliabyak@users.sf.net>
8 *
9 * Copyright (C) 2004-2005 Authors
10 * Released under GNU GPL
11 */
13 #ifdef HAVE_CONFIG_H
14 # include "config.h"
15 #endif
16 #include <gtk/gtk.h>
17 #include <glibmm/i18n.h>
19 #include "application/application.h"
20 #include "application/editor.h"
21 #include "helper/window.h"
22 #include "helper/unit-menu.h"
23 #include "helper/units.h"
24 #include "widgets/icon.h"
25 #include "../inkscape.h"
26 #include "../prefs-utils.h"
27 #include "dialog-events.h"
28 #include "../macros.h"
29 #include "../verbs.h"
30 #include "../interface.h"
31 #include "../selection.h"
32 #include "../style.h"
33 #include "../desktop-handles.h"
34 #include "../sp-namedview.h"
35 #include "../document.h"
36 #include "../message-stack.h"
37 #include "../sp-use.h"
38 #include "unclump.h"
40 #include "xml/repr.h"
42 #include "svg/svg.h"
44 #include "libnr/nr-matrix-fns.h"
45 #include "libnr/nr-matrix-ops.h"
47 #include "libnr/nr-matrix-translate-ops.h"
48 #include "libnr/nr-translate-ops.h"
49 #include "libnr/nr-translate-rotate-ops.h"
50 #include "libnr/nr-translate-scale-ops.h"
52 #include "display/nr-arena.h"
53 #include "display/nr-arena-item.h"
55 #include "ui/widget/color-picker.h"
57 static GtkWidget *dlg = NULL;
58 static win_data wd;
60 // impossible original values to make sure they are read from prefs
61 static gint x = -1000, y = -1000, w = 0, h = 0;
62 static gchar *prefs_path = "dialogs.clonetiler";
64 #define SB_MARGIN 1
65 #define VB_MARGIN 4
67 enum {
68 PICK_COLOR,
69 PICK_OPACITY,
70 PICK_R,
71 PICK_G,
72 PICK_B,
73 PICK_H,
74 PICK_S,
75 PICK_L
76 };
78 static GtkSizeGroup* table_row_labels = NULL;
80 static sigc::connection _shutdown_connection;
81 static sigc::connection _dialogs_hidden_connection;
82 static sigc::connection _dialogs_unhidden_connection;
83 static sigc::connection _desktop_activated_connection;
84 static sigc::connection _color_changed_connection;
86 static Inkscape::UI::Widget::ColorPicker *color_picker;
88 static void
89 clonetiler_dialog_destroy (GtkObject *object, gpointer data)
90 {
91 if (Inkscape::NSApplication::Application::getNewGui())
92 {
93 _shutdown_connection.disconnect();
94 _dialogs_hidden_connection.disconnect();
95 _dialogs_unhidden_connection.disconnect();
96 _desktop_activated_connection.disconnect();
97 } else {
98 sp_signal_disconnect_by_data (INKSCAPE, dlg);
99 }
100 _color_changed_connection.disconnect();
102 delete color_picker;
104 wd.win = dlg = NULL;
105 wd.stop = 0;
107 }
109 static gboolean
110 clonetiler_dialog_delete (GtkObject *object, GdkEvent * /*event*/, gpointer data)
111 {
112 gtk_window_get_position ((GtkWindow *) dlg, &x, &y);
113 gtk_window_get_size ((GtkWindow *) dlg, &w, &h);
115 prefs_set_int_attribute (prefs_path, "x", x);
116 prefs_set_int_attribute (prefs_path, "y", y);
117 prefs_set_int_attribute (prefs_path, "w", w);
118 prefs_set_int_attribute (prefs_path, "h", h);
120 return FALSE; // which means, go ahead and destroy it
122 }
124 static void on_delete()
125 {
126 (void)clonetiler_dialog_delete (0, 0, NULL);
127 }
129 static void
130 on_picker_color_changed (guint rgba)
131 {
132 static bool is_updating = false;
133 if (is_updating || !SP_ACTIVE_DESKTOP)
134 return;
136 is_updating = true;
138 Inkscape::XML::Node *repr = inkscape_get_repr(INKSCAPE, prefs_path);
139 gchar c[32];
140 sp_svg_write_color(c, 32, rgba);
141 repr->setAttribute("initial_color", c);
143 is_updating = false;
144 }
146 static guint clonetiler_number_of_clones (SPObject *obj);
148 static void
149 clonetiler_change_selection (Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg)
150 {
151 GtkWidget *buttons = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles");
152 GtkWidget *status = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "status");
154 if (selection->isEmpty()) {
155 gtk_widget_set_sensitive (buttons, FALSE);
156 gtk_label_set_markup (GTK_LABEL(status), _("<small>Nothing selected.</small>"));
157 return;
158 }
160 if (g_slist_length ((GSList *) selection->itemList()) > 1) {
161 gtk_widget_set_sensitive (buttons, FALSE);
162 gtk_label_set_markup (GTK_LABEL(status), _("<small>More than one object selected.</small>"));
163 return;
164 }
166 guint n = clonetiler_number_of_clones(selection->singleItem());
167 if (n > 0) {
168 gtk_widget_set_sensitive (buttons, TRUE);
169 gchar *sta = g_strdup_printf (_("<small>Object has <b>%d</b> tiled clones.</small>"), n);
170 gtk_label_set_markup (GTK_LABEL(status), sta);
171 g_free (sta);
172 } else {
173 gtk_widget_set_sensitive (buttons, FALSE);
174 gtk_label_set_markup (GTK_LABEL(status), _("<small>Object has no tiled clones.</small>"));
175 }
176 }
178 static void
179 clonetiler_external_change (Inkscape::Application * /*inkscape*/, GtkWidget *dlg)
180 {
181 clonetiler_change_selection (NULL, SP_DT_SELECTION(SP_ACTIVE_DESKTOP), dlg);
182 }
184 static void clonetiler_disconnect_gsignal (GObject *widget, gpointer source) {
185 if (source && G_IS_OBJECT(source))
186 sp_signal_disconnect_by_data (source, widget);
187 }
190 enum {
191 TILE_P1,
192 TILE_P2,
193 TILE_PM,
194 TILE_PG,
195 TILE_CM,
196 TILE_PMM,
197 TILE_PMG,
198 TILE_PGG,
199 TILE_CMM,
200 TILE_P4,
201 TILE_P4M,
202 TILE_P4G,
203 TILE_P3,
204 TILE_P31M,
205 TILE_P3M1,
206 TILE_P6,
207 TILE_P6M
208 };
211 static NR::Matrix
212 clonetiler_get_transform (
213 // symmetry group
214 int type,
215 // row, column
216 int x, int y,
217 // center, width, height of the tile
218 double cx, double cy,
219 double w, double h,
221 // values from the dialog:
222 double d_x_per_x, double d_y_per_x, double d_x_per_y, double d_y_per_y,
223 int alternate_x, int alternate_y, double rand_x, double rand_y,
224 double d_per_x_exp, double d_per_y_exp,
225 double d_rot_per_x, double d_rot_per_y, int alternate_rotx, int alternate_roty, double rand_rot,
226 double d_scalex_per_x, double d_scaley_per_x, double d_scalex_per_y, double d_scaley_per_y,
227 int alternate_scalex, int alternate_scaley, double rand_scalex, double rand_scaley
228 )
229 {
230 // in abs units
231 double eff_x = (alternate_x? (x%2) : pow ((double) x, d_per_x_exp));
232 double eff_y = (alternate_y? (y%2) : pow ((double) y, d_per_y_exp));
233 double dx = d_x_per_x * w * eff_x + d_x_per_y * w * eff_y + rand_x * w * g_random_double_range (-1, 1);
234 double dy = d_y_per_x * h * eff_x + d_y_per_y * h * eff_y + rand_y * h * g_random_double_range (-1, 1);
236 NR::Matrix rect_translate (NR::translate (w * pow ((double) x, d_per_x_exp) + dx, h * pow ((double) y, d_per_y_exp) + dy));
238 // in deg
239 double eff_x_rot = (alternate_rotx? (x%2) : (x));
240 double eff_y_rot = (alternate_roty? (y%2) : (y));
241 double drot = d_rot_per_x * eff_x_rot + d_rot_per_y * eff_y_rot + rand_rot * 180 * g_random_double_range (-1, 1);
243 // times the original
244 double eff_x_s = (alternate_scalex? (x%2) : (x));
245 double eff_y_s = (alternate_scaley? (y%2) : (y));
246 double rand_scale_x, rand_scale_y;
247 if (rand_scaley == rand_scalex) {
248 // if rands are equal, scale proportionally
249 rand_scale_x = rand_scale_y = rand_scalex * 1 * g_random_double_range (-1, 1);
250 } else {
251 rand_scale_x = rand_scalex * 1 * g_random_double_range (-1, 1);
252 rand_scale_y = rand_scaley * 1 * g_random_double_range (-1, 1);
253 }
254 double dscalex = 1 + d_scalex_per_x * eff_x_s + d_scalex_per_y * eff_y_s + rand_scale_x;
255 if (dscalex < 0) dscalex = 0;
256 double dscaley = 1 + d_scaley_per_x * eff_x_s + d_scaley_per_y * eff_y_s + rand_scale_y;
257 if (dscaley < 0) dscaley = 0;
259 NR::Matrix drot_c = NR::translate(-cx, -cy) * NR::rotate (M_PI*drot/180) * NR::translate(cx, cy);
261 NR::Matrix dscale_c = NR::translate(-cx, -cy) * NR::scale (dscalex, dscaley) * NR::translate(cx, cy);
263 NR::Matrix d_s_r = dscale_c * drot_c;
265 NR::Matrix rotate_180_c = NR::translate(-cx, -cy) * NR::rotate (M_PI) * NR::translate(cx, cy);
267 NR::Matrix rotate_90_c = NR::translate(-cx, -cy) * NR::rotate (-M_PI/2) * NR::translate(cx, cy);
268 NR::Matrix rotate_m90_c = NR::translate(-cx, -cy) * NR::rotate (M_PI/2) * NR::translate(cx, cy);
270 NR::Matrix rotate_120_c = NR::translate(-cx, -cy) * NR::rotate (-2*M_PI/3) * NR::translate(cx, cy);
271 NR::Matrix rotate_m120_c = NR::translate(-cx, -cy) * NR::rotate (2*M_PI/3) * NR::translate(cx, cy);
273 NR::Matrix rotate_60_c = NR::translate(-cx, -cy) * NR::rotate (-M_PI/3) * NR::translate(cx, cy);
274 NR::Matrix rotate_m60_c = NR::translate(-cx, -cy) * NR::rotate (M_PI/3) * NR::translate(cx, cy);
276 double cos60 = cos(M_PI/3);
277 double sin60 = sin(M_PI/3);
278 double cos30 = cos(M_PI/6);
279 double sin30 = sin(M_PI/6);
281 NR::Matrix flip_x = NR::translate(-cx, -cy) * NR::scale (-1, 1) * NR::translate(cx, cy);
282 NR::Matrix flip_y = NR::translate(-cx, -cy) * NR::scale (1, -1) * NR::translate(cx, cy);
284 x = (int) pow ((double) x, d_per_x_exp);
285 y = (int) pow ((double) y, d_per_y_exp);
287 switch (type) {
289 case TILE_P1:
290 return d_s_r * rect_translate;
291 break;
293 case TILE_P2:
294 if (x % 2 == 0) {
295 return d_s_r * rect_translate;
296 } else {
297 return d_s_r * rotate_180_c * rect_translate;
298 }
299 break;
301 case TILE_PM:
302 if (x % 2 == 0) {
303 return d_s_r * rect_translate;
304 } else {
305 return d_s_r * flip_x * rect_translate;
306 }
307 break;
309 case TILE_PG:
310 if (y % 2 == 0) {
311 return d_s_r * rect_translate;
312 } else {
313 return d_s_r * flip_x * rect_translate;
314 }
315 break;
317 case TILE_CM:
318 if ((x + y) % 2 == 0) {
319 return d_s_r * rect_translate;
320 } else {
321 return d_s_r * flip_x * rect_translate;
322 }
323 break;
325 case TILE_PMM:
326 if (y % 2 == 0) {
327 if (x % 2 == 0) {
328 return d_s_r * rect_translate;
329 } else {
330 return d_s_r * flip_x * rect_translate;
331 }
332 } else {
333 if (x % 2 == 0) {
334 return d_s_r * flip_y * rect_translate;
335 } else {
336 return d_s_r * flip_x * flip_y * rect_translate;
337 }
338 }
339 break;
341 case TILE_PMG:
342 if (y % 4 == 0) {
343 return d_s_r * rect_translate;
344 } else if (y % 4 == 1) {
345 return d_s_r * flip_y * rect_translate;
346 } else if (y % 4 == 2) {
347 return d_s_r * flip_x * rect_translate;
348 } else if (y % 4 == 3) {
349 return d_s_r * flip_x * flip_y * rect_translate;
350 }
351 break;
353 case TILE_PGG:
354 if (y % 2 == 0) {
355 if (x % 2 == 0) {
356 return d_s_r * rect_translate;
357 } else {
358 return d_s_r * flip_y * rect_translate;
359 }
360 } else {
361 if (x % 2 == 0) {
362 return d_s_r * rotate_180_c * rect_translate;
363 } else {
364 return d_s_r * rotate_180_c * flip_y * rect_translate;
365 }
366 }
367 break;
369 case TILE_CMM:
370 if (y % 4 == 0) {
371 if (x % 2 == 0) {
372 return d_s_r * rect_translate;
373 } else {
374 return d_s_r * flip_x * rect_translate;
375 }
376 } else if (y % 4 == 1) {
377 if (x % 2 == 0) {
378 return d_s_r * flip_y * rect_translate;
379 } else {
380 return d_s_r * flip_x * flip_y * rect_translate;
381 }
382 } else if (y % 4 == 2) {
383 if (x % 2 == 1) {
384 return d_s_r * rect_translate;
385 } else {
386 return d_s_r * flip_x * rect_translate;
387 }
388 } else {
389 if (x % 2 == 1) {
390 return d_s_r * flip_y * rect_translate;
391 } else {
392 return d_s_r * flip_x * flip_y * rect_translate;
393 }
394 }
395 break;
397 case TILE_P4:
398 {
399 NR::Matrix ori (NR::translate ((w + h) * (x/2) + dx, (h + w) * (y/2) + dy));
400 NR::Matrix dia1 (NR::translate (w/2 + h/2, -h/2 + w/2));
401 NR::Matrix dia2 (NR::translate (-w/2 + h/2, h/2 + w/2));
402 if (y % 2 == 0) {
403 if (x % 2 == 0) {
404 return d_s_r * ori;
405 } else {
406 return d_s_r * rotate_m90_c * dia1 * ori;
407 }
408 } else {
409 if (x % 2 == 0) {
410 return d_s_r * rotate_90_c * dia2 * ori;
411 } else {
412 return d_s_r * rotate_180_c * dia1 * dia2 * ori;
413 }
414 }
415 }
416 break;
418 case TILE_P4M:
419 {
420 double max = MAX(w, h);
421 NR::Matrix ori (NR::translate ((max + max) * (x/4) + dx, (max + max) * (y/2) + dy));
422 NR::Matrix dia1 (NR::translate (w/2 - h/2, h/2 - w/2));
423 NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 - h/2));
424 if (y % 2 == 0) {
425 if (x % 4 == 0) {
426 return d_s_r * ori;
427 } else if (x % 4 == 1) {
428 return d_s_r * flip_y * rotate_m90_c * dia1 * ori;
429 } else if (x % 4 == 2) {
430 return d_s_r * rotate_m90_c * dia1 * NR::translate (h, 0) * ori;
431 } else if (x % 4 == 3) {
432 return d_s_r * flip_x * NR::translate (w, 0) * ori;
433 }
434 } else {
435 if (x % 4 == 0) {
436 return d_s_r * flip_y * NR::translate(0, h) * ori;
437 } else if (x % 4 == 1) {
438 return d_s_r * rotate_90_c * dia2 * NR::translate(0, h) * ori;
439 } else if (x % 4 == 2) {
440 return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate(h, 0) * NR::translate(0, h) * ori;
441 } else if (x % 4 == 3) {
442 return d_s_r * flip_y * flip_x * NR::translate(w, 0) * NR::translate(0, h) * ori;
443 }
444 }
445 }
446 break;
448 case TILE_P4G:
449 {
450 double max = MAX(w, h);
451 NR::Matrix ori (NR::translate ((max + max) * (x/4) + dx, (max + max) * y + dy));
452 NR::Matrix dia1 (NR::translate (w/2 + h/2, h/2 - w/2));
453 NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 + h/2));
454 if (((x/4) + y) % 2 == 0) {
455 if (x % 4 == 0) {
456 return d_s_r * ori;
457 } else if (x % 4 == 1) {
458 return d_s_r * rotate_m90_c * dia1 * ori;
459 } else if (x % 4 == 2) {
460 return d_s_r * rotate_90_c * dia2 * ori;
461 } else if (x % 4 == 3) {
462 return d_s_r * rotate_180_c * dia1 * dia2 * ori;
463 }
464 } else {
465 if (x % 4 == 0) {
466 return d_s_r * flip_y * NR::translate (0, h) * ori;
467 } else if (x % 4 == 1) {
468 return d_s_r * flip_y * rotate_m90_c * dia1 * NR::translate (-h, 0) * ori;
469 } else if (x % 4 == 2) {
470 return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate (h, 0) * ori;
471 } else if (x % 4 == 3) {
472 return d_s_r * flip_x * NR::translate (w, 0) * ori;
473 }
474 }
475 }
476 break;
478 case TILE_P3:
479 {
480 double width;
481 double height;
482 NR::Matrix dia1;
483 NR::Matrix dia2;
484 if (w > h) {
485 width = w + w * cos60;
486 height = 2 * w * sin60;
487 dia1 = NR::Matrix (NR::translate (w/2 + w/2 * cos60, -(w/2 * sin60)));
488 dia2 = dia1 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60)));
489 } else {
490 width = h * cos (M_PI/6);
491 height = h;
492 dia1 = NR::Matrix (NR::translate (h/2 * cos30, -(h/2 * sin30)));
493 dia2 = dia1 * NR::Matrix (NR::translate (0, h/2));
494 }
495 NR::Matrix ori (NR::translate (width * (2*(x/3) + y%2) + dx, (height/2) * y + dy));
496 if (x % 3 == 0) {
497 return d_s_r * ori;
498 } else if (x % 3 == 1) {
499 return d_s_r * rotate_m120_c * dia1 * ori;
500 } else if (x % 3 == 2) {
501 return d_s_r * rotate_120_c * dia2 * ori;
502 }
503 }
504 break;
506 case TILE_P31M:
507 {
508 NR::Matrix ori;
509 NR::Matrix dia1;
510 NR::Matrix dia2;
511 NR::Matrix dia3;
512 NR::Matrix dia4;
513 if (w > h) {
514 ori = NR::Matrix(NR::translate (w * (x/6) + w/2 * (y%2) + dx, (w * cos30) * y + dy));
515 dia1 = NR::Matrix (NR::translate (0, h/2) * NR::translate (w/2, 0) * NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, -h/2 * sin30) );
516 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
517 dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
518 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
519 } else {
520 ori = NR::Matrix (NR::translate (2*h * cos30 * (x/6 + 0.5*(y%2)) + dx, (2*h - h * sin30) * y + dy));
521 dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30));
522 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
523 dia3 = dia2 * NR::Matrix (NR::translate (0, h/2));
524 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
525 }
526 if (x % 6 == 0) {
527 return d_s_r * ori;
528 } else if (x % 6 == 1) {
529 return d_s_r * flip_y * rotate_m120_c * dia1 * ori;
530 } else if (x % 6 == 2) {
531 return d_s_r * rotate_m120_c * dia2 * ori;
532 } else if (x % 6 == 3) {
533 return d_s_r * flip_y * rotate_120_c * dia3 * ori;
534 } else if (x % 6 == 4) {
535 return d_s_r * rotate_120_c * dia4 * ori;
536 } else if (x % 6 == 5) {
537 return d_s_r * flip_y * NR::translate(0, h) * ori;
538 }
539 }
540 break;
542 case TILE_P3M1:
543 {
544 double width;
545 double height;
546 NR::Matrix dia1;
547 NR::Matrix dia2;
548 NR::Matrix dia3;
549 NR::Matrix dia4;
550 if (w > h) {
551 width = w + w * cos60;
552 height = 2 * w * sin60;
553 dia1 = NR::Matrix (NR::translate (0, h/2) * NR::translate (w/2, 0) * NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, -h/2 * sin30) );
554 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
555 dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30)));
556 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
557 } else {
558 width = 2 * h * cos (M_PI/6);
559 height = 2 * h;
560 dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30));
561 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30));
562 dia3 = dia2 * NR::Matrix (NR::translate (0, h/2));
563 dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30));
564 }
565 NR::Matrix ori (NR::translate (width * (2*(x/6) + y%2) + dx, (height/2) * y + dy));
566 if (x % 6 == 0) {
567 return d_s_r * ori;
568 } else if (x % 6 == 1) {
569 return d_s_r * flip_y * rotate_m120_c * dia1 * ori;
570 } else if (x % 6 == 2) {
571 return d_s_r * rotate_m120_c * dia2 * ori;
572 } else if (x % 6 == 3) {
573 return d_s_r * flip_y * rotate_120_c * dia3 * ori;
574 } else if (x % 6 == 4) {
575 return d_s_r * rotate_120_c * dia4 * ori;
576 } else if (x % 6 == 5) {
577 return d_s_r * flip_y * NR::translate(0, h) * ori;
578 }
579 }
580 break;
582 case TILE_P6:
583 {
584 NR::Matrix ori;
585 NR::Matrix dia1;
586 NR::Matrix dia2;
587 NR::Matrix dia3;
588 NR::Matrix dia4;
589 NR::Matrix dia5;
590 if (w > h) {
591 ori = NR::Matrix(NR::translate (2*w * (x/6) + w * (y%2) + dx, (2*w * sin60) * y + dy));
592 dia1 = NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60));
593 dia2 = dia1 * NR::Matrix (NR::translate (w/2, 0));
594 dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, w/2 * sin60));
595 dia4 = dia3 * NR::Matrix (NR::translate (-w/2 * cos60, w/2 * sin60));
596 dia5 = dia4 * NR::Matrix (NR::translate (-w/2, 0));
597 } else {
598 ori = NR::Matrix(NR::translate (2*h * cos30 * (x/6 + 0.5*(y%2)) + dx, (h + h * sin30) * y + dy));
599 dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60));
600 dia2 = dia1 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2 * cos60, w/2 * sin60));
601 dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2, h/2));
602 dia4 = dia3 * dia1.inverse();
603 dia5 = dia3 * dia2.inverse();
604 }
605 if (x % 6 == 0) {
606 return d_s_r * ori;
607 } else if (x % 6 == 1) {
608 return d_s_r * rotate_m60_c * dia1 * ori;
609 } else if (x % 6 == 2) {
610 return d_s_r * rotate_m120_c * dia2 * ori;
611 } else if (x % 6 == 3) {
612 return d_s_r * rotate_180_c * dia3 * ori;
613 } else if (x % 6 == 4) {
614 return d_s_r * rotate_120_c * dia4 * ori;
615 } else if (x % 6 == 5) {
616 return d_s_r * rotate_60_c * dia5 * ori;
617 }
618 }
619 break;
621 case TILE_P6M:
622 {
624 NR::Matrix ori;
625 NR::Matrix dia1, dia2, dia3, dia4, dia5, dia6, dia7, dia8, dia9, dia10;
626 if (w > h) {
627 ori = NR::Matrix(NR::translate (2*w * (x/12) + w * (y%2) + dx, (2*w * sin60) * y + dy));
628 dia1 = NR::Matrix (NR::translate (w/2, h/2) * NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, h/2 * sin30));
629 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30));
630 dia3 = dia2 * NR::Matrix (NR::translate (-h/2 * cos30, h/2 * sin30) * NR::translate (w * cos60, 0) * NR::translate (-h/2 * cos30, -h/2 * sin30));
631 dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30));
632 dia5 = dia4 * NR::Matrix (NR::translate (-h/2 * cos30, -h/2 * sin30) * NR::translate (-w/2 * cos60, w/2 * sin60) * NR::translate (w/2, -h/2));
633 dia6 = dia5 * NR::Matrix (NR::translate (0, h));
634 dia7 = dia6 * dia1.inverse();
635 dia8 = dia6 * dia2.inverse();
636 dia9 = dia6 * dia3.inverse();
637 dia10 = dia6 * dia4.inverse();
638 } else {
639 ori = NR::Matrix(NR::translate (4*h * cos30 * (x/12 + 0.5*(y%2)) + dx, (2*h + 2*h * sin30) * y + dy));
640 dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60));
641 dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30));
642 dia3 = dia2 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h * cos30, 0) * NR::translate (-w/2 * cos60, w/2 * sin60));
643 dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30));
644 dia5 = dia4 * NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2, h/2));
645 dia6 = dia5 * NR::Matrix (NR::translate (0, h));
646 dia7 = dia6 * dia1.inverse();
647 dia8 = dia6 * dia2.inverse();
648 dia9 = dia6 * dia3.inverse();
649 dia10 = dia6 * dia4.inverse();
650 }
651 if (x % 12 == 0) {
652 return d_s_r * ori;
653 } else if (x % 12 == 1) {
654 return d_s_r * flip_y * rotate_m60_c * dia1 * ori;
655 } else if (x % 12 == 2) {
656 return d_s_r * rotate_m60_c * dia2 * ori;
657 } else if (x % 12 == 3) {
658 return d_s_r * flip_y * rotate_m120_c * dia3 * ori;
659 } else if (x % 12 == 4) {
660 return d_s_r * rotate_m120_c * dia4 * ori;
661 } else if (x % 12 == 5) {
662 return d_s_r * flip_x * dia5 * ori;
663 } else if (x % 12 == 6) {
664 return d_s_r * flip_x * flip_y * dia6 * ori;
665 } else if (x % 12 == 7) {
666 return d_s_r * flip_y * rotate_120_c * dia7 * ori;
667 } else if (x % 12 == 8) {
668 return d_s_r * rotate_120_c * dia8 * ori;
669 } else if (x % 12 == 9) {
670 return d_s_r * flip_y * rotate_60_c * dia9 * ori;
671 } else if (x % 12 == 10) {
672 return d_s_r * rotate_60_c * dia10 * ori;
673 } else if (x % 12 == 11) {
674 return d_s_r * flip_y * NR::translate (0, h) * ori;
675 }
676 }
677 break;
679 default:
680 break;
681 }
683 return NR::identity();
684 }
686 static bool
687 clonetiler_is_a_clone_of (SPObject *tile, SPObject *obj)
688 {
689 char *id_href = NULL;
691 if (obj) {
692 Inkscape::XML::Node *obj_repr = SP_OBJECT_REPR(obj);
693 id_href = g_strdup_printf("#%s", obj_repr->attribute("id"));
694 }
696 if (SP_IS_USE(tile) &&
697 SP_OBJECT_REPR(tile)->attribute("xlink:href") &&
698 (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("xlink:href"))) &&
699 SP_OBJECT_REPR(tile)->attribute("inkscape:tiled-clone-of") &&
700 (!id_href || !strcmp(id_href, SP_OBJECT_REPR(tile)->attribute("inkscape:tiled-clone-of"))))
701 {
702 if (id_href)
703 g_free (id_href);
704 return true;
705 } else {
706 if (id_href)
707 g_free (id_href);
708 return false;
709 }
710 }
712 static NRArena const *trace_arena = NULL;
713 static unsigned trace_visionkey;
714 static NRArenaItem *trace_root;
715 static gdouble trace_zoom;
717 static void
718 clonetiler_trace_hide_tiled_clones_recursively (SPObject *from)
719 {
720 if (!trace_arena)
721 return;
723 for (SPObject *o = sp_object_first_child(from); o != NULL; o = SP_OBJECT_NEXT(o)) {
724 if (SP_IS_ITEM(o) && clonetiler_is_a_clone_of (o, NULL))
725 sp_item_invoke_hide(SP_ITEM(o), trace_visionkey); // FIXME: hide each tiled clone's original too!
726 clonetiler_trace_hide_tiled_clones_recursively (o);
727 }
728 }
730 static void
731 clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original)
732 {
733 trace_arena = NRArena::create();
734 /* Create ArenaItem and set transform */
735 trace_visionkey = sp_item_display_key_new(1);
736 trace_root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT (doc)),
737 (NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY);
739 // hide the (current) original and any tiled clones, we only want to pick the background
740 sp_item_invoke_hide(original, trace_visionkey);
741 clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (doc)));
743 sp_document_root (doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
744 sp_document_ensure_up_to_date(doc);
746 trace_zoom = zoom;
747 }
749 static guint32
750 clonetiler_trace_pick (NR::Rect box)
751 {
752 if (!trace_arena)
753 return 0;
755 NRMatrix t;
756 nr_matrix_set_scale(&t, trace_zoom, trace_zoom);
757 nr_arena_item_set_transform(trace_root, &t);
758 NRGC gc(NULL);
759 nr_matrix_set_identity(&gc.transform);
760 nr_arena_item_invoke_update( trace_root, NULL, &gc,
761 NR_ARENA_ITEM_STATE_ALL,
762 NR_ARENA_ITEM_STATE_NONE );
764 /* Item integer bbox in points */
765 NRRectL ibox;
766 ibox.x0 = (int) floor(trace_zoom * box.min()[NR::X] + 0.5);
767 ibox.y0 = (int) floor(trace_zoom * box.min()[NR::Y] + 0.5);
768 ibox.x1 = (int) floor(trace_zoom * box.max()[NR::X] + 0.5);
769 ibox.y1 = (int) floor(trace_zoom * box.max()[NR::Y] + 0.5);
771 /* Find visible area */
772 int width = ibox.x1 - ibox.x0;
773 int height = ibox.y1 - ibox.y0;
775 /* Set up pixblock */
776 guchar *px = nr_new(guchar, 4 * width * height);
777 memset(px, 0x00, 4 * width * height);
779 /* Render */
780 NRPixBlock pb;
781 nr_pixblock_setup_extern( &pb, NR_PIXBLOCK_MODE_R8G8B8A8N,
782 ibox.x0, ibox.y0, ibox.x1, ibox.y1,
783 px, 4 * width, FALSE, FALSE );
784 nr_arena_item_invoke_render( trace_root, &ibox, &pb,
785 NR_ARENA_ITEM_RENDER_NO_CACHE );
787 double R = 0, G = 0, B = 0, A = 0;
788 double count = 0;
789 double weight = 0;
791 for (int y = ibox.y0; y < ibox.y1; y++) {
792 const unsigned char *s = NR_PIXBLOCK_PX (&pb) + (y - ibox.y0) * pb.rs;
793 for (int x = ibox.x0; x < ibox.x1; x++) {
794 count += 1;
795 weight += s[3] / 255.0;
796 R += s[0] / 255.0;
797 G += s[1] / 255.0;
798 B += s[2] / 255.0;
799 A += s[3] / 255.0;
800 s += 4;
801 }
802 }
804 nr_pixblock_release(&pb);
806 R = R / weight;
807 G = G / weight;
808 B = B / weight;
809 A = A / count;
811 R = CLAMP (R, 0.0, 1.0);
812 G = CLAMP (G, 0.0, 1.0);
813 B = CLAMP (B, 0.0, 1.0);
814 A = CLAMP (A, 0.0, 1.0);
816 return SP_RGBA32_F_COMPOSE (R, G, B, A);
817 }
819 static void
820 clonetiler_trace_finish ()
821 {
822 if (trace_arena) {
823 ((NRObject *) trace_arena)->unreference();
824 trace_arena = NULL;
825 }
826 }
828 static void
829 clonetiler_unclump (GtkWidget *widget, void *)
830 {
831 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
832 if (desktop == NULL)
833 return;
835 Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
837 // check if something is selected
838 if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
839 SP_DT_MSGSTACK(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump."));
840 return;
841 }
843 SPObject *obj = SP_OBJECT(selection->singleItem());
844 SPObject *parent = SP_OBJECT_PARENT (obj);
846 GSList *to_unclump = NULL; // not including the original
848 for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
849 if (clonetiler_is_a_clone_of (child, obj)) {
850 to_unclump = g_slist_prepend (to_unclump, child);
851 }
852 }
854 sp_document_ensure_up_to_date(SP_DT_DOCUMENT(desktop));
856 unclump (to_unclump);
858 g_slist_free (to_unclump);
860 sp_document_done (SP_DT_DOCUMENT (desktop));
861 }
863 static guint
864 clonetiler_number_of_clones (SPObject *obj)
865 {
866 SPObject *parent = SP_OBJECT_PARENT (obj);
868 guint n = 0;
870 for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
871 if (clonetiler_is_a_clone_of (child, obj)) {
872 n ++;
873 }
874 }
876 return n;
877 }
879 static void
880 clonetiler_remove (GtkWidget *widget, void *, bool do_undo = true)
881 {
882 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
883 if (desktop == NULL)
884 return;
886 Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
888 // check if something is selected
889 if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) {
890 SP_DT_MSGSTACK(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
891 return;
892 }
894 SPObject *obj = SP_OBJECT(selection->singleItem());
895 SPObject *parent = SP_OBJECT_PARENT (obj);
897 // remove old tiling
898 GSList *to_delete = NULL;
899 for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
900 if (clonetiler_is_a_clone_of (child, obj)) {
901 to_delete = g_slist_prepend (to_delete, child);
902 }
903 }
904 for (GSList *i = to_delete; i; i = i->next) {
905 SP_OBJECT(i->data)->deleteObject();
906 }
907 g_slist_free (to_delete);
909 clonetiler_change_selection (NULL, selection, dlg);
911 if (do_undo)
912 sp_document_done (SP_DT_DOCUMENT (desktop));
913 }
915 static NR::Rect
916 transform_rect(NR::Rect const &r, NR::Matrix const &m)
917 {
918 using NR::X;
919 using NR::Y;
920 NR::Point const p1 = r.corner(1) * m;
921 NR::Point const p2 = r.corner(2) * m;
922 NR::Point const p3 = r.corner(3) * m;
923 NR::Point const p4 = r.corner(4) * m;
924 return NR::Rect(
925 NR::Point(
926 std::min(std::min(p1[X], p2[X]), std::min(p3[X], p4[X])),
927 std::min(std::min(p1[Y], p2[Y]), std::min(p3[Y], p4[Y]))),
928 NR::Point(
929 std::max(std::max(p1[X], p2[X]), std::max(p3[X], p4[X])),
930 std::max(std::max(p1[Y], p2[Y]), std::max(p3[Y], p4[Y]))));
931 }
933 /**
934 Randomizes \a val by \a rand, with 0 < val < 1 and all values (including 0, 1) having the same
935 probability of being displaced.
936 */
937 static double
938 randomize01 (double val, double rand)
939 {
940 double base = MIN (val - rand, 1 - 2*rand);
941 if (base < 0) base = 0;
942 val = base + g_random_double_range (0, MIN (2 * rand, 1 - base));
943 return CLAMP(val, 0, 1); // this should be unnecessary with the above provisions, but just in case...
944 }
947 static void
948 clonetiler_apply (GtkWidget *widget, void *)
949 {
950 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
951 if (desktop == NULL)
952 return;
954 Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
956 // check if something is selected
957 if (selection->isEmpty()) {
958 SP_DT_MSGSTACK(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object</b> to clone."));
959 return;
960 }
962 // Check if more than one object is selected.
963 if (g_slist_length((GSList *) selection->itemList()) > 1) {
964 SP_DT_MSGSTACK(desktop)->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>."));
965 return;
966 }
968 SPObject *obj = SP_OBJECT(selection->singleItem());
969 Inkscape::XML::Node *obj_repr = SP_OBJECT_REPR(obj);
970 const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id"));
971 SPObject *parent = SP_OBJECT_PARENT (obj);
973 clonetiler_remove (NULL, NULL, false);
975 double d_x_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_x_per_x", 0, -100, 1000);
976 double d_y_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_y_per_x", 0, -100, 1000);
977 double d_per_x_exp = prefs_get_double_attribute_limited (prefs_path, "d_per_x_exp", 1, 0, 10);
978 double d_x_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_x_per_y", 0, -100, 1000);
979 double d_y_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_y_per_y", 0, -100, 1000);
980 double d_per_y_exp = prefs_get_double_attribute_limited (prefs_path, "d_per_y_exp", 1, 0, 10);
981 int alternate_x = prefs_get_int_attribute (prefs_path, "alternate_x", 0);
982 int alternate_y = prefs_get_int_attribute (prefs_path, "alternate_y", 0);
983 double rand_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_x", 0, 0, 1000);
984 double rand_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_y", 0, 0, 1000);
986 double d_scalex_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scalex_per_x", 0, -100, 1000);
987 double d_scaley_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scaley_per_x", 0, -100, 1000);
988 double d_scalex_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scalex_per_y", 0, -100, 1000);
989 double d_scaley_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_scaley_per_y", 0, -100, 1000);
990 int alternate_scalex = prefs_get_int_attribute (prefs_path, "alternate_scalex", 0);
991 int alternate_scaley = prefs_get_int_attribute (prefs_path, "alternate_scaley", 0);
992 double rand_scalex = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scalex", 0, 0, 1000);
993 double rand_scaley = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_scaley", 0, 0, 1000);
995 double d_rot_per_x = prefs_get_double_attribute_limited (prefs_path, "d_rot_per_x", 0, -180, 180);
996 double d_rot_per_y = prefs_get_double_attribute_limited (prefs_path, "d_rot_per_y", 0, -180, 180);
997 int alternate_rotx = prefs_get_int_attribute (prefs_path, "alternate_rotx", 0);
998 int alternate_roty = prefs_get_int_attribute (prefs_path, "alternate_roty", 0);
999 double rand_rot = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_rot", 0, 0, 100);
1001 double d_opacity_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_y", 0, 0, 100);
1002 double d_opacity_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_opacity_per_x", 0, 0, 100);
1003 int alternate_opacityy = prefs_get_int_attribute (prefs_path, "alternate_opacityy", 0);
1004 int alternate_opacityx = prefs_get_int_attribute (prefs_path, "alternate_opacityx", 0);
1005 double rand_opacity = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_opacity", 0, 0, 100);
1007 const gchar *initial_color = prefs_get_string_attribute (prefs_path, "initial_color");
1008 double d_hue_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_hue_per_y", 0, -100, 100);
1009 double d_hue_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_hue_per_x", 0, -100, 100);
1010 double rand_hue = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_hue", 0, 0, 100);
1011 double d_saturation_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_saturation_per_y", 0, -100, 100);
1012 double d_saturation_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_saturation_per_x", 0, -100, 100);
1013 double rand_saturation = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_saturation", 0, 0, 100);
1014 double d_lightness_per_y = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_lightness_per_y", 0, -100, 100);
1015 double d_lightness_per_x = 0.01 * prefs_get_double_attribute_limited (prefs_path, "d_lightness_per_x", 0, -100, 100);
1016 double rand_lightness = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_lightness", 0, 0, 100);
1017 int alternate_color_y = prefs_get_int_attribute (prefs_path, "alternate_color_y", 0);
1018 int alternate_color_x = prefs_get_int_attribute (prefs_path, "alternate_color_x", 0);
1020 int type = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
1022 int keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
1024 int xmax = prefs_get_int_attribute (prefs_path, "xmax", 2);
1025 int ymax = prefs_get_int_attribute (prefs_path, "ymax", 2);
1027 int fillrect = prefs_get_int_attribute (prefs_path, "fillrect", 0);
1028 double fillwidth = prefs_get_double_attribute_limited (prefs_path, "fillwidth", 50, 0, 6000);
1029 double fillheight = prefs_get_double_attribute_limited (prefs_path, "fillheight", 50, 0, 6000);
1031 int dotrace = prefs_get_int_attribute (prefs_path, "dotrace", 0);
1032 int pick = prefs_get_int_attribute (prefs_path, "pick", 0);
1033 int pick_to_presence = prefs_get_int_attribute (prefs_path, "pick_to_presence", 0);
1034 int pick_to_size = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
1035 int pick_to_color = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
1036 int pick_to_opacity = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
1037 double rand_picked = 0.01 * prefs_get_double_attribute_limited (prefs_path, "rand_picked", 0, 0, 100);
1038 int invert_picked = prefs_get_int_attribute (prefs_path, "invert_picked", 0);
1039 double gamma_picked = prefs_get_double_attribute_limited (prefs_path, "gamma_picked", 0, -10, 10);
1041 if (dotrace) {
1042 clonetiler_trace_setup (SP_DT_DOCUMENT(desktop), 1.0, SP_ITEM (obj));
1043 }
1045 NR::Point c;
1046 double w;
1047 double h;
1049 if (keepbbox &&
1050 obj_repr->attribute("inkscape:tile-w") &&
1051 obj_repr->attribute("inkscape:tile-h") &&
1052 obj_repr->attribute("inkscape:tile-cx") &&
1053 obj_repr->attribute("inkscape:tile-cy")) {
1055 double cx = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cx", 0);
1056 double cy = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cy", 0);
1058 c = NR::Point (cx, cy);
1060 w = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-w", 0);
1061 h = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-h", 0);
1062 } else {
1063 NR::Rect const r = SP_ITEM(obj)->invokeBbox(sp_item_i2doc_affine(SP_ITEM(obj)));
1064 c = r.midpoint();
1065 w = r.dimensions()[NR::X];
1066 h = r.dimensions()[NR::Y];
1068 sp_repr_set_svg_double(obj_repr, "inkscape:tile-w", w);
1069 sp_repr_set_svg_double(obj_repr, "inkscape:tile-h", h);
1070 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", c[NR::X]);
1071 sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", c[NR::Y]);
1072 }
1074 NR::Point cur = NR::Point (0, 0);
1075 NR::Rect bbox_original = NR::Rect (NR::Point (c[NR::X] - w/2, c[NR::Y] - h/2), NR::Point (c[NR::X] + w/2, c[NR::Y] + h/2));
1077 for (int x = 0;
1078 fillrect?
1079 (fabs(cur[NR::X]) < fillwidth && x < 200) // prevent "freezing" with too large fillrect, arbitrarily limit rows
1080 : (x < xmax);
1081 x ++) {
1082 for (int y = 0;
1083 fillrect?
1084 (fabs(cur[NR::Y]) < fillheight && y < 200) // prevent "freezing" with too large fillrect, arbitrarily limit cols
1085 : (y < ymax);
1086 y ++) {
1088 // Note: We create a clone at 0,0 too, right over the original, in case our clones are colored
1090 // Get transform from symmetry, shift, scale, rotation
1091 NR::Matrix t = clonetiler_get_transform (type, x, y, c[NR::X], c[NR::Y], w, h,
1092 d_x_per_x, d_y_per_x, d_x_per_y, d_y_per_y, alternate_x, alternate_y, rand_x, rand_y,
1093 d_per_x_exp, d_per_y_exp,
1094 d_rot_per_x, d_rot_per_y, alternate_rotx, alternate_roty, rand_rot,
1095 d_scalex_per_x, d_scaley_per_x, d_scalex_per_y, d_scaley_per_y,
1096 alternate_scalex, alternate_scaley, rand_scalex, rand_scaley);
1098 cur = c * t - c;
1099 if (fillrect) {
1100 if ((cur[NR::X] > fillwidth) || (cur[NR::Y] > fillheight)) { // off limits
1101 continue;
1102 }
1103 }
1105 gchar color_string[32]; *color_string = 0;
1107 // Color tab
1108 if (initial_color) {
1109 guint32 rgba = sp_svg_read_color (initial_color, 0x000000ff);
1110 float hsl[3];
1111 sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba));
1113 double eff_x = (alternate_color_x? (x%2) : (x));
1114 double eff_y = (alternate_color_y? (y%2) : (y));
1116 hsl[0] += d_hue_per_x * eff_x + d_hue_per_y * eff_y + rand_hue * g_random_double_range (-1, 1);
1117 if (hsl[0] < 0) hsl[0] += 1;
1118 if (hsl[0] > 1) hsl[0] -= 1;
1119 hsl[1] += d_saturation_per_x * eff_x + d_saturation_per_y * eff_y + rand_saturation * g_random_double_range (-1, 1);
1120 hsl[1] = CLAMP (hsl[1], 0, 1);
1121 hsl[2] += d_lightness_per_x * eff_x + d_lightness_per_y * eff_y + rand_lightness * g_random_double_range (-1, 1);
1122 hsl[2] = CLAMP (hsl[2], 0, 1);
1124 float rgb[3];
1125 sp_color_hsl_to_rgb_floatv (rgb, hsl[0], hsl[1], hsl[2]);
1126 sp_svg_write_color(color_string, 32, SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1.0));
1127 }
1129 // Opacity tab
1130 double opacity = 1.0;
1131 int eff_x = (alternate_opacityx? (x%2) : (x));
1132 int eff_y = (alternate_opacityy? (y%2) : (y));
1133 opacity = 1 - (d_opacity_per_x * eff_x + d_opacity_per_y * eff_y + rand_opacity * g_random_double_range (-1, 1));
1134 opacity = CLAMP (opacity, 0, 1);
1136 // Trace tab
1137 if (dotrace) {
1138 NR::Rect bbox_t = transform_rect (bbox_original, t);
1140 guint32 rgba = clonetiler_trace_pick (bbox_t);
1141 float r = SP_RGBA32_R_F(rgba);
1142 float g = SP_RGBA32_G_F(rgba);
1143 float b = SP_RGBA32_B_F(rgba);
1144 float a = SP_RGBA32_A_F(rgba);
1146 float hsl[3];
1147 sp_color_rgb_to_hsl_floatv (hsl, r, g, b);
1149 gdouble val = 0;
1150 switch (pick) {
1151 case PICK_COLOR:
1152 val = 1 - hsl[2]; // inverse lightness; to match other picks where black = max
1153 break;
1154 case PICK_OPACITY:
1155 val = a;
1156 break;
1157 case PICK_R:
1158 val = r;
1159 break;
1160 case PICK_G:
1161 val = g;
1162 break;
1163 case PICK_B:
1164 val = b;
1165 break;
1166 case PICK_H:
1167 val = hsl[0];
1168 break;
1169 case PICK_S:
1170 val = hsl[1];
1171 break;
1172 case PICK_L:
1173 val = 1 - hsl[2];
1174 break;
1175 default:
1176 break;
1177 }
1179 if (rand_picked > 0) {
1180 val = randomize01 (val, rand_picked);
1181 r = randomize01 (r, rand_picked);
1182 g = randomize01 (g, rand_picked);
1183 b = randomize01 (b, rand_picked);
1184 }
1186 if (gamma_picked != 0) {
1187 double power;
1188 if (gamma_picked < 0)
1189 power = 1/(1 + fabs(gamma_picked));
1190 else
1191 power = 1 + gamma_picked;
1193 val = pow (val, power);
1194 r = pow (r, power);
1195 g = pow (g, power);
1196 b = pow (b, power);
1197 }
1199 if (invert_picked) {
1200 val = 1 - val;
1201 r = 1 - r;
1202 g = 1 - g;
1203 b = 1 - b;
1204 }
1206 val = CLAMP (val, 0, 1);
1207 r = CLAMP (r, 0, 1);
1208 g = CLAMP (g, 0, 1);
1209 b = CLAMP (b, 0, 1);
1211 // recompose tweaked color
1212 rgba = SP_RGBA32_F_COMPOSE(r, g, b, a);
1214 if (pick_to_presence) {
1215 if (g_random_double_range (0, 1) > val) {
1216 continue; // skip!
1217 }
1218 }
1219 if (pick_to_size) {
1220 t = NR::translate(-c[NR::X], -c[NR::Y]) * NR::scale (val, val) * NR::translate(c[NR::X], c[NR::Y]) * t;
1221 }
1222 if (pick_to_opacity) {
1223 opacity *= val;
1224 }
1225 if (pick_to_color) {
1226 sp_svg_write_color(color_string, 32, rgba);
1227 }
1228 }
1230 if (opacity < 1e-6) { // invisibly transparent, skip
1231 continue;
1232 }
1234 if (fabs(t[0]) + fabs (t[1]) + fabs(t[2]) + fabs(t[3]) < 1e-6) { // too small, skip
1235 continue;
1236 }
1238 // Create the clone
1239 Inkscape::XML::Node *clone = sp_repr_new("svg:use");
1240 clone->setAttribute("x", "0");
1241 clone->setAttribute("y", "0");
1242 clone->setAttribute("inkscape:tiled-clone-of", id_href);
1243 clone->setAttribute("xlink:href", id_href);
1245 gchar affinestr[80];
1246 if (sp_svg_transform_write(affinestr, 79, t)) {
1247 clone->setAttribute("transform", affinestr);
1248 } else {
1249 clone->setAttribute("transform", NULL);
1250 }
1252 if (opacity < 1.0) {
1253 sp_repr_set_css_double(clone, "opacity", opacity);
1254 }
1256 if (*color_string) {
1257 clone->setAttribute("fill", color_string);
1258 clone->setAttribute("stroke", color_string);
1259 }
1261 // add the new clone to the top of the original's parent
1262 SP_OBJECT_REPR(parent)->appendChild(clone);
1263 Inkscape::GC::release(clone);
1264 }
1265 cur[NR::Y] = 0;
1266 }
1268 if (dotrace) {
1269 clonetiler_trace_finish ();
1270 }
1272 clonetiler_change_selection (NULL, selection, dlg);
1274 sp_document_done(SP_DT_DOCUMENT(desktop));
1275 }
1277 static GtkWidget *
1278 clonetiler_new_tab (GtkWidget *nb, const gchar *label)
1279 {
1280 GtkWidget *l = gtk_label_new_with_mnemonic (label);
1281 GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN);
1282 gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN);
1283 gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l);
1284 return vb;
1285 }
1287 static void
1288 clonetiler_checkbox_toggled (GtkToggleButton *tb, gpointer *data)
1289 {
1290 const gchar *attr = (const gchar *) data;
1291 prefs_set_int_attribute (prefs_path, attr, gtk_toggle_button_get_active (tb));
1292 }
1294 static GtkWidget *
1295 clonetiler_checkbox (GtkTooltips *tt, const char *tip, const char *attr)
1296 {
1297 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
1299 GtkWidget *b = gtk_check_button_new ();
1300 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, tip, NULL);
1302 int value = prefs_get_int_attribute (prefs_path, attr, 0);
1303 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value);
1305 gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0);
1306 gtk_signal_connect ( GTK_OBJECT (b), "clicked",
1307 GTK_SIGNAL_FUNC (clonetiler_checkbox_toggled), (gpointer) attr);
1309 g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
1311 return hb;
1312 }
1315 static void
1316 clonetiler_value_changed (GtkAdjustment *adj, gpointer data)
1317 {
1318 const gchar *pref = (const gchar *) data;
1319 prefs_set_double_attribute (prefs_path, pref, adj->value);
1320 }
1322 static GtkWidget *
1323 clonetiler_spinbox (GtkTooltips *tt, const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false)
1324 {
1325 GtkWidget *hb = gtk_hbox_new(FALSE, 0);
1327 {
1328 GtkObject *a;
1329 if (exponent)
1330 a = gtk_adjustment_new(1.0, lower, upper, 0.01, 0.05, 0.1);
1331 else
1332 a = gtk_adjustment_new(0.0, lower, upper, 0.1, 0.5, 2);
1334 GtkWidget *sb;
1335 if (exponent)
1336 sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.01, 2);
1337 else
1338 sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 0.1, 1);
1340 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, tip, NULL);
1341 gtk_entry_set_width_chars (GTK_ENTRY (sb), 4);
1342 gtk_box_pack_start (GTK_BOX (hb), sb, FALSE, FALSE, SB_MARGIN);
1344 double value = prefs_get_double_attribute_limited (prefs_path, attr, exponent? 1 : 0, lower, upper);
1345 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
1346 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
1347 GTK_SIGNAL_FUNC(clonetiler_value_changed), (gpointer) attr);
1349 if (exponent)
1350 g_object_set_data (G_OBJECT(sb), "oneable", GINT_TO_POINTER(TRUE));
1351 else
1352 g_object_set_data (G_OBJECT(sb), "zeroable", GINT_TO_POINTER(TRUE));
1353 }
1355 {
1356 GtkWidget *l = gtk_label_new ("");
1357 gtk_label_set_markup (GTK_LABEL(l), suffix);
1358 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0);
1359 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
1360 }
1362 return hb;
1363 }
1365 static void
1366 clonetiler_symgroup_changed (GtkMenuItem *item, gpointer data)
1367 {
1368 gint group_new = GPOINTER_TO_INT (data);
1369 prefs_set_int_attribute ( prefs_path, "symmetrygroup", group_new );
1370 }
1372 static void
1373 clonetiler_xy_changed (GtkAdjustment *adj, gpointer data)
1374 {
1375 const gchar *pref = (const gchar *) data;
1376 prefs_set_int_attribute (prefs_path, pref, (int) floor(adj->value + 0.5));
1377 }
1379 static void
1380 clonetiler_keep_bbox_toggled (GtkToggleButton *tb, gpointer data)
1381 {
1382 prefs_set_int_attribute (prefs_path, "keepbbox", gtk_toggle_button_get_active (tb));
1383 }
1385 static void
1386 clonetiler_pick_to (GtkToggleButton *tb, gpointer data)
1387 {
1388 const gchar *pref = (const gchar *) data;
1389 prefs_set_int_attribute (prefs_path, pref, gtk_toggle_button_get_active (tb));
1390 }
1393 static void
1394 clonetiler_reset_recursive (GtkWidget *w)
1395 {
1396 if (w && GTK_IS_OBJECT(w)) {
1397 {
1398 int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "zeroable"));
1399 if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton
1400 GtkAdjustment *a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(w));
1401 gtk_adjustment_set_value (a, 0);
1402 }
1403 }
1404 {
1405 int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "oneable"));
1406 if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton
1407 GtkAdjustment *a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(w));
1408 gtk_adjustment_set_value (a, 1);
1409 }
1410 }
1411 {
1412 int r = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT(w), "uncheckable"));
1413 if (r && GTK_IS_TOGGLE_BUTTON(w)) { // checkbox
1414 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(w), FALSE);
1415 }
1416 }
1417 }
1419 if (GTK_IS_CONTAINER(w)) {
1420 GList *ch = gtk_container_get_children (GTK_CONTAINER(w));
1421 for (GList *i = ch; i != NULL; i = i->next) {
1422 clonetiler_reset_recursive (GTK_WIDGET(i->data));
1423 }
1424 g_list_free (ch);
1425 }
1426 }
1428 static void
1429 clonetiler_reset (GtkWidget *widget, void *)
1430 {
1431 clonetiler_reset_recursive (dlg);
1432 }
1434 static void
1435 clonetiler_table_attach (GtkWidget *table, GtkWidget *widget, float align, int row, int col)
1436 {
1437 GtkWidget *a = gtk_alignment_new (align, 0, 0, 0);
1438 gtk_container_add(GTK_CONTAINER(a), widget);
1439 gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 );
1440 }
1442 static GtkWidget *
1443 clonetiler_table_x_y_rand (int values)
1444 {
1445 GtkWidget *table = gtk_table_new (values + 2, 5, FALSE);
1446 gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
1447 gtk_table_set_row_spacings (GTK_TABLE (table), 6);
1448 gtk_table_set_col_spacings (GTK_TABLE (table), 8);
1450 {
1451 GtkWidget *hb = gtk_hbox_new (FALSE, 0);
1453 GtkWidget *i = sp_icon_new (GTK_ICON_SIZE_MENU, "clonetiler_per_row");
1454 gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
1456 GtkWidget *l = gtk_label_new ("");
1457 gtk_label_set_markup (GTK_LABEL(l), _("<small>Per row:</small>"));
1458 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2);
1460 clonetiler_table_attach (table, hb, 0, 1, 2);
1461 }
1463 {
1464 GtkWidget *hb = gtk_hbox_new (FALSE, 0);
1466 GtkWidget *i = sp_icon_new (GTK_ICON_SIZE_MENU, "clonetiler_per_column");
1467 gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2);
1469 GtkWidget *l = gtk_label_new ("");
1470 gtk_label_set_markup (GTK_LABEL(l), _("<small>Per column:</small>"));
1471 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2);
1473 clonetiler_table_attach (table, hb, 0, 1, 3);
1474 }
1476 {
1477 GtkWidget *l = gtk_label_new ("");
1478 gtk_label_set_markup (GTK_LABEL(l), _("<small>Randomize:</small>"));
1479 clonetiler_table_attach (table, l, 0, 1, 4);
1480 }
1482 return table;
1483 }
1485 static void
1486 clonetiler_pick_switched (GtkToggleButton *tb, gpointer data)
1487 {
1488 guint v = GPOINTER_TO_INT (data);
1489 prefs_set_int_attribute (prefs_path, "pick", v);
1490 }
1493 static void
1494 clonetiler_switch_to_create (GtkToggleButton *tb, GtkWidget *dlg)
1495 {
1496 GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
1497 GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
1499 if (rowscols) {
1500 gtk_widget_set_sensitive (rowscols, TRUE);
1501 }
1502 if (widthheight) {
1503 gtk_widget_set_sensitive (widthheight, FALSE);
1504 }
1506 prefs_set_int_attribute (prefs_path, "fillrect", 0);
1507 }
1510 static void
1511 clonetiler_switch_to_fill (GtkToggleButton *tb, GtkWidget *dlg)
1512 {
1513 GtkWidget *rowscols = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "rowscols");
1514 GtkWidget *widthheight = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "widthheight");
1516 if (rowscols) {
1517 gtk_widget_set_sensitive (rowscols, FALSE);
1518 }
1519 if (widthheight) {
1520 gtk_widget_set_sensitive (widthheight, TRUE);
1521 }
1523 prefs_set_int_attribute (prefs_path, "fillrect", 1);
1524 }
1529 static void
1530 clonetiler_fill_width_changed (GtkAdjustment *adj, GtkWidget *u)
1531 {
1532 gdouble const raw_dist = adj->value;
1533 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
1534 gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
1536 prefs_set_double_attribute (prefs_path, "fillwidth", pixels);
1537 }
1539 static void
1540 clonetiler_fill_height_changed (GtkAdjustment *adj, GtkWidget *u)
1541 {
1542 gdouble const raw_dist = adj->value;
1543 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
1544 gdouble const pixels = sp_units_get_pixels (raw_dist, unit);
1546 prefs_set_double_attribute (prefs_path, "fillheight", pixels);
1547 }
1550 static void
1551 clonetiler_do_pick_toggled (GtkToggleButton *tb, gpointer data)
1552 {
1553 GtkWidget *vvb = (GtkWidget *) g_object_get_data (G_OBJECT(dlg), "dotrace");
1555 prefs_set_int_attribute (prefs_path, "dotrace", gtk_toggle_button_get_active (tb));
1557 if (vvb)
1558 gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb));
1559 }
1564 void
1565 clonetiler_dialog (void)
1566 {
1567 if (!dlg)
1568 {
1569 gchar title[500];
1570 sp_ui_dialog_title_string (Inkscape::Verb::get(SP_VERB_DIALOG_CLONETILER), title);
1572 dlg = sp_window_new (title, TRUE);
1573 if (x == -1000 || y == -1000) {
1574 x = prefs_get_int_attribute (prefs_path, "x", 0);
1575 y = prefs_get_int_attribute (prefs_path, "y", 0);
1576 }
1578 if (w ==0 || h == 0) {
1579 w = prefs_get_int_attribute (prefs_path, "w", 0);
1580 h = prefs_get_int_attribute (prefs_path, "h", 0);
1581 }
1583 if (x != 0 || y != 0) {
1584 gtk_window_move ((GtkWindow *) dlg, x, y);
1586 } else {
1587 gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
1588 }
1590 if (w && h) {
1591 gtk_window_resize ((GtkWindow *) dlg, w, h);
1592 }
1594 sp_transientize (dlg);
1595 wd.win = dlg;
1596 wd.stop = 0;
1599 gtk_signal_connect ( GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg);
1601 gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (clonetiler_dialog_destroy), dlg);
1602 gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (clonetiler_dialog_delete), dlg);
1604 if (Inkscape::NSApplication::Application::getNewGui())
1605 {
1606 _shutdown_connection = Inkscape::NSApplication::Editor::connectShutdown (&on_delete);
1607 _dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::bind (&on_dialog_hide, dlg));
1608 _dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::bind (&on_dialog_unhide, dlg));
1609 _desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::bind (&on_transientize, &wd));
1610 } else {
1611 g_signal_connect ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg);
1612 g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg);
1613 g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg);
1614 g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
1615 }
1617 GtkTooltips *tt = gtk_tooltips_new();
1619 GtkWidget *mainbox = gtk_vbox_new(FALSE, 4);
1620 gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6);
1621 gtk_container_add (GTK_CONTAINER (dlg), mainbox);
1623 GtkWidget *nb = gtk_notebook_new ();
1624 gtk_box_pack_start (GTK_BOX (mainbox), nb, FALSE, FALSE, 0);
1627 // Symmetry
1628 {
1629 GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry"));
1631 GtkWidget *om = gtk_option_menu_new ();
1632 /* TRANSLATORS: For the following 17 symmetry groups, see
1633 * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples);
1634 * http://www.clarku.edu/~djoyce/wallpaper/seventeen.html (English vocabulary); or
1635 * http://membres.lycos.fr/villemingerard/Geometri/Sym1D.htm (French vocabulary).
1636 */
1637 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), om, _("Select one of the 17 symmetry groups for the tiling"), NULL);
1638 gtk_box_pack_start (GTK_BOX (vb), om, FALSE, FALSE, SB_MARGIN);
1640 GtkWidget *m = gtk_menu_new ();
1641 int current = prefs_get_int_attribute (prefs_path, "symmetrygroup", 0);
1643 struct SymGroups {
1644 int group;
1645 gchar const *label;
1646 } const sym_groups[] = {
1647 // TRANSLATORS: "translation" means "shift" / "displacement" here.
1648 {TILE_P1, _("<b>P1</b>: simple translation")},
1649 {TILE_P2, _("<b>P2</b>: 180° rotation")},
1650 {TILE_PM, _("<b>PM</b>: reflection")},
1651 // TRANSLATORS: "glide reflection" is a reflection and a translation combined.
1652 // For more info, see http://mathforum.org/sum95/suzanne/symsusan.html
1653 {TILE_PG, _("<b>PG</b>: glide reflection")},
1654 {TILE_CM, _("<b>CM</b>: reflection + glide reflection")},
1655 {TILE_PMM, _("<b>PMM</b>: reflection + reflection")},
1656 {TILE_PMG, _("<b>PMG</b>: reflection + 180° rotation")},
1657 {TILE_PGG, _("<b>PGG</b>: glide reflection + 180° rotation")},
1658 {TILE_CMM, _("<b>CMM</b>: reflection + reflection + 180° rotation")},
1659 {TILE_P4, _("<b>P4</b>: 90° rotation")},
1660 {TILE_P4M, _("<b>P4M</b>: 90° rotation + 45° reflection")},
1661 {TILE_P4G, _("<b>P4G</b>: 90° rotation + 90° reflection")},
1662 {TILE_P3, _("<b>P3</b>: 120° rotation")},
1663 {TILE_P31M, _("<b>P31M</b>: reflection + 120° rotation, dense")},
1664 {TILE_P3M1, _("<b>P3M1</b>: reflection + 120° rotation, sparse")},
1665 {TILE_P6, _("<b>P6</b>: 60° rotation")},
1666 {TILE_P6M, _("<b>P6M</b>: reflection + 60° rotation")},
1667 };
1669 for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) {
1670 SymGroups const &sg = sym_groups[j];
1672 GtkWidget *l = gtk_label_new ("");
1673 gtk_label_set_markup (GTK_LABEL(l), sg.label);
1674 gtk_misc_set_alignment (GTK_MISC(l), 0, 0.5);
1676 GtkWidget *item = gtk_menu_item_new ();
1677 gtk_container_add (GTK_CONTAINER (item), l);
1679 gtk_signal_connect ( GTK_OBJECT (item), "activate",
1680 GTK_SIGNAL_FUNC (clonetiler_symgroup_changed),
1681 GINT_TO_POINTER (sg.group) );
1683 gtk_menu_append (GTK_MENU (m), item);
1684 }
1686 gtk_option_menu_set_menu (GTK_OPTION_MENU (om), m);
1687 gtk_option_menu_set_history ( GTK_OPTION_MENU (om), current);
1688 }
1690 table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1692 // Shift
1693 {
1694 GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift"));
1696 GtkWidget *table = clonetiler_table_x_y_rand (3);
1697 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1699 // X
1700 {
1701 GtkWidget *l = gtk_label_new ("");
1702 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount
1703 // xgettext:no-c-format
1704 gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift X:</b>"));
1705 gtk_size_group_add_widget(table_row_labels, l);
1706 clonetiler_table_attach (table, l, 1, 2, 1);
1707 }
1709 {
1710 GtkWidget *l = clonetiler_spinbox (tt,
1711 // xgettext:no-c-format
1712 _("Horizontal shift per row (in % of tile width)"), "d_x_per_y",
1713 -100, 1000, "%");
1714 clonetiler_table_attach (table, l, 0, 2, 2);
1715 }
1717 {
1718 GtkWidget *l = clonetiler_spinbox (tt,
1719 // xgettext:no-c-format
1720 _("Horizontal shift per column (in % of tile width)"), "d_x_per_x",
1721 -100, 1000, "%");
1722 clonetiler_table_attach (table, l, 0, 2, 3);
1723 }
1725 {
1726 GtkWidget *l = clonetiler_spinbox (tt,
1727 _("Randomize the horizontal shift by this percentage"), "rand_x",
1728 0, 1000, "%");
1729 clonetiler_table_attach (table, l, 0, 2, 4);
1730 }
1732 // Y
1733 {
1734 GtkWidget *l = gtk_label_new ("");
1735 // TRANSLATORS: "shift" means: the tiles will be shifted (offset) vertically by this amount
1736 // xgettext:no-c-format
1737 gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift Y:</b>"));
1738 gtk_size_group_add_widget(table_row_labels, l);
1739 clonetiler_table_attach (table, l, 1, 3, 1);
1740 }
1742 {
1743 GtkWidget *l = clonetiler_spinbox (tt,
1744 // xgettext:no-c-format
1745 _("Vertical shift per row (in % of tile height)"), "d_y_per_y",
1746 -100, 1000, "%");
1747 clonetiler_table_attach (table, l, 0, 3, 2);
1748 }
1750 {
1751 GtkWidget *l = clonetiler_spinbox (tt,
1752 // xgettext:no-c-format
1753 _("Vertical shift per column (in % of tile height)"), "d_y_per_x",
1754 -100, 1000, "%");
1755 clonetiler_table_attach (table, l, 0, 3, 3);
1756 }
1758 {
1759 GtkWidget *l = clonetiler_spinbox (tt,
1760 _("Randomize the vertical shift by this percentage"), "rand_y",
1761 0, 1000, "%");
1762 clonetiler_table_attach (table, l, 0, 3, 4);
1763 }
1765 // Exponent
1766 {
1767 GtkWidget *l = gtk_label_new ("");
1768 gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>"));
1769 gtk_size_group_add_widget(table_row_labels, l);
1770 clonetiler_table_attach (table, l, 1, 4, 1);
1771 }
1773 {
1774 GtkWidget *l = clonetiler_spinbox (tt,
1775 _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_y_exp",
1776 0, 10, "", true);
1777 clonetiler_table_attach (table, l, 0, 4, 2);
1778 }
1780 {
1781 GtkWidget *l = clonetiler_spinbox (tt,
1782 _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "d_per_x_exp",
1783 0, 10, "", true);
1784 clonetiler_table_attach (table, l, 0, 4, 3);
1785 }
1787 { // alternates
1788 GtkWidget *l = gtk_label_new ("");
1789 // TRANSLATORS: "Alternate" is a verb here
1790 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
1791 gtk_size_group_add_widget(table_row_labels, l);
1792 clonetiler_table_attach (table, l, 1, 5, 1);
1793 }
1795 {
1796 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each row"), "alternate_y");
1797 clonetiler_table_attach (table, l, 0, 5, 2);
1798 }
1800 {
1801 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each column"), "alternate_x");
1802 clonetiler_table_attach (table, l, 0, 5, 3);
1803 }
1805 }
1808 // Scale
1809 {
1810 GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale"));
1812 GtkWidget *table = clonetiler_table_x_y_rand (2);
1813 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1815 // X
1816 {
1817 GtkWidget *l = gtk_label_new ("");
1818 gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale X:</b>"));
1819 gtk_size_group_add_widget(table_row_labels, l);
1820 clonetiler_table_attach (table, l, 1, 2, 1);
1821 }
1823 {
1824 GtkWidget *l = clonetiler_spinbox (tt,
1825 // xgettext:no-c-format
1826 _("Horizontal scale per row (in % of tile width)"), "d_scalex_per_y",
1827 -100, 1000, "%");
1828 clonetiler_table_attach (table, l, 0, 2, 2);
1829 }
1831 {
1832 GtkWidget *l = clonetiler_spinbox (tt,
1833 // xgettext:no-c-format
1834 _("Horizontal scale per column (in % of tile width)"), "d_scalex_per_x",
1835 -100, 1000, "%");
1836 clonetiler_table_attach (table, l, 0, 2, 3);
1837 }
1839 {
1840 GtkWidget *l = clonetiler_spinbox (tt,
1841 _("Randomize the horizontal scale by this percentage"), "rand_scalex",
1842 0, 1000, "%");
1843 clonetiler_table_attach (table, l, 0, 2, 4);
1844 }
1846 // Y
1847 {
1848 GtkWidget *l = gtk_label_new ("");
1849 gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale Y:</b>"));
1850 gtk_size_group_add_widget(table_row_labels, l);
1851 clonetiler_table_attach (table, l, 1, 3, 1);
1852 }
1854 {
1855 GtkWidget *l = clonetiler_spinbox (tt,
1856 // xgettext:no-c-format
1857 _("Vertical scale per row (in % of tile height)"), "d_scaley_per_y",
1858 -100, 1000, "%");
1859 clonetiler_table_attach (table, l, 0, 3, 2);
1860 }
1862 {
1863 GtkWidget *l = clonetiler_spinbox (tt,
1864 // xgettext:no-c-format
1865 _("Vertical scale per column (in % of tile height)"), "d_scaley_per_x",
1866 -100, 1000, "%");
1867 clonetiler_table_attach (table, l, 0, 3, 3);
1868 }
1870 {
1871 GtkWidget *l = clonetiler_spinbox (tt,
1872 _("Randomize the vertical scale by this percentage"), "rand_scaley",
1873 0, 1000, "%");
1874 clonetiler_table_attach (table, l, 0, 3, 4);
1875 }
1877 { // alternates
1878 GtkWidget *l = gtk_label_new ("");
1879 // TRANSLATORS: "Alternate" is a verb here
1880 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
1881 gtk_size_group_add_widget(table_row_labels, l);
1882 clonetiler_table_attach (table, l, 1, 4, 1);
1883 }
1885 {
1886 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each row"), "alternate_scaley");
1887 clonetiler_table_attach (table, l, 0, 4, 2);
1888 }
1890 {
1891 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each column"), "alternate_scalex");
1892 clonetiler_table_attach (table, l, 0, 4, 3);
1893 }
1895 }
1898 // Rotation
1899 {
1900 GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation"));
1902 GtkWidget *table = clonetiler_table_x_y_rand (1);
1903 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1905 // Angle
1906 {
1907 GtkWidget *l = gtk_label_new ("");
1908 gtk_label_set_markup (GTK_LABEL(l), _("<b>Angle:</b>"));
1909 gtk_size_group_add_widget(table_row_labels, l);
1910 clonetiler_table_attach (table, l, 1, 2, 1);
1911 }
1913 {
1914 GtkWidget *l = clonetiler_spinbox (tt,
1915 // xgettext:no-c-format
1916 _("Rotate tiles by this angle for each row"), "d_rot_per_y",
1917 -180, 180, "°");
1918 clonetiler_table_attach (table, l, 0, 2, 2);
1919 }
1921 {
1922 GtkWidget *l = clonetiler_spinbox (tt,
1923 // xgettext:no-c-format
1924 _("Rotate tiles by this angle for each column"), "d_rot_per_x",
1925 -180, 180, "°");
1926 clonetiler_table_attach (table, l, 0, 2, 3);
1927 }
1929 {
1930 GtkWidget *l = clonetiler_spinbox (tt,
1931 _("Randomize the rotation angle by this percentage"), "rand_rot",
1932 0, 100, "%");
1933 clonetiler_table_attach (table, l, 0, 2, 4);
1934 }
1936 { // alternates
1937 GtkWidget *l = gtk_label_new ("");
1938 // TRANSLATORS: "Alternate" is a verb here
1939 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
1940 gtk_size_group_add_widget(table_row_labels, l);
1941 clonetiler_table_attach (table, l, 1, 3, 1);
1942 }
1944 {
1945 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each row"), "alternate_roty");
1946 clonetiler_table_attach (table, l, 0, 3, 2);
1947 }
1949 {
1950 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each column"), "alternate_rotx");
1951 clonetiler_table_attach (table, l, 0, 3, 3);
1952 }
1953 }
1956 // Opacity
1957 {
1958 GtkWidget *vb = clonetiler_new_tab (nb, _("_Opacity"));
1960 GtkWidget *table = clonetiler_table_x_y_rand (1);
1961 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
1963 // Dissolve
1964 {
1965 GtkWidget *l = gtk_label_new ("");
1966 gtk_label_set_markup (GTK_LABEL(l), _("<b>Fade out:</b>"));
1967 gtk_size_group_add_widget(table_row_labels, l);
1968 clonetiler_table_attach (table, l, 1, 2, 1);
1969 }
1971 {
1972 GtkWidget *l = clonetiler_spinbox (tt,
1973 _("Decrease tile opacity by this percentage for each row"), "d_opacity_per_y",
1974 0, 100, "%");
1975 clonetiler_table_attach (table, l, 0, 2, 2);
1976 }
1978 {
1979 GtkWidget *l = clonetiler_spinbox (tt,
1980 _("Decrease tile opacity by this percentage for each column"), "d_opacity_per_x",
1981 0, 100, "%");
1982 clonetiler_table_attach (table, l, 0, 2, 3);
1983 }
1985 {
1986 GtkWidget *l = clonetiler_spinbox (tt,
1987 _("Randomize the tile opacity by this percentage"), "rand_opacity",
1988 0, 100, "%");
1989 clonetiler_table_attach (table, l, 0, 2, 4);
1990 }
1992 { // alternates
1993 GtkWidget *l = gtk_label_new ("");
1994 // TRANSLATORS: "Alternate" is a verb here
1995 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
1996 gtk_size_group_add_widget(table_row_labels, l);
1997 clonetiler_table_attach (table, l, 1, 3, 1);
1998 }
2000 {
2001 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each row"), "alternate_opacityy");
2002 clonetiler_table_attach (table, l, 0, 3, 2);
2003 }
2005 {
2006 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each column"), "alternate_opacityx");
2007 clonetiler_table_attach (table, l, 0, 3, 3);
2008 }
2009 }
2012 // Color
2013 {
2014 GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor"));
2016 {
2017 GtkWidget *hb = gtk_hbox_new (FALSE, 0);
2019 GtkWidget *l = gtk_label_new (_("Initial color: "));
2020 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
2022 guint32 rgba = 0x000000ff | sp_svg_read_color (prefs_get_string_attribute(prefs_path, "initial_color"), 0x000000ff);
2023 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);
2024 _color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed));
2026 gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0);
2028 gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);
2029 }
2032 GtkWidget *table = clonetiler_table_x_y_rand (3);
2033 gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0);
2035 // Hue
2036 {
2037 GtkWidget *l = gtk_label_new ("");
2038 gtk_label_set_markup (GTK_LABEL(l), _("<b>H:</b>"));
2039 gtk_size_group_add_widget(table_row_labels, l);
2040 clonetiler_table_attach (table, l, 1, 2, 1);
2041 }
2043 {
2044 GtkWidget *l = clonetiler_spinbox (tt,
2045 _("Change the tile hue by this percentage for each row"), "d_hue_per_y",
2046 -100, 100, "%");
2047 clonetiler_table_attach (table, l, 0, 2, 2);
2048 }
2050 {
2051 GtkWidget *l = clonetiler_spinbox (tt,
2052 _("Change the tile hue by this percentage for each column"), "d_hue_per_x",
2053 -100, 100, "%");
2054 clonetiler_table_attach (table, l, 0, 2, 3);
2055 }
2057 {
2058 GtkWidget *l = clonetiler_spinbox (tt,
2059 _("Randomize the tile hue by this percentage"), "rand_hue",
2060 0, 100, "%");
2061 clonetiler_table_attach (table, l, 0, 2, 4);
2062 }
2065 // Saturation
2066 {
2067 GtkWidget *l = gtk_label_new ("");
2068 gtk_label_set_markup (GTK_LABEL(l), _("<b>S:</b>"));
2069 gtk_size_group_add_widget(table_row_labels, l);
2070 clonetiler_table_attach (table, l, 1, 3, 1);
2071 }
2073 {
2074 GtkWidget *l = clonetiler_spinbox (tt,
2075 _("Change the color saturation by this percentage for each row"), "d_saturation_per_y",
2076 -100, 100, "%");
2077 clonetiler_table_attach (table, l, 0, 3, 2);
2078 }
2080 {
2081 GtkWidget *l = clonetiler_spinbox (tt,
2082 _("Change the color saturation by this percentage for each column"), "d_saturation_per_x",
2083 -100, 100, "%");
2084 clonetiler_table_attach (table, l, 0, 3, 3);
2085 }
2087 {
2088 GtkWidget *l = clonetiler_spinbox (tt,
2089 _("Randomize the color saturation by this percentage"), "rand_saturation",
2090 0, 100, "%");
2091 clonetiler_table_attach (table, l, 0, 3, 4);
2092 }
2094 // Lightness
2095 {
2096 GtkWidget *l = gtk_label_new ("");
2097 gtk_label_set_markup (GTK_LABEL(l), _("<b>L:</b>"));
2098 gtk_size_group_add_widget(table_row_labels, l);
2099 clonetiler_table_attach (table, l, 1, 4, 1);
2100 }
2102 {
2103 GtkWidget *l = clonetiler_spinbox (tt,
2104 _("Change the color lightness by this percentage for each row"), "d_lightness_per_y",
2105 -100, 100, "%");
2106 clonetiler_table_attach (table, l, 0, 4, 2);
2107 }
2109 {
2110 GtkWidget *l = clonetiler_spinbox (tt,
2111 _("Change the color lightness by this percentage for each column"), "d_lightness_per_x",
2112 -100, 100, "%");
2113 clonetiler_table_attach (table, l, 0, 4, 3);
2114 }
2116 {
2117 GtkWidget *l = clonetiler_spinbox (tt,
2118 _("Randomize the color lightness by this percentage"), "rand_lightness",
2119 0, 100, "%");
2120 clonetiler_table_attach (table, l, 0, 4, 4);
2121 }
2124 { // alternates
2125 GtkWidget *l = gtk_label_new ("");
2126 gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>"));
2127 gtk_size_group_add_widget(table_row_labels, l);
2128 clonetiler_table_attach (table, l, 1, 5, 1);
2129 }
2131 {
2132 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each row"), "alternate_color_y");
2133 clonetiler_table_attach (table, l, 0, 5, 2);
2134 }
2136 {
2137 GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each column"), "alternate_color_x");
2138 clonetiler_table_attach (table, l, 0, 5, 3);
2139 }
2141 }
2143 // Trace
2144 {
2145 GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace"));
2148 {
2149 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2150 gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0);
2152 GtkWidget *b = gtk_check_button_new_with_label (_("Trace the drawing under the tiles"));
2153 g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE));
2154 gint old = prefs_get_int_attribute (prefs_path, "dotrace", 0);
2155 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2156 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone"), NULL);
2157 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
2159 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2160 GTK_SIGNAL_FUNC(clonetiler_do_pick_toggled), dlg);
2161 }
2163 {
2164 GtkWidget *vvb = gtk_vbox_new (FALSE, 0);
2165 gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0);
2166 g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb);
2169 {
2170 GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:"));
2171 gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0);
2173 GtkWidget *table = gtk_table_new (3, 3, FALSE);
2174 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2175 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2176 gtk_container_add(GTK_CONTAINER(frame), table);
2179 GtkWidget* radio;
2180 {
2181 radio = gtk_radio_button_new_with_label (NULL, _("Color"));
2182 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the visible color and opacity"), NULL);
2183 clonetiler_table_attach (table, radio, 0.0, 1, 1);
2184 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2185 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR));
2186 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_COLOR);
2187 }
2188 {
2189 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Opacity"));
2190 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the total accumulated opacity"), NULL);
2191 clonetiler_table_attach (table, radio, 0.0, 2, 1);
2192 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2193 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY));
2194 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_OPACITY);
2195 }
2196 {
2197 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("R"));
2198 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Red component of the color"), NULL);
2199 clonetiler_table_attach (table, radio, 0.0, 1, 2);
2200 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2201 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R));
2202 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_R);
2203 }
2204 {
2205 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("G"));
2206 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Green component of the color"), NULL);
2207 clonetiler_table_attach (table, radio, 0.0, 2, 2);
2208 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2209 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G));
2210 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_G);
2211 }
2212 {
2213 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("B"));
2214 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the Blue component of the color"), NULL);
2215 clonetiler_table_attach (table, radio, 0.0, 3, 2);
2216 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2217 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B));
2218 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_B);
2219 }
2220 {
2221 //TRANSLATORS: only translate "string" in "context|string".
2222 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
2223 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|H"));
2224 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the hue of the color"), NULL);
2225 clonetiler_table_attach (table, radio, 0.0, 1, 3);
2226 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2227 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H));
2228 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_H);
2229 }
2230 {
2231 //TRANSLATORS: only translate "string" in "context|string".
2232 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
2233 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|S"));
2234 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the saturation of the color"), NULL);
2235 clonetiler_table_attach (table, radio, 0.0, 2, 3);
2236 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2237 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S));
2238 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_S);
2239 }
2240 {
2241 //TRANSLATORS: only translate "string" in "context|string".
2242 // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
2243 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|L"));
2244 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the lightness of the color"), NULL);
2245 clonetiler_table_attach (table, radio, 0.0, 3, 3);
2246 gtk_signal_connect (GTK_OBJECT (radio), "toggled",
2247 GTK_SIGNAL_FUNC (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L));
2248 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs_get_int_attribute(prefs_path, "pick", 0) == PICK_L);
2249 }
2251 }
2253 {
2254 GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:"));
2255 gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN);
2257 GtkWidget *table = gtk_table_new (4, 2, FALSE);
2258 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2259 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2260 gtk_container_add(GTK_CONTAINER(frame), table);
2262 {
2263 GtkWidget *l = gtk_label_new ("");
2264 gtk_label_set_markup (GTK_LABEL(l), _("Gamma-correct:"));
2265 clonetiler_table_attach (table, l, 1.0, 1, 1);
2266 }
2267 {
2268 GtkWidget *l = clonetiler_spinbox (tt,
2269 _("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked",
2270 -10, 10, "");
2271 clonetiler_table_attach (table, l, 0.0, 1, 2);
2272 }
2274 {
2275 GtkWidget *l = gtk_label_new ("");
2276 gtk_label_set_markup (GTK_LABEL(l), _("Randomize:"));
2277 clonetiler_table_attach (table, l, 1.0, 1, 3);
2278 }
2279 {
2280 GtkWidget *l = clonetiler_spinbox (tt,
2281 _("Randomize the picked value by this percentage"), "rand_picked",
2282 0, 100, "%");
2283 clonetiler_table_attach (table, l, 0.0, 1, 4);
2284 }
2286 {
2287 GtkWidget *l = gtk_label_new ("");
2288 gtk_label_set_markup (GTK_LABEL(l), _("Invert:"));
2289 clonetiler_table_attach (table, l, 1.0, 2, 1);
2290 }
2291 {
2292 GtkWidget *l = clonetiler_checkbox (tt, _("Invert the picked value"), "invert_picked");
2293 clonetiler_table_attach (table, l, 0.0, 2, 2);
2294 }
2295 }
2297 {
2298 GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':"));
2299 gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0);
2302 GtkWidget *table = gtk_table_new (2, 2, FALSE);
2303 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2304 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2305 gtk_container_add(GTK_CONTAINER(frame), table);
2307 {
2308 GtkWidget *b = gtk_check_button_new_with_label (_("Presence"));
2309 gint old = prefs_get_int_attribute (prefs_path, "pick_to_presence", 1);
2310 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2311 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is created with the probability determined by the picked value in that point"), NULL);
2312 clonetiler_table_attach (table, b, 0.0, 1, 1);
2313 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2314 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_presence");
2315 }
2317 {
2318 GtkWidget *b = gtk_check_button_new_with_label (_("Size"));
2319 gint old = prefs_get_int_attribute (prefs_path, "pick_to_size", 0);
2320 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2321 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's size is determined by the picked value in that point"), NULL);
2322 clonetiler_table_attach (table, b, 0.0, 2, 1);
2323 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2324 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_size");
2325 }
2327 {
2328 GtkWidget *b = gtk_check_button_new_with_label (_("Color"));
2329 gint old = prefs_get_int_attribute (prefs_path, "pick_to_color", 0);
2330 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2331 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)"), NULL);
2332 clonetiler_table_attach (table, b, 0.0, 1, 2);
2333 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2334 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_color");
2335 }
2337 {
2338 GtkWidget *b = gtk_check_button_new_with_label (_("Opacity"));
2339 gint old = prefs_get_int_attribute (prefs_path, "pick_to_opacity", 0);
2340 gtk_toggle_button_set_active ((GtkToggleButton *) b, old != 0);
2341 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's opacity is determined by the picked value in that point"), NULL);
2342 clonetiler_table_attach (table, b, 0.0, 2, 2);
2343 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2344 GTK_SIGNAL_FUNC(clonetiler_pick_to), (gpointer) "pick_to_opacity");
2345 }
2346 }
2347 gtk_widget_set_sensitive (vvb, prefs_get_int_attribute (prefs_path, "dotrace", 0));
2348 }
2349 }
2351 // Rows/columns, width/height
2352 {
2353 GtkWidget *table = gtk_table_new (2, 2, FALSE);
2354 gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN);
2355 gtk_table_set_row_spacings (GTK_TABLE (table), 4);
2356 gtk_table_set_col_spacings (GTK_TABLE (table), 6);
2357 gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0);
2359 {
2360 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2361 g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb);
2363 {
2364 GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
2365 int value = prefs_get_int_attribute (prefs_path, "ymax", 2);
2366 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
2367 GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
2368 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many rows in the tiling"), NULL);
2369 gtk_entry_set_width_chars (GTK_ENTRY (sb), 5);
2370 gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0);
2372 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2373 GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "ymax");
2374 }
2376 {
2377 GtkWidget *l = gtk_label_new ("");
2378 gtk_label_set_markup (GTK_LABEL(l), "×");
2379 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
2380 gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
2381 }
2383 {
2384 GtkObject *a = gtk_adjustment_new(0.0, 1, 500, 1, 10, 10);
2385 int value = prefs_get_int_attribute (prefs_path, "xmax", 2);
2386 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), value);
2387 GtkWidget *sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 0);
2388 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), sb, _("How many columns in the tiling"), NULL);
2389 gtk_entry_set_width_chars (GTK_ENTRY (sb), 5);
2390 gtk_box_pack_start (GTK_BOX (hb), sb, TRUE, TRUE, 0);
2392 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2393 GTK_SIGNAL_FUNC(clonetiler_xy_changed), (gpointer) "xmax");
2394 }
2396 clonetiler_table_attach (table, hb, 0.0, 1, 2);
2397 }
2399 {
2400 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2401 g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb);
2403 // unitmenu
2404 GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
2405 sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), SP_DT_NAMEDVIEW(SP_ACTIVE_DESKTOP)->doc_units);
2407 {
2408 // Width spinbutton
2409 GtkObject *a = gtk_adjustment_new (0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0);
2410 sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
2412 double value = prefs_get_double_attribute (prefs_path, "fillwidth", 50);
2413 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
2414 gdouble const units = sp_pixels_get_units (value, unit);
2415 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
2417 GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2);
2418 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), e, _("Width of the rectangle to be filled"), NULL);
2419 gtk_entry_set_width_chars (GTK_ENTRY (e), 5);
2420 gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0);
2421 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2422 GTK_SIGNAL_FUNC(clonetiler_fill_width_changed), u);
2423 }
2424 {
2425 GtkWidget *l = gtk_label_new ("");
2426 gtk_label_set_markup (GTK_LABEL(l), "×");
2427 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
2428 gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
2429 }
2431 {
2432 // Height spinbutton
2433 GtkObject *a = gtk_adjustment_new (0.0, -SP_DESKTOP_SCROLL_LIMIT, SP_DESKTOP_SCROLL_LIMIT, 1.0, 10.0, 10.0);
2434 sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a));
2436 double value = prefs_get_double_attribute (prefs_path, "fillheight", 50);
2437 SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u));
2438 gdouble const units = sp_pixels_get_units (value, unit);
2439 gtk_adjustment_set_value (GTK_ADJUSTMENT (a), units);
2442 GtkWidget *e = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0 , 2);
2443 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), e, _("Height of the rectangle to be filled"), NULL);
2444 gtk_entry_set_width_chars (GTK_ENTRY (e), 5);
2445 gtk_box_pack_start (GTK_BOX (hb), e, TRUE, TRUE, 0);
2446 gtk_signal_connect(GTK_OBJECT(a), "value_changed",
2447 GTK_SIGNAL_FUNC(clonetiler_fill_height_changed), u);
2448 }
2450 gtk_box_pack_start (GTK_BOX (hb), u, TRUE, TRUE, 0);
2451 clonetiler_table_attach (table, hb, 0.0, 2, 2);
2453 }
2455 // Switch
2456 GtkWidget* radio;
2457 {
2458 radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: "));
2459 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Create the specified number of rows and columns"), NULL);
2460 clonetiler_table_attach (table, radio, 0.0, 1, 1);
2461 gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_create), (gpointer) dlg);
2462 }
2463 if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 0) {
2464 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
2465 gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
2466 }
2467 {
2468 radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Width, height: "));
2469 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Fill the specified width and height with the tiling"), NULL);
2470 clonetiler_table_attach (table, radio, 0.0, 2, 1);
2471 gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_fill), (gpointer) dlg);
2472 }
2473 if (prefs_get_int_attribute(prefs_path, "fillrect", 0) == 1) {
2474 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
2475 gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio));
2476 }
2477 }
2480 // Use saved pos
2481 {
2482 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2483 gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
2485 GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile"));
2486 gint keepbbox = prefs_get_int_attribute (prefs_path, "keepbbox", 1);
2487 gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox != 0);
2488 gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size"), NULL);
2489 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
2491 gtk_signal_connect(GTK_OBJECT(b), "toggled",
2492 GTK_SIGNAL_FUNC(clonetiler_keep_bbox_toggled), NULL);
2493 }
2495 // Statusbar
2496 {
2497 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2498 gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
2499 GtkWidget *l = gtk_label_new("");
2500 g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l);
2501 gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0);
2502 }
2504 // Buttons
2505 {
2506 GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN);
2507 gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0);
2509 {
2510 GtkWidget *b = gtk_button_new ();
2511 GtkWidget *l = gtk_label_new ("");
2512 gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" <b>_Create</b> "));
2513 gtk_container_add (GTK_CONTAINER(b), l);
2514 gtk_tooltips_set_tip (tt, b, _("Create and tile the clones of the selection"), NULL);
2515 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_apply), NULL);
2516 gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0);
2517 }
2519 { // buttons which are enabled only when there are tiled clones
2520 GtkWidget *sb = gtk_hbox_new(FALSE, 0);
2521 gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0);
2522 g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb);
2523 {
2524 // TRANSLATORS: if a group of objects are "clumped" together, then they
2525 // are unevenly spread in the given amount of space - as shown in the
2526 // diagrams on the left in the following screenshot:
2527 // http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png
2528 // So unclumping is the process of spreading a number of objects out more evenly.
2529 GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump "));
2530 gtk_tooltips_set_tip (tt, b, _("Spread out clones to reduce clumping; can be applied repeatedly"), NULL);
2531 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_unclump), NULL);
2532 gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0);
2533 }
2535 {
2536 GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move "));
2537 gtk_tooltips_set_tip (tt, b, _("Remove existing tiled clones of the selected object (siblings only)"), NULL);
2538 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_remove), NULL);
2539 gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0);
2540 }
2542 // connect to global selection changed signal (so we can change desktops) and
2543 // external_change (so we're not fooled by undo)
2544 g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg);
2545 g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg);
2546 g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE));
2548 // update now
2549 clonetiler_change_selection (NULL, SP_DT_SELECTION(SP_ACTIVE_DESKTOP), dlg);
2550 }
2552 {
2553 GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset "));
2554 // TRANSLATORS: "change" is a noun here
2555 gtk_tooltips_set_tip (tt, b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero"), NULL);
2556 gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (clonetiler_reset), NULL);
2557 gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0);
2558 }
2559 }
2561 gtk_widget_show_all (mainbox);
2563 } // end of if (!dlg)
2565 gtk_window_present ((GtkWindow *) dlg);
2566 }
2569 /*
2570 Local Variables:
2571 mode:c++
2572 c-file-style:"stroustrup"
2573 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2574 indent-tabs-mode:nil
2575 fill-column:99
2576 End:
2577 */
2578 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :