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