Merge pull request #1295 from campagnola/acq4-merge
TextItem performance
This commit is contained in:
commit
46dafe4803
@ -67,27 +67,34 @@ class TextItem(GraphicsObject):
|
||||
"""
|
||||
if color is not None:
|
||||
self.setColor(color)
|
||||
self.textItem.setPlainText(text)
|
||||
self.updateTextPos()
|
||||
self.setPlainText(text)
|
||||
|
||||
def setPlainText(self, *args):
|
||||
def setPlainText(self, text):
|
||||
"""
|
||||
Set the plain text to be rendered by this item.
|
||||
|
||||
See QtGui.QGraphicsTextItem.setPlainText().
|
||||
"""
|
||||
self.textItem.setPlainText(*args)
|
||||
if text != self.toPlainText():
|
||||
self.textItem.setPlainText(text)
|
||||
self.updateTextPos()
|
||||
|
||||
def setHtml(self, *args):
|
||||
def toPlainText(self):
|
||||
return self.textItem.toPlainText()
|
||||
|
||||
def setHtml(self, html):
|
||||
"""
|
||||
Set the HTML code to be rendered by this item.
|
||||
|
||||
See QtGui.QGraphicsTextItem.setHtml().
|
||||
"""
|
||||
self.textItem.setHtml(*args)
|
||||
if self.toHtml() != html:
|
||||
self.textItem.setHtml(html)
|
||||
self.updateTextPos()
|
||||
|
||||
def toHtml(self):
|
||||
return self.textItem.toHtml()
|
||||
|
||||
def setTextWidth(self, *args):
|
||||
"""
|
||||
Set the width of the text.
|
||||
@ -176,7 +183,15 @@ class TextItem(GraphicsObject):
|
||||
p.setRenderHint(p.Antialiasing, True)
|
||||
p.drawPolygon(self.textItem.mapToParent(self.textItem.boundingRect()))
|
||||
|
||||
def setVisible(self, v):
|
||||
GraphicsObject.setVisible(self, v)
|
||||
if v:
|
||||
self.updateTransform()
|
||||
|
||||
def updateTransform(self, force=False):
|
||||
if not self.isVisible():
|
||||
return
|
||||
|
||||
# update transform such that this item has the correct orientation
|
||||
# and scaling relative to the scene, but inherits its position from its
|
||||
# parent.
|
||||
|
Loading…
Reference in New Issue
Block a user