index bb5d89107f521b617b9f4034e093b450a2dede71..a1c4697e55007eecbd85d90faa8ee94354303e5a 100644 (file)
--- a/src/sp-conn-end-pair.cpp
+++ b/src/sp-conn-end-pair.cpp
#include "xml/repr.h"
#include "sp-path.h"
#include "libavoid/vertices.h"
+#include "libavoid/router.h"
+#include "document.h"
SPConnEndPair::SPConnEndPair(SPPath *const owner)
delete _connRef;
_connRef = NULL;
}
-
+
_invalid_path_connection.disconnect();
_transformed_connection.disconnect();
}
}
-static void
+static void
avoid_conn_move(NR::Matrix const *mp, SPItem *moved_item)
{
- // Detach from objects if attached.
- sp_conn_end_detach(moved_item, 0);
- sp_conn_end_detach(moved_item, 1);
// Reroute connector
SPPath *path = SP_PATH(moved_item);
path->connEndPair.makePathInvalid();
if (key == SP_ATTR_CONNECTOR_TYPE) {
if (value && (strcmp(value, "polyline") == 0)) {
_connType = SP_CONNECTOR_POLYLINE;
-
+
+ Avoid::Router *router = _path->document->router;
GQuark itemID = g_quark_from_string(SP_OBJECT(_path)->id);
- _connRef = new Avoid::ConnRef(itemID);
+ _connRef = new Avoid::ConnRef(router, itemID);
_invalid_path_connection = connectInvalidPath(
sigc::ptr_fun(&sp_conn_adjust_invalid_path));
_transformed_connection = _path->connectTransformed(
}
else {
_connType = SP_CONNECTOR_NOAVOID;
-
+
if (_connRef) {
_connRef->removeFromGraph();
delete _connRef;
return;
}
-
+
unsigned const handle_ix = key - SP_ATTR_CONNECTION_START;
g_assert( handle_ix <= 1 );
this->_connEnd[handle_ix]->setAttacherHref(value);
SPCurve *curve = _path->curve;
SPItem *h2attItem[2];
getAttachedItems(h2attItem);
-
+
for (unsigned h = 0; h < 2; ++h) {
if ( h2attItem[h] ) {
NR::Rect const bbox = h2attItem[h]->invokeBbox(sp_item_i2doc_affine(h2attItem[h]));
endPts[h] = bbox.midpoint();
}
- else
+ else
{
if (h == 0) {
endPts[h] = sp_curve_first_point(curve);
// then all connectors (that require it) will be rerouted. Otherwise,
// one connector could get rerouted several times as a result of
// dragging a couple of shapes.
-
+
SPPath *path = SP_PATH(ptr);
path->connEndPair._invalid_path_signal.emit(path);
}
void SPConnEndPair::storeIds(void)
{
if (_connEnd[0]->href) {
- GQuark itemId = g_quark_from_string(_connEnd[0]->href);
+ // href begins with a '#' which we don't want.
+ const char *startId = _connEnd[0]->href + 1;
+ GQuark itemId = g_quark_from_string(startId);
_connRef->setEndPointId(Avoid::VertID::src, itemId);
}
else {
_connRef->setEndPointId(Avoid::VertID::src, 0);
}
if (_connEnd[1]->href) {
- GQuark itemId = g_quark_from_string(_connEnd[1]->href);
+ // href begins with a '#' which we don't want.
+ const char *endId = _connEnd[1]->href + 1;
+ GQuark itemId = g_quark_from_string(endId);
_connRef->setEndPointId(Avoid::VertID::tar, itemId);
}
else {
}
return false;
}
-
+
void
SPConnEndPair::makePathInvalid(void)
{
Avoid::Point src = { endPt[0][NR::X], endPt[0][NR::Y] };
Avoid::Point dst = { endPt[1][NR::X], endPt[1][NR::Y] };
-
+
_connRef->updateEndPoint(Avoid::VertID::src, src);
_connRef->updateEndPoint(Avoid::VertID::tar, dst);
Avoid::PolyLine route = _connRef->route();
_connRef->calcRouteDist();
-
+
sp_curve_reset(curve);
sp_curve_moveto(curve, endPt[0]);