clonetiler.cpp revision 6c3e745a94ef6b25a4ef9f018d350a7535aa45af
/** @file
* Clone tiling dialog
*/
/* Authors:
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <goejendaagh@zonnet.nl>
*
* 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 "application/application.h"
#include "application/editor.h"
#include "helper/unit-menu.h"
#include "../inkscape.h"
#include "preferences.h"
#include "dialog-events.h"
#include "../macros.h"
#include "../verbs.h"
#include "../interface.h"
#include "../selection.h"
#include "../style.h"
#include "../desktop.h"
#include "../desktop-handles.h"
#include "../sp-namedview.h"
#include "../document.h"
#include "../message-stack.h"
#include "../sp-use.h"
#include "unclump.h"
#include "svg/svg-color.h"
#include "libnr/nr-matrix-fns.h"
#include "libnr/nr-matrix-ops.h"
#include "libnr/nr-matrix-translate-ops.h"
#include "libnr/nr-translate-ops.h"
#include "libnr/nr-translate-rotate-ops.h"
#include "libnr/nr-translate-scale-ops.h"
#include "display/nr-arena.h"
#include "display/nr-arena-item.h"
#include "ui/widget/color-picker.h"
#include "../sp-filter.h"
#include "../filter-chemistry.h"
#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 {
};
static void
{
{
} else {
}
delete color_picker;
}
static gboolean
{
if (x<0) x=0;
if (y<0) y=0;
return FALSE; // which means, go ahead and destroy it
}
static void on_delete()
{
(void)clonetiler_dialog_delete (0, 0, NULL);
}
static void
{
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 {
}
}
static void
{
}
}
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::Matrix drot_c = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI*dr/180) * Geom::Translate(cx, cy);
Geom::Matrix dscale_c = Geom::Translate(-cx, -cy) * Geom::Scale (scalex, scaley) * Geom::Translate(cx, cy);
Geom::Matrix rotate_180_c = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI) * Geom::Translate(cx, cy);
Geom::Matrix rotate_90_c = Geom::Translate(-cx, -cy) * Geom::Rotate (-M_PI/2) * Geom::Translate(cx, cy);
Geom::Matrix rotate_m90_c = Geom::Translate(-cx, -cy) * Geom::Rotate ( M_PI/2) * Geom::Translate(cx, cy);
Geom::Matrix rotate_120_c = Geom::Translate(-cx, -cy) * Geom::Rotate (-2*M_PI/3) * Geom::Translate(cx, cy);
Geom::Matrix rotate_m120_c = Geom::Translate(-cx, -cy) * Geom::Rotate ( 2*M_PI/3) * Geom::Translate(cx, cy);
Geom::Matrix rotate_60_c = Geom::Translate(-cx, -cy) * Geom::Rotate (-M_PI/3) * Geom::Translate(cx, cy);
Geom::Matrix 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::Matrix 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::Matrix 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::Matrix 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::Matrix 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::Matrix(Geom::Translate (w * pow((i/6) + 0.5*(j%2), shiftx_exp) + dx, (w * cos30) * pow(j, shifty_exp) + dy));
dia1 = Geom::Matrix (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::Matrix (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::Matrix (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::Matrix 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::Matrix(Geom::Translate (w * pow((2*(i/6) + (j%2)), shiftx_exp) + dx, (2*w * sin60) * pow(j, shifty_exp) + dy));
} else {
ori = Geom::Matrix(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::Matrix (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::Matrix (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::Matrix (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::Matrix(Geom::Translate (w * pow((2*(i/12) + (j%2)), shiftx_exp) + dx, (2*w * sin60) * pow(j, shifty_exp) + dy));
dia1 = Geom::Matrix (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::Matrix (Geom::Translate (-h/2 * cos30, h/2 * sin30) * Geom::Translate (w * cos60, 0) * Geom::Translate (-h/2 * cos30, -h/2 * sin30));
dia5 = dia4 * Geom::Matrix (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::Matrix(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::Matrix (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::Matrix (Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (h * cos30, 0) * Geom::Translate (-w/2 * cos60, w/2 * sin60));
dia5 = dia4 * Geom::Matrix (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;
}
}
static bool
{
if (obj) {
}
{
if (id_href)
return true;
} else {
if (id_href)
return false;
}
}
static unsigned trace_visionkey;
static NRArenaItem *trace_root;
static gdouble trace_zoom;
static SPDocument *trace_doc;
static void
{
if (!trace_arena)
return;
}
}
static void
{
/* Create ArenaItem and set transform */
// hide the (current) original and any tiled clones, we only want to pick the background
trace_zoom = zoom;
}
static guint32
{
if (!trace_arena)
return 0;
/* Item integer bbox in points */
/* Find visible area */
/* Set up pixblock */
return 0; // buffer is too big or too small, cannot pick, so return 0
}
/* Render */
double R = 0, G = 0, B = 0, A = 0;
double count = 0;
double weight = 0;
count += 1;
R += s[0] / 255.0;
G += s[1] / 255.0;
B += s[2] / 255.0;
A += s[3] / 255.0;
s += 4;
}
}
R = R / weight;
G = G / weight;
B = B / weight;
A = A / count;
return SP_RGBA32_F_COMPOSE (R, G, B, A);
}
static void
{
if (trace_doc) {
}
if (trace_arena) {
trace_arena = NULL;
}
}
static void
{
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;
}
for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
}
}
_("Unclump tiled clones"));
}
static guint
{
guint n = 0;
for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
n ++;
}
}
return n;
}
static void
{
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
for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) {
}
}
}
if (do_undo)
_("Delete tiled clones"));
}
{
using NR::X;
using NR::Y;
}
/**
Randomizes \a val by \a rand, with 0 < val < 1 and all values (including 0, 1) having the same
probability of being displaced.
*/
static double
{
return CLAMP(val, 0, 1); // this should be unnecessary with the above provisions, but just in case...
}
static void
{
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[NR::X]) < fillwidth && i < 200) // prevent "freezing" with too large fillrect, arbitrarily limit rows
: (i < imax);
i ++) {
for (int j = 0;
(fabs(cur[NR::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, NR::expansion(t), NR::expansionX(t), NR::expansionY(t), perimeter, perimeter);
}
if (center_set) {
}
}
}
}
if (dotrace) {
}
_("Create tiled clones"));
}
static GtkWidget *
{
return vb;
}
static void
{
}
static GtkWidget *
{
GtkWidget *b = gtk_check_button_new ();
return hb;
}
static void
{
}
static GtkWidget *
clonetiler_spinbox (GtkTooltips *tt, 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
{
}
static void
{
}
static void
{
}
static void
{
}
static void
{
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
{
}
static void
{
gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, (GtkAttachOptions)4, (GtkAttachOptions)0, 0, 0 );
}
static GtkWidget *
{
{
}
{
}
{
}
return table;
}
static void
{
}
static void
{
if (rowscols) {
}
if (widthheight) {
}
}
static void
{
if (rowscols) {
}
if (widthheight) {
}
}
static void
{
}
static void
{
}
static void
{
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 {
}
{
_dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::bind (&on_dialog_hide, dlg));
_dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::bind (&on_dialog_unhide, dlg));
_desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::bind (&on_transientize, &wd));
} 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).
*/
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), om, _("Select one of the 17 symmetry groups for the tiling"), NULL);
GtkWidget *m = gtk_menu_new ();
struct SymGroups {
int group;
} 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")},
};
for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) {
}
}
// Shift
{
// X
{
// TRANSLATORS: "shift" means: the tiles will be shifted (offset) horizontally by this amount
// xgettext:no-c-format
}
{
// xgettext:no-c-format
_("Horizontal shift per row (in % of tile width)"), "shiftx_per_j",
-10000, 10000, "%");
}
{
// xgettext:no-c-format
_("Horizontal shift per column (in % of tile width)"), "shiftx_per_i",
-10000, 10000, "%");
}
{
_("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
}
{
// xgettext:no-c-format
_("Vertical shift per row (in % of tile height)"), "shifty_per_j",
-10000, 10000, "%");
}
{
// xgettext:no-c-format
_("Vertical shift per column (in % of tile height)"), "shifty_per_i",
-10000, 10000, "%");
}
{
_("Randomize the vertical shift by this percentage"), "shifty_rand",
0, 1000, "%");
}
// Exponent
{
}
{
_("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp",
0, 10, "", true);
}
{
_("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 (tt, _("Alternate the sign of shifts for each row"), "shifty_alternate");
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of shifts for each column"), "shiftx_alternate");
}
{ // Cumulate
// TRANSLATORS: "Cumulate" is a verb here
}
{
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the shifts for each column"), "shiftx_cumulate");
}
{ // Exclude tile width and height in shift
// TRANSLATORS: "Cumulate" is a verb here
}
{
}
{
}
}
// Scale
{
// X
{
}
{
// xgettext:no-c-format
_("Horizontal scale per row (in % of tile width)"), "scalex_per_j",
-100, 1000, "%");
}
{
// xgettext:no-c-format
_("Horizontal scale per column (in % of tile width)"), "scalex_per_i",
-100, 1000, "%");
}
{
_("Randomize the horizontal scale by this percentage"), "scalex_rand",
0, 1000, "%");
}
// Y
{
}
{
// xgettext:no-c-format
_("Vertical scale per row (in % of tile height)"), "scaley_per_j",
-100, 1000, "%");
}
{
// xgettext:no-c-format
_("Vertical scale per column (in % of tile height)"), "scaley_per_i",
-100, 1000, "%");
}
{
_("Randomize the vertical scale by this percentage"), "scaley_rand",
0, 1000, "%");
}
// Exponent
{
}
{
_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp",
0, 10, "", true);
}
{
_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp",
0, 10, "", true);
}
// Logarithmic (as in logarithmic spiral)
{
}
{
_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log",
0, 10, "", false);
}
{
_("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 (tt, _("Alternate the sign of scales for each row"), "scaley_alternate");
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of scales for each column"), "scalex_alternate");
}
{ // Cumulate
// TRANSLATORS: "Cumulate" is a verb here
}
{
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the scales for each column"), "scalex_cumulate");
}
}
// Rotation
{
// Angle
{
}
{
// xgettext:no-c-format
_("Rotate tiles by this angle for each row"), "rotate_per_j",
-180, 180, "°");
}
{
// xgettext:no-c-format
_("Rotate tiles by this angle for each column"), "rotate_per_i",
-180, 180, "°");
}
{
_("Randomize the rotation angle by this percentage"), "rotate_rand",
0, 100, "%");
}
{ // alternates
// TRANSLATORS: "Alternate" is a verb here
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each row"), "rotate_alternatej");
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the rotation direction for each column"), "rotate_alternatei");
}
{ // Cumulate
// TRANSLATORS: "Cumulate" is a verb here
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the rotation for each row"), "rotate_cumulatej");
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Cumulate the rotation for each column"), "rotate_cumulatei");
}
}
// Blur and opacity
{
// Blur
{
}
{
_("Blur tiles by this percentage for each row"), "blur_per_j",
0, 100, "%");
}
{
_("Blur tiles by this percentage for each column"), "blur_per_i",
0, 100, "%");
}
{
_("Randomize the tile blur by this percentage"), "blur_rand",
0, 100, "%");
}
{ // alternates
// TRANSLATORS: "Alternate" is a verb here
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each row"), "blur_alternatej");
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of blur change for each column"), "blur_alternatei");
}
// Dissolve
{
}
{
_("Decrease tile opacity by this percentage for each row"), "opacity_per_j",
0, 100, "%");
}
{
_("Decrease tile opacity by this percentage for each column"), "opacity_per_i",
0, 100, "%");
}
{
_("Randomize the tile opacity by this percentage"), "opacity_rand",
0, 100, "%");
}
{ // alternates
// TRANSLATORS: "Alternate" is a verb here
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of opacity change for each row"), "opacity_alternatej");
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("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
{
}
{
_("Change the tile hue by this percentage for each row"), "hue_per_j",
-100, 100, "%");
}
{
_("Change the tile hue by this percentage for each column"), "hue_per_i",
-100, 100, "%");
}
{
_("Randomize the tile hue by this percentage"), "hue_rand",
0, 100, "%");
}
// Saturation
{
}
{
_("Change the color saturation by this percentage for each row"), "saturation_per_j",
-100, 100, "%");
}
{
_("Change the color saturation by this percentage for each column"), "saturation_per_i",
-100, 100, "%");
}
{
_("Randomize the color saturation by this percentage"), "saturation_rand",
0, 100, "%");
}
// Lightness
{
}
{
_("Change the color lightness by this percentage for each row"), "lightness_per_j",
-100, 100, "%");
}
{
_("Change the color lightness by this percentage for each column"), "lightness_per_i",
-100, 100, "%");
}
{
_("Randomize the color lightness by this percentage"), "lightness_rand",
0, 100, "%");
}
{ // alternates
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each row"), "color_alternatej");
}
{
GtkWidget *l = clonetiler_checkbox (tt, _("Alternate the sign of color changes for each column"), "color_alternatei");
}
}
// Trace
{
{
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);
}
{
{
{
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_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_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_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_group (GTK_RADIO_BUTTON (radio)), _("B"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B);
}
{
//TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|H"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H);
}
{
//TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|S"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S);
}
{
//TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|L"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L);
}
}
{
{
}
{
_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked",
-10, 10, "");
}
{
}
{
_("Randomize the picked value by this percentage"), "rand_picked",
0, 100, "%");
}
{
}
{
}
}
{
{
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone is created with the probability determined by the picked value in that point"), NULL);
}
{
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's size is determined by the picked value in that point"), NULL);
}
{
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);
}
{
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), b, _("Each clone's opacity is determined by the picked value in that point"), NULL);
}
}
}
}
{
{
{
}
{
}
{
}
}
{
// unitmenu
sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units);
{
// Width spinbutton
}
{
}
{
// Height spinbutton
}
}
// Switch
{
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Create the specified number of rows and columns"), NULL);
gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_create), (gpointer) dlg);
}
}
{
radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), _("Width, height: "));
gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Fill the specified width and height with the tiling"), NULL);
gtk_signal_connect (GTK_OBJECT (radio), "toggled", GTK_SIGNAL_FUNC (clonetiler_switch_to_fill), (gpointer) dlg);
}
}
}
// Use saved pos
{
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);
}
// Statusbar
{
}
// Buttons
{
{
GtkWidget *b = gtk_button_new ();
gtk_container_add (GTK_CONTAINER(b), l);
}
{ // 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_tooltips_set_tip (tt, b, _("Spread out clones to reduce clumping; can be applied repeatedly"), NULL);
}
{
gtk_tooltips_set_tip (tt, b, _("Remove existing tiled clones of the selected object (siblings only)"), NULL);
}
// 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_tooltips_set_tip (tt, b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero"), NULL);
}
}
} // 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:encoding=utf-8:textwidth=99 :