Integrate sticky vertices in new QGraphicsItem framework.

This commit is contained in:
Tats
2015-07-06 21:58:48 -06:00
parent 57fe2607a9
commit 2ab3b137d9
4 changed files with 54 additions and 28 deletions
+23 -23
View File
@@ -334,29 +334,29 @@ void MapperGLCanvas::enableStickyVertices(bool value)
_stickyVertices = value;
}
/* Stick vertex p of Shape orig to another Shape's vertex, if the 2 vertices are
* close enough. The distance per coordinate is currently set in dist_stick
* variable. Perhaps the sticky-sensitivity should be configurable through GUI */
void MapperGLCanvas::glueVertex(MShape *orig, QPointF *p)
{
MappingManager manager = getMainWindow()->getMappingManager();
for (int i = 0; i < manager.nMappings(); i++)
{
MShape *shape = getShapeFromMappingId(manager.getMapping(i)->getId());
if (shape && shape != orig)
{
for (int vertex = 0; vertex < shape->nVertices(); vertex++)
{
const QPointF& v = shape->getVertex(vertex);
if (distIsInside(v, *p, MM::VERTEX_STICK_RADIUS))
{
p->setX(v.x());
p->setY(v.y());
}
}
}
}
}
///* Stick vertex p of Shape orig to another Shape's vertex, if the 2 vertices are
// * close enough. The distance per coordinate is currently set in dist_stick
// * variable. Perhaps the sticky-sensitivity should be configurable through GUI */
//void MapperGLCanvas::glueVertex(MShape *orig, QPointF *p)
//{
// MappingManager manager = getMainWindow()->getMappingManager();
// for (int i = 0; i < manager.nMappings(); i++)
// {
// MShape *shape = getShapeFromMappingId(manager.getMapping(i)->getId());
// if (shape && shape != orig)
// {
// for (int vertex = 0; vertex < shape->nVertices(); vertex++)
// {
// const QPointF& v = shape->getVertex(vertex);
// if (distIsInside(v, *p, MM::VERTEX_STICK_RADIUS))
// {
// p->setX(v.x());
// p->setY(v.y());
// }
// }
// }
// }
//}
void MapperGLCanvas::deselectVertices()