path-chemistry.cpp revision ae22ad7adc4a7a418e71f5dbab8c1f0f7f464562
#define __SP_PATH_CHEMISTRY_C__
/*
* Here are handlers for modifying selections, specific to paths
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
*
* Copyright (C) 1999-2008 Authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <cstring>
#include <string>
#include "sp-path.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "text-editing.h"
#include "style.h"
#include "inkscape.h"
#include "desktop.h"
#include "document.h"
#include "message-stack.h"
#include "selection.h"
#include "desktop-handles.h"
#include "box3d.h"
#include "path-chemistry.h"
/* Helper functions for sp_selected_path_to_curves */
enum {
/* Not used yet. This is the placeholder of Lauris's idea. */
SP_TOCURVE_INTERACTIVE = 1 << 0,
};
void
sp_selected_path_combine(void)
{
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>at least two objects</b> to combine."));
return;
}
// set "busy" cursor
// remember the position, id and style of the topmost path, they will be assigned to the combined one
bool did = false;
if (!SP_IS_PATH(item))
continue;
did = true;
// FIXME: merge styles of combined objects instead of using the first one's style
curve = c;
} else {
sp_curve_append(curve, c, false);
sp_curve_unref(c);
}
// unless this is the topmost object,
// reduce position only if the same parent
position--;
// delete the object for real, so that its clones can take appropriate action
}
}
if (did) {
// delete the topmost one so that its clones don't get alerted; this object will be
// restored shortly, with the same id
// restore id and style
// set path data corresponding to new curve
// add the new group to the parent of the topmost
// move to the position of the topmost, reduced by the number of deleted items
_("Combine"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to combine in the selection."));
}
}
void
{
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to break apart."));
return;
}
// set "busy" cursor
bool did = false;
if (!SP_IS_PATH(item))
continue;
continue;
did = true;
// it's going to resurrect as one of the pieces, so we delete without advertisement
// add the new repr to the parent
// move to the saved position
// if it's the first one, restore id
if (l == list)
}
}
if (did) {
_("Break apart"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to break apart in the selection."));
}
}
/* This function is an entry point from GUI */
void
{
if (interactive) {
} else {
sp_selected_path_to_curves0(false, 0);
}
}
static void
{
if (interactive)
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to path."));
return;
}
bool did = false;
if (interactive) {
// set "busy" cursor
}
if (interactive) {
if (did) {
_("Object to path"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No objects</b> to convert to path in the selection."));
return;
}
}
}
static bool
{
bool did = false;
for (;
continue; // already a path, and no path effect
}
if (SP_IS_BOX3D(item)) {
// convert 3D box to ordinary group of paths; replace the old element in 'selected' with the new group
if (repr) {
did = true;
}
continue;
}
if (SP_IS_GROUP(item)) {
did = true;
continue;
}
if (!repr)
continue;
did = true;
// remember the position of the item
// remember parent
// remember id
// It's going to resurrect, so we delete without notifying listeners.
// restore id
// add the new repr to the parent
// move to the saved position
/* Buglet: We don't re-add the (new version of the) object to the selection of any other
* desktops where it was previously selected. */
}
return did;
}
{
if (!item)
return NULL;
if (SP_IS_SHAPE(item)) {
}
if (!curve)
return NULL;
// Prevent empty paths from being added to the document
// otherwise we end up with zomby markup in the SVG file
{
return NULL;
}
/* Transformation */
/* Style */
/* Mask */
if ( mask_str )
/* Clip path */
if ( clip_path_str )
/* Rotation center */
sp_repr_set_attr(repr, "inkscape:transform-center-x", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-x"));
sp_repr_set_attr(repr, "inkscape:transform-center-y", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-y"));
/* Definition */
return repr;
}
// FIXME: THIS DOES NOT REVERSE THE NODETYPES ORDER!
void
{
if (!items) {
sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse."));
return;
}
// set "busy" cursor
bool did = false;
if (!SP_IS_PATH(i->data))
continue;
did = true;
} else {
}
}
if (did) {
_("Reverse path"));
} else {
sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection."));
}
}
/*
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 :