Repository: pyqtgraph/pyqtgraph

Issue:
Rotating TextItem dosen't work
I want to dynamically rotate TextItem but cannot get it to work. Changing position or anchor with setPos and setAnchor updates the item, but wanting to change angel with setAngle doesn't update the text. The strangest thing is that it does update once I drag the canvas. I am wondering what signal or function to call so that the item updates immediately. 
Below is some code that should move and rotate a TextItem.
```python
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph as pg

app = QtGui.QApplication([])

w = pg.GraphicsView()
w.show()
w.resize(800,800)

view = pg.ViewBox()
w.setCentralItem(view)
view.setAspectLocked(True)
view.setRange(QtCore.QRectF(0, 0, 200, 200))

anchor = pg.TextItem()
anchor.setText("hey")
anchor.setColor(QtGui.QColor(255, 255, 255))

view.addItem(anchor)


def rotate():
    x, y = anchor.pos()
    anchor.setPos(x + 1, y + 1)
    anchor.setAngle(anchor.angle + 10)


timer = QtCore.QTimer()
timer.timeout.connect(rotate)
timer.start(1000)


if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
```


Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/TextItem.py b/pyqtgraph/graphicsItems/TextItem.py
--- a/pyqtgraph/graphicsItems/TextItem.py
+++ b/pyqtgraph/graphicsItems/TextItem.py
@@ -110,9 +110,16 @@ def setFont(self, *args):
         self.updateTextPos()
         
     def setAngle(self, angle):
+        """
+        Set the angle of the text in degrees.
+
+        This sets the rotation angle of the text as a whole, measured
+        counter-clockwise from the x axis of the parent. Note that this rotation
+        angle does not depend on horizontal/vertical scaling of the parent.
+        """
         self.angle = angle
-        self.updateTransform()
-        
+        self.updateTransform(force=True)
+
     def setAnchor(self, anchor):
         self.anchor = Point(anchor)
         self.updateTextPos()
@@ -169,7 +176,7 @@ def paint(self, p, *args):
             p.setRenderHint(p.Antialiasing, True)
             p.drawPolygon(self.textItem.mapToParent(self.textItem.boundingRect()))
         
-    def updateTransform(self):
+    def updateTransform(self, force=False):
         # update transform such that this item has the correct orientation
         # and scaling relative to the scene, but inherits its position from its
         # parent.
@@ -181,7 +188,7 @@ def updateTransform(self):
         else:
             pt = p.sceneTransform()
         
-        if pt == self._lastTransform:
+        if not force and pt == self._lastTransform:
             return
 
         t = pt.inverted()[0]


Test patch:
diff --git a/pyqtgraph/graphicsItems/tests/test_TextItem.py b/pyqtgraph/graphicsItems/tests/test_TextItem.py
new file mode 100644
--- /dev/null
+++ b/pyqtgraph/graphicsItems/tests/test_TextItem.py
@@ -0,0 +1,23 @@
+import pytest
+import pyqtgraph as pg
+
+app = pg.mkQApp()
+
+
+def test_TextItem_setAngle():
+    plt = pg.plot()
+    plt.setXRange(-10, 10)
+    plt.setYRange(-20, 20)
+    item = pg.TextItem(text="test")
+    plt.addItem(item)
+
+    t1 = item.transform()
+
+    item.setAngle(30)
+    app.processEvents()
+
+    t2 = item.transform()
+
+    assert t1 != t2
+    assert not t1.isRotating()
+    assert t2.isRotating()