Hi,

I have an object in the scene and I use mapFromScene to map a point, which is in the item's scene's coordinate system, to the item's coordinate system.

When the item’s transformation matrix is identity, and I move the object around the scene and then I use mapFromScene with the current scenePos, the result is always (0,0). However, if I apply to the item a transformation that scales the object to double its width, and I move the object around the scene and then I use mapFromScene with the current scenePos, the result is different at different places of the scene. See for example:

The object is at the top left of the scene:
***************** Start Map pivot ***************
ScenePos X: 117
ScenePos Y: 67
Transformed X: 9.88098e-15
Transformed Y: 0
Current transformation Matrix:
|---|---|---|
| 2 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |
|---|---|---|
***************** End map pivot ***************

The object is at the top right of the scene:
***************** Start Map pivot ***************
ScenePos X: 623
ScenePos Y: 69
Transformed X: 2.9976e-15
Transformed Y: 0
Current transformation Matrix:
|---|---|---|
| 2 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |
|---|---|---|
***************** End map pivot ***************

The object is around the center or the scene
***************** Start Map pivot ***************
ScenePos X: 368
ScenePos Y: 218
Transformed X: -5.15143e-14
Transformed Y: 0
Current transformation Matrix:
|---|---|---|
| 2 | 0 | 0 |
| 0 | 1 | 0 |
| 0 | 0 | 1 |
|---|---|---|
***************** End map pivot ***************

Here is the code:
Qt Code:
  1. void tnkdesignscene::setTransPivotPoint()
  2. {
  3. QPointF refCoordinate;
  4. refCoordinate = SelectedItem->scenePos();
  5. qgraphicsitem_cast<tnkitemcontainer *>(SelectedItem)->setTransPivotPoint(QVector2D(refCoordinate));
  6. }
  7.  
  8. void tnkitemcontainer::setTransPivotPoint(QVector2D vector)
  9. {
  10. qDebug() << "***************** Start Map pivot ***************";
  11.  
  12. qDebug() << "ScenePos X: " << vector.x();
  13. qDebug() << "ScenePos Y: " << vector.y();
  14.  
  15. transPivotPoint = QVector2D(this->mapFromScene(vector.toPointF()));
  16.  
  17. qDebug() << "Transformed X: " << transPivotPoint.x();
  18. qDebug() << "Transformed Y: " << transPivotPoint.y();
  19.  
  20. printMatrix(this->transform());
  21.  
  22. qDebug() << "***************** End map pivot ***************";
  23. }
To copy to clipboard, switch view to plain text mode 

Any idea why?

Thanks,
Carlos.