;i-<~dZddlmZddlmZddlmZddlmZddlmZm Z m Z m Z dgZ Gdde j Zd S) z GraphicsView.py - Extension of QGraphicsView Copyright 2010 Luke Campagnola Distributed under MIT/X11 license. See license.txt for more information. ) functions)getConfigOption) GraphicsScene)Point)QT_LIBQtCoreQtGui QtWidgets GraphicsViewceZdZdZejeeZejeZejeZ ejeZ ejeZ dZ d'dZ dZdZfdZfdZfd Zd(d Zd Zd ZdZdZdZd(dZdZdZd(dZdZdZdZd)dZ d*dZ!dZ"dZ#d+dZ$d+dZ%fdZ&d Z'd!Z(fd"Z)fd#Z*fd$Z+d%Z,d&Z-xZ.S),r aRe-implementation of QGraphicsView that removes scrollbars and allows unambiguous control of the viewed coordinate range. Also automatically creates a GraphicsScene and a central QGraphicsWidget that is automatically scaled to the full view geometry. This widget is the basis for :class:`PlotWidget `, :class:`GraphicsLayoutWidget `, and the view widget in :class:`ImageView `. By default, the view coordinate system matches the widget's pixel coordinates and automatically updates when the view is resized. This can be overridden by setting autoPixelRange=False. The exact visible range can be set with setRange(). The view can be panned using the middle mouse button and scaled using the right mouse button if enabled via enableMouse() (but ordinarily, we use ViewBox for this functionality).Ndefaultcd|_tj||ddlm}||t d}||||j j | tj jj|||t$jjj|tjjj|t$jjj|t$jjj|tjjj |!tjjj"|#tjj$j%g|_&d|_'|(dd|_)t%j*dddd|_+d|_,d|_-|.|/ta| |_1|2|j1d|_3|4tj5tj6|_7|j38|j7d|_9d|_:d|_;dS) a  ============== ============================================================ **Arguments:** parent Optional parent widget useOpenGL If True, the GraphicsView will use OpenGL to do all of its rendering. This can improve performance on some systems, but may also introduce bugs (the combination of QGraphicsView and QOpenGLWidget is still an 'experimental' feature of Qt) background Set the background color of the GraphicsView. Accepts any single argument accepted by :func:`mkColor `. By default, the background color is determined using the 'backgroundColor' configuration option (see :func:`setConfigOptions `). ============== ============================================================ Fr)_connectCleanupN useOpenGLT)parent)<closedr QGraphicsView__init__rrr setCacheMode CacheModeFlagCacheBackgroundsetBackgroundRoler QPalette ColorRoleNoRole setBackgroundsetFocusPolicyrQt FocusPolicy StrongFocus setFrameShapeQFrameShapeNoFramesetVerticalScrollBarPolicyScrollBarPolicyScrollBarAlwaysOffsetHorizontalScrollBarPolicysetTransformationAnchorViewportAnchorNoAnchorsetResizeAnchorAnchorViewCentersetViewportUpdateModeViewportUpdateModeMinimalViewportUpdatelockedViewports lastMousePossetMouseTracking aspectLockedQRectFrangeautoPixelRange currentItem clearMouse updateMatrixrsceneObjsetScene centralWidgetsetCentralItemQGraphicsWidgetQGraphicsGridLayout centralLayout setLayout mouseEnabled scaleCenter clickAccepted)selfrr backgroundrs RC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pyqtgraph/widgets/GraphicsView.pyrzGraphicsView.__init__(s& ((v666 '&&&&&  ' 44I y!!! $,<=== u~7>??? :&&& FI1=>>> 9+19::: '' (A(TUUU ))&)*C*VWWW $$Y%<%K%TUUU Y4CTUUU ""9#:#M#cddd "  d###!]1aA.. "  %T222  dm$$$" I577888&:<< $$T%7888! "c|r@||tjjjzdS||tjjjzdS)zEnable or disable default antialiasing. Note that this will only affect items that do not specify their own antialiasing options.N)setRenderHints renderHintsr QPainter RenderHint Antialiasing)rIaas rKsetAntialiasingzGraphicsView.setAntialiasingssv  ^    0 0 2 2U^5N5[ [ \ \ \ \ \    0 0 2 2en6O6\5\ \ ] ] ] ] ]rLc||_|dkrtd}tj|}||dS)z Set the background color of the GraphicsView. To use the defaults specified py pyqtgraph.setConfigOption, use background='default'. To make the background transparent, use background=None. r rJN) _backgroundrfnmkBrushsetBackgroundBrush)rIrJbrushs rKrzGraphicsView.setBackground{sM &  " "(66J :&& &&&&&rLc|t|SN)sceneprepareForPaintsuper paintEventrIev __class__s rKr`zGraphicsView.paintEvents5 $$&&&ww!!"%%%rLc|tj|i|Sr\)r]r^r_render)rIargskwdsrcs rKrezGraphicsView.renders8 $$&&&uww~t,t,,,rLcd|_|d|_d|_d|_|dtt| dS)NT) r@r]clearr;r>r setViewportr_r close)rIrcs rKrkzGraphicsView.closesq!     lD!!'')))))rLTc|r:ttd}|stdtj}ntj}||dS)N QOpenGLWidgetzORequested to use OpenGL with QGraphicsView, but QOpenGLWidget is not available.)hasattrr ExceptionrmQWidgetrj)rIb HAVE_OPENGLvs rKrzGraphicsView.useOpenGLsi  $!)_==K s qrrr'))AA!##A rLcT||dSr\)r] keyPressEventrIrbs rKruzGraphicsView.keyPressEvents$ ""2&&&&&rLc,||Sr\)setCentralWidgetrIitems rKrAzGraphicsView.setCentralItems$$T***rLc|j,||j||_|1|j||ddSdS)zSets a QGraphicsWidget to automatically fill the entire view (the item will be automatically resize whenever the GraphicsView is resized).N)r@r] removeItemr>addItem resizeEventrys rKrxzGraphicsView.setCentralWidgetsr   ) JJLL # #D$6 7 7 7!   M ! !$ ' ' '   T " " " " "  rLc:|j|Sr\)r]r}rIrfs rKr}zGraphicsView.addItems#tzz||#T**rLc:|j|Sr\)r]r|rs rKr|zGraphicsView.removeItems&tzz||&--rLc$||_| |_dSr\)rFr:)rIrqs rK enableMousezGraphicsView.enableMouses#$urLc"g|_d|_dSr\) mouseTraillastButtonReleasedrIs rKr<zGraphicsView.clearMouses"&rLc\|jrdS|jrdtjdd|||_t ||jdd| dS)NrF)paddingdisableAutoPixel) rr:rr8sizewidthheightr9r setRanger=rvs rKr~zGraphicsView.resizeEvents ;  F   Xq!TYY[[->->-@-@$))++BTBTBVBVWWDJdDJERRR rLc||j|jr|nf|jr0||jt jjj n/||jt jjj |r&|j D]}| |jd|j ||j|j|dS)Nrr) setSceneRectr9r:resetTransformr7 fitInViewrr!AspectRatioModeKeepAspectRatioIgnoreAspectRatior4 setXRangesigDeviceRangeChangedemitsigDeviceTransformChanged)rI propagaterss rKr=zGraphicsView.updateMatrixs $*%%%   X    ! ! ! !  Xtz69+D+TUUUUtz69+D+VWWW  3) 3 3 DJ 2222 "''dj999 &++D11111rLctj|}|d|S)z6Return the boundaries of the view in scene coordinatesr)rr8rectviewportTransforminvertedmapRect)rIrs rKviewRectzGraphicsView.viewRectsL M$))++ & &%%''002215==a@@@rLc*|Sr\)rrs rK visibleRangezGraphicsView.visibleRanges}}rLch|j|||||dSr\)r9adjustr=)rIdxdys rK translatezGraphicsView.translates6 "b"b))) rLc||g}|jr |d|d<|jrd}||j}|j|dz }|j|dz }t j|||j z |dz z | | |j z |dz z |||_| |j |dS)Nrr)r7rGr9centerrrrr8xleftytopr=sigScaleChangedr)rIsxsyrscalewhs rKrzGraphicsView.scalessR   QxE!H   F >Z&&((F J    %( * J    %( *]688::DJOO>K[K[4[4[L   )   * *4: 6 6 6 )$$$  ,  % %d + + + + + , ,rLc|}|d |j|jn#t t f$rYnwxYw|}| |dz}| |dz}tj ||||}t ||d|j|jdS)z{Scales such that pixels in image are the same size as screen pixels. This may result in a significant performance increase.TrrrN) pixelSize setPxModer disconnect setScaledMode TypeError RuntimeErrorsceneBoundingRecttopLeftrrrrr8rrr rconnect)rIimagepxSizetlrrr9s rK scaleToImagezGraphicsView.scaleToImages+""    + +E,? @ @ @ @<(    D   $ $ & & . . 0 0 IIKK    &) + IIKK   6!9 , bddffbddffa33dE1555 $$U%899999sA AAcP||jvr|j|dSdSr\)r4append)rIv1s rK lockXRangezGraphicsView.lockXRange%s5T)))  ' ' + + + + +*)rLctj|j}||||t|||dgddSNrF)rr) rr8r9setLeftrsetRightrightr rrIrrr1s rKrzGraphicsView.setXRange)sn ]4: & & 16688 AGGIIdB! NNNNNrLctj|j}||||t||d|gddSr) rr8r9setTopr setBottombottomr rrs rK setYRangezGraphicsView.setYRange/sn ]4: & & !%%'' QXXZZ   dBG NNNNNrLc6t||jsdS|}|dkr&|}d|z}|||dS)Nrgjt?)r_ wheelEventrF angleDeltarrr)rIrbdeltascrcs rKrzGraphicsView.wheelEvent5s 2   F !!## A::MMOO%%''E e^ 2rrLc||_dSr\)r7)rIss rKsetAspectLockedzGraphicsView.setAspectLockedBsrLcT||dSr\)r] leaveEventrvs rKrzGraphicsView.leaveEventEs$ #####rLctt||jsdSt|dr|n|}||_||_||_ |j s&| dS)Nposition) r_mousePressEventrFrnrlocalPosr5 mousePressPos isAcceptedrHr]clearSelection)rIrblposrcs rKrzGraphicsView.mousePressEventHs ###   F 'J 7 7Jr{{}}}R[[]] !]]__! * JJLL ' ' ) ) )rLct||jsdS|j|||_dSr\)r_mouseReleaseEventrFsigMouseReleasedrbuttonrras rKrzGraphicsView.mouseReleaseEventVsW !!"%%%   F ""2&&&"$))++rLct|dr|n|}|j||_t ||jz }||_t ||jsdS|j | | |j rdS| tjjjkrt t%j|dddt%j|d dd}d|z}||d|d| |j |j ||jdS| tjjjtjjjfvr^|}| |z}||d|d|j ||jdSdS)Nrri2rg)\(?)r)rnrrr5rr_mouseMoveEventrFsigSceneMouseMovedr mapToScenetoPointrHbuttonsrr! MouseButton RightButtonrW clip_scalarrrrr9 MiddleButton LeftButtonrr)rIrbrrrpxtrrcs rKrzGraphicsView.mouseMoveEvent^s 'J 7 7Jr{{}}}R[[]]   $ $D dT..//  r"""   F $$T__T\\^^%D%DEEE    F ::<<690< < <".q3;;R^USTXIWZ\^=_=_``EEME JJuQxq$//$BTB\B\B^B^2_2_J ` ` `  & + +D$* = = = = = ZZ\\fi3@&)BWBbc c c!!B"B NN2a5"Q% ( ( (  & + +D$* = = = = = d crLctdd}tdd}|d}||}||}t||z S)zNReturn vector with the length and width of one view pixel in scene coordinatesrr)r transformrmap)rIp0p1rp01p11s rKrzGraphicsView.pixelSizezsl 1QZZ 1QZZ ^^   & & ( ( +ffRjjffRjjS3YrLc.|dSr\)ignorervs rKdragEnterEventzGraphicsView.dragEnterEvents rL)NNr )Tr\)NrNTT)r)/__name__ __module__ __qualname____doc__rSignalobjectrrrrr lastFileDirrrTrr`rerkrrurArxr}r|rr<r~r=rrrrrrrrrrrrrrrrr  __classcell__)rcs@rKr r s [ [*FM&&99 - f 5 5$v}V,,&v..#fmF++OKI#I#I#I#V^^^ ' ' '&&&&&----- *****    ''' +++###+++...&&&&'''2222"AAA ((((",,,,. : : :",,,OOOO OOOO     $$$     >>>>>8   rLN)rrrrWrrrr!rrr r __all__rr rLrKrs ))))))111111111111  ttttt9*tttttrL