Fixed translation and display of controls of triangle texture.

This commit is contained in:
Tats
2014-12-28 19:53:36 -05:00
parent 78294f2ef0
commit 2b7a6e82a5
2 changed files with 16 additions and 6 deletions
+9 -6
View File
@@ -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();
+7
View File
@@ -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()));
}
};
/**