sp-lpe-item.cpp revision 96d7f74ab56c7ce6cf9df0108ce925f59bcf0035
#define __SP_LPE_ITEM_CPP__
/** \file
* Base class for live path effect items
*/
/*
* Authors:
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
* Bastien Bouclet <bgkweb@gmail.com>
*
* Copyright (C) 2008 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "sp-path.h"
#include "sp-item-group.h"
#include "streq.h"
#include "macros.h"
#include "attributes.h"
#include "sp-lpe-item.h"
#include "uri.h"
#include "message-stack.h"
#include "inkscape.h"
#include "desktop.h"
#include <algorithm>
/* LPEItem base class */
static Inkscape::XML::Node *sp_lpe_item_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags);
static void sp_lpe_item_child_added (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref);
static SPItemClass *parent_class;
{
static GType lpe_item_type = 0;
if (!lpe_item_type) {
sizeof(SPLPEItemClass),
sizeof(SPLPEItem),
16,
NULL, /* value_table */
};
}
return lpe_item_type;
}
static void
{
}
static void
{
lpeitem->adding_helperpaths = false;
lpeitem->removing_helperpaths = false;
}
static void
{
}
}
/**
* Reads the Inkscape::XML::Node, and initializes SPLPEItem variables. For this to get called,
* our name must be associated with a repr via "sp_object_type_register". Best done through
* sp-object-repr.cpp's repr_name_entries array.
*/
static void
{
}
}
/**
* Drops any allocated memory.
*/
static void
{
// unlink and delete all references in the list
delete *it;
}
// delete the list itself
}
/**
* Sets a specific value in the SPLPEItem.
*/
static void
{
switch (key) {
{
// Disable the path effects while populating the LPE list
sp_lpe_item_enable_path_effects(lpeitem, false);
// Clear the path effect list
{
delete *it;
}
// Parse the contents of "value" to rebuild the path effect reference list
if ( value ) {
{
path_effect_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(lpeobject_ref_changed), SP_LPE_ITEM(object)));
// Now do the attaching, which emits the changed signal.
// Fixme, it should not do this changed signal and updating before all effects are added to the path_effect_list
try {
} catch (Inkscape::BadURIException &e) {
delete path_effect_ref;
}
if (path_effect_ref) {
}
}
}
}
break;
default:
}
break;
}
}
/**
* Receives update notifications.
*/
static void
{
}
}
/**
* Sets modified flag for all sub-item views.
*/
static void
{
if (SP_IS_GROUP(object) && (flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_USER_MODIFIED_FLAG_B)) {
}
}
}
/**
* Writes its settings to an incoming repr object, if any.
*/
sp_lpe_item_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
if ( sp_lpe_item_has_path_effect(lpeitem) ) {
} else {
}
}
return repr;
}
if (!lpeitem) return;
if (!curve) return;
for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
{
if (!lpeobj) {
g_warning("sp_lpe_item_perform_path_effect - NULL lpeobj in list!");
return;
}
g_warning("sp_lpe_item_perform_path_effect - lpeobj without lpe!");
return;
}
// if the effect expects mouse input before being applied and the input is not finished
// yet, we don't alter the path
return;
}
// Groups have their doBeforeEffect called elsewhere
if (!SP_IS_GROUP(lpeitem)) {
}
try {
}
_("An exception occurred during execution of the Path Effect.") );
}
}
}
}
}
/**
* Calls any registered handlers for the update_patheffect action
*/
void
{
#ifdef SHAPE_VERBOSE
#endif
return;
if (wholetree) {
while (parent && SP_IS_LPE_ITEM(parent) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(parent))) {
}
}
else {
}
// TODO: ditch inkscape_active_desktop()
if (desktop) {
//sp_lpe_item_remove_temporary_canvasitems(lpeitem, desktop);
//sp_lpe_item_add_temporary_canvasitems(lpeitem, desktop);
}
}
}
/**
* Gets called when (re)attached to another lpeobject.
*/
static void
{
if (old_ref) {
}
{
lpeitem->lpe_modified_connection = ref->connectModified(sigc::bind(sigc::ptr_fun(&lpeobject_ref_modified), lpeitem));
}
}
/**
* Gets called when lpeobject repr contents change: i.e. parameter change.
*/
static void
{
sp_lpe_item_update_patheffect (lpeitem, true, true);
}
static void
{
if (SP_IS_GROUP(lpeitem)) {
if (SP_IS_LPE_ITEM(subitem)) {
}
}
}
else if (SP_IS_PATH(lpeitem)) {
}
}
}
static void
{
if (SP_IS_GROUP(lpeitem)) {
if (SP_IS_LPE_ITEM(subitem)) {
}
}
}
else if (SP_IS_PATH(lpeitem)) {
}
else {
sp_lpe_item_update_patheffect(lpeitem, true, true);
}
}
}
{
if (value) {
// Apply the path effects here because in the casse of a group, lpe->resetDefaults
// needs that all the subitems have their effects applied
sp_lpe_item_update_patheffect(lpeitem, false, true);
// Disable the path effects while preparing the new lpe
sp_lpe_item_enable_path_effects(lpeitem, false);
// Add the new reference to the list of LPE references
for (PathEffectList::const_iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
{
}
// make sure there is an original-d for paths!!!
// Ask the path effect to reset itself if it doesn't have parameters yet
if (reset) {
// has to be called when all the subitems have their lpes applied
}
// perform this once when the effect is applied
// if the effect expects a number of mouse clicks to set a parameter path, perform the
// necessary preparations
if (lpe->acceptsNumParams() > 0) {
}
}
//Enable the path effects now that everything is ready to apply the new path effect
// Apply the path effect
sp_lpe_item_update_patheffect(lpeitem, true, true);
}
}
{
}
{
Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem);
if (!lperef)
return;
if (!keep_paths) {
}
}
{
if (!keep_paths) {
}
}
{
Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem);
if (!lperef)
return;
down_it++;
}
}
}
{
Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem);
if (!lperef)
return;
up_it--;
}
}
{
}
{
return sp_lpe_item_has_path_effect(lpeitem) || sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(parent));
}
else {
return sp_lpe_item_has_path_effect(lpeitem);
}
}
{
}
}
return NULL;
}
/* Return false if the item is not a path or already has a shape applied */
{
if (!SP_IS_PATH(lpeitem))
return false;
return false;
return true;
}
{
Inkscape::LivePathEffect::LPEObjectReference *lperef = sp_lpe_item_get_current_lpereference(lpeitem);
}
}
static void
{
}
}
}
static void
{
}
}
}
{
{
}
return hreflist_write_svg(hreflist);
}
/**
* THE function that should be used to generate any patheffectlist string.
* one of the methods to change the effect list:
* - create temporary href list
* - populate the templist with the effects from the old list that you want to have and their order
* - call this function with temp list as param
*/
{
bool semicolon_first = false;
{
if (semicolon_first) {
r += ';';
}
semicolon_first = true;
r += (*it);
}
return r;
}
// Return a copy of the effect list
{
return *lpeitem->path_effect_list;
}
Inkscape::LivePathEffect::LPEObjectReference* sp_lpe_item_get_current_lpereference(SPLPEItem *lpeitem)
{
return lpeitem->current_path_effect;
}
{
Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem);
else
return NULL;
}
bool sp_lpe_item_set_current_path_effect(SPLPEItem *lpeitem, Inkscape::LivePathEffect::LPEObjectReference* lperef)
{
for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); it++) {
lpeobject_ref_changed(NULL, (*it)->lpeobject, SP_LPE_ITEM(lpeitem)); // FIXME: explain why this is here?
lpeitem->current_path_effect = (*it); // current_path_effect should always be a pointer from the path_effect_list !
return true;
}
}
return false;
}
{
for (PathEffectList::const_iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
{
}
else {
}
}
}
// Enable or disable the path effects of the item.
// The counter allows nested calls
{
if (enable) {
}
else {
}
}
// Are the path effects enabled on this item ?
{
return lpeitem->path_effects_enabled > 0;
}
void
{
if (lpeitem->adding_helperpaths) {
return;
}
lpeitem->adding_helperpaths = true;
// FIXME: for some reason it seems that we must create the variable lpe AFTER checking
// for adding_helperpaths == true; otherwise we get a crash on startup. why??
if (lpe) {
// TODO: can we just update the tempitem's SPCurve instead of recreating it each time?
}
lpeitem->adding_helperpaths = false;
}
void
{
if (lpeitem->removing_helperpaths) {
return;
}
lpeitem->removing_helperpaths = true;
// destroy all temporary canvasitems created by LPEs
}
lpeitem->removing_helperpaths = 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:encoding=utf-8:textwidth=99 :