We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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_()
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pyqtgraph/graphicsItems/TextItem.py`
Content:
```
1 import numpy as np
2 from ..Qt import QtCore, QtGui
3 from ..Point import Point
4 from .. import functions as fn
5 from .GraphicsObject import GraphicsObject
6 
7 
8 class TextItem(GraphicsObject):
9     """
10     GraphicsItem displaying unscaled text (the text will always appear normal even inside a scaled ViewBox). 
11     """
12     def __init__(self, text='', color=(200,200,200), html=None, anchor=(0,0),
13                  border=None, fill=None, angle=0, rotateAxis=None):
14         """
15         ==============  =================================================================================
16         **Arguments:**
17         *text*          The text to display
18         *color*         The color of the text (any format accepted by pg.mkColor)
19         *html*          If specified, this overrides both *text* and *color*
20         *anchor*        A QPointF or (x,y) sequence indicating what region of the text box will
21                         be anchored to the item's position. A value of (0,0) sets the upper-left corner
22                         of the text box to be at the position specified by setPos(), while a value of (1,1)
23                         sets the lower-right corner.
24         *border*        A pen to use when drawing the border
25         *fill*          A brush to use when filling within the border
26         *angle*         Angle in degrees to rotate text. Default is 0; text will be displayed upright.
27         *rotateAxis*    If None, then a text angle of 0 always points along the +x axis of the scene.
28                         If a QPointF or (x,y) sequence is given, then it represents a vector direction
29                         in the parent's coordinate system that the 0-degree line will be aligned to. This
30                         Allows text to follow both the position and orientation of its parent while still
31                         discarding any scale and shear factors.
32         ==============  =================================================================================
33 
34 
35         The effects of the `rotateAxis` and `angle` arguments are added independently. So for example:
36 
37         * rotateAxis=None, angle=0 -> normal horizontal text
38         * rotateAxis=None, angle=90 -> normal vertical text
39         * rotateAxis=(1, 0), angle=0 -> text aligned with x axis of its parent
40         * rotateAxis=(0, 1), angle=0 -> text aligned with y axis of its parent
41         * rotateAxis=(1, 0), angle=90 -> text orthogonal to x axis of its parent        
42         """
43                      
44         self.anchor = Point(anchor)
45         self.rotateAxis = None if rotateAxis is None else Point(rotateAxis)
46         #self.angle = 0
47         GraphicsObject.__init__(self)
48         self.textItem = QtGui.QGraphicsTextItem()
49         self.textItem.setParentItem(self)
50         self._lastTransform = None
51         self._lastScene = None
52         self._bounds = QtCore.QRectF()
53         if html is None:
54             self.setColor(color)
55             self.setText(text)
56         else:
57             self.setHtml(html)
58         self.fill = fn.mkBrush(fill)
59         self.border = fn.mkPen(border)
60         self.setAngle(angle)
61 
62     def setText(self, text, color=None):
63         """
64         Set the text of this item. 
65         
66         This method sets the plain text of the item; see also setHtml().
67         """
68         if color is not None:
69             self.setColor(color)
70         self.textItem.setPlainText(text)
71         self.updateTextPos()
72         
73     def setPlainText(self, *args):
74         """
75         Set the plain text to be rendered by this item. 
76         
77         See QtGui.QGraphicsTextItem.setPlainText().
78         """
79         self.textItem.setPlainText(*args)
80         self.updateTextPos()
81         
82     def setHtml(self, *args):
83         """
84         Set the HTML code to be rendered by this item. 
85         
86         See QtGui.QGraphicsTextItem.setHtml().
87         """
88         self.textItem.setHtml(*args)
89         self.updateTextPos()
90         
91     def setTextWidth(self, *args):
92         """
93         Set the width of the text.
94         
95         If the text requires more space than the width limit, then it will be
96         wrapped into multiple lines.
97         
98         See QtGui.QGraphicsTextItem.setTextWidth().
99         """
100         self.textItem.setTextWidth(*args)
101         self.updateTextPos()
102         
103     def setFont(self, *args):
104         """
105         Set the font for this text. 
106         
107         See QtGui.QGraphicsTextItem.setFont().
108         """
109         self.textItem.setFont(*args)
110         self.updateTextPos()
111         
112     def setAngle(self, angle):
113         self.angle = angle
114         self.updateTransform()
115         
116     def setAnchor(self, anchor):
117         self.anchor = Point(anchor)
118         self.updateTextPos()
119 
120     def setColor(self, color):
121         """
122         Set the color for this text.
123         
124         See QtGui.QGraphicsItem.setDefaultTextColor().
125         """
126         self.color = fn.mkColor(color)
127         self.textItem.setDefaultTextColor(self.color)
128         
129     def updateTextPos(self):
130         # update text position to obey anchor
131         r = self.textItem.boundingRect()
132         tl = self.textItem.mapToParent(r.topLeft())
133         br = self.textItem.mapToParent(r.bottomRight())
134         offset = (br - tl) * self.anchor
135         self.textItem.setPos(-offset)
136         
137         ### Needed to maintain font size when rendering to image with increased resolution
138         #self.textItem.resetTransform()
139         ##self.textItem.rotate(self.angle)
140         #if self._exportOpts is not False and 'resolutionScale' in self._exportOpts:
141             #s = self._exportOpts['resolutionScale']
142             #self.textItem.scale(s, s)
143         
144     def boundingRect(self):
145         return self.textItem.mapToParent(self.textItem.boundingRect()).boundingRect()
146 
147     def viewTransformChanged(self):
148         # called whenever view transform has changed.
149         # Do this here to avoid double-updates when view changes.
150         self.updateTransform()
151         
152     def paint(self, p, *args):
153         # this is not ideal because it requires the transform to be updated at every draw.
154         # ideally, we would have a sceneTransformChanged event to react to..
155         s = self.scene()
156         ls = self._lastScene
157         if s is not ls:
158             if ls is not None:
159                 ls.sigPrepareForPaint.disconnect(self.updateTransform)
160             self._lastScene = s
161             if s is not None:
162                 s.sigPrepareForPaint.connect(self.updateTransform)
163             self.updateTransform()
164             p.setTransform(self.sceneTransform())
165         
166         if self.border.style() != QtCore.Qt.NoPen or self.fill.style() != QtCore.Qt.NoBrush:
167             p.setPen(self.border)
168             p.setBrush(self.fill)
169             p.setRenderHint(p.Antialiasing, True)
170             p.drawPolygon(self.textItem.mapToParent(self.textItem.boundingRect()))
171         
172     def updateTransform(self):
173         # update transform such that this item has the correct orientation
174         # and scaling relative to the scene, but inherits its position from its
175         # parent.
176         # This is similar to setting ItemIgnoresTransformations = True, but 
177         # does not break mouse interaction and collision detection.
178         p = self.parentItem()
179         if p is None:
180             pt = QtGui.QTransform()
181         else:
182             pt = p.sceneTransform()
183         
184         if pt == self._lastTransform:
185             return
186 
187         t = pt.inverted()[0]
188         # reset translation
189         t.setMatrix(t.m11(), t.m12(), t.m13(), t.m21(), t.m22(), t.m23(), 0, 0, t.m33())
190         
191         # apply rotation
192         angle = -self.angle
193         if self.rotateAxis is not None:
194             d = pt.map(self.rotateAxis) - pt.map(Point(0, 0))
195             a = np.arctan2(d.y(), d.x()) * 180 / np.pi
196             angle += a
197         t.rotate(angle)
198         
199         self.setTransform(t)
200         
201         self._lastTransform = pt
202         
203         self.updateTextPos()
204
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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 @@
         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 @@
             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 @@
         else:
             pt = p.sceneTransform()
         
-        if pt == self._lastTransform:
+        if not force and pt == self._lastTransform:
             return
 
         t = pt.inverted()[0]

{"golden_diff": "diff --git a/pyqtgraph/graphicsItems/TextItem.py b/pyqtgraph/graphicsItems/TextItem.py\n--- a/pyqtgraph/graphicsItems/TextItem.py\n+++ b/pyqtgraph/graphicsItems/TextItem.py\n@@ -110,9 +110,16 @@\n         self.updateTextPos()\n         \n     def setAngle(self, angle):\n+        \"\"\"\n+        Set the angle of the text in degrees.\n+\n+        This sets the rotation angle of the text as a whole, measured\n+        counter-clockwise from the x axis of the parent. Note that this rotation\n+        angle does not depend on horizontal/vertical scaling of the parent.\n+        \"\"\"\n         self.angle = angle\n-        self.updateTransform()\n-        \n+        self.updateTransform(force=True)\n+\n     def setAnchor(self, anchor):\n         self.anchor = Point(anchor)\n         self.updateTextPos()\n@@ -169,7 +176,7 @@\n             p.setRenderHint(p.Antialiasing, True)\n             p.drawPolygon(self.textItem.mapToParent(self.textItem.boundingRect()))\n         \n-    def updateTransform(self):\n+    def updateTransform(self, force=False):\n         # update transform such that this item has the correct orientation\n         # and scaling relative to the scene, but inherits its position from its\n         # parent.\n@@ -181,7 +188,7 @@\n         else:\n             pt = p.sceneTransform()\n         \n-        if pt == self._lastTransform:\n+        if not force and pt == self._lastTransform:\n             return\n \n         t = pt.inverted()[0]\n", "issue": "Rotating TextItem dosen't work\nI 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. \r\nBelow is some code that should move and rotate a TextItem.\r\n```python\r\nfrom pyqtgraph.Qt import QtCore, QtGui\r\nimport pyqtgraph as pg\r\n\r\napp = QtGui.QApplication([])\r\n\r\nw = pg.GraphicsView()\r\nw.show()\r\nw.resize(800,800)\r\n\r\nview = pg.ViewBox()\r\nw.setCentralItem(view)\r\nview.setAspectLocked(True)\r\nview.setRange(QtCore.QRectF(0, 0, 200, 200))\r\n\r\nanchor = pg.TextItem()\r\nanchor.setText(\"hey\")\r\nanchor.setColor(QtGui.QColor(255, 255, 255))\r\n\r\nview.addItem(anchor)\r\n\r\n\r\ndef rotate():\r\n    x, y = anchor.pos()\r\n    anchor.setPos(x + 1, y + 1)\r\n    anchor.setAngle(anchor.angle + 10)\r\n\r\n\r\ntimer = QtCore.QTimer()\r\ntimer.timeout.connect(rotate)\r\ntimer.start(1000)\r\n\r\n\r\nif __name__ == '__main__':\r\n    import sys\r\n    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):\r\n        QtGui.QApplication.instance().exec_()\r\n```\n", "before_files": [{"content": "import numpy as np\nfrom ..Qt import QtCore, QtGui\nfrom ..Point import Point\nfrom .. import functions as fn\nfrom .GraphicsObject import GraphicsObject\n\n\nclass TextItem(GraphicsObject):\n    \"\"\"\n    GraphicsItem displaying unscaled text (the text will always appear normal even inside a scaled ViewBox). \n    \"\"\"\n    def __init__(self, text='', color=(200,200,200), html=None, anchor=(0,0),\n                 border=None, fill=None, angle=0, rotateAxis=None):\n        \"\"\"\n        ==============  =================================================================================\n        **Arguments:**\n        *text*          The text to display\n        *color*         The color of the text (any format accepted by pg.mkColor)\n        *html*          If specified, this overrides both *text* and *color*\n        *anchor*        A QPointF or (x,y) sequence indicating what region of the text box will\n                        be anchored to the item's position. A value of (0,0) sets the upper-left corner\n                        of the text box to be at the position specified by setPos(), while a value of (1,1)\n                        sets the lower-right corner.\n        *border*        A pen to use when drawing the border\n        *fill*          A brush to use when filling within the border\n        *angle*         Angle in degrees to rotate text. Default is 0; text will be displayed upright.\n        *rotateAxis*    If None, then a text angle of 0 always points along the +x axis of the scene.\n                        If a QPointF or (x,y) sequence is given, then it represents a vector direction\n                        in the parent's coordinate system that the 0-degree line will be aligned to. This\n                        Allows text to follow both the position and orientation of its parent while still\n                        discarding any scale and shear factors.\n        ==============  =================================================================================\n\n\n        The effects of the `rotateAxis` and `angle` arguments are added independently. So for example:\n\n        * rotateAxis=None, angle=0 -> normal horizontal text\n        * rotateAxis=None, angle=90 -> normal vertical text\n        * rotateAxis=(1, 0), angle=0 -> text aligned with x axis of its parent\n        * rotateAxis=(0, 1), angle=0 -> text aligned with y axis of its parent\n        * rotateAxis=(1, 0), angle=90 -> text orthogonal to x axis of its parent        \n        \"\"\"\n                     \n        self.anchor = Point(anchor)\n        self.rotateAxis = None if rotateAxis is None else Point(rotateAxis)\n        #self.angle = 0\n        GraphicsObject.__init__(self)\n        self.textItem = QtGui.QGraphicsTextItem()\n        self.textItem.setParentItem(self)\n        self._lastTransform = None\n        self._lastScene = None\n        self._bounds = QtCore.QRectF()\n        if html is None:\n            self.setColor(color)\n            self.setText(text)\n        else:\n            self.setHtml(html)\n        self.fill = fn.mkBrush(fill)\n        self.border = fn.mkPen(border)\n        self.setAngle(angle)\n\n    def setText(self, text, color=None):\n        \"\"\"\n        Set the text of this item. \n        \n        This method sets the plain text of the item; see also setHtml().\n        \"\"\"\n        if color is not None:\n            self.setColor(color)\n        self.textItem.setPlainText(text)\n        self.updateTextPos()\n        \n    def setPlainText(self, *args):\n        \"\"\"\n        Set the plain text to be rendered by this item. \n        \n        See QtGui.QGraphicsTextItem.setPlainText().\n        \"\"\"\n        self.textItem.setPlainText(*args)\n        self.updateTextPos()\n        \n    def setHtml(self, *args):\n        \"\"\"\n        Set the HTML code to be rendered by this item. \n        \n        See QtGui.QGraphicsTextItem.setHtml().\n        \"\"\"\n        self.textItem.setHtml(*args)\n        self.updateTextPos()\n        \n    def setTextWidth(self, *args):\n        \"\"\"\n        Set the width of the text.\n        \n        If the text requires more space than the width limit, then it will be\n        wrapped into multiple lines.\n        \n        See QtGui.QGraphicsTextItem.setTextWidth().\n        \"\"\"\n        self.textItem.setTextWidth(*args)\n        self.updateTextPos()\n        \n    def setFont(self, *args):\n        \"\"\"\n        Set the font for this text. \n        \n        See QtGui.QGraphicsTextItem.setFont().\n        \"\"\"\n        self.textItem.setFont(*args)\n        self.updateTextPos()\n        \n    def setAngle(self, angle):\n        self.angle = angle\n        self.updateTransform()\n        \n    def setAnchor(self, anchor):\n        self.anchor = Point(anchor)\n        self.updateTextPos()\n\n    def setColor(self, color):\n        \"\"\"\n        Set the color for this text.\n        \n        See QtGui.QGraphicsItem.setDefaultTextColor().\n        \"\"\"\n        self.color = fn.mkColor(color)\n        self.textItem.setDefaultTextColor(self.color)\n        \n    def updateTextPos(self):\n        # update text position to obey anchor\n        r = self.textItem.boundingRect()\n        tl = self.textItem.mapToParent(r.topLeft())\n        br = self.textItem.mapToParent(r.bottomRight())\n        offset = (br - tl) * self.anchor\n        self.textItem.setPos(-offset)\n        \n        ### Needed to maintain font size when rendering to image with increased resolution\n        #self.textItem.resetTransform()\n        ##self.textItem.rotate(self.angle)\n        #if self._exportOpts is not False and 'resolutionScale' in self._exportOpts:\n            #s = self._exportOpts['resolutionScale']\n            #self.textItem.scale(s, s)\n        \n    def boundingRect(self):\n        return self.textItem.mapToParent(self.textItem.boundingRect()).boundingRect()\n\n    def viewTransformChanged(self):\n        # called whenever view transform has changed.\n        # Do this here to avoid double-updates when view changes.\n        self.updateTransform()\n        \n    def paint(self, p, *args):\n        # this is not ideal because it requires the transform to be updated at every draw.\n        # ideally, we would have a sceneTransformChanged event to react to..\n        s = self.scene()\n        ls = self._lastScene\n        if s is not ls:\n            if ls is not None:\n                ls.sigPrepareForPaint.disconnect(self.updateTransform)\n            self._lastScene = s\n            if s is not None:\n                s.sigPrepareForPaint.connect(self.updateTransform)\n            self.updateTransform()\n            p.setTransform(self.sceneTransform())\n        \n        if self.border.style() != QtCore.Qt.NoPen or self.fill.style() != QtCore.Qt.NoBrush:\n            p.setPen(self.border)\n            p.setBrush(self.fill)\n            p.setRenderHint(p.Antialiasing, True)\n            p.drawPolygon(self.textItem.mapToParent(self.textItem.boundingRect()))\n        \n    def updateTransform(self):\n        # update transform such that this item has the correct orientation\n        # and scaling relative to the scene, but inherits its position from its\n        # parent.\n        # This is similar to setting ItemIgnoresTransformations = True, but \n        # does not break mouse interaction and collision detection.\n        p = self.parentItem()\n        if p is None:\n            pt = QtGui.QTransform()\n        else:\n            pt = p.sceneTransform()\n        \n        if pt == self._lastTransform:\n            return\n\n        t = pt.inverted()[0]\n        # reset translation\n        t.setMatrix(t.m11(), t.m12(), t.m13(), t.m21(), t.m22(), t.m23(), 0, 0, t.m33())\n        \n        # apply rotation\n        angle = -self.angle\n        if self.rotateAxis is not None:\n            d = pt.map(self.rotateAxis) - pt.map(Point(0, 0))\n            a = np.arctan2(d.y(), d.x()) * 180 / np.pi\n            angle += a\n        t.rotate(angle)\n        \n        self.setTransform(t)\n        \n        self._lastTransform = pt\n        \n        self.updateTextPos()\n", "path": "pyqtgraph/graphicsItems/TextItem.py"}], "after_files": [{"content": "import numpy as np\nfrom ..Qt import QtCore, QtGui\nfrom ..Point import Point\nfrom .. import functions as fn\nfrom .GraphicsObject import GraphicsObject\n\n\nclass TextItem(GraphicsObject):\n    \"\"\"\n    GraphicsItem displaying unscaled text (the text will always appear normal even inside a scaled ViewBox). \n    \"\"\"\n    def __init__(self, text='', color=(200,200,200), html=None, anchor=(0,0),\n                 border=None, fill=None, angle=0, rotateAxis=None):\n        \"\"\"\n        ==============  =================================================================================\n        **Arguments:**\n        *text*          The text to display\n        *color*         The color of the text (any format accepted by pg.mkColor)\n        *html*          If specified, this overrides both *text* and *color*\n        *anchor*        A QPointF or (x,y) sequence indicating what region of the text box will\n                        be anchored to the item's position. A value of (0,0) sets the upper-left corner\n                        of the text box to be at the position specified by setPos(), while a value of (1,1)\n                        sets the lower-right corner.\n        *border*        A pen to use when drawing the border\n        *fill*          A brush to use when filling within the border\n        *angle*         Angle in degrees to rotate text. Default is 0; text will be displayed upright.\n        *rotateAxis*    If None, then a text angle of 0 always points along the +x axis of the scene.\n                        If a QPointF or (x,y) sequence is given, then it represents a vector direction\n                        in the parent's coordinate system that the 0-degree line will be aligned to. This\n                        Allows text to follow both the position and orientation of its parent while still\n                        discarding any scale and shear factors.\n        ==============  =================================================================================\n\n\n        The effects of the `rotateAxis` and `angle` arguments are added independently. So for example:\n\n        * rotateAxis=None, angle=0 -> normal horizontal text\n        * rotateAxis=None, angle=90 -> normal vertical text\n        * rotateAxis=(1, 0), angle=0 -> text aligned with x axis of its parent\n        * rotateAxis=(0, 1), angle=0 -> text aligned with y axis of its parent\n        * rotateAxis=(1, 0), angle=90 -> text orthogonal to x axis of its parent        \n        \"\"\"\n                     \n        self.anchor = Point(anchor)\n        self.rotateAxis = None if rotateAxis is None else Point(rotateAxis)\n        #self.angle = 0\n        GraphicsObject.__init__(self)\n        self.textItem = QtGui.QGraphicsTextItem()\n        self.textItem.setParentItem(self)\n        self._lastTransform = None\n        self._lastScene = None\n        self._bounds = QtCore.QRectF()\n        if html is None:\n            self.setColor(color)\n            self.setText(text)\n        else:\n            self.setHtml(html)\n        self.fill = fn.mkBrush(fill)\n        self.border = fn.mkPen(border)\n        self.setAngle(angle)\n\n    def setText(self, text, color=None):\n        \"\"\"\n        Set the text of this item. \n        \n        This method sets the plain text of the item; see also setHtml().\n        \"\"\"\n        if color is not None:\n            self.setColor(color)\n        self.textItem.setPlainText(text)\n        self.updateTextPos()\n        \n    def setPlainText(self, *args):\n        \"\"\"\n        Set the plain text to be rendered by this item. \n        \n        See QtGui.QGraphicsTextItem.setPlainText().\n        \"\"\"\n        self.textItem.setPlainText(*args)\n        self.updateTextPos()\n        \n    def setHtml(self, *args):\n        \"\"\"\n        Set the HTML code to be rendered by this item. \n        \n        See QtGui.QGraphicsTextItem.setHtml().\n        \"\"\"\n        self.textItem.setHtml(*args)\n        self.updateTextPos()\n        \n    def setTextWidth(self, *args):\n        \"\"\"\n        Set the width of the text.\n        \n        If the text requires more space than the width limit, then it will be\n        wrapped into multiple lines.\n        \n        See QtGui.QGraphicsTextItem.setTextWidth().\n        \"\"\"\n        self.textItem.setTextWidth(*args)\n        self.updateTextPos()\n        \n    def setFont(self, *args):\n        \"\"\"\n        Set the font for this text. \n        \n        See QtGui.QGraphicsTextItem.setFont().\n        \"\"\"\n        self.textItem.setFont(*args)\n        self.updateTextPos()\n        \n    def setAngle(self, angle):\n        \"\"\"\n        Set the angle of the text in degrees.\n\n        This sets the rotation angle of the text as a whole, measured\n        counter-clockwise from the x axis of the parent. Note that this rotation\n        angle does not depend on horizontal/vertical scaling of the parent.\n        \"\"\"\n        self.angle = angle\n        self.updateTransform(force=True)\n\n    def setAnchor(self, anchor):\n        self.anchor = Point(anchor)\n        self.updateTextPos()\n\n    def setColor(self, color):\n        \"\"\"\n        Set the color for this text.\n        \n        See QtGui.QGraphicsItem.setDefaultTextColor().\n        \"\"\"\n        self.color = fn.mkColor(color)\n        self.textItem.setDefaultTextColor(self.color)\n        \n    def updateTextPos(self):\n        # update text position to obey anchor\n        r = self.textItem.boundingRect()\n        tl = self.textItem.mapToParent(r.topLeft())\n        br = self.textItem.mapToParent(r.bottomRight())\n        offset = (br - tl) * self.anchor\n        self.textItem.setPos(-offset)\n        \n        ### Needed to maintain font size when rendering to image with increased resolution\n        #self.textItem.resetTransform()\n        ##self.textItem.rotate(self.angle)\n        #if self._exportOpts is not False and 'resolutionScale' in self._exportOpts:\n            #s = self._exportOpts['resolutionScale']\n            #self.textItem.scale(s, s)\n        \n    def boundingRect(self):\n        return self.textItem.mapToParent(self.textItem.boundingRect()).boundingRect()\n\n    def viewTransformChanged(self):\n        # called whenever view transform has changed.\n        # Do this here to avoid double-updates when view changes.\n        self.updateTransform()\n        \n    def paint(self, p, *args):\n        # this is not ideal because it requires the transform to be updated at every draw.\n        # ideally, we would have a sceneTransformChanged event to react to..\n        s = self.scene()\n        ls = self._lastScene\n        if s is not ls:\n            if ls is not None:\n                ls.sigPrepareForPaint.disconnect(self.updateTransform)\n            self._lastScene = s\n            if s is not None:\n                s.sigPrepareForPaint.connect(self.updateTransform)\n            self.updateTransform()\n            p.setTransform(self.sceneTransform())\n        \n        if self.border.style() != QtCore.Qt.NoPen or self.fill.style() != QtCore.Qt.NoBrush:\n            p.setPen(self.border)\n            p.setBrush(self.fill)\n            p.setRenderHint(p.Antialiasing, True)\n            p.drawPolygon(self.textItem.mapToParent(self.textItem.boundingRect()))\n        \n    def updateTransform(self, force=False):\n        # update transform such that this item has the correct orientation\n        # and scaling relative to the scene, but inherits its position from its\n        # parent.\n        # This is similar to setting ItemIgnoresTransformations = True, but \n        # does not break mouse interaction and collision detection.\n        p = self.parentItem()\n        if p is None:\n            pt = QtGui.QTransform()\n        else:\n            pt = p.sceneTransform()\n        \n        if not force and pt == self._lastTransform:\n            return\n\n        t = pt.inverted()[0]\n        # reset translation\n        t.setMatrix(t.m11(), t.m12(), t.m13(), t.m21(), t.m22(), t.m23(), 0, 0, t.m33())\n        \n        # apply rotation\n        angle = -self.angle\n        if self.rotateAxis is not None:\n            d = pt.map(self.rotateAxis) - pt.map(Point(0, 0))\n            a = np.arctan2(d.y(), d.x()) * 180 / np.pi\n            angle += a\n        t.rotate(angle)\n        \n        self.setTransform(t)\n        \n        self._lastTransform = pt\n        \n        self.updateTextPos()\n", "path": "pyqtgraph/graphicsItems/TextItem.py"}]}