sp-path.cpp revision 58adcec645c8073a243d02ab1a3ffca507269814
#define __SP_PATH_C__
/*
* SVG <path> implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* David Turner <novalis@gnu.org>
*
* Copyright (C) 2004 David Turner
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libnr/n-art-bpath.h>
#include <libnr/nr-matrix-fns.h>
#include "attributes.h"
#include "sp-path.h"
#include "sp-guide.h"
#include "document.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "desktop-style.h"
#include "event-context.h"
#include "inkscape.h"
#include "style.h"
#include "message-stack.h"
#include "prefs-utils.h"
#include "selection.h"
#define noPATH_VERBOSE
static Inkscape::XML::Node *sp_path_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
static SPShapeClass *parent_class;
/**
* Gets the GType object for SPPathClass
*/
sp_path_get_type(void)
{
if (!type) {
sizeof(SPPathClass),
sizeof(SPPath),
16,
NULL, /* value_table */
};
}
return type;
}
/**
* Does the object-oriented work of initializing the class structure
* including parent class, and registers function pointers for
* the functions build, set, write, and set_transform.
*/
static void
{
}
{
if (!curve) return 0;
if (i > r) i = r; // sometimes after switching from node editor length is wrong, e.g. f6 - draw - f2 - tab - f1, this fixes it
for (; i >= 0; i --)
r --;
return r;
}
static gchar *
{
} else {
}
}
static void
{
if (!curve) return;
/* we only convert straight line segments (converting curve segments would be unintuitive) */
}
/* remember current point for potential reuse in the next step
(e.g., in case this was an NR_MOVETO or NR_MOVETO_OPEN) */
}
}
/**
* Initializes an SPPath.
*/
static void
{
}
static void
{
}
/**
* Given a repr, this sets the data items in the path object such as
* fill & style attributes, markers, and CSS properties.
*/
static void
{
/* Are these calls actually necessary? */
}
/* d is a required attribute */
if (d == NULL) {
}
}
static void
{
if (path->original_curve) {
}
}
}
/**
* Sets a value in the path object given by 'key', to 'value'. This is used
* for setting attributes and markers on a path object.
*/
static void
{
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;
}
}
/**
*
* Writes the path object into a Inkscape::XML::Node
*/
{
}
if (abp) {
} else {
}
} else {
}
if (abp) {
} else {
}
} else {
}
}
return repr;
}
static void
{
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
}
}
}
/**
* Writes the given transform into the repr for the given item.
*/
{
}
if (origcurve) {
}
} else { /* Transform the path */
if (curve) {
}
}
// Adjust stroke
// Adjust pattern fill
// Adjust gradient fill
// Adjust LPE
// nothing remains - we've written all of the transform, so return identity
}
static void
{
if (path->original_curve) {
if (write) {
// could also do SP_OBJECT(shape)->updateRepr(); but only the d attribute needs updating.
if (abp) {
} else {
}
} else {
}
}
} else {
}
}
/**
* 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 the an effect is present
* an also triggers a request to update the display. Does not write
* result to XML when write=false.
*/
void
{
if (path->original_curve) {
}
if (curve) {
if (owner) {
} else {
}
}
}
/**
* Return duplicate of original_curve (if any exists) or NULL if there is no curve
*/
SPCurve *
{
if (path->original_curve) {
}
return NULL;
}
/**
* Return duplicate of edittable curve which is original_curve if it exists or
* shape->curve if not.
*/
{
if (path->original_curve) {
return sp_path_get_original_curve(path);
} else {
}
}
/**
* Return a reference to original_curve if it exists or
* shape->curve if not.
*/
const SPCurve*
{
if (path->original_curve) {
return path->original_curve;
} else {
}
}
/* Create a single dot represented by a circle */
void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state) {
/* apply the tool's current style */
/* find out stroke width (TODO: is there an easier way??) */
double stroke_width = 3.0;
if (style_str) {
}
/* unset stroke and set fill color to former stroke color */
str = g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8);
/* put the circle where the mouse click occurred and set the diameter to the
current stroke width, multiplied by the amount specified in the preferences */
if (event_state & GDK_MOD1_MASK) {
/* TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size
as specified in prefs. Very simple, but it might be sufficient in practice. If not,
we need to devise something more sophisticated. */
rad *= (1 + s);
}
if (event_state & GDK_SHIFT_MASK) {
// double the point size
rad *= 2;
}
item->updateRepr();
unsigned int tool_code = !strcmp(tool, "tools.freehand.pencil") ? SP_VERB_CONTEXT_PENCIL : SP_VERB_CONTEXT_PEN;
}
/*
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 :