diff options
Diffstat (limited to 'src/sp-conn-end.cpp')
| -rw-r--r-- | src/sp-conn-end.cpp | 106 |
1 files changed, 16 insertions, 90 deletions
diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index cabda82d3..c136cea66 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -21,11 +21,10 @@ SPConnEnd::SPConnEnd(SPObject *const owner) : ref(owner), href(NULL), // Default to center connection endpoint - type(ConnPointDefault), - id(4), _changed_connection(), _delete_connection(), - _transformed_connection() + _transformed_connection(), + _group_connection() { } @@ -154,9 +153,9 @@ sp_conn_get_route_and_redraw(SPPath *const path, Geom::PathVector conn_pv = path->_curve->get_pathvector(); double endPos[2] = { 0.0, static_cast<double>(conn_pv[0].size()) }; - SPConnEnd** _connEnd = path->connEndPair.getConnEnds(); for (unsigned h = 0; h < 2; ++h) { - if (h2attItem[h] && _connEnd[h]->type == ConnPointDefault && _connEnd[h]->id == ConnPointPosCC) { + // Assume center point for all + if (h2attItem[h]) { Geom::Affine h2i2anc = i2anc_affine(h2attItem[h], ancestor); try_get_intersect_point_with_item(path, h2attItem[h], h2i2anc, path2anc, (h == 0), endPos[h]); @@ -228,13 +227,9 @@ change_endpts(SPCurve *const curve, double const endPos[2]) static void sp_conn_end_deleted(SPObject *, SPObject *const owner, unsigned const handle_ix) { - // todo: The first argument is the deleted object, or just NULL if - // called by sp_conn_end_detach. - g_return_if_fail(handle_ix < 2); - char const * const attr_strs[] = {"inkscape:connection-start", "inkscape:connection-start-point", - "inkscape:connection-end", "inkscape:connection-end-point"}; - owner->getRepr()->setAttribute(attr_strs[2*handle_ix], NULL); - owner->getRepr()->setAttribute(attr_strs[2*handle_ix+1], NULL); + char const * const attrs[] = { + "inkscape:connection-start", "inkscape:connection-end"}; + owner->getRepr()->setAttribute(attrs[handle_ix], NULL); /* I believe this will trigger sp_conn_end_href_changed. */ } @@ -283,84 +278,6 @@ SPConnEnd::setAttacherHref(gchar const *value, SPPath* /*path*/) } } -void -SPConnEnd::setAttacherEndpoint(gchar const *value, SPPath* /*path*/) -{ - - /* 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; - ConnPointType newtype = type; - - if (!value) - { - // Default to center endpoint - type = ConnPointDefault; - id = 4; - } - else - { - switch (value[0]) - { - case 'd': - if ( newtype != ConnPointDefault ) - { - newtype = ConnPointDefault; - changed = true; - } - break; - case 'u': - if ( newtype != ConnPointUserDefined) - { - newtype = ConnPointUserDefined; - changed = true; - } - break; - default: - g_warning("Bad reference to a connection point."); - } - - int newid = (int) g_ascii_strtod( value+1, 0 ); - if ( id != newid ) - { - id = newid; - 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 - SPItem* item = ref.getObject(); - if ( item ) - { - if (!item->avoidRef->isValidConnPointId( newtype, newid ) ) - { - g_warning("Bad reference to a connection point."); - } - else - { - type = newtype; - id = newid; - } - /* // Update the connector - if (path->connEndPair.isAutoRoutingConn()) { - path->connEndPair.tellLibavoidNewEndpoints(); - } - */ - } - } - } -} void sp_conn_end_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, @@ -370,6 +287,7 @@ sp_conn_end_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPConnEnd &connEnd = *connEndPtr; connEnd._delete_connection.disconnect(); connEnd._transformed_connection.disconnect(); + connEnd._group_connection.disconnect(); if (connEnd.href) { SPObject *refobj = connEnd.ref.getObject(); @@ -377,6 +295,14 @@ sp_conn_end_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, connEnd._delete_connection = refobj->connectDelete(sigc::bind(sigc::ptr_fun(&sp_conn_end_deleted), path, handle_ix)); + // This allows the connector tool to dive into a group's children + // And connect to their children's centers. + SPObject *parent = refobj->parent; + if (SP_IS_GROUP(parent) and ! SP_IS_LAYER(parent)) { + connEnd._group_connection + = SP_ITEM(parent)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_conn_end_shape_move), + path)); + } connEnd._transformed_connection = SP_ITEM(refobj)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_conn_end_shape_move), path)); |
