sp-lpe-item.cpp revision b2275bb1684a0e6775bf32414ebd25a04a1e705f
#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/lpe-path_length.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 "node-context.h"
#include "shape-editor.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
{
}
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 ) {
{
Inkscape::LivePathEffect::LPEObjectReference *path_effect_ref = new Inkscape::LivePathEffect::LPEObjectReference(SP_OBJECT(lpeitem));
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;
}
// something has gone wrong in finding the right patheffect.
g_warning("Unknown LPE type specified, LPE stack effectively disabled");
// keep the effect in the lpestack, so the whole stack is effectively disabled but maintained
}
}
}
}
break;
default:
}
break;
}
}
/**
* Receives update notifications.
*/
static void
{
}
// update the helperpaths of all LPEs applied to the item
// TODO: is there a more canonical place for this, since we don't have instant access to the item's nodepath?
// FIXME: this is called multiple (at least 3) times; how can we avoid this?
// FIXME: ditch inkscape_active_event_context()
if (!SP_IS_NODE_CONTEXT(ec)) return;
if (!sh->has_nodepath()) return;
}
/**
* 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 (flags & SP_OBJECT_WRITE_EXT) {
if ( sp_lpe_item_has_path_effect(lpeitem) ) {
} else {
}
}
}
return repr;
}
/**
* returns true when LPE was successful.
*/
if (!lpeitem) return false;
if (!curve) return false;
for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
{
if (!lpeobj) {
/** \todo Investigate the cause of this.
* For example, this happens when copy pasting an object with LPE applied. Probably because the object is pasted while the effect is not yet pasted to defs, and cannot be found.
*/
g_warning("sp_lpe_item_perform_path_effect - NULL lpeobj in list!");
return false;
}
if (!lpe) {
/** \todo Investigate the cause of this.
* Not sure, but I think this can happen when an unknown effect type is specified...
*/
g_warning("sp_lpe_item_perform_path_effect - lpeobj with invalid lpe in the stack!");
return false;
}
// if the effect expects mouse input before being applied and the input is not finished
// yet, we don't alter the path
return false;
}
// Groups have their doBeforeEffect called elsewhere
if (!SP_IS_GROUP(lpeitem)) {
}
try {
}
_("An exception occurred during execution of the Path Effect.") );
}
return false;
}
}
}
}
return true;
}
/**
* Calls any registered handlers for the update_patheffect action
*/
void
{
#ifdef SHAPE_VERBOSE
#endif
return;
// TODO: hack! this will be removed when path length measuring is reimplemented in a better way
if ((*i)->lpeobject) {
// we manually disable text for LPEPathLength
}
}
}
}
if (wholetree) {
while (parent && SP_IS_LPE_ITEM(parent) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(parent))) {
}
}
else {
}
}
}
/**
* 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
// indicate that all necessary preparations are done and the effect can be performed
}
//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--;
}
}
/** used for shapes so they can see if they should also disable shape calculation and read from d= */
{
return false;
// go through the list; if some are unknown or invalid, return true
{
return true;
}
return false;
}
{
return false;
// go through the list; if some are unknown or invalid, we are not an LPE item!
{
return false;
}
return true;
}
{
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 lpe;
}
}
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;
}
/*
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 :