sp-conn-end.cpp revision 6d8430ca47c35cff45dee59e1f9c025567d0af49
#include <cstring>
#include <string>
#include <limits>
#include "sp-conn-end.h"
#include "sp-path.h"
#include "uri.h"
#include "document.h"
#include "sp-item-group.h"
#include "2geom/pathvector.h"
#include "2geom/path-intersection.h"
// Default to center connection endpoint
{
}
static SPObject const *
for (unsigned i = 0; i < 2; ++i) {
}
}
return anc_sofar;
}
double initial_pos = intersect_pos;
// if this is a group...
if (SP_IS_GROUP(item)) {
// consider all first-order children
double child_pos = 0.0;
if (intersect_pos < child_pos)
}
return intersect_pos != initial_pos;
}
// if this is not a shape, nothing to be done
if (!SP_IS_SHAPE(item)) return false;
// make sure it has an associated curve
if (!item_curve) return false;
// apply transformations (up to common ancestor)
// iterate over all Crossings
//TODO: check correctness of the following code: inner loop uses loop variable
// with a name identical to the loop variable of the outer loop. Then rename.
}
}
item_curve->unref();
return intersect_pos != initial_pos;
}
// This function returns the outermost intersection point between the path (a connector)
// and the item given. If the item is a group, then the component items are considered.
// The transforms given should be to a common ancestor of both the path and item.
//
const bool at_start, double& intersect_pos) {
// Copy the curve and apply transformations up to common ancestor.
// If this is not the starting point, use Geom::Path::reverse() to reverse the path
if (!at_start)
{
// connectors are actually a single path, so consider the first element from a Geom::PathVector
}
// We start with the intersection point at the beginning of the path
intersect_pos = 0.0;
// Find the intersection.
bool result = try_get_intersect_point_with_item_recursive(conn_pv, item, item_transform, intersect_pos);
if (!result)
// No intersection point has been found (why?)
// just default to connector end
intersect_pos = 0;
// If not at the starting point, recompute position with respect to original path
if (!at_start)
// Free the curve copy.
conn_curve->unref();
return result;
}
static void
const bool updatePathRepr = true)
{
// Get the new route around obstacles.
if (!rerouted) {
return;
}
// Set sensible values incase there the connector ends are not
// attached to any shapes.
for (unsigned h = 0; h < 2; ++h) {
// Assume center point for all
if (h2attItem[h]) {
(h == 0), endPos[h]);
}
}
if (updatePathRepr) {
path->updateRepr();
}
}
static void
{
}
}
void
{
}
}
void
{
bool processTransaction = true;
}
// Don't update the path repr or else connector dragging is slowed by
// constant update of values to the xml editor, and each step is also
bool const updatePathRepr = false;
}
{
}
static void
{
// Use Geom::Path::portion to cut the curve at the end positions
{
// Path is "negative", reset the curve and return
return;
}
}
static void
{
char const * const attrs[] = {
"inkscape:connection-start", "inkscape:connection-end"};
/* I believe this will trigger sp_conn_end_href_changed. */
}
void
{
}
void
{
/* No change, do nothing. */
}
else
{
if (!value)
{
}
else
{
bool validRef = true;
// Now do the attaching, which emits the changed signal.
try {
} catch (Inkscape::BadURIException &e) {
/* TODO: Proper error handling as per
* http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. (Also needed for
* sp-use.) */
validRef = false;
}
if ( !validRef )
{
}
}
}
}
void
{
if (refobj) {
// This allows the connector tool to dive into a group's children
// And connect to their children's centers.
path));
}
path));
}
}
}
/*
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 :