;i$pddlmZmZddlmZddlmZddlmZm Z m Z ddl m Z dgZ Gd de Z d S) )atan2degrees) functions)Point)QtCoreQtGui QtWidgets)GraphicsObjectTextItemceZdZdZ ddZdd Zd Zd Zd Zd Z dZ dZ dZ dZ dZdZddZdZdZdZdZddZdS)r zs GraphicsItem displaying unscaled text (the text will always appear normal even inside a scaled ViewBox). rrNrrrFc Zt||_|dnt||_tj|t j|_|j|d|_ d|_ | rd|_ tj |_|+||||n||t%j||_t%j||_||dS)a ================ ================================================================================= **Arguments:** *text* The text to display *color* The color of the text (any format accepted by pg.mkColor) *html* If specified, this overrides both *text* and *color* *anchor* A QPointF or (x,y) sequence indicating what region of the text box will be anchored to the item's position. A value of (0,0) sets the upper-left corner of the text box to be at the position specified by setPos(), while a value of (1,1) sets the lower-right corner. *border* A pen to use when drawing the border *fill* A brush to use when filling within the border *angle* Angle in degrees to rotate text. Default is 0; text will be displayed upright. *rotateAxis* If None, then a text angle of 0 always points along the +x axis of the scene. If a QPointF or (x,y) sequence is given, then it represents a vector direction in the parent's coordinate system that the 0-degree line will be aligned to. This Allows text to follow both the position and orientation of its parent while still discarding any scale and shear factors. *ensureInBounds* Ensures that the entire TextItem will be visible when using autorange, but may produce runaway scaling in certain circumstances (See issue #2642). Setting to "True" retains legacy behavior. ================ ================================================================================= The effects of the `rotateAxis` and `angle` arguments are added independently. So for example: * rotateAxis=None, angle=0 -> normal horizontal text * rotateAxis=None, angle=90 -> normal vertical text * rotateAxis=(1, 0), angle=0 -> text aligned with x axis of its parent * rotateAxis=(0, 1), angle=0 -> text aligned with y axis of its parent * rotateAxis=(1, 0), angle=90 -> text orthogonal to x axis of its parent N)ranchor rotateAxisr __init__r QGraphicsTextItemtextItem setParentItem_lastTransform _lastScene dataBoundsrQRectF_boundssetColorsetTextsetHtmlfnmkBrushfillmkPenbordersetAngle) selftextcolorhtmlrr&r$anglerensureInBoundss TC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pyqtgraph/graphicsItems/TextItem.pyrzTextItem.__init__sFFmm ","4$$% :K:K%%%!355  ##D)))"  #"DO} < MM% LL     LL   Jt$$ hv&&  ec^|||||dS)z Set the text of this item. This method sets the plain text of the item; see also setHtml(). N)r setPlainText)r(r)r*s r.r zTextItem.setTextJs6   MM%  $r/c||kr0|j||dSdS)z Set the plain text to be rendered by this item. See QtWidgets.QGraphicsTextItem.setPlainText(). N) toPlainTextrr1 updateTextPos)r(r)s r.r1zTextItem.setPlainTextTsQ 4##%% % % M & &t , , ,     & %r/c4|jSN)rr3r(s r.r3zTextItem.toPlainText^s}((***r/c||kr0|j||dSdS)z} Set the HTML code to be rendered by this item. See QtWidgets.QGraphicsTextItem.setHtml(). N)toHtmlrr!r4)r(r+s r.r!zTextItem.setHtmlasM ;;==D M ! !$ ' ' '     ! r/c4|jSr6)rr9r7s r.r9zTextItem.toHtmlks}##%%%r/cL|jj||dS)z Set the width of the text. If the text requires more space than the width limit, then it will be wrapped into multiple lines. See QtWidgets.QGraphicsTextItem.setTextWidth(). N)r setTextWidthr4r(argss r.r<zTextItem.setTextWidthns. # "D)) r/cL|jj||dS)zj Set the font for this text. See QtWidgets.QGraphicsTextItem.setFont(). N)rsetFontr4r=s r.r@zTextItem.setFontzs.  t$$ r/c@||_|ddS)a 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. T)forceN)r,updateTransform)r(r,s r.r'zTextItem.setAngles(  4(((((r/cVt||_|dSr6)rrr4)r(rs r. setAnchorzTextItem.setAnchors'Fmm  r/cvtj||_|j|jdS)zr Set the color for this text. See QtWidgets.QGraphicsItem.setDefaultTextColor(). N)r"mkColorr*rsetDefaultTextColor)r(r*s r.rzTextItem.setColors3 Z&&  ))$*55555r/c8|j}|j|}|j|}||z |jz}|j| dSr6)r boundingRect mapToParenttopLeft bottomRightrsetPos)r(rtlbroffsets r.r4zTextItem.updateTextPoss} M & & ( ( ] & &qyy{{ 3 3 ] & &q}} 7 7r'T[( fW%%%%%r/?c|r.|d|d}}||j|cxkr|ksnddgS|j||j|gS)z Returns only the anchor point for when calulating view ranges. Sacrifices some visual polish for fixing issue #2642. rr N)r)r(axfrac orthoRange range_min range_maxs r.rzTextItem.dataBoundssc  $#-a=*Q-yI B<<<<9<<<<d|# BR11r/cd|j|jSr6)rmapRectToParentrJr7s r.rJzTextItem.boundingRects&},,T]-G-G-I-IJJJr/c.|dSr6)rCr7s r.viewTransformChangedzTextItem.viewTransformChangeds r/cD|}|j}||ur||j|j||_||j|j||||j tj j j ks1|j tj jjkr||j||j||jjd||j|jdSdS)NT)scenersigPrepareForPaint disconnectrCconnect setTransformsceneTransformr&stylerQtPenStyleNoPenr$ BrushStyleNoBrushsetPensetBrush setRenderHint RenderHint Antialiasing drawPolygonrrKrJ)r(pr>slss r.paintzTextItem.paintsW JJLL _ B;;~%001EFFFDO}$,,T-ABBB  " " " NN4..00 1 1 1 ;    &)"4": : :dioo>O>OSYS\SgSo>o>o HHT[ ! ! ! JJty ! ! ! OOAL5t < < < MM$-33DM4N4N4P4PQQ R R R R R ?p>or/c`tj|||r|dSdSr6)r setVisiblerC)r(vs r.rvzTextItem.setVisibles?!$***  #  " " " " " # #r/c |sdS|}|tj}n|}|s ||jkrdSt j|}|| | | | | |dd| |j }|j||j|t'ddz }t)t+||}||z }||||||_|dS)Nr) isVisible parentItemr QTransformrdrr"invertQTransform setMatrixm11m12m13m21m22m23m33r,rmaprrryxrotatercr4)r(rBrqpttr,das r.rCzTextItem.updateTransforms~~  F OO   9!##BB!!##B t222 F   # # AEEGGQUUWWaeeggquuww!QPQPUPUPWPWXXX  ? &t''"&&q!*=*==AacceeQSSUU++,,A QJE  !  r/) rrNrNNrNFr6)rSN)F)__name__ __module__ __qualname____doc__rr r1r3r!r9r<r@r'rErr4rrJr]rtrvrCr/r.r r sQHMRW::::x    !!!+++!!!&&&    ) ) )666&&& 2 2 2 2KKK SSS(### r/N)mathrrrrr"rrfrr r r __all__r rr/r.rs))))))))))****** ,fffff~fffffr/