mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Fixed translation and display of controls of triangle texture.
This commit is contained in:
+9
-6
@@ -214,14 +214,19 @@ void TextureGraphicsItem::paint(QPainter *painter,
|
||||
|
||||
if (_output)
|
||||
{
|
||||
bool selected = option->state & QStyle::State_Selected;
|
||||
|
||||
// Prepare drawing.
|
||||
_preDraw(painter);
|
||||
|
||||
// Perform the actual mapping (done by subclasses).
|
||||
_doDraw(painter, option->state & QStyle::State_Selected);
|
||||
_doDraw(painter, selected);
|
||||
|
||||
// End drawing.
|
||||
_postDraw(painter);
|
||||
|
||||
if (selected)
|
||||
_doDrawControls(painter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,13 +275,11 @@ QPainterPath PolygonTextureGraphicsItem::shape() const
|
||||
Polygon* poly = static_cast<Polygon*>(_shape.get());
|
||||
Q_ASSERT(poly);
|
||||
path.addPolygon(poly->toPolygon());
|
||||
return path;
|
||||
return mapFromScene(path);
|
||||
}
|
||||
|
||||
QRectF PolygonTextureGraphicsItem::boundingRect() const {
|
||||
Polygon* poly = static_cast<Polygon*>(_shape.get());
|
||||
Q_ASSERT(poly);
|
||||
return poly->toPolygon().boundingRect();
|
||||
return shape().boundingRect();
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +293,7 @@ void TriangleTextureGraphicsItem::_doDraw(QPainter* painter, bool selected)
|
||||
{
|
||||
for (int i=0; i<_inputShape->nVertices(); i++)
|
||||
{
|
||||
Util::setGlTexPoint(*_texture, _inputShape->getVertex(i), _shape->getVertex(i));
|
||||
Util::setGlTexPoint(*_texture, _inputShape->getVertex(i), mapFromScene(_shape->getVertex(i)));
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
@@ -149,6 +149,7 @@ public:
|
||||
const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
virtual void _doDraw(QPainter* painter, bool selected) = 0;
|
||||
virtual void _doDrawControls(QPainter* painter) { Q_UNUSED(painter); }
|
||||
void _preDraw(QPainter* painter);
|
||||
void _postDraw(QPainter* painter);
|
||||
|
||||
@@ -177,6 +178,12 @@ public:
|
||||
virtual ~TriangleTextureGraphicsItem(){}
|
||||
|
||||
virtual void _doDraw(QPainter* painter, bool selected);
|
||||
virtual void _doDrawControls(QPainter* painter) {
|
||||
painter->setPen(MM::SHAPE_STROKE);
|
||||
Polygon* poly = static_cast<Polygon*>(_shape.get());
|
||||
Q_ASSERT(poly);
|
||||
painter->drawPolygon(mapFromScene(poly->toPolygon()));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user