diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index c04ad9e49a4cb2d3a0c122653faf16a986bf721e..b9dc218b4fcc84bfaa48e06df9b81ad0c11cf701 100644 (file)
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
{
_transformed_connection.disconnect();
{
_transformed_connection.disconnect();
- // If the document is being destroyed then the router instance
+ // If the document is being destroyed then the router instance
// and the ShapeRefs will have been destroyed with it.
const bool routerInstanceExists = (item->document->router != NULL);
// and the ShapeRefs will have been destroyed with it.
const bool routerInstanceExists = (item->document->router != NULL);
Update the connectors for which
the endpoint has changed.
*/
Update the connectors for which
the endpoint has changed.
*/
-
+
gchar ** strarray = g_strsplit(value, "|", 0);
gchar ** iter = strarray;
gchar ** strarray = g_strsplit(value, "|", 0);
gchar ** iter = strarray;
-
+
while (*iter != NULL) {
ConnectionPoint cp;
Inkscape::SVGIStringStream is(*iter);
while (*iter != NULL) {
ConnectionPoint cp;
Inkscape::SVGIStringStream is(*iter);
{
SPPath* path = SP_PATH(i->data);
SPConnEnd** connEnds = path->connEndPair.getConnEnds();
{
SPPath* path = SP_PATH(i->data);
SPConnEnd** connEnds = path->connEndPair.getConnEnds();
- for (int ix=0; ix<2; ++ix)
- if (connEnds[ix]->type == ConnPointUserDefined)
- if (updates.find(connEnds[ix]->id) != updates.end())
- if (path->connEndPair.isAutoRoutingConn())
+ for (int ix=0; ix<2; ++ix) {
+ if (connEnds[ix]->type == ConnPointUserDefined) {
+ if (updates.find(connEnds[ix]->id) != updates.end()) {
+ if (path->connEndPair.isAutoRoutingConn()) {
path->connEndPair.tellLibavoidNewEndpoints();
path->connEndPair.tellLibavoidNewEndpoints();
- else
- {
+ } else {
}
}
- else
- if (deletes.find(connEnds[ix]->id) != deletes.end())
- sp_conn_end_detach(path, ix);
+ }
+ else if (deletes.find(connEnds[ix]->id) != deletes.end()) {
+ sp_conn_end_detach(path, ix);
+ }
+ }
+ }
}
g_slist_free(conns);
// Remove all deleted connection points
}
g_slist_free(conns);
// Remove all deleted connection points
void SPAvoidRef::setConnectionPointsAttrUndoable(const gchar* value, const gchar* action)
{
SPDocument* doc = SP_OBJECT_DOCUMENT(item);
void SPAvoidRef::setConnectionPointsAttrUndoable(const gchar* value, const gchar* action)
{
SPDocument* doc = SP_OBJECT_DOCUMENT(item);
-
+
sp_object_setAttribute( SP_OBJECT(item), "inkscape:connection-points", value, 0 );
item->updateRepr();
sp_document_ensure_up_to_date(doc);
sp_object_setAttribute( SP_OBJECT(item), "inkscape:connection-points", value, 0 );
item->updateRepr();
sp_document_ensure_up_to_date(doc);
}
else
ostr<<'|'<<cp;
}
else
ostr<<'|'<<cp;
-
+
this->setConnectionPointsAttrUndoable( ostr.str().c_str(), _("Added a new connection point") );
}
this->setConnectionPointsAttrUndoable( ostr.str().c_str(), _("Added a new connection point") );
}
{
Inkscape::SVGOStringStream ostr;
IdConnectionPointMap::iterator cp_pos = connection_points.find( cp.id );
{
Inkscape::SVGOStringStream ostr;
IdConnectionPointMap::iterator cp_pos = connection_points.find( cp.id );
- if ( cp_pos != connection_points.end() )
- {
+ if ( cp_pos != connection_points.end() ) {
bool first = true;
bool first = true;
- for (IdConnectionPointMap::iterator it = connection_points.begin(); it != connection_points.end(); ++it)
- {
- if ( it != cp_pos )
- if ( first )
- {
+ for (IdConnectionPointMap::iterator it = connection_points.begin(); it != connection_points.end(); ++it) {
+ if ( it != cp_pos ) {
+ if ( first ) {
first = false;
ostr<<it->second;
first = false;
ostr<<it->second;
- }
- else
+ } else {
ostr<<'|'<<it->second;
ostr<<'|'<<it->second;
+ }
+ }
}
this->setConnectionPointsAttrUndoable( ostr.str().c_str(), _("Removed a connection point") );
}
}
this->setConnectionPointsAttrUndoable( ostr.str().c_str(), _("Removed a connection point") );
}
setting = new_setting;
Router *router = item->document->router;
setting = new_setting;
Router *router = item->document->router;
-
+
_transformed_connection.disconnect();
if (new_setting) {
Avoid::Polygon poly = avoid_item_poly(item);
_transformed_connection.disconnect();
if (new_setting) {
Avoid::Polygon poly = avoid_item_poly(item);
const char *id = SP_OBJECT_REPR(item)->attribute("id");
g_assert(id != NULL);
const char *id = SP_OBJECT_REPR(item)->attribute("id");
g_assert(id != NULL);
-
+
// Get a unique ID for the item.
GQuark itemID = g_quark_from_string(id);
shapeRef = new Avoid::ShapeRef(router, poly, itemID);
// Get a unique ID for the item.
GQuark itemID = g_quark_from_string(id);
shapeRef = new Avoid::ShapeRef(router, poly, itemID);
-
+
router->addShape(shapeRef);
}
}
else
{
g_assert(shapeRef);
router->addShape(shapeRef);
}
}
else
{
g_assert(shapeRef);
-
+
router->removeShape(shapeRef);
delete shapeRef;
shapeRef = NULL;
router->removeShape(shapeRef);
delete shapeRef;
shapeRef = NULL;
Avoid::IntList shapes;
GQuark shapeId = g_quark_from_string(item->id);
item->document->router->attachedShapes(shapes, shapeId, type);
Avoid::IntList shapes;
GQuark shapeId = g_quark_from_string(item->id);
item->document->router->attachedShapes(shapes, shapeId, type);
-
+
Avoid::IntList::iterator finish = shapes.end();
for (Avoid::IntList::iterator i = shapes.begin(); i != finish; ++i) {
const gchar *connId = g_quark_to_string(*i);
Avoid::IntList::iterator finish = shapes.end();
for (Avoid::IntList::iterator i = shapes.begin(); i != finish; ++i) {
const gchar *connId = g_quark_to_string(*i);
Avoid::IntList conns;
GQuark shapeId = g_quark_from_string(item->id);
item->document->router->attachedConns(conns, shapeId, type);
Avoid::IntList conns;
GQuark shapeId = g_quark_from_string(item->id);
item->document->router->attachedConns(conns, shapeId, type);
-
+
Avoid::IntList::iterator finish = conns.end();
for (Avoid::IntList::iterator i = conns.begin(); i != finish; ++i) {
const gchar *connId = g_quark_to_string(*i);
Avoid::IntList::iterator finish = conns.end();
for (Avoid::IntList::iterator i = conns.begin(); i != finish; ++i) {
const gchar *connId = g_quark_to_string(*i);
g_assert(item);
Geom::Point pos;
const Geom::Matrix& transform = sp_item_i2doc_affine(item);
g_assert(item);
Geom::Point pos;
const Geom::Matrix& transform = sp_item_i2doc_affine(item);
+ // TODO investigate why this was asking for the active desktop:
SPDesktop *desktop = inkscape_active_desktop();
if ( type == ConnPointDefault )
SPDesktop *desktop = inkscape_active_desktop();
if ( type == ConnPointDefault )
else
return connection_points.find( id ) != connection_points.end();
}
else
return connection_points.find( id ) != connection_points.end();
}
-
+
return true;
}
return true;
}
if ( convex_hull_approximation_enabled && SP_IS_SHAPE (item) ) {
// The number of points to use for approximation
if ( convex_hull_approximation_enabled && SP_IS_SHAPE (item) ) {
// The number of points to use for approximation
- const unsigned NUM_POINTS = 64;
+ const unsigned NUM_POINTS = 64;
// printf("[sommer] is a shape\n");
SPCurve* curve = sp_shape_get_curve (SP_SHAPE (item));
// printf("[sommer] is a shape\n");
SPCurve* curve = sp_shape_get_curve (SP_SHAPE (item));
const Geom::PathVector& curve_pv = curve->get_pathvector();
std::vector<Geom::Point> hull_points;
for (Geom::PathVector::const_iterator i = curve_pv.begin(); i != curve_pv.end(); i++) {
const Geom::PathVector& curve_pv = curve->get_pathvector();
std::vector<Geom::Point> hull_points;
for (Geom::PathVector::const_iterator i = curve_pv.begin(); i != curve_pv.end(); i++) {
- const Geom::Path& curve_pv_path = *i;
+ const Geom::Path& curve_pv_path = *i;
// printf("[sommer] tracing sub-path\n");
// FIXME: enlarge path by "desktop->namedview->connector_spacing" (using sp_selected_path_do_offset)?
// printf("[sommer] tracing sub-path\n");
// FIXME: enlarge path by "desktop->namedview->connector_spacing" (using sp_selected_path_do_offset)?
// sample points along the path for approximation of convex hull
for (unsigned n = 0; n < num_points; n++) {
// sample points along the path for approximation of convex hull
for (unsigned n = 0; n < num_points; n++) {
- double at = curve_pv_path.size() / static_cast<double>(num_points) * n;
+ double at = curve_pv_path.size() / static_cast<double>(num_points) * n;
Geom::Point pt = curve_pv_path.pointAt(at);
hull_points.push_back(pt);
}
Geom::Point pt = curve_pv_path.pointAt(at);
hull_points.push_back(pt);
}
// store expanded convex hull in Avoid::Polygn
unsigned n = 0;
Avoid::Polygon poly;
// store expanded convex hull in Avoid::Polygn
unsigned n = 0;
Avoid::Polygon poly;
+/*
const Geom::Point& old_pt = *hull.boundary.begin();
const Geom::Point& old_pt = *hull.boundary.begin();
+*/
Geom::Line hull_edge(*hull.boundary.begin(), *(hull.boundary.begin()+1));
Geom::Line parallel_hull_edge;
Geom::Line hull_edge(*hull.boundary.begin(), *(hull.boundary.begin()+1));
Geom::Line parallel_hull_edge;
if (int_pt)
{
if (int_pt)
{
- Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
+ Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
(parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);
// printf("[sommer] %f, %f\n", old_pt[Geom::X], old_pt[Geom::Y]);
(parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);
// printf("[sommer] %f, %f\n", old_pt[Geom::X], old_pt[Geom::Y]);
-/* printf("[sommer] %f, %f\n", (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
+/* printf("[sommer] %f, %f\n", (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
(parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);*/
poly.ps.push_back(avoid_pt);
}
for (std::vector<Geom::Point>::const_iterator i = hull.boundary.begin() + 1; i != hull.boundary.end(); i++, n++) {
(parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);*/
poly.ps.push_back(avoid_pt);
}
for (std::vector<Geom::Point>::const_iterator i = hull.boundary.begin() + 1; i != hull.boundary.end(); i++, n++) {
+/*
const Geom::Point& old_pt = *i;
const Geom::Point& old_pt = *i;
+*/
Geom::Line hull_edge(*i, *(i+1));
Geom::Line parallel_hull_edge;
parallel_hull_edge.origin(hull_edge.origin()+hull_edge.versor().ccw()*spacing);
Geom::Line hull_edge(*i, *(i+1));
Geom::Line parallel_hull_edge;
parallel_hull_edge.origin(hull_edge.origin()+hull_edge.versor().ccw()*spacing);
if (int_pt)
{
if (int_pt)
{
- Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
+ Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
(parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);
/* printf("[sommer] %f, %f\n", old_pt[Geom::X], old_pt[Geom::Y]);
(parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);
/* printf("[sommer] %f, %f\n", old_pt[Geom::X], old_pt[Geom::Y]);
- printf("[sommer] %f, %f\n", (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
+ printf("[sommer] %f, %f\n", (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X],
(parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);*/
poly.ps.push_back(avoid_pt);
}
}
(parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]);*/
poly.ps.push_back(avoid_pt);
}
}
-
+
return poly;
}// else printf("[sommer] is no curve\n");
}// else printf("[sommer] is no shape\n");
}
return poly;
}// else printf("[sommer] is no curve\n");
}// else printf("[sommer] is no shape\n");
}
-
+
Geom::OptRect rHull = item->getBounds(sp_item_i2doc_affine(item));
if (!rHull) {
return Avoid::Polygon();
Geom::OptRect rHull = item->getBounds(sp_item_i2doc_affine(item));
if (!rHull) {
return Avoid::Polygon();
// Add a little buffer around the edge of each object.
Geom::Rect rExpandedHull = *rHull;
// Add a little buffer around the edge of each object.
Geom::Rect rExpandedHull = *rHull;
- rExpandedHull.expandBy(spacing);
+ rExpandedHull.expandBy(spacing);
Avoid::Polygon poly(4);
for (size_t n = 0; n < 4; ++n) {
Avoid::Polygon poly(4);
for (size_t n = 0; n < 4; ++n) {
}
}
-GSList *get_avoided_items(GSList *list, SPObject *from, SPDesktop *desktop,
+GSList *get_avoided_items(GSList *list, SPObject *from, SPDesktop *desktop,
bool initialised)
{
for (SPObject *child = sp_object_first_child(SP_OBJECT(from)) ;
child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (SP_IS_ITEM(child) &&
!desktop->isLayer(SP_ITEM(child)) &&
bool initialised)
{
for (SPObject *child = sp_object_first_child(SP_OBJECT(from)) ;
child != NULL; child = SP_OBJECT_NEXT(child) ) {
if (SP_IS_ITEM(child) &&
!desktop->isLayer(SP_ITEM(child)) &&
- !SP_ITEM(child)->isLocked() &&
+ !SP_ITEM(child)->isLocked() &&
!desktop->itemIsHidden(SP_ITEM(child)) &&
(!initialised || SP_ITEM(child)->avoidRef->shapeRef)
)
!desktop->itemIsHidden(SP_ITEM(child)) &&
(!initialised || SP_ITEM(child)->avoidRef->shapeRef)
)
SPDocument *document = sp_desktop_document(desktop);
bool saved = sp_document_get_undo_sensitive(document);
sp_document_set_undo_sensitive(document, false);
SPDocument *document = sp_desktop_document(desktop);
bool saved = sp_document_get_undo_sensitive(document);
sp_document_set_undo_sensitive(document, false);
-
+
bool initialised = false;
GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop,
initialised);
bool initialised = false;
GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop,
initialised);