sp-path.cpp revision 817bc5b52fb01e9b56966e9c41fb0d8d876ed7eb
/*
* SVG <path> implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* David Turner <novalis@gnu.org>
* Abhishek Sharma
* Johan Engelen
*
* Copyright (C) 2004 David Turner
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
* Copyright (C) 1999-2012 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-lpe-item.h"
#include "helper/geom-curves.h"
#include "attributes.h"
#include "sp-path.h"
#include "sp-guide.h"
#include "document.h"
#include "desktop.h"
#include "desktop-style.h"
#include "ui/tools/tool-base.h"
#include "inkscape.h"
#include "style.h"
#include "message-stack.h"
#include "selection.h"
#define noPATH_VERBOSE
{
}
const char* SPPath::displayName() const {
return _("Path");
}
int count = this->nodesInPath();
if (hasPathEffect()) {
{
break;
}
if (s.empty()) {
} else {
}
}
}
return ret;
}
void SPPath::convert_to_guides() const {
if (!this->_curve) {
return;
}
// only add curves for straight line segments
if( is_straight_curve(*cit) )
{
}
}
}
}
}
}
/* Are these calls actually necessary? */
this->readAttr( "marker" );
this->readAttr( "marker-start" );
this->readAttr( "marker-mid" );
this->readAttr( "marker-end" );
sp_conn_end_pair_build(this);
// this->readAttr( "inkscape:original-d" ); // bug #1299948
// Why we take the long way of doing this probably needs some explaining:
//
// Normally upon being built, reading the inkscape:original-d attribute
// will cause the path to actually _write to its repr_ in response to this.
// This is bad, bad news if the attached effect refers to a path which
// hasn't been constructed yet.
//
// What will happen is the effect parameter will cause the effect to
// recalculate with a completely different value due to the parameter being
// "empty" -- even worse, an undo event might be created with the bad value,
// and undoing the current action could cause it to revert to the "bad"
// state. (After that, the referred object will be constructed and the
// reference will trigger the path effect to update and commit the right
// value to "d".)
//
// This mild nastiness here (don't recalculate effects on build) prevents a
// plethora of issues with effects with linked parameters doing wild and
// stupid things on new documents upon a mere undo.
{
// Write the value to _curve_before_lpe, do not recalculate effects
if (_curve_before_lpe) {
}
if (curve) {
}
}
this->readAttr( "d" );
/* d is a required attribute */
if (d == NULL) {
// First see if calculating the path effect will generate "d":
this->update_patheffect(true);
// I guess that didn't work, now we have nothing useful to write ("")
if (d == NULL) {
}
}
}
this->connEndPair.release();
}
switch (key) {
if (value) {
if (curve) {
}
} else {
}
break;
case SP_ATTR_D:
if (value) {
if (curve) {
}
} else {
}
break;
case SP_PROP_MARKER:
case SP_PROP_MARKER_START:
case SP_PROP_MARKER_MID:
case SP_PROP_MARKER_END:
break;
case SP_ATTR_CONNECTOR_TYPE:
case SP_ATTR_CONNECTION_START:
case SP_ATTR_CONNECTION_END:
break;
default:
break;
}
}
Inkscape::XML::Node* SPPath::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
}
#ifdef PATH_VERBOSE
g_message("sp_path_write writes 'd' attribute");
#endif
} else {
}
if (flags & SP_OBJECT_WRITE_EXT) {
if ( this->_curve_before_lpe != NULL ) {
} else {
}
}
return repr;
}
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore
}
this->connEndPair.update();
}
if (!_curve) { // 0 nodes, nothing to transform
}
// Transform the original-d path if this is a valid LPE this, other else the (ordinary) path
if (_curve_before_lpe && hasPathEffectRecursive()) {
if (this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) || this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH)) {
// if path has the CLONE_ORIGINAL LPE applied, don't write the transform to the pathdata, but write it 'unoptimized'
// also if the effect is type BEND PATH to fix bug #179842
return transform;
} else {
}
} else {
}
// Adjust stroke
// Adjust pattern fill
this->adjust_pattern(transform);
// Adjust gradient fill
this->adjust_gradient(transform);
// Adjust LPE
this->adjust_livepatheffect(transform);
// nothing remains - we've written all of the transform, so return identity
}
#ifdef PATH_VERBOSE
g_message("sp_path_update_patheffect");
#endif
if (_curve_before_lpe && hasPathEffectRecursive()) {
/* if a path has an lpeitem applied, then reset the curve to the _curve_before_lpe.
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
// could also do this->getRepr()->updateRepr(); but only the d attribute needs updating.
#ifdef PATH_VERBOSE
g_message("sp_path_update_patheffect writes 'd' attribute");
#endif
if (_curve) {
} else {
}
} else if (!success) {
// LPE was unsuccesfull. Read the old 'd'-attribute.
if (oldcurve) {
}
}
}
}
}
/**
* Adds a original_curve to the path. If owner is specified, a reference
* will be made, otherwise the curve will be copied into the path.
* Any existing curve in the path will be unreferenced first.
* This routine triggers reapplication of an effect if present
* and also triggers a request to update the display. Does not write
* result to XML when write=false.
*/
{
if (_curve_before_lpe) {
}
if (new_curve) {
if (owner) {
} else {
}
}
sp_lpe_item_update_patheffect(this, true, write);
}
/**
* Return duplicate of _curve_before_lpe (if any exists) or NULL if there is no curve
*/
{
if (_curve_before_lpe) {
return _curve_before_lpe->copy();
}
return NULL;
}
/**
* Return duplicate of edittable curve which is _curve_before_lpe if it exists or
* shape->curve if not.
*/
{
if (_curve_before_lpe && hasPathEffectRecursive()) {
return get_original_curve();
} else {
return getCurve();
}
}
/**
* Returns \c _curve_before_lpe if it is not NULL and a valid LPE is applied or
* \c curve if not.
*/
{
if (_curve_before_lpe && hasPathEffectRecursive()) {
return _curve_before_lpe;
} else {
return _curve;
}
}
/**
* Returns \c _curve_before_lpe if it is not NULL and a valid LPE is applied or \c curve if not.
* \todo should only be available to class friends!
*/
{
if (_curve_before_lpe && hasPathEffectRecursive()) {
return _curve_before_lpe;
} else {
return _curve;
}
}
/*
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 :