2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Spiral aux toolbar
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * MenTaLguY <mental@rydia.net>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Lauris Kaplinski <lauris@kaplinski.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * bulia byak <buliabyak@users.sf.net>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Frank Felfe <innerspace@iname.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * John Cliff <simarilius@yahoo.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * David Turner <novalis@gnu.org>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Josh Andler <scislac@scislac.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Jon A. Cruz <jon@joncruz.org>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Maximilian Albert <maximilian.albert@gmail.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Tavmjong Bah <tavmjong@free.fr>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Abhishek Sharma
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Kris De Gussem <Kris.DeGussem@gmail.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Copyright (C) 2004 David Turner
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Copyright (C) 2003 MenTaLguY
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Copyright (C) 1999-2011 authors
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Copyright (C) 2001-2002 Ximian, Inc.
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Released under GNU GPL, read the file 'COPYING' for more information
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith//########################
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith//## Spiral ##
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith//########################
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustring const &value_name)
6b0fbf10b982696648debeede2b57f2b32a6a958Alex Valavanis SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith Inkscape::Preferences *prefs = Inkscape::Preferences::get();
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith prefs->setDouble("/tools/shapes/spiral/" + value_name,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // quit if run by the attr_changed listener
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // in turn, prevent listener from responding
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar* namespaced_name = g_strconcat("sodipodi:", value_name.data(), NULL);
acd93b79c034f4bcc8ff02de8aa877f70f081881Marc Jeanmougin std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
41c4ddd6064c35b849f347c88f4e39bb31d4ce62Kris De Gussem for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_SPIRAL,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Change spiral"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_revolution_value_changed(GtkAdjustment *adj, GObject *tbl)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_expansion_value_changed(GtkAdjustment *adj, GObject *tbl)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_t0_value_changed(GtkAdjustment *adj, GObject *tbl)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_defaults(GtkWidget * /*widget*/, GObject *obj)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // fixme: make settable
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(obj, "revolution"));
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(obj, "expansion"));
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(obj, "t0"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void spiral_tb_event_attr_changed(Inkscape::XML::Node *repr,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith bool /*is_interactive*/,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // quit if run by the _changed callbacks
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // in turn, prevent callbacks from responding
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE));
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "revolution"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_get_double(repr, "sodipodi:revolution", &revolution);
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "expansion"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_get_double(repr, "sodipodi:expansion", &expansion);
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "t0"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic Inkscape::XML::NodeEventVector spiral_tb_repr_events = {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl)
acd93b79c034f4bcc8ff02de8aa877f70f081881Marc Jeanmougin std::vector<SPItem*> itemlist=selection->itemList();
41c4ddd6064c35b849f347c88f4e39bb31d4ce62Kris De Gussem for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith EgeOutputAction* act = EGE_OUTPUT_ACTION( g_object_get_data( tbl, "mode_action" ) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set( G_OBJECT(act), "label", _("<b>New:</b>"), NULL );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set( G_OBJECT(act), "label", _("<b>Change:</b>"), NULL );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_add_listener(repr, &spiral_tb_repr_events, tbl);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_synthesize_events(repr, &spiral_tb_repr_events, tbl);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // FIXME: implement averaging of all parameters for multiple selected
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith //gtk_label_set_markup(GTK_LABEL(l), _("<b>Average:</b>"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set( G_OBJECT(act), "label", _("<b>Change:</b>"), NULL );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithvoid sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith EgeOutputAction* act = ege_output_action_new( "SpiralStateAction", _("<b>New:</b>"), "", 0 );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith /* Revolution */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar const* labels[] = {_("just a curve"), 0, _("one full revolution"), 0, 0, 0, 0, 0, 0};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gdouble values[] = {0.01, 0.5, 1, 2, 3, 5, 10, 20, 50, 100};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith eact = create_adjustment_action( "SpiralRevolutionAction",
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Number of turns"), _("Turns:"), _("Number of revolutions"),
bf9ec3e969ba6b11cbbc613545aedc63cc886973Matthew Petroff GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-spiral",
add38d633bbf8ef881bdb908735ea27385c554b8Matthew Petroff sp_spl_tb_revolution_value_changed, NULL /*unit tracker*/, 1, 2);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith /* Expansion */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar const* labels[] = {_("circle"), _("edge is much denser"), _("edge is denser"), _("even"), _("center is denser"), _("center is much denser"), 0};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith eact = create_adjustment_action( "SpiralExpansionAction",
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Divergence"), _("Divergence:"), _("How much denser/sparser are outer revolutions; 1 = uniform"),
bf9ec3e969ba6b11cbbc613545aedc63cc886973Matthew Petroff GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar const* labels[] = {_("starts from center"), _("starts mid-way"), _("starts near edge")};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith eact = create_adjustment_action( "SpiralT0Action",
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Inner radius"), _("Inner radius:"), _("Radius of the innermost revolution (relative to the spiral size)"),
bf9ec3e969ba6b11cbbc613545aedc63cc886973Matthew Petroff GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith InkAction* inky = ink_action_new( "SpiralResetAction",
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Defaults"),
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Reset shape parameters to defaults (use Inkscape Preferences > Tools to change defaults)"),
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_spl_tb_defaults), holder );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sigc::connection *connection = new sigc::connection(
769a6887551cf7ff7bce4b48d3ac303cbea69507Liam P. White desktop->getSelection()->connectChanged(sigc::bind(sigc::ptr_fun(sp_spiral_toolbox_selection_changed), holder))
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith Local Variables:
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith c-file-style:"stroustrup"
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith indent-tabs-mode:nil
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith fill-column:99
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :