summaryrefslogtreecommitdiffstats
path: root/src/libavoid/shape.cpp
diff options
context:
space:
mode:
authormjwybrow <mjwybrow@users.sourceforge.net>2006-07-14 05:30:15 +0000
committermjwybrow <mjwybrow@users.sourceforge.net>2006-07-14 05:30:15 +0000
commit4d9217f4f7b6e5b11f88af486e8659f539dc1300 (patch)
tree4e554ba1a27ff9ef8d3d3299cca9eb303c73a726 /src/libavoid/shape.cpp
parentfixed warnings (diff)
downloadinkscape-4d9217f4f7b6e5b11f88af486e8659f539dc1300.tar.gz
inkscape-4d9217f4f7b6e5b11f88af486e8659f539dc1300.zip
* src/sp-conn-end-pair.cpp, src/connector-context.cpp,
src/document.cpp, src/libavoid/*: Update libavoid with upstream fixes, optimisations and new features. (bzr r1411)
Diffstat (limited to 'src/libavoid/shape.cpp')
-rw-r--r--src/libavoid/shape.cpp72
1 files changed, 64 insertions, 8 deletions
diff --git a/src/libavoid/shape.cpp b/src/libavoid/shape.cpp
index 84f0312ee..2b241b728 100644
--- a/src/libavoid/shape.cpp
+++ b/src/libavoid/shape.cpp
@@ -37,6 +37,7 @@ ShapeRef::ShapeRef(Router *router, unsigned int id, Polygn& ply)
, _id(id)
, _poly(copyPoly(ply))
, _active(false)
+ , _inMoveList(false)
, _firstVert(NULL)
, _lastVert(NULL)
{
@@ -60,18 +61,15 @@ ShapeRef::ShapeRef(Router *router, unsigned int id, Polygn& ply)
//node->lstPrev = last;
//last->lstNext = node;
}
- _router->vertices.addVertex(node);
last = node;
i++;
- // Increase total vertices count ++;
}
_lastVert = node;
_lastVert->shNext = _firstVert;
_firstVert->shPrev = _lastVert;
- // Increase total shape count ++;
makeActive();
}
@@ -80,23 +78,20 @@ ShapeRef::~ShapeRef()
{
assert(_firstVert != NULL);
+ makeInactive();
+
VertInf *it = _firstVert;
do
{
VertInf *tmp = it;
it = it->shNext;
- // XXX: This could possibly be done less
- // safely but faster, all at once.
- _router->vertices.removeVertex(tmp);
delete tmp;
}
while (it != _firstVert);
_firstVert = _lastVert = NULL;
freePoly(_poly);
-
- makeInactive();
}
@@ -131,6 +126,18 @@ void ShapeRef::makeActive(void)
// Add to connRefs list.
_pos = _router->shapeRefs.insert(_router->shapeRefs.begin(), this);
+
+ // Add points to vertex list.
+ VertInf *it = _firstVert;
+ do
+ {
+ VertInf *tmp = it;
+ it = it->shNext;
+
+ _router->vertices.addVertex(tmp);
+ }
+ while (it != _firstVert);
+
_active = true;
}
@@ -141,6 +148,18 @@ void ShapeRef::makeInactive(void)
// Remove from connRefs list.
_router->shapeRefs.erase(_pos);
+
+ // Remove points from vertex list.
+ VertInf *it = _firstVert;
+ do
+ {
+ VertInf *tmp = it;
+ it = it->shNext;
+
+ _router->vertices.removeVertex(tmp);
+ }
+ while (it != _firstVert);
+
_active = false;
}
@@ -224,6 +243,43 @@ void ShapeRef::removeFromGraph(void)
}
+void ShapeRef::markForMove(void)
+{
+ if (!_inMoveList)
+ {
+ _inMoveList = true;
+ }
+ else
+ {
+ fprintf(stderr, "WARNING: two moves queued for same shape prior to "
+ "rerouting.\n This is not safe.\n");
+ }
+}
+
+
+void ShapeRef::clearMoveMark(void)
+{
+ _inMoveList = false;
+}
+
+
+VertInf *ShapeRef::getPointVertex(const Point& point)
+{
+ VertInf *curr = _firstVert;
+ do
+ {
+ if (curr->point == point)
+ {
+ return curr;
+ }
+ curr = curr->shNext;
+ }
+ while (curr != _firstVert);
+
+ return NULL;
+}
+
+
}