Hi,
I have a QGraphicsPolygonItem defined as:
myShape << QPointF(-50, -50) << QPointF(50, -50)
<< QPointF(50, 50) << QPointF(-50, 50)
<< QPointF(-50, -50);
mypolygon.setPolygon(myShape);
Its starting matrix is identity:
|---|---|---|
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |
|---|---|---|
When I dilate the shape to double its size with a TransformationPivotVector = (-50,0) I get the following matrix:
Matrix after Scale:
|----|---|---|
| 2 | 0 | 0 |
| 0 | 1 | 0 |
| 50 | 0 | 1 |
|----|---|---|
This means that the center of the shape has been translated by 50 units along the X axis.
Now, Giving that the shape currently has the matrix after scale, When I intent to contract the shape using a TransformationPivotVector = (50,0) the translation automatically becomes negative, see for example when I contract just 0.01 of the shape:
|-------|---|---|
| 1.99 | 0 | 0 |
| 0 | 1 | 0 |
| -49.5 | 0 | 1 |
|-------|---|---|
I use the following function to get an overall transformation matrix:
myShape->setTransform(QTransform().translate(transPivotVector.x(), transPivotVector.y()).rotate(rotation).scale(xFactor, yFactor).translate(-transPivotVector.x(),-transPivotVector.y()));
The function basically gets a final matrix from: translate * rotate * scale * -translate.
I guess these function needs to include any previous translation of the object but I don’t know how.
Please help me!!
Many thanks in advance,
Carlos.