;i7gdZddlZddlmZddlmZddlmZGddeZGd d eZ Gd d eZ dS) )MouseDragEventMouseClickEvent HoverEventN) perf_counter)Point)QtCoreceZdZdZddZdZdZdZdZdZ dd Z dd Z d Z d Z dZdZdZdZddZdZdZdZdZd S)rz Instances of this class are delivered to items in a :class:`GraphicsScene ` via their mouseDragEvent() method when the item is being mouse-dragged. Fc,||_||_d|_d|_i|_i|_t jjj t jjj t jjj fD]<}| ||j|<| ||j|<=||_||_|3||_||_n2||_||_||_||_||_d|_dSNF)startfinishaccepted currentItem_buttonDownScenePos_buttonDownScreenPosr Qt MouseButton LeftButton MiddleButton RightButtonbuttonDownScenePosbuttonDownScreenPosscenePos _scenePos screenPos _screenPos _lastScenePos_lastScreenPosbuttons_buttonsbutton_button modifiers _modifiers acceptedItem)self moveEvent pressEvent lastEventr rbtns WC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pyqtgraph/GraphicsScene/mouseEvents.py__init__zMouseDragEvent.__init__s`   #% $&!I)4fi6K6XZ`ZcZoZ{| P PC,5,H,H,M,MD $S )-6-J-J3-O-OD %c * *"++--#--//  !+!4!4!6!6D ","6"6"8"8D  !*!3!3!5!5D "+"5"5"7"7D !))++ !((** #--// c,d|_|j|_dSz{An item should call this method if it can handle the event. This will prevent the event being delivered to any other items.TNrrr&r's r,acceptzMouseDragEvent.accept)  ,r.cd|_dSzxAn item should call this method if it cannot handle the event. This will allow the event to be delivered to other items.FNrr2s r,ignorezMouseDragEvent.ignore.  r.c|jSNr7r2s r, isAcceptedzMouseDragEvent.isAccepted2 }r.c*t|jSz/Return the current scene position of the mouse.rrr2s r,rzMouseDragEvent.scenePos5T^$$$r.c*t|jSzLReturn the current screen position (pixels relative to widget) of the mouse.rrr2s r,rzMouseDragEvent.screenPos9T_%%%r.Ncb||}t|j|S)z Return the scene position of the mouse at the time *btn* was pressed. If *btn* is omitted, then the button that initiated the drag is assumed. )r"rrr'r+s r,rz!MouseDragEvent.buttonDownScenePos=s, ;++--CT-c2333r.cb||}t|j|S)z Return the screen position (pixels relative to widget) of the mouse at the time *btn* was pressed. If *btn* is omitted, then the button that initiated the drag is assumed. )r"rrrGs r,rz"MouseDragEvent.buttonDownScreenPosFs, ;++--CT.s3444r.c*t|jS)zY Return the scene position of the mouse immediately prior to this event. rrr2s r, lastScenePoszMouseDragEvent.lastScenePosOsT'(((r.c*t|jS)zZ Return the screen position of the mouse immediately prior to this event. rrr2s r, lastScreenPoszMouseDragEvent.lastScreenPosUsT()))r.c|jSz Return the buttons currently pressed on the mouse. (see QGraphicsSceneMouseEvent::buttons in the Qt documentation) r!r2s r,r zMouseDragEvent.buttons[ }r.c|jS)zReturn the button that initiated the drag (may be different from the buttons currently pressed) (see QGraphicsSceneMouseEvent::button in the Qt documentation) r#r2s r,r"zMouseDragEvent.buttonbs |r.cZt|j|jSz Return the current position of the mouse in the coordinate system of the item that the event was delivered to. rr mapFromScenerr2s r,poszMouseDragEvent.posi% T%224>BBCCCr.cZt|j|jSz Return the previous position of the mouse in the coordinate system of the item that the event was delivered to. rrrXrr2s r,lastPoszMouseDragEvent.lastPosp& T%2243EFFGGGr.c||}t|j|j|S)z Return the position of the mouse at the time the drag was initiated in the coordinate system of the item that the event was delivered to. )r"rrrXrrGs r, buttonDownPoszMouseDragEvent.buttonDownPosws= ;++--CT%2243KC3PQQRRRr.c|jS)zCReturns True if this event is the first since a drag was initiated.)r r2s r,isStartzMouseDragEvent.isStart zr.c|jS)zReturns False if this is the last event in a drag. Note that this event will have the same position as the previous one.)rr2s r,isFinishzMouseDragEvent.isFinishs {r.c |j|j}|j}n(|}|}d||||t|t| t| fzS)Nz?(%g,%g) buttons=%s start=%s finish=%s>) rrrr^rYxystrr rcrfr'lpps r,__repr__zMouseDragEvent.__repr__s(   ##BAAB APTVTXTXTZTZ\^\`\`\b\bdedgdgdidiklknknkpkpruvzwCwCwEwEsFsFHKLPLXLXLZLZH[H[]`aeananapap]q]qTrr rr.c|jS)zReturn any keyboard modifiers currently pressed. (see QGraphicsSceneMouseEvent::modifiers in the Qt documentation) r%r2s r,r$zMouseDragEvent.modifierss r.)FFr;)__name__ __module__ __qualname____doc__r-r3r8r<rrrrrKrNr r"rYr^rarcrfrnr$r.r,rr s\!!!!.--- %%%&&&44445555))) *** DDDHHHSSSS rrrr.rcheZdZdZddZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdS)rz Instances of this class are delivered to items in a :class:`GraphicsScene ` via their mouseClickEvent() method when the item is clicked. Fc^d|_d|_||_||_||_||_| |_ | |_ t|_d|_dSr )rr_doublerrrrr"r#r r!r$r%r_timer&)r'r)doubles r,r-zMouseClickEvent.__init__s  #,,..$..00!((** "**,, $..00!^^  r.c,d|_|j|_dSr0r1r2s r,r3zMouseClickEvent.acceptr4r.cd|_dSr6r7r2s r,r8zMouseClickEvent.ignorer9r.c|jSr;r7r2s r,r<zMouseClickEvent.isAcceptedr=r.c*t|jSr?r@r2s r,rzMouseClickEvent.scenePosrAr.c*t|jSrCrDr2s r,rzMouseClickEvent.screenPosrEr.c|jSrPrQr2s r,r zMouseClickEvent.buttonsrRr.c|jS)zReturn the mouse button that generated the click event. (see QGraphicsSceneMouseEvent::button in the Qt documentation) rTr2s r,r"zMouseClickEvent.buttons |r.c|jS)z&Return True if this is a double-click.)rxr2s r,rzzMouseClickEvent.doubles |r.cZt|j|jSrVrWr2s r,rYzMouseClickEvent.posrZr.cZt|j|jSr\r]r2s r,r^zMouseClickEvent.lastPosr_r.c|jSzReturn any keyboard modifiers currently pressed. (see QGraphicsSceneMouseEvent::modifiers in the Qt documentation) rpr2s r,r$zMouseClickEvent.modifiers r.c6 |j|j}n|}d||t |fzS#dt |zcYSxYw)Nz#z)rrrYrhrirjr")r'rms r,rnzMouseClickEvent.__repr__s H'NHHJJ8ACCEE13355#dkkmmJ\J\;]] ] H0C 4F4FG G G Gs A-A00&Bc|jSr;)ryr2s r,timezMouseClickEvent.times zr.N)F)rqrrrsrtr-r3r8r<rrr r"rzrYr^r$rnrrur.r,rrs ! ! ! !--- %%%&&& DDDHHH HHHr.rcreZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdS)ra Instances of this class are delivered to items in a :class:`GraphicsScene ` via their hoverEvent() method when the mouse is hovering over the item. This event class both informs items that the mouse cursor is nearby and allows items to communicate with one another about whether each item will accept *potential* mouse events. It is common for multiple overlapping items to receive hover events and respond by changing their appearance. This can be misleading to the user since, in general, only one item will respond to mouse events. To avoid this, items make calls to event.acceptClicks(button) and/or acceptDrags(button). Each item may make multiple calls to acceptClicks/Drags, each time for a different button. If the method returns True, then the item is guaranteed to be the recipient of the claimed event IF the user presses the specified mouse button before moving. If claimEvent returns False, then this item is guaranteed NOT to get the specified event (because another has already claimed it) and the item should change its appearance accordingly. event.isEnter() returns True if the mouse has just entered the item's shape; event.isExit() returns True if the mouse has just left. cd|_||_d|_tj|_tj|_d|_|||_ | |_ | |_ ||_||_||_dSd|_dS)NFT)enter acceptableexitweakrefWeakValueDictionary_HoverEvent__clickItems_HoverEvent__dragItemsrrrrrrKrrNrr r!r$r%)r'r(rs r,r-zHoverEvent.__init__ s $ #799"688  &//11DN'1133DO!*!7!7!9!9D "+"9"9";";D %--//DM'1133DOOODIIIr.c|jS)z;Returns True if the mouse has just entered the item's shape)rr2s r,isEnterzHoverEvent.isEnterrdr.c|jS)z:Returns True if the mouse has just exited the item's shape)rr2s r,isExitzHoverEvent.isExit s yr.cL|jsdS||jvr|j|j|<dSdS)aRInform the scene that the item (that the event was delivered to) would accept a mouse click event if the user were to click before moving the mouse again. Returns True if the request is successful, otherwise returns False (indicating that some other item would receive an incoming click). FT)rrrr'r"s r, acceptClickszHoverEvent.acceptClicks$s; 5 * * *(,(8D f %4ur.cL|jsdS||jvr|j|j|<dSdS)aSInform the scene that the item (that the event was delivered to) would accept a mouse drag event if the user were to drag before the next hover event. Returns True if the request is successful, otherwise returns False (indicating that some other item would receive an incoming drag event). FT)rrrrs r, acceptDragszHoverEvent.acceptDrags3s; 5 ) ) )'+'7D V $4ur.c*t|jSr?r@r2s r,rzHoverEvent.scenePosBrAr.c*t|jS)z0Return the current screen position of the mouse.rDr2s r,rzHoverEvent.screenPosFrEr.c*t|jS)z0Return the previous scene position of the mouse.rJr2s r,rKzHoverEvent.lastScenePosJsT'(((r.c*t|jS)z1Return the previous screen position of the mouse.rMr2s r,rNzHoverEvent.lastScreenPosNsT()))r.c|jSrPrQr2s r,r zHoverEvent.buttonsRrRr.cZt|j|jSrVrWr2s r,rYzHoverEvent.posYrZr.cZt|j|jSr\r]r2s r,r^zHoverEvent.lastPos`r_r.c |jrdS|j|j}|j}n(|}|}d||||t| t| t| fzS)Nzz9(%g,%g) buttons=%s enter=%s exit=%s>) rrrrr^rYrhrirjr rrrks r,rnzHoverEvent.__repr__gs 9 ,++   ##BAAB AJbddffVXVZVZV\V\^_^a^a^c^cefehehejejloptp|p|p~p~llBEFJFRFRFTFTBUBUWZ[_[f[f[h[hWiWiNjj jr.c|jSrrpr2s r,r$zHoverEvent.modifierssrr.c|jSr;)rr2s r, clickItemszHoverEvent.clickItemsys   r.c|jSr;)rr2s r, dragItemszHoverEvent.dragItems|s r.N)rqrrrsrtr-rrrrrrrKrNr rYr^rnr$rrrur.r,rrs("      %%%&&&)))***DDDHHH j j j !!!     r.r) __all__rrrrrr objectrrrrur.r,rs = = =MMMMMVMMMbWWWWWfWWWvG G G G G G G G G G r.