clonetiler.cpp revision c730b7fa118ad88d7cc6047dcc78e7098cdf79ca
/** @file
* Clone tiling dialog
*/
/* Authors:
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <goejendaagh@zonnet.nl>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 2004-2006 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "desktop.h"
#include "desktop-handles.h"
#include "dialog-events.h"
#include "display/cairo-utils.h"
#include "display/nr-arena.h"
#include "display/nr-arena-item.h"
#include "document.h"
#include "filter-chemistry.h"
#include "helper/unit-menu.h"
#include "inkscape.h"
#include "interface.h"
#include "macros.h"
#include "message-stack.h"
#include "preferences.h"
#include "selection.h"
#include "sp-filter.h"
#include "sp-namedview.h"
#include "sp-use.h"
#include "style.h"
#include "svg/svg-color.h"
#include "ui/icon-names.h"
#include "ui/widget/color-picker.h"
#include "unclump.h"
#include "verbs.h"
#include "sp-root.h"
using Inkscape::DocumentUndo;
#define MIN_ONSCREEN_DISTANCE 50
// impossible original values to make sure they are read from prefs
#define SB_MARGIN 1
#define VB_MARGIN 4
enum {
};
{
delete color_picker;
}
static gboolean clonetiler_dialog_delete(GtkObject */*object*/, GdkEvent * /*event*/, gpointer /*data*/)
{
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
return FALSE; // which means, go ahead and destroy it
}
{
static bool is_updating = false;
if (is_updating || !SP_ACTIVE_DESKTOP)
return;
is_updating = true;
gchar c[32];
sp_svg_write_color(c, sizeof(c), rgba);
is_updating = false;
}
static void clonetiler_change_selection(Inkscape::Application * /*inkscape*/, Inkscape::Selection *selection, GtkWidget *dlg)
{
return;
}
return;
}
if (n > 0) {
} else {
}
}
{
}
{
}
}
enum {
};
// symmetry group
int type,
// row, column
int i, int j,
// center, width, height of the tile
double w, double h,
// values from the dialog:
// Shift
double shiftx_per_i, double shifty_per_i,
double shiftx_per_j, double shifty_per_j,
double shiftx_rand, double shifty_rand,
double shiftx_exp, double shifty_exp,
int shiftx_alternate, int shifty_alternate,
int shiftx_cumulate, int shifty_cumulate,
int shiftx_excludew, int shifty_excludeh,
// Scale
double scalex_per_i, double scaley_per_i,
double scalex_per_j, double scaley_per_j,
double scalex_rand, double scaley_rand,
double scalex_exp, double scaley_exp,
double scalex_log, double scaley_log,
int scalex_alternate, int scaley_alternate,
int scalex_cumulate, int scaley_cumulate,
// Rotation
double rotate_per_i, double rotate_per_j,
double rotate_rand,
int rotate_alternatei, int rotate_alternatej,
int rotate_cumulatei, int rotate_cumulatej
)
{
// Shift (in units of tile width or height) -------------
double delta_shifti = 0.0;
double delta_shiftj = 0.0;
if( shiftx_alternate ) {
delta_shifti = (double)(i%2);
} else {
if( shiftx_cumulate ) { // Should the delta shifts be cumulative (i.e. 1, 1+2, 1+2+3, ...)
delta_shifti = (double)(i*i);
} else {
delta_shifti = (double)i;
}
}
if( shifty_alternate ) {
delta_shiftj = (double)(j%2);
} else {
if( shifty_cumulate ) {
delta_shiftj = (double)(j*j);
} else {
delta_shiftj = (double)j;
}
}
// Random shift, only calculate if non-zero.
double delta_shiftx_rand = 0.0;
double delta_shifty_rand = 0.0;
// Shift in actual x and y, used below
// Include tile width and height in shift if required
if( !shiftx_excludew ) shifti += i;
if( !shifty_excludeh ) shiftj += j;
// Add exponential shift if necessary
// Final shift
// Rotation (in degrees) ------------
double delta_rotationi = 0.0;
double delta_rotationj = 0.0;
if( rotate_alternatei ) {
delta_rotationi = (double)(i%2);
} else {
if( rotate_cumulatei ) {
delta_rotationi = (double)(i*i + i)/2.0;
} else {
delta_rotationi = (double)i;
}
}
if( rotate_alternatej ) {
delta_rotationj = (double)(j%2);
} else {
if( rotate_cumulatej ) {
delta_rotationj = (double)(j*j + j)/2.0;
} else {
delta_rotationj = (double)j;
}
}
double delta_rotate_rand = 0.0;
// Scale (times the original) -----------
double delta_scalei = 0.0;
double delta_scalej = 0.0;
if( scalex_alternate ) {
delta_scalei = (double)(i%2);
} else {
if( scalex_cumulate ) { // Should the delta scales be cumulative (i.e. 1, 1+2, 1+2+3, ...)
delta_scalei = (double)(i*i + i)/2.0;
} else {
delta_scalei = (double)i;
}
}
if( scaley_alternate ) {
delta_scalej = (double)(j%2);
} else {
if( scaley_cumulate ) {
delta_scalej = (double)(j*j + j)/2.0;
} else {
delta_scalej = (double)j;
}
}
// Random scale, only calculate if non-zero.
double delta_scalex_rand = 0.0;
double delta_scaley_rand = 0.0;
// But if random factors are same, scale x and y proportionally
// Total delta scale
double scalex = 1.0 + scalex_per_i * delta_scalei + scalex_per_j * delta_scalej + delta_scalex_rand;
double scaley = 1.0 + scaley_per_i * delta_scalei + scaley_per_j * delta_scalej + delta_scaley_rand;
// Add exponential scale if necessary
// Add logarithmic factor if necessary
// Alternative using rotation angle
//if ( scalex_log != 1.0 ) scalex *= pow( scalex_log, M_PI*dr/180 );
//if ( scaley_log != 1.0 ) scaley *= pow( scaley_log, M_PI*dr/180 );
// Calculate transformation matrices, translating back to "center of tile" (rotation center) before transforming
Geom::Affine drot_c = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI*dr/180) * Geom::Translate(cx, cy);
Geom::Affine dscale_c = Geom::Translate(-cx, -cy) * Geom::Scale (scalex, scaley) * Geom::Translate(cx, cy);
Geom::Affine rotate_180_c = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI) * Geom::Translate(cx, cy);
Geom::Affine rotate_90_c = Geom::Translate(-cx, -cy) * Geom::Rotate (-M_PI/2) * Geom::Translate(cx, cy);
Geom::Affine rotate_m90_c = Geom::Translate(-cx, -cy) * Geom::Rotate ( M_PI/2) * Geom::Translate(cx, cy);
Geom::Affine rotate_120_c = Geom::Translate(-cx, -cy) * Geom::Rotate (-2*M_PI/3) * Geom::Translate(cx, cy);
Geom::Affine rotate_m120_c = Geom::Translate(-cx, -cy) * Geom::Rotate ( 2*M_PI/3) * Geom::Translate(cx, cy);
Geom::Affine rotate_60_c = Geom::Translate(-cx, -cy) * Geom::Rotate (-M_PI/3) * Geom::Translate(cx, cy);
Geom::Affine rotate_m60_c = Geom::Translate(-cx, -cy) * Geom::Rotate ( M_PI/3) * Geom::Translate(cx, cy);
// Create tile with required symmetry
switch (type) {
case TILE_P1:
return d_s_r * rect_translate;
break;
case TILE_P2:
if (i % 2 == 0) {
return d_s_r * rect_translate;
} else {
}
break;
case TILE_PM:
if (i % 2 == 0) {
return d_s_r * rect_translate;
} else {
}
break;
case TILE_PG:
if (j % 2 == 0) {
return d_s_r * rect_translate;
} else {
}
break;
case TILE_CM:
if ((i + j) % 2 == 0) {
return d_s_r * rect_translate;
} else {
}
break;
case TILE_PMM:
if (j % 2 == 0) {
if (i % 2 == 0) {
return d_s_r * rect_translate;
} else {
}
} else {
if (i % 2 == 0) {
} else {
}
}
break;
case TILE_PMG:
if (j % 2 == 0) {
if (i % 2 == 0) {
return d_s_r * rect_translate;
} else {
}
} else {
if (i % 2 == 0) {
} else {
}
}
break;
case TILE_PGG:
if (j % 2 == 0) {
if (i % 2 == 0) {
return d_s_r * rect_translate;
} else {
}
} else {
if (i % 2 == 0) {
} else {
}
}
break;
case TILE_CMM:
if (j % 4 == 0) {
if (i % 2 == 0) {
return d_s_r * rect_translate;
} else {
}
} else if (j % 4 == 1) {
if (i % 2 == 0) {
} else {
}
} else if (j % 4 == 2) {
if (i % 2 == 1) {
return d_s_r * rect_translate;
} else {
}
} else {
if (i % 2 == 1) {
} else {
}
}
break;
case TILE_P4:
{
Geom::Affine ori (Geom::Translate ((w + h) * pow((i/2), shiftx_exp) + dx, (h + w) * pow((j/2), shifty_exp) + dy));
if (j % 2 == 0) {
if (i % 2 == 0) {
} else {
}
} else {
if (i % 2 == 0) {
} else {
}
}
}
break;
case TILE_P4M:
{
Geom::Affine ori (Geom::Translate ((max + max) * pow((i/4), shiftx_exp) + dx, (max + max) * pow((j/2), shifty_exp) + dy));
if (j % 2 == 0) {
if (i % 4 == 0) {
} else if (i % 4 == 1) {
} else if (i % 4 == 2) {
} else if (i % 4 == 3) {
}
} else {
if (i % 4 == 0) {
} else if (i % 4 == 1) {
} else if (i % 4 == 2) {
} else if (i % 4 == 3) {
}
}
}
break;
case TILE_P4G:
{
Geom::Affine ori (Geom::Translate ((max + max) * pow((i/4), shiftx_exp) + dx, (max + max) * pow(j, shifty_exp) + dy));
if (((i/4) + j) % 2 == 0) {
if (i % 4 == 0) {
} else if (i % 4 == 1) {
} else if (i % 4 == 2) {
} else if (i % 4 == 3) {
}
} else {
if (i % 4 == 0) {
} else if (i % 4 == 1) {
} else if (i % 4 == 2) {
} else if (i % 4 == 3) {
}
}
}
break;
case TILE_P3:
{
double width;
double height;
if (w > h) {
} else {
height = h;
}
Geom::Affine ori (Geom::Translate (width * pow((2*(i/3) + j%2), shiftx_exp) + dx, (height/2) * pow(j, shifty_exp) + dy));
if (i % 3 == 0) {
} else if (i % 3 == 1) {
} else if (i % 3 == 2) {
}
}
break;
case TILE_P31M:
{
if (w > h) {
ori = Geom::Affine(Geom::Translate (w * pow((i/6) + 0.5*(j%2), shiftx_exp) + dx, (w * cos30) * pow(j, shifty_exp) + dy));
dia1 = Geom::Affine (Geom::Translate (0, h/2) * Geom::Translate (w/2, 0) * Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (-h/2 * cos30, -h/2 * sin30) );
} else {
ori = Geom::Affine (Geom::Translate (2*h * cos30 * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx, (2*h - h * sin30) * pow(j, shifty_exp) + dy));
}
if (i % 6 == 0) {
} else if (i % 6 == 1) {
} else if (i % 6 == 2) {
} else if (i % 6 == 3) {
} else if (i % 6 == 4) {
} else if (i % 6 == 5) {
}
}
break;
case TILE_P3M1:
{
double width;
double height;
if (w > h) {
dia1 = Geom::Affine (Geom::Translate (0, h/2) * Geom::Translate (w/2, 0) * Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (-h/2 * cos30, -h/2 * sin30) );
} else {
height = 2 * h;
}
Geom::Affine ori (Geom::Translate (width * pow((2*(i/6) + j%2), shiftx_exp) + dx, (height/2) * pow(j, shifty_exp) + dy));
if (i % 6 == 0) {
} else if (i % 6 == 1) {
} else if (i % 6 == 2) {
} else if (i % 6 == 3) {
} else if (i % 6 == 4) {
} else if (i % 6 == 5) {
}
}
break;
case TILE_P6:
{
if (w > h) {
ori = Geom::Affine(Geom::Translate (w * pow((2*(i/6) + (j%2)), shiftx_exp) + dx, (2*w * sin60) * pow(j, shifty_exp) + dy));
} else {
ori = Geom::Affine(Geom::Translate (2*h * cos30 * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx, (h + h * sin30) * pow(j, shifty_exp) + dy));
dia1 = Geom::Affine (Geom::Translate (-w/2, -h/2) * Geom::Translate (h/2 * cos30, -h/2 * sin30) * Geom::Translate (w/2 * cos60, w/2 * sin60));
dia2 = dia1 * Geom::Affine (Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (h/2 * cos30, -h/2 * sin30) * Geom::Translate (h/2 * cos30, h/2 * sin30) * Geom::Translate (-w/2 * cos60, w/2 * sin60));
dia3 = dia2 * Geom::Affine (Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (h/2 * cos30, h/2 * sin30) * Geom::Translate (-w/2, h/2));
}
if (i % 6 == 0) {
} else if (i % 6 == 1) {
} else if (i % 6 == 2) {
} else if (i % 6 == 3) {
} else if (i % 6 == 4) {
} else if (i % 6 == 5) {
}
}
break;
case TILE_P6M:
{
if (w > h) {
ori = Geom::Affine(Geom::Translate (w * pow((2*(i/12) + (j%2)), shiftx_exp) + dx, (2*w * sin60) * pow(j, shifty_exp) + dy));
dia1 = Geom::Affine (Geom::Translate (w/2, h/2) * Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (-h/2 * cos30, h/2 * sin30));
dia3 = dia2 * Geom::Affine (Geom::Translate (-h/2 * cos30, h/2 * sin30) * Geom::Translate (w * cos60, 0) * Geom::Translate (-h/2 * cos30, -h/2 * sin30));
dia5 = dia4 * Geom::Affine (Geom::Translate (-h/2 * cos30, -h/2 * sin30) * Geom::Translate (-w/2 * cos60, w/2 * sin60) * Geom::Translate (w/2, -h/2));
} else {
ori = Geom::Affine(Geom::Translate (4*h * cos30 * pow((i/12 + 0.5*(j%2)), shiftx_exp) + dx, (2*h + 2*h * sin30) * pow(j, shifty_exp) + dy));
dia1 = Geom::Affine (Geom::Translate (-w/2, -h/2) * Geom::Translate (h/2 * cos30, -h/2 * sin30) * Geom::Translate (w/2 * cos60, w/2 * sin60));
dia3 = dia2 * Geom::Affine (Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (h * cos30, 0) * Geom::Translate (-w/2 * cos60, w/2 * sin60));
dia5 = dia4 * Geom::Affine (Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (h/2 * cos30, h/2 * sin30) * Geom::Translate (-w/2, h/2));
}
if (i % 12 == 0) {
} else if (i % 12 == 1) {
} else if (i % 12 == 2) {
} else if (i % 12 == 3) {
} else if (i % 12 == 4) {
} else if (i % 12 == 5) {
} else if (i % 12 == 6) {
} else if (i % 12 == 7) {
} else if (i % 12 == 8) {
} else if (i % 12 == 9) {
} else if (i % 12 == 10) {
} else if (i % 12 == 11) {
}
}
break;
default:
break;
}
}
{
bool result = false;
if (obj) {
}
{
result = true;
} else {
result = false;
}
if (id_href) {
id_href = 0;
}
return result;
}
static unsigned trace_visionkey;
static NRArenaItem *trace_root;
static gdouble trace_zoom;
static SPDocument *trace_doc;
{
if (!trace_arena)
return;
}
}
{
/* Create ArenaItem and set transform */
trace_root = SP_ITEM(trace_doc->getRoot())->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY);
// hide the (current) original and any tiled clones, we only want to pick the background
trace_zoom = zoom;
}
{
if (!trace_arena) {
return 0;
}
/* Item integer bbox in points */
/* Find visible area */
double R = 0, G = 0, B = 0, A = 0;
/* Render */
ink_cairo_surface_average_color(s, R, G, B, A);
return SP_RGBA32_F_COMPOSE (R, G, B, A);
}
static void clonetiler_trace_finish()
{
if (trace_doc) {
}
if (trace_arena) {
trace_arena = NULL;
}
}
{
return;
}
// check if something is selected
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump."));
return;
}
}
}
_("Unclump tiled clones"));
}
{
guint n = 0;
n ++;
}
}
return n;
}
{
return;
}
// check if something is selected
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
return;
}
// remove old tiling
}
}
}
if (do_undo) {
_("Delete tiled clones"));
}
}
{
using Geom::X;
using Geom::Y;
}
/**
Randomizes \a val by \a rand, with 0 < val < 1 and all values (including 0, 1) having the same
probability of being displaced.
*/
{
if (base < 0) {
base = 0;
}
return CLAMP(val, 0, 1); // this should be unnecessary with the above provisions, but just in case...
}
{
return;
}
// check if something is selected
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object</b> to clone."));
return;
}
// Check if more than one object is selected.
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>."));
return;
}
// set "busy" cursor
// set statusbar text
double shiftx_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_i", 0, -10000, 10000);
double shifty_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_i", 0, -10000, 10000);
double shiftx_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_j", 0, -10000, 10000);
double shifty_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_j", 0, -10000, 10000);
double saturation_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "saturation_per_j", 0, -100, 100);
double saturation_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "saturation_per_i", 0, -100, 100);
double lightness_per_j = 0.01 * prefs->getDoubleLimited(prefs_path + "lightness_per_j", 0, -100, 100);
double lightness_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "lightness_per_i", 0, -100, 100);
if (dotrace) {
}
double w;
double h;
double x0;
double y0;
if (keepbbox &&
} else {
if (r) {
w = r->dimensions()[Geom::X];
h = r->dimensions()[Geom::Y];
} else {
w = h = 0;
}
}
double perimeter_original = (w + h)/4;
// The integers i and j are reserved for tile column and row.
// The doubles x and y are used for coordinates
for (int i = 0;
(fabs(cur[Geom::X]) < fillwidth && i < 200) // prevent "freezing" with too large fillrect, arbitrarily limit rows
: (i < imax);
i ++) {
for (int j = 0;
(fabs(cur[Geom::Y]) < fillheight && j < 200) // prevent "freezing" with too large fillrect, arbitrarily limit cols
: (j < jmax);
j ++) {
// Note: We create a clone at 0,0 too, right over the original, in case our clones are colored
// Get transform from symmetry, shift, scale, rotation
if (fillrect) {
continue;
}
}
// Color tab
if (!initial_color.empty()) {
float hsl[3];
double notused;
hsl[1] += saturation_per_i * eff_i + saturation_per_j * eff_j + saturation_rand * g_random_double_range (-1, 1);
hsl[2] += lightness_per_i * eff_i + lightness_per_j * eff_j + lightness_rand * g_random_double_range (-1, 1);
float rgb[3];
sp_svg_write_color(color_string, sizeof(color_string), SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1.0));
}
// Blur
double blur = 0.0;
{
}
// Opacity
double opacity = 1.0;
{
opacity = 1 - (opacity_per_i * eff_i + opacity_per_j * eff_j + opacity_rand * g_random_double_range (-1, 1));
}
// Trace tab
if (dotrace) {
float r = SP_RGBA32_R_F(rgba);
float g = SP_RGBA32_G_F(rgba);
float b = SP_RGBA32_B_F(rgba);
float a = SP_RGBA32_A_F(rgba);
float hsl[3];
sp_color_rgb_to_hsl_floatv (hsl, r, g, b);
switch (pick) {
case PICK_COLOR:
break;
case PICK_OPACITY:
val = a;
break;
case PICK_R:
val = r;
break;
case PICK_G:
val = g;
break;
case PICK_B:
val = b;
break;
case PICK_H:
break;
case PICK_S:
break;
case PICK_L:
break;
default:
break;
}
if (rand_picked > 0) {
r = randomize01 (r, rand_picked);
g = randomize01 (g, rand_picked);
b = randomize01 (b, rand_picked);
}
if (gamma_picked != 0) {
double power;
if (gamma_picked > 0)
else
}
if (invert_picked) {
r = 1 - r;
g = 1 - g;
b = 1 - b;
}
r = CLAMP (r, 0, 1);
g = CLAMP (g, 0, 1);
b = CLAMP (b, 0, 1);
// recompose tweaked color
rgba = SP_RGBA32_F_COMPOSE(r, g, b, a);
if (pick_to_presence) {
continue; // skip!
}
}
if (pick_to_size) {
t = Geom::Translate(-center[Geom::X], -center[Geom::Y]) * Geom::Scale (val, val) * Geom::Translate(center[Geom::X], center[Geom::Y]) * t;
}
if (pick_to_opacity) {
}
if (pick_to_color) {
}
}
continue;
}
continue;
}
// Create the clone
bool center_set = false;
if (obj_repr->attribute("inkscape:transform-center-x") || obj_repr->attribute("inkscape:transform-center-y")) {
center_set = true;
}
if (opacity < 1.0) {
}
if (*color_string) {
}
// add the new clone to the top of the original's parent
if (blur > 0.0) {
// this is necessary for all newly added clones to have correct bboxes,
// otherwise filters won't work:
// that we can take bbox of; however here we only need a lower bound so that blur
// margins are not too small, and the perimeter should work
SPFilter *constructed = new_filter_gaussian_blur(sp_desktop_document(desktop), radius, t.descrim(), t.expansionX(), t.expansionY(), perimeter, perimeter);
}
if (center_set) {
}
}
}
}
if (dotrace) {
}
_("Create tiled clones"));
}
{
return vb;
}
{
}
{
GtkWidget *b = gtk_check_button_new ();
return hb;
}
{
}
static GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false)
{
{
GtkObject *a;
if (exponent) {
} else {
}
if (exponent) {
} else {
}
if (exponent) {
} else {
}
}
{
}
return hb;
}
{
}
{
}
{
}
{
}
static void clonetiler_reset_recursive(GtkWidget *w)
{
if (w && GTK_IS_OBJECT(w)) {
{
if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton
gtk_adjustment_set_value (a, 0);
}
}
{
if (r && GTK_IS_SPIN_BUTTON(w)) { // spinbutton
gtk_adjustment_set_value (a, 1);
}
}
{
if (r && GTK_IS_TOGGLE_BUTTON(w)) { // checkbox
}
}
}
if (GTK_IS_CONTAINER(w)) {
}
g_list_free (ch);
}
}
{
}
static void clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col)
{
gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 );
}
{
{
}
{
}
{
}
return table;
}
{
}
{
if (rowscols) {
}
if (widthheight) {
}
}
{
if (rowscols) {
}
if (widthheight) {
}
}
{
}
{
}
{
if (vvb) {
}
}
void clonetiler_dialog(void)
{
if (!dlg)
{
if (x == -1000 || y == -1000) {
}
if (w ==0 || h == 0) {
}
// if (x<0) x=0;
// if (y<0) y=0;
if (w && h) {
}
if (x >= 0 && y >= 0 && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE))) {
} else {
}
g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
// Symmetry
{
/* TRANSLATORS: For the following 17 symmetry groups, see
* http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples);
* http://www.clarku.edu/~djoyce/wallpaper/seventeen.html (English vocabulary); or
* http://membres.lycos.fr/villemingerard/Geometri/Sym1D.htm (French vocabulary).
*/
struct SymGroups {
} const sym_groups[] = {
// TRANSLATORS: "translation" means "shift" / "displacement" here.
{TILE_P1, _("<b>P1</b>: simple translation")},
{TILE_P2, _("<b>P2</b>: 180° rotation")},
{TILE_PM, _("<b>PM</b>: reflection")},
// TRANSLATORS: "glide reflection" is a reflection and a translation combined.
// For more info, see http://mathforum.org/sum95/suzanne/symsusan.html
{TILE_PG, _("<b>PG</b>: glide reflection")},
{TILE_CM, _("<b>CM</b>: reflection + glide reflection")},
{TILE_PMM, _("<b>PMM</b>: reflection + reflection")},
{TILE_PMG, _("<b>PMG</b>: reflection + 180° rotation")},
{TILE_PGG, _("<b>PGG</b>: glide reflection + 180° rotation")},
{TILE_CMM, _("<b>CMM</b>: reflection + reflection + 180° rotation")},
{TILE_P4, _("<b>P4</b>: 90° rotation")},
{TILE_P4M, _("<b>P4M</b>: 90° rotation + 45° reflection")},
{TILE_P4G, _("<b>P4G</b>: 90° rotation + 90° reflection")},
{TILE_P3, _("<b>P3</b>: 120° rotation")},
{TILE_P31M, _("<b>P31M</b>: reflection + 120° rotation, dense")},
{TILE_P3M1, _("<b>P3M1</b>: reflection + 120° rotation, sparse")},
{TILE_P6, _("<b>P6</b>: 60° rotation")},
{TILE_P6M, _("<b>P6M</b>: reflection + 60° rotation")},
};
// Create a list structure containing all the data to be displayed in
// the symmetry group combo box.
for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) {
// Add the description of the symgroup to a new row
-1);
}
// Add a new combo box widget with the list of symmetry groups to the vbox
// Specify the rendering of data from the list in a combo box cell
"markup", 0,
NULL);
NULL);
}
// Shift
{
// X
{
// TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount
// xgettext:no-c-format
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Horizontal shift per row (in % of tile width)"), "shiftx_per_j",
-10000, 10000, "%");
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Horizontal shift per column (in % of tile width)"), "shiftx_per_i",
-10000, 10000, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand",
0, 1000, "%");
}
// Y
{
// TRANSLATORS: "shift" means: the tiles will be shifted (offset) vertically by this amount
// xgettext:no-c-format
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Vertical shift per row (in % of tile height)"), "shifty_per_j",
-10000, 10000, "%");
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Vertical shift per column (in % of tile height)"), "shifty_per_i",
-10000, 10000, "%");
}
{
GtkWidget *l = clonetiler_spinbox (
_("Randomize the vertical shift by this percentage"), "shifty_rand",
0, 1000, "%");
}
// Exponent
{
}
{
GtkWidget *l = clonetiler_spinbox (
_("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp",
0, 10, "", true);
}
{
GtkWidget *l = clonetiler_spinbox (
_("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp",
0, 10, "", true);
}
{ // alternates
// TRANSLATORS: "Alternate" is a verb here
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate");
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate");
}
{ // Cumulate
// TRANSLATORS: "Cumulate" is a verb here
}
{
}
{
}
{ // Exclude tile width and height in shift
// TRANSLATORS: "Cumulate" is a verb here
}
{
}
{
}
}
// Scale
{
// X
{
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Horizontal scale per row (in % of tile width)"), "scalex_per_j",
-100, 1000, "%");
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Horizontal scale per column (in % of tile width)"), "scalex_per_i",
-100, 1000, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand",
0, 1000, "%");
}
// Y
{
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Vertical scale per row (in % of tile height)"), "scaley_per_j",
-100, 1000, "%");
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Vertical scale per column (in % of tile height)"), "scaley_per_i",
-100, 1000, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand",
0, 1000, "%");
}
// Exponent
{
}
{
GtkWidget *l = clonetiler_spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp",
0, 10, "", true);
}
{
GtkWidget *l = clonetiler_spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp",
0, 10, "", true);
}
// Logarithmic (as in logarithmic spiral)
{
}
{
GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log",
0, 10, "", false);
}
{
GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log",
0, 10, "", false);
}
{ // alternates
// TRANSLATORS: "Alternate" is a verb here
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate");
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate");
}
{ // Cumulate
// TRANSLATORS: "Cumulate" is a verb here
}
{
}
{
}
}
// Rotation
{
// Angle
{
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Rotate tiles by this angle for each row"), "rotate_per_j",
-180, 180, "°");
}
{
GtkWidget *l = clonetiler_spinbox (
// xgettext:no-c-format
_("Rotate tiles by this angle for each column"), "rotate_per_i",
-180, 180, "°");
}
{
GtkWidget *l = clonetiler_spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand",
0, 100, "%");
}
{ // alternates
// TRANSLATORS: "Alternate" is a verb here
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej");
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei");
}
{ // Cumulate
// TRANSLATORS: "Cumulate" is a verb here
}
{
}
{
GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei");
}
}
// Blur and opacity
{
// Blur
{
}
{
0, 100, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i",
0, 100, "%");
}
{
0, 100, "%");
}
{ // alternates
// TRANSLATORS: "Alternate" is a verb here
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej");
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei");
}
// Dissolve
{
}
{
GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j",
0, 100, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i",
0, 100, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand",
0, 100, "%");
}
{ // alternates
// TRANSLATORS: "Alternate" is a verb here
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej");
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei");
}
}
// Color
{
{
guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff);
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);
gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0);
}
// Hue
{
}
{
GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j",
-100, 100, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i",
-100, 100, "%");
}
{
0, 100, "%");
}
// Saturation
{
}
{
GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j",
-100, 100, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i",
-100, 100, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand",
0, 100, "%");
}
// Lightness
{
}
{
GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j",
-100, 100, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i",
-100, 100, "%");
}
{
GtkWidget *l = clonetiler_spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand",
0, 100, "%");
}
{ // alternates
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej");
}
{
GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei");
}
}
// Trace
{
{
gtk_widget_set_tooltip_text (b, _("For each clone, pick a value from the drawing in that clone's location and apply it to the clone"));
}
{
{
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S);
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L);
}
}
{
{
}
{
GtkWidget *l = clonetiler_spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked",
-10, 10, "");
}
{
}
{
GtkWidget *l = clonetiler_spinbox (_("Randomize the picked value by this percentage"), "rand_picked",
0, 100, "%");
}
{
}
{
}
}
{
{
gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point"));
}
{
gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point"));
}
{
gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)"));
}
{
gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point"));
}
}
}
}
{
{
{
}
{
}
{
}
}
{
// unitmenu
sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units);
{
// Width spinbutton
gtk_widget_set_tooltip_text (e, _("Width of the rectangle to be filled"));
}
{
}
{
// Height spinbutton
gtk_widget_set_tooltip_text (e, _("Height of the rectangle to be filled"));
}
}
// Switch
{
g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) dlg);
}
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: "));
g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) dlg);
}
}
}
// Use saved pos
{
gtk_widget_set_tooltip_text (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"));
}
// Statusbar
{
}
// Buttons
{
{
GtkWidget *b = gtk_button_new ();
gtk_container_add (GTK_CONTAINER(b), l);
gtk_widget_set_tooltip_text (b, _("Create and tile the clones of the selection"));
}
{ // buttons which are enabled only when there are tiled clones
{
// TRANSLATORS: if a group of objects are "clumped" together, then they
// are unevenly spread in the given amount of space - as shown in the
// diagrams on the left in the following screenshot:
// So unclumping is the process of spreading a number of objects out more evenly.
gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly"));
}
{
gtk_widget_set_tooltip_text (b, _("Remove existing tiled clones of the selected object (siblings only)"));
}
// connect to global selection changed signal (so we can change desktops) and
// external_change (so we're not fooled by undo)
g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (clonetiler_change_selection), dlg);
g_signal_connect (G_OBJECT (INKSCAPE), "external_change", G_CALLBACK (clonetiler_external_change), dlg);
g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), G_OBJECT (INKSCAPE));
// update now
}
{
// TRANSLATORS: "change" is a noun here
gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero"));
}
}
} // end of if (!dlg)
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :