/**
* @file
* Clone tiling dialog
*/
/* Authors:
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <goejendaagh@zonnet.nl>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
* Romain de Bossoreille
*
* Copyright (C) 2004-2011 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "clonetiler.h"
#include <climits>
#include <gtkmm/adjustment.h>
#include "desktop.h"
#include "display/cairo-utils.h"
#include "display/drawing-context.h"
#include "display/drawing-item.h"
#include "document.h"
#include "document-undo.h"
#include "filter-chemistry.h"
#include "ui/widget/unit-menu.h"
#include "inkscape.h"
#include "ui/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/spinbutton.h"
#include "unclump.h"
#include "verbs.h"
#include "sp-root.h"
using Inkscape::DocumentUndo;
namespace Inkscape {
namespace UI {
namespace Dialog {
static unsigned trace_visionkey;
deskTrack(),
{
contents->set_spacing(0);
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
nb = gtk_notebook_new ();
// 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
}
// 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
}
// 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
{
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
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 or on spray tool in copy mode)")), 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
{
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
b = gtk_check_button_new_with_label (_("Trace the drawing under the clones/sprayed items"));
gtk_widget_set_tooltip_text (b, _("For each clone/sprayed item, pick a value from the drawing in its location and apply it"));
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
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);
}
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
}
{
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, "%");
}
{
}
{
}
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
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"));
}
}
}
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
// TODO: C++ification
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
{
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
// TODO: C++ification
}
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
// unitmenu
unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::clonetiler_unit_changed));
{
// Width spinbutton
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
e->set_tooltip_text (_("Width of the rectangle to be filled"));
e->set_width_chars (7);
e->set_digits (4);
// TODO: C++ification
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
{
// Height spinbutton
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
#else
#endif
e->set_tooltip_text (_("Height of the rectangle to be filled"));
e->set_width_chars (7);
e->set_digits (4);
// TODO: C++ification
}
}
// 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
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
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
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
// Buttons
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
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
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
// 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)
selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg));
externChangedConn = INKSCAPE.signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg));
// 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"));
}
}
}
show_all();
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &CloneTiler::setTargetDesktop) );
}
CloneTiler::~CloneTiler (void)
{
//subselChangedConn.disconnect();
//selectChangedConn.disconnect();
//selectModifiedConn.disconnect();
}
{
}
{
if (this->desktop) {
//selectModifiedConn.disconnect();
//subselChangedConn.disconnect();
//selectChangedConn.disconnect();
}
//selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection)));
//subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection)));
//selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection)));
}
}
}
{
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;
}
{
return;
}
return;
}
if (n > 0) {
} else {
}
}
{
}
{
}
// 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) -------------
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.
// 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) ------------
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;
}
}
// Scale (times the original) -----------
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.
// 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;
}
{
if (!trace_drawing)
return;
}
}
}
{
/* Create ArenaItem and set transform */
trace_drawing->setRoot(trace_doc->getRoot()->invoke_show(*trace_drawing, 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_drawing) {
return 0;
}
trace_drawing->update();
/* Item integer bbox in points */
/* Find visible area */
/* Render */
double R = 0, G = 0, B = 0, A = 0;
ink_cairo_surface_average_color(s, R, G, B, A);
return SP_RGBA32_F_COMPOSE (R, G, B, A);
}
{
if (trace_doc) {
delete trace_drawing;
}
}
{
return;
}
// check if something is selected
desktop->getMessageStack()->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
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove."));
return;
}
// remove old tiling
}
}
obj->deleteObject();
}
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
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object</b> to clone."));
return;
}
// Check if more than one object is selected.
desktop->getMessageStack()->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
if (!obj) {
// Should never happen (empty selection checked above).
return;
}
double scale_units = Inkscape::Util::Quantity::convert(1, "px", &desktop->getDocument()->getSVGUnit());
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 = 0;
double h = 0;
double x0 = 0;
double y0 = 0;
if (keepbbox &&
double cx = 0;
double cy = 0;
} else {
if (r) {
} else {
w = h = 0;
}
}
// 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
Geom::Affine parent_transform = (((SPItem*)item->parent)->i2doc_affine())*(item->document->getRoot()->c2p.inverse());
if (fillrect) {
continue;
}
}
// Color tab
if (!initial_color.empty()) {
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);
sp_svg_write_color(color_string, sizeof(color_string), SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1.0));
}
// Blur
{
}
// Opacity
{
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);
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) {
* parent_transform.inverse() * 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(desktop->getDocument(), radius, t.descrim(), t.expansionX(), t.expansionY(), perimeter, perimeter);
}
if (center_set) {
if (clone_object && item) {
}
}
}
}
if (dotrace) {
}
_("Create tiled clones"));
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
return vb;
}
{
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
GtkWidget *b = gtk_check_button_new ();
return hb;
}
{
}
GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/)
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
#if WITH_GTKMM_3_0
if (exponent) {
} else {
}
#else
Gtk::Adjustment *a;
if (exponent) {
} else {
}
#endif
#if WITH_GTKMM_3_0
if (exponent) {
} else {
}
#else
if (exponent) {
} else {
}
#endif
// TODO: C++ification
if (exponent) {
} else {
}
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
return hb;
}
{
}
{
}
{
}
{
}
{
if (w && G_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);
}
}
{
}
void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col)
{
#if GTK_CHECK_VERSION(3,0,0)
#else
gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, GTK_FILL, (GtkAttachOptions)0, 0, 0 );
#endif
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
{
}
return table;
}
{
}
{
if (rowscols) {
}
if (widthheight) {
}
}
{
if (rowscols) {
}
if (widthheight) {
}
}
void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u)
{
}
void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u)
{
}
{
}
{
if (vvb) {
}
}
{
gtk_toggle_button_set_active ((GtkToggleButton *) b, false);
}
}
}
}
/*
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 :