;ipddlmZddlmZddlmZddlmZddlmZddlmZdgZ Gd deZ d S) ) functions) QtWidgets)GraphicsWidget) LabelItem)PlotItem)ViewBoxGraphicsLayoutceZdZdZddZdZdZdZdZdd Z dd Z dd Z dd Z ddZ dZdZdZdZdZdZdZdZdS)r z Used for laying out GraphicsWidgets in a grid. This is usually created automatically as part of a :class:`GraphicsLayoutWidget `. Nctj|||durd}n|durd}||_tj|_||ji|_i|_i|_ d|_ d|_ | tj tj jjtj jjdS)NT)dr r F)r__init__borderrQGraphicsGridLayoutlayout setLayoutitemsrows itemBorders currentRow currentCol setSizePolicy QSizePolicyPolicy Expanding)selfparentrs ZC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pyqtgraph/graphicsItems/GraphicsLayout.pyrzGraphicsLayout.__init__sf--- T>>"FF u__F 355  t{###   901F1M1WYbYnYuYAA B B B B Bctj|i||_|jD]}||jdS)z Set the pen used to draw border between cells. See :func:`mkPen ` for arguments. N)fnmkPenrrvaluessetPen)rargskwds borderRects r setBorderzGraphicsLayout.setBorder&s[ h--- *1133 + +J   dk * * * * + +r c\|xjdz c_d|_|dS)z0Advance to next row for automatic item placementrN)rr nextColumnrs rnextRowzGraphicsLayout.nextRow1s/ 1 r c|xjdz c_||j|j2|xjdz c_||j|j0dSdS)z]Advance to next available column (generally only for internal use--called by addItem)rN)rgetItemrr-s rr,zGraphicsLayout.nextColumn7sb 1ll4?DO<<H OOq OOll4?DO<<HHHHHr c|j|i|S)zAlias of nextColumn)r,)rr&kargss rnextColzGraphicsLayout.nextCol>st....r rc Ptdi|}|||||||S)z Create a PlotItem and place it in the next available cell (or in the cell specified) All extra keyword arguments are passed to :func:`PlotItem.__init__ ` Returns the created item. )raddItem)rrowcolrowspancolspanr2plots raddPlotzGraphicsLayout.addPlotBs6   %   T3Wg666 r c Ptdi|}|||||||S)z Create a ViewBox and place it in the next available cell (or in the cell specified) All extra keyword arguments are passed to :func:`ViewBox.__init__ ` Returns the created item. r5)r r6)rr7r8r9r:r2vbs r addViewBoxzGraphicsLayout.addViewBoxLs6   u   Rc7G444 r  c Rt|fi|}|||||||S)aA Create a LabelItem with *text* and place it in the next available cell (or in the cell specified) All extra keyword arguments are passed to :func:`LabelItem.__init__ ` Returns the created item. To create a vertical label, use *angle* = -90. )rr6)rtextr7r8r9r:r2s raddLabelzGraphicsLayout.addLabelVs8'''' T3Wg666 r c Ptdi|}|||||||S)a  Create an empty GraphicsLayout and place it in the next available cell (or in the cell specified) All extra keyword arguments are passed to :func:`GraphicsLayout.__init__ ` Returns the created item. r5)r r6)rr7r8r9r:r2rs r addLayoutzGraphicsLayout.addLayoutbs6  ((%(( VS#w888 r c||j}||j}g|j|<t|D]c}t|D]Q}||z}||z} ||jvr i|j|<||j|| <|j||| fRdt j} | || d| tj |j | |j|<|j|j|j||||||j|dS)z Add an item to the layout and place it in the next available cell (or in the cell specified). The item must be an instance of a QGraphicsWidget subclass. Ng@@)rrrrangerappendrQGraphicsRectItem setParentItem setZValuer%r"r#rrgeometryChangedconnect_updateItemBorderrr6activater,) ritemr7r8r9r:ijrow2col2r(s rr6zGraphicsLayout.addItemls| ;/C ;/C 4w 6 6A7^^ 6 6QwQwty((&(DIdO(, $% 4 ''t 5555  6022   &&&S!!!"(4;//000!+ $$T%;<<< D#sGW===  r c`|j|i|dS)zEReturn the item in (*row*, *col*). If the cell is empty, return None.N)rget)rr7r8s rr0zGraphicsLayout.getItems(y}}S"%%))#t444r c*|SN)rectr-s r boundingRectzGraphicsLayout.boundingRectsyy{{r ct|jD]4}|j||ur|cS5t d|)aReturn the numerical index of GraphicsItem object passed in Parameters ---------- item : QGraphicsLayoutItem Item to query the index position of Returns ------- int Index of the item within the graphics layout Raises ------ ValueError Raised if item could not be found inside the GraphicsLayout instance. z"Could not determine index of item )rGrcountitemAt graphicsItem ValueError)rrPrQs r itemIndexzGraphicsLayout.itemIndexsu$t{((**++  A{!!!$$1133t;;<DdDDEEEr c||}|j||||j|D]\}}|j||=|j|=|j|j |j |}||| dS)zRemove *item* from the layout.N) r`rremoveAtscene removeItemrrrL disconnectrNrpopupdate)rrPindrc itemBorders rrdzGraphicsLayout.removeItemsnnT"" S!!! %%%Jt$  DAq ! Q Jt  ''(>???%))$//   +++ r ct|jD]}||d|_d|_dS)zQRemove all items from the layout and set the current row and column to 0 rN)listrkeysrdrr)rrQs rclearzGraphicsLayout.clearsNdjoo''((  A OOA    r c$|jj|dSrX)rsetContentsMarginsrr&s rrqz!GraphicsLayout.setContentsMarginss ' &----r c$|jj|dSrX)r setSpacingrrs rrtzGraphicsLayout.setSpacings %%%%r c|jdS|}|dS||}|j||dSrX)rsendermapRectToParentrZrsetRect)rrPris rrNz GraphicsLayout._updateItemBordersg ;  F{{}} < F  !2!2!4!4 5 5 &&q)))))r )NN)NNrr)r@NNrr)__name__ __module__ __qualname____doc__rr)r.r,r3r<r?rCrEr6r0rZr`rdrorqrtrNr5r rr r sR BBBB* + + + !!!///    """"H555FFF. ... &&& * * * * *r N) rr"Qtrrrrr __all__r r5r rrs******   M*M*M*M*M*^M*M*M*M*M*r