index 25466a4a4d5de6daf4af48c497801f7ca039737a..49d6fbcdbc67e8823b9cd996974555c165f34591 100644 (file)
--- a/src/sp-conn-end-pair.cpp
+++ b/src/sp-conn-end-pair.cpp
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include <cstring>
+#include <string>
+
#include "attributes.h"
#include "sp-conn-end.h"
#include "uri.h"
static void
-avoid_conn_move(NR::Matrix const *mp, SPItem *moved_item)
+avoid_conn_move(Geom::Matrix const */*mp*/, SPItem *moved_item)
{
// Reroute connector
SPPath *path = SP_PATH(moved_item);
h2attItem[h] = this->_connEnd[h]->ref.getObject();
// Deal with the case of the attached object being an empty group.
- // A group containing no items does not have a valid bbox, so
+ // A group containing no items does not have a valid bbox, so
// causes problems for the auto-routing code. Also, since such a
// group no longer has an onscreen representation and can only be
// selected through the XML editor, it makes sense just to detach
}
void
-SPConnEndPair::getEndpoints(NR::Point endPts[]) const {
+SPConnEndPair::getEndpoints(Geom::Point endPts[]) const {
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]->getBounds(sp_item_i2doc_affine(h2attItem[h]));
- endPts[h] = bbox.midpoint();
+ Geom::OptRect bbox = h2attItem[h]->getBounds(sp_item_i2doc_affine(h2attItem[h]));
+ if (bbox) {
+ endPts[h] = bbox->midpoint();
+ } else {
+ // FIXME
+ endPts[h] = Geom::Point(0, 0);
+ }
}
else
{
if (h == 0) {
- endPts[h] = sp_curve_first_point(curve);
+ endPts[h] = *(curve->first_point());
}
else {
- endPts[h] = sp_curve_last_point(curve);
+ endPts[h] = *(curve->last_point());
}
}
}
if (_connType != SP_CONNECTOR_NOAVOID) {
g_assert(_connRef != NULL);
if (!(_connRef->isInitialised())) {
- NR::Point endPt[2];
+ Geom::Point endPt[2];
getEndpoints(endPt);
- Avoid::Point src(endPt[0][NR::X], endPt[0][NR::Y]);
- Avoid::Point dst(endPt[1][NR::X], endPt[1][NR::Y]);
+ Avoid::Point src(endPt[0][Geom::X], endPt[0][Geom::Y]);
+ Avoid::Point dst(endPt[1][Geom::X], endPt[1][Geom::Y]);
_connRef->lateSetup(src, dst);
_connRef->setCallback(&emitPathInvalidationNotification, _path);
SPCurve *curve = _path->curve;
- NR::Point endPt[2];
+ Geom::Point endPt[2];
getEndpoints(endPt);
- Avoid::Point src(endPt[0][NR::X], endPt[0][NR::Y]);
- Avoid::Point dst(endPt[1][NR::X], endPt[1][NR::Y]);
+ Avoid::Point src(endPt[0][Geom::X], endPt[0][Geom::Y]);
+ Avoid::Point dst(endPt[1][Geom::X], endPt[1][Geom::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]);
+ curve->reset();
+ curve->moveto(endPt[0]);
for (int i = 1; i < route.pn; ++i) {
- NR::Point p(route.ps[i].x, route.ps[i].y);
- sp_curve_lineto(curve, p);
+ Geom::Point p(route.ps[i].x, route.ps[i].y);
+ curve->lineto(p);
}
}