sp-conn-end.cpp revision 10645ff0c20ab2670c82ec94823fc334912f4dfa
#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
id(4),
{
}
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) {
(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
{
// todo: The first argument is the deleted object, or just NULL if
// called by sp_conn_end_detach.
"inkscape:connection-end", "inkscape:connection-end-point"};
/* 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
{
/* References to the connection points have the following format
<t><id>, where t is the type of the point, which
can be either "d" for default or "u" for user-defined, and
id is the local (inside the item) id of the connection point.
In the case of default points id represents the position on the
item (i.e. Top-Left, Center-Center, etc.).
*/
bool changed = false;
if (!value)
{
// Default to center endpoint
id = 4;
}
else
{
switch (value[0])
{
case 'd':
if ( newtype != ConnPointDefault )
{
changed = true;
}
break;
case 'u':
if ( newtype != ConnPointUserDefined)
{
changed = true;
}
break;
default:
g_warning("Bad reference to a connection point.");
}
{
changed = true;
}
// We have to verify that the reference to the
// connection point is a valid one.
if ( changed )
{
// Get the item the connector is attached to
if ( item )
{
{
g_warning("Bad reference to a connection point.");
}
else
{
}
/* // Update the connector
if (path->connEndPair.isAutoRoutingConn()) {
path->connEndPair.tellLibavoidNewEndpoints();
}
*/
}
}
}
}
void
{
if (refobj) {
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 :