pencil-toolbar.cpp revision 98f9f27a27115988e05366a69d7b38be9c12f69d
/**
* @file
* Pencil aux toolbar
*/
/* Authors:
* MenTaLguY <mental@rydia.net>
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Frank Felfe <innerspace@iname.com>
* John Cliff <simarilius@yahoo.com>
* David Turner <novalis@gnu.org>
* Josh Andler <scislac@scislac.com>
* Jon A. Cruz <jon@joncruz.org>
* Maximilian Albert <maximilian.albert@gmail.com>
* Tavmjong Bah <tavmjong@free.fr>
* Abhishek Sharma
* Kris De Gussem <Kris.DeGussem@gmail.com>
*
* Copyright (C) 2004 David Turner
* Copyright (C) 2003 MenTaLguY
* Copyright (C) 1999-2011 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gtkmm.h>
#include <list>
#include "pencil-toolbar.h"
#include "desktop.h"
#include "document-undo.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
#include "widgets/ink-action.h"
#include "preferences.h"
#include "toolbox.h"
#include "ui/tools-switch.h"
#include "ui/icon-names.h"
#include "ui/tools/pen-tool.h"
#include "ui/uxmanager.h"
#include "widgets/spinbutton-events.h"
#include <selection.h>
#include "live_effects/effect.h"
#include "live_effects/lpe-simplify.h"
#include "live_effects/effect-enum.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "sp-lpe-item.h"
#include "util/glib-list-iterators.h"
using Inkscape::DocumentUndo;
//########################
//########################
/* This is used in generic functions below to share large portions of code between pen and pencil tool */
{
}
{
// in pen tool we have more options than in pencil tool; if one of them was chosen, we do any
// preparatory work here
pc->setPolylineMode();
}
}
static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* holder, bool tool_is_pencil)
{
/* Freehand mode toggle buttons */
{
guint freehandMode = prefs->getInt(( tool_is_pencil ? "/tools/freehand/pencil/freehand-mode" : "/tools/freehand/pen/freehand-mode" ), 0);
{
0, _("Bezier"),
1, _("Create regular Bezier path"),
-1 );
0, _("Spiro"),
1, _("Create Spiro path"),
-1 );
0, _("BSpline"),
1, _("Create BSpline path"),
-1 );
if (!tool_is_pencil) {
0, _("Zigzag"),
1, _("Create a sequence of straight line segments"),
-1 );
0, _("Paraxial"),
1, _("Create a sequence of paraxial line segments"),
-1 );
}
"FreehandModeActionPencil" :
"FreehandModeActionPen",
}
}
}
}
}
/**
* Generate the list of freehand advanced shape option entries.
*/
static GList * freehand_shape_dropdown_items_list() {
return glist;
}
static void freehand_add_advanced_shape_options(GtkActionGroup* mainActions, GObject* holder, bool tool_is_pencil)
{
/*advanced shape options */
{
{
count++;
}
g_list_free( items );
items = 0;
ege_select_one_action_set_active( act1, prefs->getInt(( tool_is_pencil ? "/tools/freehand/pencil/shape" : "/tools/freehand/pen/shape" ), 0) );
}
}
{
}
{
// fixme: make settable
}
{
if (lpeobj) {
if(shape){
lpeitem->setCurrentPathEffect(*i);
lpeitem->removeCurrentPathEffect(true);
shape->setCurveBeforeLPE(c);
} else {
lpeitem->removeCurrentPathEffect(false);
}
break;
}
}
}
}
}
}
}
{
// quit if run by the attr_changed listener
return;
}
// in turn, prevent listener from responding
Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY);
if(thisEffect){
Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast<Inkscape::LivePathEffect::LPESimplify*>(thisEffect->getLPEObj()->get_lpe());
if (lpe) {
}
}
}
}
}
/*
class PencilToleranceObserver : public Inkscape::Preferences::Observer {
public:
PencilToleranceObserver(Glib::ustring const &path, GObject *x) : Observer(path), _obj(x)
{
g_object_set_data(_obj, "prefobserver", this);
}
virtual ~PencilToleranceObserver() {
if (g_object_get_data(_obj, "prefobserver") == this) {
g_object_set_data(_obj, "prefobserver", NULL);
}
}
virtual void notify(Inkscape::Preferences::Entry const &val) {
GObject* tbl = _obj;
if (g_object_get_data( tbl, "freeze" )) {
return;
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
GtkAdjustment * adj = GTK_ADJUSTMENT(g_object_get_data(tbl, "tolerance"));
double v = val.getDouble(adj->value);
gtk_adjustment_set_value(adj, v);
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
private:
GObject *_obj;
};
*/
{
EgeAdjustmentAction* eact = 0;
/* Tolerance */
{
gchar const* labels[] = {_("(many nodes, rough)"), _("(default)"), 0, 0, 0, 0, _("(few nodes, smooth)")};
_("Smoothing:"), _("Smoothing: "),
_("How much smoothing (simplifying) is applied to the line"),
3.0,
1, 100.0, 0.5, 1.0,
NULL /*unit tracker*/,
1, 2);
}
/* advanced shape options */
/* Reset */
{
_("Defaults"),
_("Reset pencil parameters to defaults (use Inkscape Preferences > Tools to change defaults)"),
INKSCAPE_ICON("edit-clear"),
}
/* LPE simplify based tolerance */
{
_("LPE based interactive simplify"),
_("LPE based interactive simplify"),
INKSCAPE_ICON("interactive_simplify"),
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(itact), prefs->getInt("/tools/freehand/pencil/simplify", 0) );
}
/* LPE simplify flatten */
{
_("LPE simplify flatten"),
_("LPE simplify flatten"),
INKSCAPE_ICON("flatten_simplify"),
}
}
/*
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 :