def __init__(self, track, *args, **kwargs):
super(TrackWidget, self).__init__(*args, **kwargs)
self.track = track
self.setBrush(QtGui.QBrush(QtGui.QColor(43, 52, 59, 255)))
self._populate()
python类QColor()的实例源码
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)))
def itemChange(self, change, value):
if change == QtGui.QGraphicsItem.ItemSelectedHasChanged:
self.setPen(
QtGui.QColor(0, 255, 0, 255) if self.isSelected()
else QtGui.QColor(0, 0, 0, 255)
)
return super(Marker, self).itemChange(change, value)
def __init__(self, *args, **kwargs):
super(TimeSlider, self).__init__(*args, **kwargs)
self.setBrush(QtGui.QBrush(QtGui.QColor(64, 78, 87, 255)))
def __init__(self, composition, *args, **kwargs):
super(CompositionWidget, self).__init__(*args, **kwargs)
self.composition = composition
self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(64, 78, 87, 255)))
self._adjust_scene_size()
self._add_time_slider()
self._add_tracks()
self._add_markers()
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)
def PutColor(self,colorvalue):
self.colorvalue = colorvalue
self.CommunityColor = QtGui.QColor(colorvalue)
self.NodeCommunityColor = True
def setOpaqueNodes(self):
self.colorTransparency = False
self.nodeColor = QtGui.QColor(self.graph().DataColor[self.counter])
if self.NodeCommunityColor:
self.CommunityColor.setAlpha(255)
else:
self.nodeColor.setAlpha(255)
self.update()
def unsetOpaqueNodes(self):
self.colorTransparency = True
self.nodeColor = QtGui.QColor(self.graph().DataColor[self.counter])
if not(self.setTransp):
return
if self.NodeCommunityColor:
self.CommunityColor.setAlpha(25)
else:
self.nodeColor.setAlpha(25)
self.update()
def PutColor(self,colorvalue,alphaValue = -1):
self.colorvalue = colorvalue
self.CommunityColor = QtGui.QColor(colorvalue)
self.NodeCommunityColor = True
self.update()
def ChangeColors(self):
"""
Clustered Order is the sorted order of different brain regions based on the communities detected
"""
"""Calling the Parent Method for Sorting the cells"""
self.sortDataStructure(self.Order,self.Brain_Regions)
"""Sorting the header labels vertical and horizontalHeader"""
self.setVerticalHeaderLabels(self.ClusteredOrder)
self.setHorizontalHeaderLabels(['\n'.join(name) for name in self.ClusteredOrder])
for i in range(len(self.correlationTable.header)):
for j in range(len(self.correlationTable.header)):
table_item = self.item(i,j)
if (self.GraphDataStructure().ThresholdData[self.sortedOrder[i]][self.sortedOrder[j]] != 0) and self.sortedValues[i] == self.sortedValues[j]:
table_item.setBackground(QtGui.QColor(*self.colors[self.sortedOrder[i]]))
else:
table_item.setBackground(QtGui.QColor(QtCore.Qt.white))
table_item.setToolTip("%s,%s,%g" % (self.Brain_Regions[self.sortedOrder[i]] ,self.Brain_Regions[self.sortedOrder[j]],self.correlationTable.data[self.sortedOrder[i], self.sortedOrder[j]]))
self.verticalHeader()
self.horizontalHeader()
def PutColor(self,colorvalue):
# print "Value", self.Nodeidss
self.colorvalue = colorvalue
self.CommunityColor = QtGui.QColor(colorvalue)
self.update()
def PutColor(self,colorvalue):
# print "Value", self.Nodeidss
self.colorvalue = colorvalue
self.CommunityColor = QtGui.QColor(colorvalue)
self.update()
def UpdateColorsInElectrodeView(self, nodelist, Offset = 0):
ElectrodeViewObjectDummy = self.electrode.SmallMultipleElectrode[1]
for i in nodelist:
try:
ElectrodeViewNumberToUpdate = self.AggregateHashmap[i['timestep']]
except KeyError:
continue
# getting the electrode view number
ElectrodeViewObject = self.electrode.SmallMultipleElectrode[ElectrodeViewNumberToUpdate]
assert ElectrodeViewObject.ChunkNo == ElectrodeViewNumberToUpdate
# get the elements in the community defined by that
CommunityNumber = i['OriginalAssignmentValue']
Elements = i['Elements']
Color = i['color'].replace("rgb(", "").replace(")", "").replace(" ", "").split(',')
Color = map(int, Color)
for element in Elements:
ActualElectrodeNumber = self.electrode.ElectrodeIds[element]
norm = ElectrodeViewObject.ElectrodeOpacity[element].normalize(i['timestep'], ActualElectrodeNumber)
ElectrodeViewObject.NodeIds[element].PutFinalColors(norm[0],norm[1], QtGui.QColor(Color[0],Color[1],Color[2]),i['timestep'],CommunityNumber,ElectrodeViewObjectDummy.slices)
assert ElectrodeViewObject.NodeIds[element].counter == element
ElectrodeViewObject.NodeIds[element].update()
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)
def PutTextColor(self,colorvalue):
self.TextColor = colorvalue
self.CommunityTextColor = QtGui.QColor(colorvalue)
self.update()
def PutColor(self,colorvalue):
self.colorvalue = colorvalue
self.CommunityColor = QtGui.QColor(colorvalue)
self.NodeCommunityColor = True
self.update()
def PutFinalColors(self,opacity,actualValue, colorvalue,timesterange,\
communityMemebership,slices= 4, alphaValue=255,\
AllFourColors = None, AlphaDraw = False):
self.slices = slices
self.numberCalled += 1
self.CommunityColor = QtGui.QColor(colorvalue)
if opacity == None:
opacity = 0
self.colorvalue = colorvalue
if self.Glyph:
self.communityMemebership.append(communityMemebership)
self.TimeStepRange.append(timesterange)
self.ColorQ.append(self.CommunityColor)
self.actualValue.append(actualValue)
self.opacity = opacity
self.AlphaValue.append(opacity)
counter= 0
new = []
for value in self.TimeStepRange:
new.append(value)
self.setToolTip(str(self.AlphaValue)+"\n"+str(self.actualValue) + str(new)+ "\n"+communityMemebership)
if len(self.ColorQ) > self.slices:
self.AlphaValue = self.AlphaValue[-self.slices:]
self.ColorQ = self.ColorQ[-self.slices:]
self.actualValue = self.actualValue[-self.slices:]
self.TimeStepRange = self.TimeStepRange[-self.slices:]
self.communityMemebership = self.communityMemebership[-self.slices:]
self.setToolTip(str(self.AlphaValue)+"\n:" + str(self.TimeStepRange)+ "\n")
self.NodeCommunityColor = True
self.update()
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)
def setColor(self, color, emit=True):
if isinstance(color, (str, bytes)):
self.color = QtGui.QColor(color)
else:
self.color = color
self.update()
if emit:
self.colorChanged.emit(self.color)