<s> import math <EOL> from PySide import QtGui , QtCore <EOL> from kraken . ui . backdrop_inspector import BackdropInspector <EOL> class KBackdropTitle ( QtGui . QGraphicsWidget ) : <EOL> __color = QtGui . QColor ( <NUM_LIT:255> , <NUM_LIT:255> , <NUM_LIT:255> ) <EOL> __font = QtGui . QFont ( '<STR_LIT>' , <NUM_LIT:11> ) <EOL> __font . setLetterSpacing ( QtGui . QFont . PercentageSpacing , <NUM_LIT> ) <EOL> __fontMetrics = QtGui . QFontMetrics ( __font ) <EOL> __labelBottomSpacing = <NUM_LIT:4> <EOL> def __init__ ( self , text , parent = None ) : <EOL> super ( KBackdropTitle , self ) . __init__ ( parent ) <EOL> self . parentWidget = parent <EOL> self . __textItem = QtGui . QGraphicsTextItem ( text , self ) <EOL> self . __textItem . setDefaultTextColor ( self . __color ) <EOL> self . __textItem . setFont ( self . __font ) <EOL> self . __textItem . setPos ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> option = self . __textItem . document ( ) . defaultTextOption ( ) <EOL> self . __textItem . document ( ) . setDefaultTextOption ( option ) <EOL> self . __textItem . adjustSize ( ) <EOL> self . __textItem . setTextWidth ( <NUM_LIT> ) <EOL> self . setPreferredSize ( self . textSize ( ) ) <EOL> def setText ( self , text ) : <EOL> self . __textItem . setPlainText ( text ) <EOL> self . nodeResized ( self . parentWidget . parentWidget . size ( ) . width ( ) ) <EOL> def setTextColor ( self , color ) : <EOL> self . __color = color <EOL> self . update ( ) <EOL> def textSize ( self ) : <EOL> return QtCore . QSizeF ( self . __textItem . textWidth ( ) , self . textHeight ( ) ) <EOL> def textHeight ( self ) : <EOL> return self . __textItem . document ( ) . documentLayout ( ) . documentSize ( ) . height ( ) + self . __labelBottomSpacing <EOL> def nodeResized ( self , width = None ) : <EOL> fmWidth = self . __fontMetrics . width ( self . __textItem . toPlainText ( ) ) <EOL> newWidth = min ( fmWidth , width ) <EOL> if width > fmWidth : <EOL> newWidth = width <EOL> self . __textItem . setTextWidth ( newWidth ) <EOL> self . setPreferredSize ( newWidth , self . textHeight ( ) ) <EOL> def getBackdropWidget ( self ) : <EOL> return self . parent ( ) . parent ( ) <EOL> class KBackdropHeader ( QtGui . QGraphicsWidget ) : <EOL> def __init__ ( self , text , parent = None ) : <EOL> super ( KBackdropHeader , self ) . __init__ ( parent ) <EOL> self . parentWidget = parent <EOL> layout = QtGui . QGraphicsLinearLayout ( ) <EOL> layout . setContentsMargins ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> layout . setSpacing ( <NUM_LIT:3> ) <EOL> layout . setOrientation ( QtCore . Qt . Horizontal ) <EOL> self . setLayout ( layout ) <EOL> self . _titleWidget = KBackdropTitle ( text , self ) <EOL> layout . addItem ( self . _titleWidget ) <EOL> layout . setAlignment ( self . _titleWidget , QtCore . Qt . AlignCenter | QtCore . Qt . AlignTop ) <EOL> def getTitleWidget ( self ) : <EOL> return self . _titleWidget <EOL> def setText ( self , text ) : <EOL> self . _titleWidget . setText ( text ) <EOL> class KBackdrop ( QtGui . QGraphicsWidget ) : <EOL> nameChanged = QtCore . Signal ( str , str ) <EOL> sizeChanged = QtCore . Signal ( float ) <EOL> __defaultColor = QtGui . QColor ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:255> ) <EOL> __defaultUnselectedColor = QtGui . QColor ( __defaultColor . darker ( <NUM_LIT> ) ) <EOL> __defaultSelectedColor = QtGui . QColor ( __defaultColor . lighter ( <NUM_LIT> ) ) <EOL> __defaultHoverColor = QtGui . QColor ( __defaultColor . lighter ( <NUM_LIT> ) ) <EOL> __defaultUnselectedPen = QtGui . QPen ( __defaultUnselectedColor , <NUM_LIT> ) <EOL> __defaultSelectedPen = QtGui . QPen ( __defaultSelectedColor , <NUM_LIT> ) <EOL> __defaultHoveredPen = QtGui . QPen ( __defaultHoverColor , <NUM_LIT> ) <EOL> __defaultLinePen = QtGui . QPen ( QtGui . QColor ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:255> ) , <NUM_LIT> ) <EOL> __resizeDistance = <NUM_LIT> <EOL> __setCustomCursor = False <EOL> __hoveredOver = False <EOL> def __init__ ( self , graph , name ) : <EOL> super ( KBackdrop , self ) . __init__ ( ) <EOL> self . setAcceptHoverEvents ( True ) <EOL> self . __name = name <EOL> self . __comment = None <EOL> self . __graph = graph <EOL> self . __color = self . __defaultColor <EOL> self . __color . setAlpha ( <NUM_LIT> ) <EOL> self . __unselectedColor = self . __defaultUnselectedColor <EOL> self . __selectedColor = self . __defaultSelectedColor <EOL> self . __hoverColor = self . __defaultHoverColor <EOL> self . __unselectedPen = QtGui . QPen ( self . __defaultUnselectedPen ) <EOL> self . __selectedPen = QtGui . QPen ( self . __defaultSelectedPen ) <EOL> self . __hoveredPen = QtGui . QPen ( self . __defaultHoveredPen ) <EOL> self . __linePen = QtGui . QPen ( self . __defaultLinePen ) <EOL> self . __inspectorWidget = None <EOL> self . setMinimumWidth ( <NUM_LIT> ) <EOL> self . setMinimumHeight ( <NUM_LIT> ) <EOL> self . setZValue ( - <NUM_LIT:100> ) <EOL> self . __selected = False <EOL> self . __dragging = False <EOL> self . __resizing = False <EOL> self . __resizeCorner = - <NUM_LIT:1> <EOL> self . __resizeEdge = - <NUM_LIT:1> <EOL> self . createLayout ( ) <EOL> self . createConnections ( ) <EOL> self . setComment ( name ) <EOL> def createLayout ( self ) : <EOL> layout = QtGui . QGraphicsLinearLayout ( ) <EOL> layout . setContentsMargins ( <NUM_LIT:5> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:7> ) <EOL> layout . setSpacing ( <NUM_LIT:7> ) <EOL> layout . setOrientation ( QtCore . Qt . Vertical ) <EOL> self . setLayout ( layout ) <EOL> self . __headerItem = KBackdropHeader ( self . __name , self ) <EOL> self . __titleWidget = self . __headerItem . getTitleWidget ( ) <EOL> layout . addItem ( self . __headerItem ) <EOL> layout . setAlignment ( self . __headerItem , QtCore . Qt . AlignCenter | QtCore . Qt . AlignTop ) <EOL> layout . addStretch ( <NUM_LIT:1> ) <EOL> def createConnections ( self ) : <EOL> self . sizeChanged . connect ( self . __titleWidget . nodeResized ) <EOL> def getName ( self ) : <EOL> return self . __name <EOL> def setName ( self , name ) : <EOL> if name != self . __name : <EOL> origName = self . __name <EOL> self . __name = name <EOL> self . nameChanged . emit ( origName , name ) <EOL> self . adjustSize ( ) <EOL> def getComment ( self ) : <EOL> return self . __comment <EOL> def setComment ( self , comment ) : <EOL> self . __comment = comment <EOL> self . __headerItem . setText ( comment ) <EOL> titleWidget = self . __headerItem . getTitleWidget ( ) <EOL> titleWidth = titleWidget . textSize ( ) . width ( ) <EOL> self . resize ( titleWidth , self . size ( ) . height ( ) ) <EOL> self . adjustSize ( ) <EOL> def getColor ( self ) : <EOL> color = QtGui . QColor ( self . __color ) <EOL> color . setAlpha ( <NUM_LIT:255> ) <EOL> return color <EOL> def setColor ( self , color ) : <EOL> self . __color = color <EOL> self . __color . setAlpha ( <NUM_LIT> ) <EOL> self . update ( ) <EOL> def getUnselectedColor ( self ) : <EOL> return self . __unselectedColor <EOL> def setUnselectedColor ( self , color ) : <EOL> self . __unselectedColor = color <EOL> self . __unselectedPen . setColor ( self . __unselectedColor ) <EOL> self . update ( ) <EOL> def getSelectedColor ( self ) : <EOL> return self . __selectedColor <EOL> def setSelectedColor ( self , color ) : <EOL> self . __selectedColor = color <EOL> self . __selectedPen . setColor ( self . __selectedColor ) <EOL> self . update ( ) <EOL> def getHoveredColor ( self ) : <EOL> return self . __hoverColor <EOL> def setHoveredColor ( self , color ) : <EOL> self . __hoverColor = color <EOL> self . __hoveredPen . setColor ( self . __hoverColor ) <EOL> self . update ( ) <EOL> def getGraph ( self ) : <EOL> return self . __graph <EOL> def getHeader ( self ) : <EOL> return self . __headerItem <EOL> def isSelected ( self ) : <EOL> return self . __selected <EOL> def setSelected ( self , selected = True ) : <EOL> self . __selected = selected <EOL> self . update ( ) <EOL> def getGraphPos ( self ) : <EOL> transform = self . transform ( ) <EOL> size = self . size ( ) <EOL> return QtCore . QPointF ( transform . dx ( ) + ( size . width ( ) * <NUM_LIT:0.5> ) , transform . dy ( ) + ( size . height ( ) * <NUM_LIT:0.5> ) ) <EOL> def setGraphPos ( self , graphPos ) : <EOL> size = self . size ( ) <EOL> self . setTransform ( QtGui . QTransform . fromTranslate ( graphPos . x ( ) - ( size . width ( ) * <NUM_LIT:0.5> ) , graphPos . y ( ) - ( size . height ( ) * <NUM_LIT:0.5> ) ) , False ) <EOL> def translate ( self , x , y ) : <EOL> super ( KBackdrop , self ) . translate ( x , y ) <EOL> def paint ( self , painter , option , widget ) : <EOL> rect = self . windowFrameRect ( ) <EOL> painter . setBrush ( self . __color ) <EOL> painter . setPen ( QtGui . QPen ( QtGui . QColor ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) , <NUM_LIT:0> ) ) <EOL> roundingY = <NUM_LIT> / ( rect . height ( ) / <NUM_LIT> ) <EOL> roundingX = rect . height ( ) / rect . width ( ) * roundingY <EOL> painter . drawRoundRect ( rect , roundingX , roundingY , mode = QtCore . Qt . AbsoluteSize ) <EOL> titleHeight = self . __headerItem . size ( ) . height ( ) - <NUM_LIT:3> <EOL> darkerColor = self . __color . darker ( <NUM_LIT> ) <EOL> darkerColor . setAlpha ( <NUM_LIT:255> ) <EOL> painter . setBrush ( darkerColor ) <EOL> roundingYHeader = rect . width ( ) * roundingX / titleHeight <EOL> painter . drawRoundRect ( <NUM_LIT:0> , <NUM_LIT:0> , rect . width ( ) , titleHeight , roundingX , roundingYHeader ) <EOL> painter . drawRect ( <NUM_LIT:0> , titleHeight * <NUM_LIT:0.5> + <NUM_LIT:2> , rect . width ( ) , titleHeight * <NUM_LIT:0.5> ) <EOL> painter . setBrush ( QtGui . QColor ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> if self . __selected : <EOL> painter . setPen ( self . __selectedPen ) <EOL> elif self . __hoveredOver : <EOL> painter . setPen ( self . __hoveredPen ) <EOL> else : <EOL> painter . setPen ( self . __unselectedPen ) <EOL> painter . drawRoundRect ( rect , roundingX , roundingY , mode = QtCore . Qt . AbsoluteSize ) <EOL> super ( KBackdrop , self ) . paint ( painter , option , widget ) <EOL> def mousePressEvent ( self , event ) : <EOL> if event . button ( ) is QtCore . Qt . MouseButton . LeftButton : <EOL> resizeCorner = self . getCorner ( event . pos ( ) ) <EOL> resizeEdge = self . getEdge ( event . pos ( ) ) <EOL> if resizeCorner != - <NUM_LIT:1> and self . isSelected ( ) : <EOL> self . __resizing = True <EOL> self . __resizeCorner = resizeCorner <EOL> self . _resizedBackdrop = False <EOL> elif resizeEdge != - <NUM_LIT:1> and self . isSelected ( ) : <EOL> self . __resizing = True <EOL> self . __resizeEdge = resizeEdge <EOL> self . _resizedBackdrop = False <EOL> else : <EOL> modifiers = event . modifiers ( ) <EOL> if modifiers == QtCore . Qt . ControlModifier : <EOL> if not self . isSelected ( ) : <EOL> self . __graph . selectNode ( self , clearSelection = False ) <EOL> else : <EOL> self . __graph . deselectNode ( self ) <EOL> elif modifiers == QtCore . Qt . ShiftModifier : <EOL> if not self . isSelected ( ) : <EOL> self . __graph . selectNode ( self , clearSelection = False ) <EOL> else : <EOL> if not self . isSelected ( ) : <EOL> self . __graph . selectNode ( self , clearSelection = True ) <EOL> if self . __headerItem . contains ( event . pos ( ) ) : <EOL> self . setCursor ( QtCore . Qt . ClosedHandCursor ) <EOL> self . __dragging = True <EOL> self . _nodesMoved = False <EOL> self . _mouseDownPoint = self . mapToScene ( event . pos ( ) ) <EOL> self . _mouseDelta = self . _mouseDownPoint - self . getGraphPos ( ) <EOL> self . _lastDragPoint = self . _mouseDownPoint <EOL> self . _initPos = self . pos ( ) <EOL> self . _initScenePos = self . mapToScene ( self . pos ( ) ) <EOL> self . _initBoundingRect = self . boundingRect ( ) <EOL> self . _initSceneBoundingRect = self . sceneBoundingRect ( ) <EOL> else : <EOL> super ( KBackdrop , self ) . mousePressEvent ( event ) <EOL> def mouseMoveEvent ( self , event ) : <EOL> if self . __dragging : <EOL> newPos = self . mapToScene ( event . pos ( ) ) <EOL> graph = self . getGraph ( ) <EOL> if graph . getSnapToGrid ( ) is True : <EOL> gridSize = graph . getGridSize ( ) <EOL> newNodePos = newPos - self . _mouseDelta <EOL> snapPosX = math . floor ( newNodePos . x ( ) / gridSize ) * gridSize <EOL> snapPosY = math . floor ( newNodePos . y ( ) / gridSize ) * gridSize <EOL> snapPos = QtCore . QPointF ( snapPosX , snapPosY ) <EOL> newPosOffset = snapPos - newNodePos <EOL> newPos = newPos + newPosOffset <EOL> delta = newPos - self . _lastDragPoint <EOL> self . __graph . moveSelectedNodes ( delta ) <EOL> self . _lastDragPoint = newPos <EOL> self . _nodesMoved = True <EOL> elif self . __resizing : <EOL> newPos = self . mapToScene ( event . pos ( ) ) <EOL> delta = newPos - self . _mouseDownPoint <EOL> self . _resizedBackdrop = True <EOL> newPosX = <NUM_LIT:0> <EOL> newPosY = <NUM_LIT:0> <EOL> newWidth = self . _initBoundingRect . width ( ) <EOL> newHeight = self . _initBoundingRect . height ( ) <EOL> if self . __resizeCorner == <NUM_LIT:0> : <EOL> newWidth = self . _initBoundingRect . width ( ) + ( delta . x ( ) * - <NUM_LIT:1.0> ) <EOL> newHeight = self . _initBoundingRect . height ( ) + ( delta . y ( ) * - <NUM_LIT:1.0> ) <EOL> if newWidth <= self . minimumWidth ( ) : <EOL> newWidth = self . minimumWidth ( ) <EOL> else : <EOL> newPosX = self . _initPos . x ( ) + delta . x ( ) <EOL> if newHeight <= self . minimumHeight ( ) : <EOL> newHeight = self . minimumHeight ( ) <EOL> else : <EOL> newPosY = self . _initPos . y ( ) + delta . y ( ) <EOL> elif self . __resizeCorner == <NUM_LIT:1> : <EOL> newWidth = self . _initBoundingRect . width ( ) + delta . x ( ) <EOL> newHeight = self . _initBoundingRect . height ( ) + ( delta . y ( ) * - <NUM_LIT:1.0> ) <EOL> if newWidth <= self . minimumWidth ( ) : <EOL> newWidth = self . minimumWidth ( ) <EOL> else : <EOL> newPosX = self . _initPos . x ( ) <EOL> if newHeight <= self . minimumHeight ( ) : <EOL> newHeight = self . minimumHeight ( ) <EOL> else : <EOL> newPosY = self . _initPos . y ( ) + delta . y ( ) <EOL> elif self . __resizeCorner == <NUM_LIT:2> : <EOL> newWidth = self . _initBoundingRect . width ( ) + ( delta . x ( ) * - <NUM_LIT:1.0> ) <EOL> newHeight = self . _initBoundingRect . height ( ) + delta . y ( ) <EOL> if newWidth <= self . minimumWidth ( ) : <EOL> newWidth = self . minimumWidth ( ) <EOL> else : <EOL> newPosX = self . _initPos . x ( ) + delta . x ( ) <EOL> if newHeight <= self . minimumHeight ( ) : <EOL> newHeight = self . minimumHeight ( ) <EOL> else : <EOL> newPosY = self . _initPos . y ( ) <EOL> elif self . __resizeCorner == <NUM_LIT:3> : <EOL> newPosX = self . _initPos . x ( ) <EOL> newPosY = self . _initPos . y ( ) <EOL> newWidth = self . _initBoundingRect . width ( ) + delta . x ( ) <EOL> newHeight = self . _initBoundingRect . height ( ) + delta . y ( ) <EOL> if newWidth <= self . minimumWidth ( ) : <EOL> newWidth = self . minimumWidth ( ) <EOL> if newHeight <= self . minimumHeight ( ) : <EOL> newHeight = self . minimumHeight ( ) <EOL> elif self . __resizeEdge == <NUM_LIT:0> : <EOL> pass <EOL> elif self . __resizeEdge == <NUM_LIT:1> : <EOL> newWidth = self . _initBoundingRect . width ( ) + delta . x ( ) <EOL> newHeight = self . _initBoundingRect . height ( ) <EOL> newPosY = self . _initPos . y ( ) <EOL> if newWidth <= self . minimumWidth ( ) : <EOL> newWidth = self . minimumWidth ( ) <EOL> else : <EOL> newPosX = self . _initPos . x ( ) <EOL> elif self . __resizeEdge == <NUM_LIT:2> : <EOL> newWidth = self . _initBoundingRect . width ( ) <EOL> newHeight = self . _initBoundingRect . height ( ) + delta . y ( ) <EOL> newPosX = self . _initPos . x ( ) <EOL> if newHeight <= self . minimumHeight ( ) : <EOL> newHeight = self . minimumHeight ( ) <EOL> else : <EOL> newPosY = self . _initPos . y ( ) <EOL> elif self . __resizeEdge == <NUM_LIT:3> : <EOL> newWidth = self . _initBoundingRect . width ( ) + ( delta . x ( ) * - <NUM_LIT:1.0> ) <EOL> newHeight = self . _initBoundingRect . height ( ) <EOL> newPosY = self . _initPos . y ( ) <EOL> if newWidth <= self . minimumWidth ( ) : <EOL> newWidth = self . minimumWidth ( ) <EOL> else : <EOL> newPosX = self . _initPos . x ( ) + delta . x ( ) <EOL> self . setPos ( newPosX , newPosY ) <EOL> self . resize ( newWidth , newHeight ) <EOL> self . sizeChanged . emit ( newWidth ) <EOL> self . prepareGeometryChange ( ) <EOL> else : <EOL> super ( KBackdrop , self ) . mouseMoveEvent ( event ) <EOL> def mouseReleaseEvent ( self , event ) : <EOL> if self . __dragging : <EOL> if self . _nodesMoved : <EOL> newPos = self . mapToScene ( event . pos ( ) ) <EOL> delta = newPos - self . _mouseDownPoint <EOL> self . __graph . endMoveSelectedNodes ( delta ) <EOL> self . setCursor ( QtCore . Qt . ArrowCursor ) <EOL> self . __dragging = False <EOL> elif self . __resizing : <EOL> self . setCursor ( QtCore . Qt . ArrowCursor ) <EOL> self . __resizing = False <EOL> self . __resizeCorner = - <NUM_LIT:1> <EOL> else : <EOL> super ( KBackdrop , self ) . mouseReleaseEvent ( event ) <EOL> def mouseDoubleClickEvent ( self , event ) : <EOL> if self . __inspectorWidget is None : <EOL> parentWidget = self . getGraph ( ) . getGraphViewWidget ( ) <EOL> self . __inspectorWidget = BackdropInspector ( parent = parentWidget , nodeItem = self ) <EOL> result = self . __inspectorWidget . exec_ ( ) <EOL> else : <EOL> self . __inspectorWidget . setFocus ( ) <EOL> super ( KBackdrop , self ) . mouseDoubleClickEvent ( event ) <EOL> def hoverEnterEvent ( self , event ) : <EOL> self . __hoveredOver = True <EOL> self . update ( ) <EOL> def hoverMoveEvent ( self , event ) : <EOL> resizeCorner = self . getCorner ( event . pos ( ) ) <EOL> resizeEdge = self . getEdge ( event . pos ( ) ) <EOL> if resizeCorner == <NUM_LIT:0> : <EOL> self . __setCustomCursor = True <EOL> self . setCursor ( QtCore . Qt . SizeFDiagCursor ) <EOL> elif resizeCorner == <NUM_LIT:1> : <EOL> self . __setCustomCursor = True <EOL> self . setCursor ( QtCore . Qt . SizeBDiagCursor ) <EOL> elif resizeCorner == <NUM_LIT:2> : <EOL> self . __setCustomCursor = True <EOL> self . setCursor ( QtCore . Qt . SizeBDiagCursor ) <EOL> elif resizeCorner == <NUM_LIT:3> : <EOL> self . __setCustomCursor = True <EOL> self . setCursor ( QtCore . Qt . SizeFDiagCursor ) <EOL> elif resizeEdge == <NUM_LIT:0> : <EOL> self . __setCustomCursor = True <EOL> self . setCursor ( QtCore . Qt . SizeVerCursor ) <EOL> elif resizeEdge == <NUM_LIT:1> : <EOL> self . __setCustomCursor = True <EOL> self . setCursor ( QtCore . Qt . SizeHorCursor ) <EOL> elif resizeEdge == <NUM_LIT:2> : <EOL> self . __setCustomCursor = True <EOL> self . setCursor ( QtCore . Qt . SizeVerCursor ) <EOL> elif resizeEdge == <NUM_LIT:3> : <EOL> self . __setCustomCursor = True <EOL> self . setCursor ( QtCore . Qt . SizeHorCursor ) <EOL> elif self . __headerItem . contains ( event . pos ( ) ) is True : <EOL> self . __setCustomCursor = True <EOL> self . setCursor ( QtCore . Qt . OpenHandCursor ) <EOL> else : <EOL> if self . __setCustomCursor is True : <EOL> self . setCursor ( QtCore . Qt . ArrowCursor ) <EOL> def hoverLeaveEvent ( self , event ) : <EOL> self . setCursor ( QtCore . Qt . ArrowCursor ) <EOL> self . __hoveredOver = False <EOL> self . update ( ) <EOL> def getCorner ( self , pos ) : <EOL> topLeft = self . mapFromItem ( self , self . boundingRect ( ) . topLeft ( ) ) <EOL> bottomRight = self . mapFromItem ( self , self . boundingRect ( ) . bottomRight ( ) ) <EOL> rect = QtCore . QRectF ( topLeft , bottomRight ) <EOL> if ( rect . topLeft ( ) - pos ) . manhattanLength ( ) < self . __resizeDistance : <EOL> return <NUM_LIT:0> <EOL> elif ( rect . topRight ( ) - pos ) . manhattanLength ( ) < self . __resizeDistance : <EOL> return <NUM_LIT:1> <EOL> elif ( rect . bottomLeft ( ) - pos ) . manhattanLength ( ) < self . __resizeDistance : <EOL> return <NUM_LIT:2> <EOL> elif ( rect . bottomRight ( ) - pos ) . manhattanLength ( ) < self . __resizeDistance : <EOL> return <NUM_LIT:3> <EOL> return - <NUM_LIT:1> <EOL> def getEdge ( self , pos ) : <EOL> topRectUpperLeft = self . mapFromItem ( self , self . boundingRect ( ) . topLeft ( ) ) <EOL> topRectLowerRight = self . mapFromItem ( self , self . boundingRect ( ) . right ( ) , self . __resizeDistance * <NUM_LIT> ) <EOL> topRect = QtCore . QRectF ( topRectUpperLeft , topRectLowerRight ) <EOL> rightRectUpperLeft = self . mapFromItem ( self , self . boundingRect ( ) . right ( ) - self . __resizeDistance * <NUM_LIT> , <NUM_LIT:0> ) <EOL> rightRectLowerRight = self . mapFromItem ( self , self . boundingRect ( ) . bottomRight ( ) ) <EOL> rightRect = QtCore . QRectF ( rightRectUpperLeft , rightRectLowerRight ) <EOL> bottomRectUpperLeft = self . mapFromItem ( self , <NUM_LIT:0> , self . boundingRect ( ) . bottom ( ) - self . __resizeDistance * <NUM_LIT> ) <EOL> bottomRectLowerRight = self . mapFromItem ( self , self . boundingRect ( ) . bottomRight ( ) ) <EOL> bottomRect = QtCore . QRectF ( bottomRectUpperLeft , bottomRectLowerRight ) <EOL> leftRectUpperLeft = self . mapFromItem ( self , self . boundingRect ( ) . topLeft ( ) ) <EOL> leftRectLowerRight = self . mapFromItem ( self , self . boundingRect ( ) . left ( ) + self . __resizeDistance * <NUM_LIT> , self . boundingRect ( ) . bottom ( ) ) <EOL> leftRect = QtCore . QRectF ( leftRectUpperLeft , leftRectLowerRight ) <EOL> if topRect . contains ( pos ) : <EOL> return - <NUM_LIT:1> <EOL> elif rightRect . contains ( pos ) : <EOL> return <NUM_LIT:1> <EOL> elif bottomRect . contains ( pos ) : <EOL> return <NUM_LIT:2> <EOL> elif leftRect . contains ( pos ) : <EOL> return <NUM_LIT:3> <EOL> return - <NUM_LIT:1> <EOL> def inspectorClosed ( self ) : <EOL> self . __inspectorWidget = None <EOL> def disconnectAllPorts ( self ) : <EOL> pass <EOL> def getData ( self ) : <EOL> """<STR_LIT>""" <EOL> data = { <EOL> '<STR_LIT:name>' : self . getName ( ) , <EOL> '<STR_LIT>' : self . getComment ( ) , <EOL> '<STR_LIT>' : self . getGraphPos ( ) . toTuple ( ) , <EOL> '<STR_LIT:size>' : self . size ( ) . toTuple ( ) , <EOL> '<STR_LIT>' : self . getColor ( ) . toTuple ( ) <EOL> } <EOL> return data <EOL> def setData ( self , data ) : <EOL> """<STR_LIT>""" <EOL> self . setComment ( data . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> size = data . get ( '<STR_LIT:size>' , ( self . minimumWidth ( ) , self . minimumHeight ( ) ) ) <EOL> self . resize ( size [ <NUM_LIT:0> ] , size [ <NUM_LIT:1> ] ) <EOL> position = data . get ( '<STR_LIT>' , ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . setGraphPos ( QtCore . QPointF ( position [ <NUM_LIT:0> ] , position [ <NUM_LIT:1> ] ) ) <EOL> color = data . get ( '<STR_LIT>' , self . __defaultColor . toTuple ( ) ) <EOL> self . setColor ( color = QtGui . QColor ( color [ <NUM_LIT:0> ] , color [ <NUM_LIT:1> ] , color [ <NUM_LIT:2> ] , color [ <NUM_LIT:3> ] ) ) <EOL> self . setUnselectedColor ( self . getColor ( ) . darker ( <NUM_LIT> ) ) <EOL> self . setSelectedColor ( self . getColor ( ) . lighter ( <NUM_LIT> ) ) <EOL> self . setHoveredColor ( self . getColor ( ) . lighter ( <NUM_LIT> ) ) <EOL> return True </s>
