Python PySide.QtCore 模块,QPointF() 实例源码

我们从Python开源项目中,提取了以下28个代码示例,用于说明如何使用PySide.QtCore.QPointF()

项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def paint(self, painter, option, widget):
        painter.setPen(QtCore.Qt.NoPen)

        if self.graphWidget.VisualizationTheme == "ObjectFlow": 
            self.drawSubClusters(painter, self.radius)
            painter.setBrush(self.CommunityColor)
            painter.setPen(QtGui.QPen(QtCore.Qt.black, 0))
            if (option.state & QtGui.QStyle.State_Selected):
                circle_path = QtGui.QPainterPath()
                painter.setPen(QtGui.QPen(QtCore.Qt.blue, 3))        
                circle_path.addEllipse(QtCore.QPointF(0,0),self.radius+2,self.radius+2);
                painter.drawPath(circle_path)
            else:
                painter.drawEllipse(-4, -4, self.radius, self.radius)

        elif self.graphWidget.VisualizationTheme == "ThemeRiver":
            self.drawSubClustersTheme(painter,option, self.radius)

        # Drawing the CirclePath Should denote a value
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def paint(self, painter, option, widget):
        painter.setPen(QtCore.Qt.NoPen)

        if self.graphWidget.VisualizationTheme == "ObjectFlow": 
            self.drawSubClusters(painter, self.radius)
            painter.setBrush(self.CommunityColor)
            painter.setPen(QtGui.QPen(QtCore.Qt.black, 0))
            if (option.state & QtGui.QStyle.State_Selected):
                circle_path = QtGui.QPainterPath()
                painter.setPen(QtGui.QPen(QtCore.Qt.blue, 3))        
                circle_path.addEllipse(QtCore.QPointF(0,0),self.radius+2,self.radius+2);
                painter.drawPath(circle_path)
            else:
                painter.drawEllipse(-4, -4, self.radius, self.radius)

        elif self.graphWidget.VisualizationTheme == "ThemeRiver":
            self.drawSubClustersTheme(painter,option, self.radius)

        # Drawing the CirclePath Should denote a value
项目:PipeLine    作者:draknova    | 项目源码 | 文件源码
def __init__(self, _nodeType, name=""):
        super(QNode,self).__init__()

        self._name=name
        self._nodeType=_nodeType
        self._inputs=list()
        self._outputs=list()

        self._parameters=list()

        self.x = 0
        self.y = 0

        self.setFlags(QtGui.QGraphicsItem.ItemIsSelectable)

        # Drawing attributes
        self.position=QtCore.QPointF()
        self.size=QtCore.QPointF(80,25)
        self.sceneScale=1

        self.inputConnector = Connector(self,True)
        self.outputConnector = Connector(self,False)

        self.setZValue(1000)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def paint(self, painter, option, parent):
        if self.line.length() == 0.:
            return
        painter.setPen(self.arrow_pen)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceOver)

        arrow_length = self.line.length() * .3
        d = self.line.angle()
        head_p1 = self.p2 - QtCore.QPointF(
            num.sin(d*d2r + num.pi/3) * arrow_length,
            num.cos(d*d2r + num.pi/3) * arrow_length)

        head_p2 = self.p2 - QtCore.QPointF(
            num.sin(d*d2r + num.pi - num.pi/3) * arrow_length,
            num.cos(d*d2r + num.pi - num.pi/3) * arrow_length)

        painter.drawLine(self.line)
        painter.drawPolyline([head_p1, self.p2, head_p2])
项目:KicadSolderTool    作者:pioupus    | 项目源码 | 文件源码
def on_select(self):
        item = self.list_widget.selectedItems()[0]
        index = self.list_widget.indexOfTopLevelItem(item)
        x = self.footprint_list[index]['x']/1000000.0
        y = self.footprint_list[index]['y']/1000000.0
        self.owner.set_marker(QtCore.QPointF(x,y),self.footprint_list[index]['bot'])
项目:rfcat-firsttry    作者:atlas0fd00m    | 项目源码 | 文件源码
def _draw_reticle(self):
        if self._reticle is None or (self._reticle.size() != self.size()):
            self._new_reticle()

            dbm_lines = [QLineF(self._hz_to_x(self._low_frequency), self._dbm_to_y(dbm),
                                self._hz_to_x(self._high_frequency), self._dbm_to_y(dbm))
                         for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]
            dbm_labels = [(dbm, QPointF(self._hz_to_x(self._low_frequency) + 2, self._dbm_to_y(dbm) - 2))
                          for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]

            frequency_lines = [QLineF(self._hz_to_x(frequency), self._dbm_to_y(self._high_dbm),
                                      self._hz_to_x(frequency), self._dbm_to_y(self._low_dbm))
                               for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 20.0)]
            frequency_labels = [(frequency, QPointF(self._hz_to_x(frequency) + 2, self._dbm_to_y(self._high_dbm) + 10))
                                for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 10.0)]

            painter = QtGui.QPainter(self._reticle)
            try:
                painter.setRenderHint(QtGui.QPainter.Antialiasing)

                painter.setPen(Qt.blue)

                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(dbm_lines)
                for dbm_line in dbm_lines: painter.drawLine(dbm_line)
                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(frequency_lines)
                for frequency_line in frequency_lines: painter.drawLine(frequency_line)

                painter.setPen(Qt.white)
                for dbm, point in dbm_labels:
                    painter.drawText(point, '%+.0f' % dbm)
                for frequency, point in frequency_labels:
                    painter.drawText(point, '%.02f' % (frequency / 1e6))

            finally:
                painter.end()
项目:OpenTimelineIO    作者:PixarAnimationStudios    | 项目源码 | 文件源码
def __init__(self, item, timeline_range, rect, *args, **kwargs):
        rect.setHeight(TRANSITION_HEIGHT)
        super(TransitionItem, self).__init__(
            item,
            timeline_range,
            rect,
            *args,
            **kwargs
        )
        self.setBrush(
            QtGui.QBrush(QtGui.QColor(237, 228, 148, 255))
        )
        self.setY(TRACK_HEIGHT - TRANSITION_HEIGHT)
        self.setZValue(2)

        # add extra bit of shading
        shading_poly_f = QtGui.QPolygonF()
        shading_poly_f.append(QtCore.QPointF(0, 0))
        shading_poly_f.append(QtCore.QPointF(rect.width(), 0))
        shading_poly_f.append(QtCore.QPointF(0, rect.height()))

        shading_poly = QtGui.QGraphicsPolygonItem(shading_poly_f, parent=self)
        shading_poly.setBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 30)))

        try:
            shading_poly.setPen(QtCore.Qt.NoPen)
        except TypeError:
            shading_poly.setPen(QtCore.Qt.transparent)
项目:OpenTimelineIO    作者:PixarAnimationStudios    | 项目源码 | 文件源码
def __init__(self, marker, *args, **kwargs):
        self.item = marker

        poly = QtGui.QPolygonF()
        poly.append(QtCore.QPointF(0.5 * MARKER_SIZE, -0.5 * MARKER_SIZE))
        poly.append(QtCore.QPointF(0.5 * MARKER_SIZE, 0.5 * MARKER_SIZE))
        poly.append(QtCore.QPointF(0, MARKER_SIZE))
        poly.append(QtCore.QPointF(-0.5 * MARKER_SIZE, 0.5 * MARKER_SIZE))
        poly.append(QtCore.QPointF(-0.5 * MARKER_SIZE, -0.5 * MARKER_SIZE))
        super(Marker, self).__init__(poly, *args, **kwargs)

        self.setFlags(QtGui.QGraphicsItem.ItemIsSelectable)
        self.setBrush(QtGui.QBrush(QtGui.QColor(121, 212, 177, 255)))
项目:BrainModulyzer    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self, graphWidget, sourceNode, destNode, counter, sourceId, destId, MaxValue,weight=100,ForCommunities=False,):
        QtGui.QGraphicsItem.__init__(self)
        self.setAcceptHoverEvents(True)

        self.EdgeThreshold = MaxValue - 0.01
        self.ColorEdgesFlag = False
        self.index = counter
        self.Alpha = 0.2
        self.sourceId = sourceId 
        self.destId = destId
        self.ColorMap = True
        self.ForCommunities= ForCommunities
        self.HighlightedColorMap = False
        self.communityWeight = weight
        self.edgeThickness = 1
        self.thickHighlightedEdges = 3 
        self.ColorOnlySelectedNodesFlag =False
        if math.isnan(weight):
            weight = 1
        self.weight = weight
        if ForCommunities:
            self.communtiyColor = ColorToInt((0,0,0,255))
            self.communtiyColor1 = QtGui.QColor(self.communtiyColor)
            self.setToolTip(str("InterModular Correlation Strength:  "+str(weight)+"\n"+"Source Community:  "+str(sourceId)+"\nDestination Community:  "+str(destId)))
        self.sourcePoint = QtCore.QPointF()
        self.destPoint = QtCore.QPointF()
        self.graph = weakref.ref(graphWidget)
        self.source = weakref.ref(sourceNode)
        self.dest = weakref.ref(destNode)
        self.EdgeColor = QtGui.QColor(self.graph().EdgeColor[self.index])
        self.source().addEdge(self)
项目:BrainModulyzer    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self, sourceNode, destNode):
        QtGui.QGraphicsItem.__init__(self)

        self.arrowSize = 10.0
        self.ColorEdgesFlag = True
        self.colorvalue = []
        self.sourcePoint = QtCore.QPointF()
        self.destPoint = QtCore.QPointF()
        self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
        self.source = weakref.ref(sourceNode)
        self.dest = weakref.ref(destNode)
        self.source().addEdge(self)
        self.dest().addEdge(self)
        self.adjust()
项目:BrainModulyzer    作者:sugeerth    | 项目源码 | 文件源码
def adjust(self):
        if not self.source() or not self.dest():
            return

        line = QtCore.QLineF(self.mapFromItem(self.source(), 0, 0), self.mapFromItem(self.dest(), 0, 0))
        length = line.length()

        if length == 0.0:
            return

        edgeOffset = QtCore.QPointF((line.dx() * 10) / length, (line.dy() * 10) / length)

        self.prepareGeometryChange()
        self.sourcePoint = line.p1() + edgeOffset
        self.destPoint = line.p2() - edgeOffset
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self, graphWidget, communities, correspondingNodes, Nodeid = -1):
        QtGui.QGraphicsItem.__init__(self)
        self.setAcceptHoverEvents(False)
        self.opacityValue = 255
        self.NodeCommunityColor = True
        self.graph = weakref.ref(graphWidget)
        self.edgeList = []
        self.SubNodesOfCommunityNodes = None
        self.node = []
        self.graphWidget = graphWidget
        self.subNodes = []
        self.colorvalue = []
        self.communityNode = None

        self.radius = 15
        self.CommunityColor = None
        self.colorvalue = None

        self.Nodeidss = communities
        self.CommunityColor = []

        self.X_Size = len(correspondingNodes)

        Tooltip = ""
        for i in correspondingNodes:
            Tooltip+= str(i) +"\n"
        Tooltip+= "TIMESTEP:" + str(self.graphWidget.Graph_interface.TimeStep-1)

        self.setToolTip(str(Tooltip))

        self.correspondingNodes = correspondingNodes
        self.newPos = QtCore.QPointF()
        self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges)
        self.setCacheMode(self.DeviceCoordinateCache)
        self.setFlag(QtGui.QGraphicsItem.ItemUsesExtendedStyleOption)
        self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges)

        self.PutColor(self.graphWidget.widget.communityDetectionEngine.clut[self.Nodeidss])

        self.setZValue(-1)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self, graphWidget, sourceNode, destNode, counter, sourceId, destId, MaxValue,weight=1,ForCommunities=False,):
        QtGui.QGraphicsItem.__init__(self)
        self.setAcceptHoverEvents(False)
        self.EdgeThreshold = MaxValue - 0.01
        self.ColorEdgesFlag = False
        self.index = counter
        self.Alpha = 0.2
        self.sourceId = sourceId 
        self.destId = destId
        self.ColorMap = True
        self.ForCommunities= ForCommunities
        self.HighlightedColorMap = False
        self.communityWeight = weight
        self.edgeThickness = 1
        self.thickHighlightedEdges = 3 
        self.ColorOnlySelectedNodesFlag =False

        if math.isnan(weight):
            weight = 0

        self.weight = weight

        if ForCommunities:
            self.communtiyColor = ColorToInt((0,0,0,255))
            self.communtiyColor1 = QtGui.QColor(self.communtiyColor)
            self.setToolTip(str("InterModular Strength:  "+"{0:.2f}".format(weight)))
        self.sourcePoint = QtCore.QPointF()
        self.destPoint = QtCore.QPointF()
        self.graph = weakref.ref(graphWidget)
        self.source = weakref.ref(sourceNode)
        self.dest = weakref.ref(destNode)
        self.EdgeColor = QtGui.QColor(self.graph().EdgeColor[self.index])
        self.source().addEdge(self)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def drawOnePie(self,painter, Opacity=255, radius = 11):
        radius = int(radius)
        self.CommunityColor.setAlpha(Opacity)
        painter.setPen(QtGui.QPen(self.CommunityColor, 0.1))

        painter.setBrush(self.CommunityColor)
        painter.drawEllipse(QtCore.QPointF(0,0),radius, radius)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def paint(self, painter, option, widget):
        """
        This method does the drawing.
        """
        painter.setPen(QtCore.Qt.darkGray)
        painter.setBrush(QtGui.QColor(250, 245, 209))

        adjustedRect = self.boundingRect() # the rectangle around the text

        if self.orientation == 'above':
            # should draw the label balloon above the point
            adjustedRect.adjust(0, 0, 0, -12)
            vertices = [QtCore.QPointF(adjustedRect.width()/2 - 6,
                                       adjustedRect.height() - 1),
                        QtCore.QPointF(adjustedRect.width()/2,
                                       adjustedRect.height() + 12),
                        QtCore.QPointF(adjustedRect.width()/2 + 6,
                                       adjustedRect.height() - 1)]
        else:
            # should draw the label balloon below the point
            adjustedRect.adjust(0, 12, 0, 0)
            vertices = [QtCore.QPointF(adjustedRect.width()/2 - 6, 1),
                        QtCore.QPointF(adjustedRect.width()/2, -12),
                        QtCore.QPointF(adjustedRect.width()/2 + 6, 1)]

        # paint the balloon rectangle
        painter.drawRoundedRect(adjustedRect, 8, 8)

        # paint the balloon arrow triangle fill
        painter.setPen(QtCore.Qt.NoPen)
        painter.drawPolygon(vertices)

        # paint the balloon arrow triangle stroke
        painter.setPen(QtCore.Qt.darkGray)

        painter.drawLine(vertices[0], vertices[1])
        painter.drawLine(vertices[2], vertices[1])

        # Finally call the parent paint method to draw the actual text
        super(GraphicsBalloonTextItem, self).paint(painter, option, widget)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def PaintElectrodes(self):
        counter = 0
        k = 0

        for x,y in zip(self.ElectrodeData.mat['xy'][0],self.ElectrodeData.mat['xy'][1]):
            if self.ElectrodeData.graphWidget.CommunityMode:
                try: 
                    temp = self.ElectrodeData.graphWidget.partition[counter]
                except IndexError:
                    temp = 0            

                if counter == len(self.ElectrodeData.ElectrodeIds): 
                        break
                if k == self.ElectrodeData.ElectrodeIds[counter]:  
                    node_value=ElectrodeNode(self,counter,k,self.ElectrodeData.contextFlag)

                    # initialize electrode opacity
                    opacity=ElectrodeOpacity(self, k, counter)
                    self.ElectrodeOpacity.append(opacity)

                    node_value.PutColor(self.ElectrodeData.graphWidget.communityDetectionEngine.clut[counter])
                    node_value.xy = (x,y)
                    node_value.translate(0,25)
                    node_value.setPos(QtCore.QPointF(x,y))
                    self.NodeIds.append(node_value)
                    self.scene.addItem(node_value)
                    counter = counter+1 
                k = k + 1
项目:rfcat    作者:EnhancedRadioDevices    | 项目源码 | 文件源码
def _draw_reticle(self):
        if self._reticle is None or (self._reticle.size() != self.size()):
            self._new_reticle()

            dbm_lines = [QLineF(self._hz_to_x(self._low_frequency), self._dbm_to_y(dbm),
                                self._hz_to_x(self._high_frequency), self._dbm_to_y(dbm))
                         for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]
            dbm_labels = [(dbm, QPointF(self._hz_to_x(self._low_frequency) + 2, self._dbm_to_y(dbm) - 2))
                          for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]

            frequency_lines = [QLineF(self._hz_to_x(frequency), self._dbm_to_y(self._high_dbm),
                                      self._hz_to_x(frequency), self._dbm_to_y(self._low_dbm))
                               for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 20.0)]
            frequency_labels = [(frequency, QPointF(self._hz_to_x(frequency) + 2, self._dbm_to_y(self._high_dbm) + 10))
                                for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 10.0)]

            painter = QtGui.QPainter(self._reticle)
            try:
                painter.setRenderHint(QtGui.QPainter.Antialiasing)

                painter.setPen(Qt.blue)

                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(dbm_lines)
                for dbm_line in dbm_lines: painter.drawLine(dbm_line)
                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(frequency_lines)
                for frequency_line in frequency_lines: painter.drawLine(frequency_line)

                painter.setPen(Qt.white)
                for dbm, point in dbm_labels:
                    painter.drawText(point, '%+.0f' % dbm)
                for frequency, point in frequency_labels:
                    painter.drawText(point, '%.02f' % (frequency / 1e6))

            finally:
                painter.end()
项目:rfcat    作者:atlas0fd00m    | 项目源码 | 文件源码
def _draw_reticle(self):
        if self._reticle is None or (self._reticle.size() != self.size()):
            self._new_reticle()

            dbm_lines = [QLineF(self._hz_to_x(self._low_frequency), self._dbm_to_y(dbm),
                                self._hz_to_x(self._high_frequency), self._dbm_to_y(dbm))
                         for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]
            dbm_labels = [(dbm, QPointF(self._hz_to_x(self._low_frequency) + 2, self._dbm_to_y(dbm) - 2))
                          for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]

            frequency_lines = [QLineF(self._hz_to_x(frequency), self._dbm_to_y(self._high_dbm),
                                      self._hz_to_x(frequency), self._dbm_to_y(self._low_dbm))
                               for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 20.0)]
            frequency_labels = [(frequency, QPointF(self._hz_to_x(frequency) + 2, self._dbm_to_y(self._high_dbm) + 10))
                                for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 10.0)]

            painter = QtGui.QPainter(self._reticle)
            try:
                painter.setRenderHint(QtGui.QPainter.Antialiasing)

                painter.setPen(Qt.blue)

                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(dbm_lines)
                for dbm_line in dbm_lines: painter.drawLine(dbm_line)
                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(frequency_lines)
                for frequency_line in frequency_lines: painter.drawLine(frequency_line)

                painter.setPen(Qt.white)
                for dbm, point in dbm_labels:
                    painter.drawText(point, '%+.0f' % dbm)
                for frequency, point in frequency_labels:
                    painter.drawText(point, '%.02f' % (frequency / 1e6))

            finally:
                painter.end()
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def updateROIPosition(self):
            source = self.source
            vec_x, vec_y = self._vectorToCenter(source.strike)

            self.setAngle(-source.strike, finish=False)
            self.setPos(
                QtCore.QPointF(source.easting - vec_x,
                               source.northing - vec_y),
                finish=False)
            # self.setPos(QtCore.QPointF(source.easting, source.northing),
            #             finish=False)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def updateROIPosition(self):
            source = self.source

            self.setAngle(-source.strike, finish=False)
            self.setSize(source.diameter, finish=False)
            vec_x, vec_y = self._vectorToCenter(source.strike)
            self.setPos(
                QtCore.QPointF(source.easting - vec_x,
                               source.northing - vec_y), finish=False)
            # self.setPos(QtCore.QPointF(source.easting, source.northing),
            #             finish=False)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, parent):
        QtGui.QGraphicsItem.__init__(self, parent=parent)

        self.p1 = QtCore.QPointF()
        self.p2 = QtCore.QPointF()
        self.line = QtCore.QLineF(self.p1, self.p2)

        self.setOrientation(0., 0.)
        self.setZValue(10000)
项目:PandwaRF    作者:ComThings    | 项目源码 | 文件源码
def _draw_reticle(self):
        if self._reticle is None or (self._reticle.size() != self.size()):
            self._new_reticle()

            dbm_lines = [QLineF(self._hz_to_x(self._low_frequency), self._dbm_to_y(dbm),
                                self._hz_to_x(self._high_frequency), self._dbm_to_y(dbm))
                         for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]
            dbm_labels = [(dbm, QPointF(self._hz_to_x(self._low_frequency) + 2, self._dbm_to_y(dbm) - 2))
                          for dbm in numpy.arange(self._low_dbm, self._high_dbm, 20.0)]

            frequency_lines = [QLineF(self._hz_to_x(frequency), self._dbm_to_y(self._high_dbm),
                                      self._hz_to_x(frequency), self._dbm_to_y(self._low_dbm))
                               for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 20.0)]
            frequency_labels = [(frequency, QPointF(self._hz_to_x(frequency) + 2, self._dbm_to_y(self._high_dbm) + 10))
                                for frequency in numpy.arange(self._low_frequency, self._high_frequency, self._frequency_step * 10.0)]

            painter = QtGui.QPainter(self._reticle)
            try:
                painter.setRenderHint(QtGui.QPainter.Antialiasing)

                painter.setPen(Qt.blue)

                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(dbm_lines)
                for dbm_line in dbm_lines: painter.drawLine(dbm_line)
                # TODO: Removed to support old (<1.0) PySide API in Ubuntu 10.10
                #painter.drawLines(frequency_lines)
                for frequency_line in frequency_lines: painter.drawLine(frequency_line)

                painter.setPen(Qt.white)
                for dbm, point in dbm_labels:
                    painter.drawText(point, '%+.0f' % dbm)
                for frequency, point in frequency_labels:
                    painter.drawText(point, '%.02f' % (frequency / 1e6))

            finally:
                painter.end()
项目:BrainModulyzer    作者:sugeerth    | 项目源码 | 文件源码
def changeLayout(self,Layout='sfdp'):
        Layout = (Layout.encode('ascii','ignore')).replace(' ','')
        self.g =  self.Graph_data().DrawHighlightedGraph(self.EdgeSliderValue)

        # asking community detection Engine to compute the Layout
        self.pos,Factor = self.communityDetectionEngine.communityLayoutCalculation(Layout,self.g)

        # Degree Centrality for the the nodes involved
        self.Centrality=nx.degree_centrality(self.g)
        self.Betweeness=nx.betweenness_centrality(self.g)  
        self.LoadCentrality = nx.load_centrality(self.g)
        self.ParticipationCoefficient = self.communityDetectionEngine.participation_coefficient(self.g,True)
        self.ClosenessCentrality = nx.closeness_centrality(self.g)

        for i in range(len(self.ParticipationCoefficient)):
            if (str(float(self.ParticipationCoefficient[i])).lower() == 'nan'):
                   self.ParticipationCoefficient[i] = 0
        i = 0 

        """ Calculate rank and Zscore """
        MetrixDataStructure=eval('self.'+self.nodeSizeFactor)
        from collections import OrderedDict

        self.sortedValues = OrderedDict(sorted(MetrixDataStructure.items(), key=lambda x:x[1]))
        self.average = np.average(self.sortedValues.values())
        self.std = np.std(self.sortedValues.values())

        for item in self.scene().items():
            if isinstance(item, Node):
                x,y=self.pos[i]
                item.setPos(QtCore.QPointF(x,y)*Factor)
                Size = eval('self.'+self.nodeSizeFactor+'[i]')
                rank, Zscore = self.calculateRankAndZscore(i)
                item.setNodeSize(Size,self.nodeSizeFactor,rank,Zscore)
                i = i + 1

        for edge in self.edges:
            edge().adjust()

        self.Refresh()

        if not(self.PositionPreserve):
            self.Scene_to_be_updated.setSceneRect(self.Scene_to_be_updated.itemsBoundingRect())
            self.setScene(self.Scene_to_be_updated)

        self.fitInView(self.Scene_to_be_updated.itemsBoundingRect(),QtCore.Qt.KeepAspectRatio)
        self.Scene_to_be_updated.update()
项目:BrainModulyzer    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self, graphWidget, counter,correlationTable,ForCommunities=False):
        QtGui.QGraphicsItem.__init__(self)

        """Accepting hover events """
        self.setAcceptHoverEvents(True)
        self.opacityValue = 255
        self.graph = weakref.ref(graphWidget)
        self.edgeList = []
        self.ForCommunities = True
        self.ForCommunities = ForCommunities
        self.CommunityColor = None
        self.MousePressede = True
        self.setTransp = True
        self.NodeCommunityColor = False
        self.counter = counter
        self.aplha = 0.2
        self.colorTransparency = True 
        self.First = True
        self.nodesize = 12
        self.degreeCentrality = 1.0

        # FIX ME switched off untill centre abbreviation is sorted out
        # self.Abbr = correlationTable.AbbrName
        self.Brain_Regions = correlationTable.RegionName[0]
        for i in range (self.counter-1):
            self.Brain_Regions[i] = self.Brain_Regions[i].replace(' ','')
        if not(self.ForCommunities): 
            self.setToolTip(str(self.Brain_Regions[self.counter-1]+ " , " + str(self.counter)))
        else: 
            self.setToolTip(str(counter))
        self.colorvalue = []
        self.Selected = False 
        self.Translate = Translate()
        self.WhitePaint= False
        self.newPos = QtCore.QPointF()
        self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
        # self.setFlag(QtGui.QGraphicsItem.ItemIgnoresTransformations)   
        # self.setFlag(QtGui.QGraphicsItem.ItemUsesExtendedStyleOption)
        # self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges)
        if not(self.ForCommunities):
            self.nodeColor = QtGui.QColor(self.graph().DataColor[self.counter])

        self.setCacheMode(self.DeviceCoordinateCache)
        if (len(correlationTable.data) > 150): 
            self.nodesize = 22 - (2000*len(correlationTable.data)*0.00001)% 3
        self.i = 0
        self.setZValue(3)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self, graphWidget, sourceNode, destNode, counter, sourceId, destId, weight):
        QtGui.QGraphicsItem.__init__(self)
        self.setAcceptHoverEvents(True)

        self.ForCommunities = False
        self.EdgeThreshold = 0 
        self.ColorEdgesFlag = False
        self.index = counter
        self.Alpha = 0.2
        self.sourceId = sourceId 
        self.destId = destId
        self.ColorMap = True
        self.HighlightedColorMap = False
        self.communityWeight = weight
        self.edgeThickness = 1
        self.thickHighlightedEdges = 3 
        self.ColorOnlySelectedNodesFlag =False
        if math.isnan(weight):
            weight = 0

        intersectingElements = list(set(sourceNode.correspondingNodes).intersection(destNode.correspondingNodes))

        # self.setToolTip(str(intersectingElements))
        # if (len(intersectingElements) == 0):
        #     return -1 
        self.sourcePoint = QtCore.QPointF()
        self.destPoint = QtCore.QPointF()
        self.graph = weakref.ref(graphWidget)
        self.source = weakref.ref(sourceNode)
        self.dest = weakref.ref(destNode)
        self.EdgeColor = QtGui.QColor(QtCore.Qt.black)
        self.source().addEdge(self)

        self.Color = sourceNode.CommunityColor
        self.weight = weight*2 + 2 

        # intersect = list(set(sourceNode.Nodeidss).intersection(destNode.Nodeidss))
        # pprint.pprint(intersectingElements)
        Tooltip = ""
        for i in intersectingElements:
            Tooltip+= str(i) +"\n"

        self.setToolTip(Tooltip)
        # print sourceNode.CommunityColor, sourceNode.colorvalue, sourceNode.Nodeidss
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self, ImageLabel, counter, tooltip, contextFlag):
        QtGui.QGraphicsItem.__init__(self)
        self.minNodeVal = 7
        self.setAcceptHoverEvents(False)
        self.opacityValue = 255
        self.opacity = 255
        self.slices = 1
        self.ElectrodeData = ImageLabel
        self.ImageLabel = ImageLabel.ElectrodeData

        self.communityMemebership = []
        self.TimeStepRange = []
        self.chart = [True,False,False] 
        self.AlphaValue = []
        self.xy = None
        self.NodeCommunityColor = True
        self.Glyph = False
        self.graph = weakref.ref(self.ImageLabel.graphWidget)
        self.edgeList = []
        self.numberCalled= 0
        self.ColorQ = []
        self.SubNodesOfCommunityNodes = None
        self.node = []
        self.Red = False
        self.subNodes = []
        self.colorvalue = []
        self.communityNode = None
        self.nodesize = 12
        self.EA = None
        self.Highlight = False
        self.AcrossCommunityMode = False
        self.actualValue = []

        self.counter = counter
        self.Nodeidss = tooltip
        self.CommunityColor = []
        self.Abbr = self.ImageLabel.graphWidget.correlationTable().AbbrName
        self.Brain_Regions = self.graph().correlationTable().RegionName[0]

        self.newPos = QtCore.QPointF()
        self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges)
        self.setCacheMode(self.DeviceCoordinateCache)
        self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
        self.setFlag(QtGui.QGraphicsItem.ItemUsesExtendedStyleOption)
        self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges)
        self.setZValue(1)
项目:PipeLine    作者:draknova    | 项目源码 | 文件源码
def paint(self,painter,option, widget):   
        blackPen = QtGui.QPen()
        whitePen = QtGui.QPen()
        blackPen.setWidth(1)
        whitePen.setWidth(1)
        blackPen.setColor(QtGui.QColor("black"))
        whitePen.setColor(QtGui.QColor("white"))

        if self.isSelected():
            gradient = QtGui.QLinearGradient(QtCore.QPointF(0, 0), QtCore.QPointF(0, 20))
            gradient.setColorAt(0, QtGui.QColor(220,170,50))
            gradient.setColorAt(0.3, QtGui.QColor(220,170,50))
            gradient.setColorAt(1, QtGui.QColor(170,150,40))
            #brush = QtGui.QBrush(gradient)
            #brush.setStyle(QtCore.Qt.LinearGradientPattern)
            brush = QtGui.QBrush(QtGui.QColor(220,160,50))


        else:
            gradient = QtGui.QLinearGradient(QtCore.QPointF(0, 0), QtCore.QPointF(0, 20))
            gradient.setColorAt(0, QtGui.QColor(55,55,55))
            gradient.setColorAt(0.3, QtGui.QColor(60,60,60))
            gradient.setColorAt(1, QtGui.QColor(50,50,50))
            #brush = QtGui.QBrush(gradient)
            #brush.setStyle(QtCore.Qt.LinearGradientPattern)
            #brush = QtGui.QBrush(QtGui.QColor(50,50,50))
            brush = QtGui.QBrush(QtGui.QColor(32,61,74))



        font = QtGui.QFont()
        font.setFamily("Helvetica")
        font.setStyleStrategy(QtGui.QFont.PreferAntialias)
        font.setPointSize(14)


        painter.setBrush(brush)
        painter.setPen(blackPen)
        painter.setFont(font)

        painter.drawRoundedRect(self.rect,5,5)

        #pen.setColor(QtGui.QColor("white"))
        if self.scale > 0.75:
            painter.setPen(whitePen)
            painter.drawText(self.rect, QtCore.Qt.AlignCenter,self.name())
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def paint(self, painter, option, parent):
        r = self.vb.viewRect()
        h = r.height()
        w = r.width()

        nvectors = config.nvectors

        nx = int(num.sqrt(nvectors) * float(w)/h)
        ny = int(num.sqrt(nvectors) * float(h)/w)
        dx = float(w) / nx
        dy = float(h) / ny
        d = dx if dx < dy else dy

        mat_N = self.sandbox.model.north.T
        mat_E = self.sandbox.model.east.T
        img_shape = self.image.image.shape
        ivec = 0

        length_scale = self.sandbox.model.max_horizontal_displacement
        self.length_scale = length_scale if length_scale > 0. else 1.
        self.scale_view = (w+h)/2 / painter.window().height()*2.5

        for ix in xrange(nx):
            for iy in xrange(ny):
                if ivec > nvectors:
                    break
                vec = self.vectors[ivec]
                pos = QtCore.QPointF(r.x() + ix * dx + dx/2,
                                     r.y() + iy * dy + dy/2)

                # Slowest operation
                img_pos = self.plot.image.mapFromScene(
                    self.vb.mapViewToScene(pos))

                pE = int(img_pos.x())
                pN = int(img_pos.y())

                if (pE >= img_shape[0] or pN >= img_shape[1]) or\
                   (pE < 0 or pN < 0):
                    dE = 0.
                    dN = 0.
                else:
                    dE = mat_E[pE, pN]
                    dN = mat_N[pE, pN]
                    dE = dE / self.length_scale * (d/self.scale_view)
                    dN = dN / self.length_scale * (d/self.scale_view)
                vec.setPos(pos)
                vec.setOrientation(dE, dN)

                if vec.scale() != self.scale_view:
                    vec.setScale(self.scale_view)
                vec.setVisible(True)

                ivec += 1

        while ivec < nvectors:
            self.vectors[ivec].hide()
            ivec += 1

        QtGui.QGraphicsItemGroup.paint(self, painter, option, parent)