livepatheffect-editor.cpp revision c0cd5511d3b975ebe07d019c1f5528108725e438
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen/**
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * \brief LivePathEffect dialog
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen *
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Authors:
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Johan Engelen <j.b.c.engelen@utwente.nl>
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen *
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Copyright (C) 2007 Author
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen *
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Released under GNU GPL. Read the file 'COPYING' for more information.
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen */
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#ifdef HAVE_CONFIG_H
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen# include <config.h>
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#endif
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include <glibmm/i18n.h>
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "livepatheffect-editor.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "verbs.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "selection.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "sp-shape.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "sp-path.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "live_effects/effect.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "live_effects/lpeobject.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "gtkmm/widget.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include <vector>
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "inkscape.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "desktop-handles.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "desktop.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "document-private.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "xml/node.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen#include "xml/document.h"
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelennamespace Inkscape {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenclass Application;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelennamespace UI {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelennamespace Dialog {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen/*####################
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * Callback functions
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen */
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenstatic void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen lpeeditor->onSelectionChanged(selection);
8001ba81cb851b38d86650a2fef5817facffb763johanengelen}
8001ba81cb851b38d86650a2fef5817facffb763johanengelen
8001ba81cb851b38d86650a2fef5817facffb763johanengelenstatic void lpeeditor_selection_modified( Inkscape::Selection *selection, guint /*flags*/, gpointer data )
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen lpeeditor_selection_changed (selection, data);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen/*#######################
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen * LivePathEffectEditor
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen */
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::LivePathEffectEditor()
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen : UI::Widget::Panel("", "dialogs.livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_apply(_("_Apply"), _("Apply chosen effect to selection")),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_remove(_("_Remove"), _("Remove effect from selection")),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectwidget(NULL),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen explain_label("", Gtk::ALIGN_CENTER),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectapplication_frame(_("Apply new effect")),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_frame(_("Current effect")),
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen current_desktop(NULL)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Gtk::Box *contents = _getContents();
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen contents->set_spacing(4);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectapplication_hbox.set_spacing(4);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.set_spacing(4);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectapplication_hbox.pack_start(combo_effecttype, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectapplication_hbox.pack_start(button_apply, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectapplication_frame.add(effectapplication_hbox);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.pack_start(explain_label, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.pack_end(button_remove, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_frame.add(effectcontrol_vbox);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen contents->pack_start(effectapplication_frame, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen contents->pack_start(effectcontrol_frame, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen // connect callback functions to buttons
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_apply.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onApply));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_remove.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onRemove));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen show_all_children();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_remove.hide();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::~LivePathEffectEditor()
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
29684a16b6c92bee28a94fdc2607bcc143950fa8johanengelen if (effectwidget) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.remove(*effectwidget);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen delete effectwidget;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectwidget = NULL;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (current_desktop) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen selection_changed_connection.disconnect();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen selection_modified_connection.disconnect();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenvoid
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::showParams(LivePathEffect::Effect* effect)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (effectwidget) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.remove(*effectwidget);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen delete effectwidget;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectwidget = NULL;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen explain_label.set_markup("<b>" + effect->getName() + "</b>");
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectwidget = effect->newWidget(&tooltips);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (effectwidget) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.pack_start(*effectwidget, true, true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_remove.show();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.show_all_children();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen // fixme: do resizing of dialog
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenvoid
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::showText(Glib::ustring const &str)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (effectwidget) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectcontrol_vbox.remove(*effectwidget);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen delete effectwidget;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen effectwidget = NULL;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen explain_label.set_label(str);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_remove.hide();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen // fixme: do resizing of dialog ?
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenvoid
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::set_sensitize_all(bool sensitive)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen combo_effecttype.set_sensitive(sensitive);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_apply.set_sensitive(sensitive);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_remove.set_sensitive(sensitive);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenvoid
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( sel && !sel->isEmpty() ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen SPItem *item = sel->singleItem();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( item ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( SP_IS_SHAPE(item) ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen SPShape *shape = SP_SHAPE(item);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(shape);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen set_sensitize_all(true);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (lpeobj) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (lpeobj->lpe) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen showParams(lpeobj->lpe);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen } else {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen showText(_("Unknown effect is applied"));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen } else {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen showText(_("No effect applied"));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen button_remove.set_sensitive(false);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen } else {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen showText(_("Item is not a shape or path"));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen set_sensitize_all(false);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen } else {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen showText(_("Only one item can be selected"));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen set_sensitize_all(false);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen } else {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen showText(_("Empty selection"));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen set_sensitize_all(false);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenvoid
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::setDesktop(SPDesktop *desktop)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Panel::setDesktop(desktop);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( desktop == current_desktop ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen return;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (current_desktop) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen selection_changed_connection.disconnect();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen selection_modified_connection.disconnect();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen current_desktop = desktop;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (desktop) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::Selection *selection = sp_desktop_selection(desktop);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen selection_changed_connection = selection->connectChanged(
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sigc::bind (sigc::ptr_fun(&lpeeditor_selection_changed), this ) );
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen selection_modified_connection = selection->connectModified(
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sigc::bind (sigc::ptr_fun(&lpeeditor_selection_modified), this ) );
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen onSelectionChanged(selection);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen } else {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen onSelectionChanged(NULL);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen/*########################################################################
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen# BUTTON CLICK HANDLERS (callbacks)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen########################################################################*/
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen// TODO: factor out the effect applying code which can be called from anywhere. (selection-chemistry.cpp also needs it)
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenvoid
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::onApply()
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::Selection *sel = _getSelection();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( sel && !sel->isEmpty() ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen SPItem *item = sel->singleItem();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( item && SP_IS_SHAPE(item) ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen SPDocument *doc = current_desktop->doc();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen const Util::EnumData<LivePathEffect::EffectType>* data = combo_effecttype.get_active_data();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (!data) return;
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect");
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen repr->setAttribute("effect", data->key.c_str() );
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc))->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen const gchar * repr_id = repr->attribute("id");
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::GC::release(repr);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen gchar *href = g_strdup_printf("#%s", repr_id);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sp_shape_set_path_effect(SP_SHAPE(item), href);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen g_free(href);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen // make sure there is an original-d for paths!!!
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( SP_IS_PATH(item) ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::XML::Node *pathrepr = SP_OBJECT_REPR(item);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( ! pathrepr->attribute("inkscape:original-d") ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen pathrepr->setAttribute("inkscape:original-d", pathrepr->attribute("d"));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(SP_SHAPE(item));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if (lpeobj && lpeobj->lpe) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen lpeobj->lpe->resetDefaults(item);
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT,
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen _("Create and apply path effect"));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenvoid
981b809bc6ed10a21e89444d9447e5475801874fjohanengelenLivePathEffectEditor::onRemove()
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen{
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen Inkscape::Selection *sel = _getSelection();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( sel && !sel->isEmpty() ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen SPItem *item = sel->singleItem();
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen if ( item && SP_IS_SHAPE(item) ) {
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sp_shape_remove_path_effect(SP_SHAPE(item));
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen _("Remove path effect") );
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen }
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen}
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen} // namespace Dialog
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen} // namespace UI
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen} // namespace Inkscape
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen
981b809bc6ed10a21e89444d9447e5475801874fjohanengelen