index 98b2aec26dc23eaf1125a5c04f601746ea35da9f..7f019979a7bd65b95fd3589de02aba5310a80d06 100644 (file)
--- a/src/sp-conn-end-pair.cpp
+++ b/src/sp-conn-end-pair.cpp
this->_connEnd[handle_ix]->ref.detach();
}
- // If the document is being destroyed then the router instance
+ // If the document is being destroyed then the router instance
// and the ConnRefs will have been destroyed with it.
const bool routerInstanceExists = (_path->document->router != NULL);
{
sp_object_read_attr(object, "inkscape:connector-type");
sp_object_read_attr(object, "inkscape:connection-start");
+ sp_object_read_attr(object, "inkscape:connection-start-point");
sp_object_read_attr(object, "inkscape:connection-end");
+ sp_object_read_attr(object, "inkscape:connection-end-point");
sp_object_read_attr(object, "inkscape:connector-curvature");
}
void
SPConnEndPair::setAttr(unsigned const key, gchar const *const value)
{
- if (key == SP_ATTR_CONNECTOR_TYPE) {
- if (value && (strcmp(value, "polyline") == 0 || strcmp(value, "orthogonal") == 0)) {
- int newconnType = strcmp(value, "polyline") ? SP_CONNECTOR_ORTHOGONAL : SP_CONNECTOR_POLYLINE;
-
- if (!_connRef)
- {
- _connType = newconnType;
- Avoid::Router *router = _path->document->router;
- GQuark itemID = g_quark_from_string(SP_OBJECT(_path)->id);
- _connRef = new Avoid::ConnRef(router, itemID);
- switch (newconnType)
- {
- case SP_CONNECTOR_POLYLINE:
- _connRef->setRoutingType(Avoid::ConnType_PolyLine);
- break;
- case SP_CONNECTOR_ORTHOGONAL:
- _connRef->setRoutingType(Avoid::ConnType_Orthogonal);
- }
- _transformed_connection = _path->connectTransformed(
- sigc::ptr_fun(&avoid_conn_transformed));
- }
- else
- if (newconnType != _connType)
+ switch (key)
+ {
+ case SP_ATTR_CONNECTOR_TYPE:
+ if (value && (strcmp(value, "polyline") == 0 || strcmp(value, "orthogonal") == 0)) {
+ int newconnType = strcmp(value, "polyline") ? SP_CONNECTOR_ORTHOGONAL : SP_CONNECTOR_POLYLINE;
+
+ if (!_connRef)
{
_connType = newconnType;
+ Avoid::Router *router = _path->document->router;
+ GQuark itemID = g_quark_from_string(_path->getId());
+ _connRef = new Avoid::ConnRef(router, itemID);
switch (newconnType)
{
case SP_CONNECTOR_POLYLINE:
case SP_CONNECTOR_ORTHOGONAL:
_connRef->setRoutingType(Avoid::ConnType_Orthogonal);
}
- sp_conn_reroute_path(_path);
+ _transformed_connection = _path->connectTransformed(
+ sigc::ptr_fun(&avoid_conn_transformed));
}
- }
- else {
- _connType = SP_CONNECTOR_NOAVOID;
+ else
+ if (newconnType != _connType)
+ {
+ _connType = newconnType;
+ switch (newconnType)
+ {
+ case SP_CONNECTOR_POLYLINE:
+ _connRef->setRoutingType(Avoid::ConnType_PolyLine);
+ break;
+ case SP_CONNECTOR_ORTHOGONAL:
+ _connRef->setRoutingType(Avoid::ConnType_Orthogonal);
+ }
+ sp_conn_reroute_path(_path);
+ }
+ }
+ else {
+ _connType = SP_CONNECTOR_NOAVOID;
- if (_connRef) {
- _connRef->removeFromGraph();
- delete _connRef;
- _connRef = NULL;
- _transformed_connection.disconnect();
+ if (_connRef) {
+ _connRef->removeFromGraph();
+ delete _connRef;
+ _connRef = NULL;
+ _transformed_connection.disconnect();
+ }
}
- }
- return;
- }
- else if (key == SP_ATTR_CONNECTOR_CURVATURE) {
- if (value) {
- _connCurvature = g_strtod(value, NULL);
- if (_connRef && _connRef->isInitialised()) {
- // Redraw the connector, but only if it has been initialised.
- sp_conn_reroute_path(_path);
+ break;
+ case SP_ATTR_CONNECTOR_CURVATURE:
+ if (value) {
+ _connCurvature = g_strtod(value, NULL);
+ if (_connRef && _connRef->isInitialised()) {
+ // Redraw the connector, but only if it has been initialised.
+ sp_conn_reroute_path(_path);
+ }
}
- }
- return;
+ break;
+ case SP_ATTR_CONNECTION_START:
+ case SP_ATTR_CONNECTION_END:
+ this->_connEnd[(key == SP_ATTR_CONNECTION_START ? 0 : 1)]->setAttacherHref(value, _path);
+ break;
+ case SP_ATTR_CONNECTION_START_POINT:
+ case SP_ATTR_CONNECTION_END_POINT:
+ this->_connEnd[(key == SP_ATTR_CONNECTION_START_POINT ? 0 : 1)]->setAttacherEndpoint(value, _path);
+ break;
}
- unsigned const handle_ix = key - SP_ATTR_CONNECTION_START;
- g_assert( handle_ix <= 1 );
- this->_connEnd[handle_ix]->setAttacherHref(value, _path);
}
void
SPConnEndPair::writeRepr(Inkscape::XML::Node *const repr) const
{
+ char const * const attr_strs[] = {"inkscape:connection-start", "inkscape:connection-start-point",
+ "inkscape:connection-end", "inkscape:connection-end-point"};
for (unsigned handle_ix = 0; handle_ix < 2; ++handle_ix) {
if (this->_connEnd[handle_ix]->ref.getURI()) {
- char const * const attr_strs[] = {"inkscape:connection-start",
- "inkscape:connection-end"};
+ repr->setAttribute(attr_strs[2*handle_ix], this->_connEnd[handle_ix]->ref.getURI()->toString());
std::ostringstream ostr;
- ostr<<this->_connEnd[handle_ix]->ref.getURI()->toString()<<"_"<<
- (this->_connEnd[handle_ix]->type == ConnPointDefault ? "d":"u") <<
- "_" << this->_connEnd[handle_ix]->id;
-
-
- repr->setAttribute(attr_strs[handle_ix], ostr.str().c_str());
+ ostr<<(this->_connEnd[handle_ix]->type == ConnPointDefault ? "d":"u") <<
+ this->_connEnd[handle_ix]->id;
+ repr->setAttribute(attr_strs[2*handle_ix+1], ostr.str().c_str());
}
}
repr->setAttribute("inkscape:connector-curvature", Glib::Ascii::dtostr(_connCurvature).c_str());
void SPConnEndPair::storeIds(void)
{
if (_connEnd[0]->href) {
- gchar ** href_strarray = NULL;
- href_strarray = g_strsplit(_connEnd[0]->href, "_", 0);
// href begins with a '#' which we don't want.
- const char *startId = href_strarray[0] + 1;
+ const char *startId = _connEnd[0]->href + 1;
GQuark itemId = g_quark_from_string(startId);
_connRef->setEndPointId(Avoid::VertID::src, itemId);
- g_strfreev(href_strarray);
}
else {
_connRef->setEndPointId(Avoid::VertID::src, 0);
}
if (_connEnd[1]->href) {
- gchar ** href_strarray = NULL;
- href_strarray = g_strsplit(_connEnd[1]->href, "_", 0);
// href begins with a '#' which we don't want.
- const char *endId = href_strarray[0] + 1;
+ const char *endId = _connEnd[1]->href + 1;
GQuark itemId = g_quark_from_string(endId);
_connRef->setEndPointId(Avoid::VertID::tar, itemId);
- g_strfreev(href_strarray);
}
else {
_connRef->setEndPointId(Avoid::VertID::tar, 0);
@@ -339,7 +339,7 @@ void recreateCurve(SPCurve *curve, Avoid::ConnRef *connRef, const gdouble curvat
if (!straight)
route = route.curvedPolyline(curvature);
connRef->calcRouteDist();
-
+
curve->reset();
curve->moveto( Geom::Point(route.ps[0].x, route.ps[0].y) );
@@ -359,7 +359,7 @@ void recreateCurve(SPCurve *curve, Avoid::ConnRef *connRef, const gdouble curvat
break;
case 'C':
g_assert( i+2<pn );
- curve->curveto( p, Geom::Point(route.ps[i+1].x, route.ps[i+1].y),
+ curve->curveto( p, Geom::Point(route.ps[i+1].x, route.ps[i+1].y),
Geom::Point(route.ps[i+2].x, route.ps[i+2].y) );
i+=2;
break;
SPCurve *curve = _path->original_curve ?_path->original_curve : _path->curve;
recreateCurve( curve, _connRef, _connCurvature );
-
+
Geom::Matrix doc2item = sp_item_i2doc_affine(SP_ITEM(_path)).inverse();
- curve->transform(doc2item);
-
+ curve->transform(doc2item);
+
return true;
}