mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Sync of vertices control points retroactive (to make ellipse works) (not fully working yet).
This commit is contained in:
+28
-10
@@ -37,23 +37,31 @@ ShapeGraphicsItem::ShapeGraphicsItem(Mapping::ptr mapping, bool output)
|
||||
|
||||
bool ShapeGraphicsItem::sceneEventFilter(QGraphicsItem * watched, QEvent * event)
|
||||
{
|
||||
VertexGraphicsItem* child = static_cast<VertexGraphicsItem*>(watched);
|
||||
Q_ASSERT(child);
|
||||
|
||||
// Change vertex in model according to moved item.
|
||||
if (event->type() == QEvent::GraphicsSceneMouseMove)
|
||||
{
|
||||
QGraphicsSceneMoveEvent* moveEvent = static_cast<QGraphicsSceneMoveEvent*>(event);
|
||||
Q_ASSERT(moveEvent);
|
||||
|
||||
int idx = childItems().indexOf(watched);
|
||||
Q_ASSERT(idx != -1);
|
||||
QPointF pos = child->pos();
|
||||
|
||||
QPointF pos = moveEvent->newPos();
|
||||
_shape->setVertex(idx, pos);
|
||||
|
||||
_syncVertices();
|
||||
|
||||
// Refresh this shape.
|
||||
update();
|
||||
|
||||
// override default
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Returns false to allow the child item to process its event.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Refresh this shape.
|
||||
update();
|
||||
|
||||
// Returns false to allow the child item to process its event.
|
||||
return false;
|
||||
}
|
||||
|
||||
void ShapeGraphicsItem::_createVertices()
|
||||
@@ -85,6 +93,16 @@ void ShapeGraphicsItem::_syncShape()
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeGraphicsItem::_syncVertices()
|
||||
{
|
||||
for (int i=0; i<_shape->nVertices(); i++)
|
||||
{
|
||||
QPointF pos = _shape->getVertex(i);// - this->pos();
|
||||
childItems().at(i)->setPos(pos);
|
||||
childItems().at(i)->update();
|
||||
}
|
||||
}
|
||||
|
||||
QPainterPath PolygonColorGraphicsItem::shape() const
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
Reference in New Issue
Block a user