Ejemplo n.º 1
0
 def canvasMoveEvent(self, e):
     super(ArkMapToolInteractive, self).canvasMoveEvent(e)
     if not self._active:
         return
     e.ignore()
     if (self._panningEnabled and e.buttons() & Qt.LeftButton):
         # Pan map mode
         if not self._dragging:
             self._dragging = True
             self.setCursor(QCursor(Qt.ClosedHandCursor))
         self.canvas().panAction(e)
         e.accept()
     elif (self._zoomingEnabled and e.buttons() & Qt.RightButton):
         # Zoom map mode
         if not self._dragging:
             self._dragging = True
             self.setCursor(QCursor(Qt.ClosedHandCursor))
             self._zoomRubberBand = QgsRubberBand(self.canvas(), QGis.Polygon)
             color = QColor(Qt.blue)
             color.setAlpha(63)
             self._zoomRubberBand.setColor(color)
             self._zoomRect = QRect(0, 0, 0, 0)
             self._zoomRect.setTopLeft(e.pos())
         self._zoomRect.setBottomRight(e.pos())
         if self._zoomRubberBand is not None:
             self._zoomRubberBand.setToCanvasRectangle(self._zoomRect)
             self._zoomRubberBand.show()
         e.accept()
     elif self._snappingEnabled:
         mapPoint, snapped = self._snapCursorPoint(e.pos())
         if (snapped):
             self._createSnappingMarker(mapPoint)
         else:
             self._deleteSnappingMarker()
Ejemplo n.º 2
0
	def paintEvent( self, event ):
		painter = QtGui.QPainter()
		color = self.color
		painter.begin( self )
		margin = 2
		x = margin
		y = margin
		w = self.width() - margin * 2
		h = self.height() - margin * 2
		gridSize = 5
		gridPart = gridSize * 1
		painter.translate( margin, margin )
		painter.setPen( Qt.black )
		painter.setBrush( Qt.white )
		painter.drawRect( 0,0,w,h )
		painter.setPen( Qt.NoPen )
		painter.setBrush( Qt.black )
		painter.setClipRect( 0,0,w,h )
		for y in range( int(h/gridSize+1) ):
				for x in range( int(w/gridSize+1) ):
					if (x % 2) == (y % 2):
						painter.drawRect( x * gridSize, y * gridSize, gridSize, gridSize )
		painter.setBrush( color )
		painter.drawRect( 0,0,w,h )
		colorFull = QColor( color )
		colorFull.setAlpha( 255 )
		painter.setBrush( colorFull )
		painter.drawRect( 0,0, w/2, h )
		painter.end()
Ejemplo n.º 3
0
    def paintEvent(self, e):
        Part.paintEvent(self, e)
        painter = QPainter(self)
        color = QColor(self._base.dark(150))
        color.setAlpha(150)
        painter.setPen(color)
        painter.pen().setWidth(2)
        painter.drawPolyline(*tuple(self._SYNTH_POINTS))
        
        if not self.songpart is None and self.activeLED.isHidden():
            color = QColor('black')
            color.setAlpha(200)
            painter.setPen(color)
            rect = QRect(0, 5, self.width() - 5, self.height() - 5)
            painter.drawText(rect,
                             Qt.AlignRight | Qt.AlignTop,
                             '[%s]' % self.songpart)

        painter.setPen(self._base.light(150))
        painter.pen().setWidth(self.margin)
        y = self.height() - self.margin
        synth = self.data
        for start, stop in self.paintNotes:
            ratio = 1 - ((stop - synth.localclock.time()) / (stop - start))
            if ratio > 0 and ratio <= 1:
                width = (self.width() - self.margin * 2) * ratio
                painter.drawLine(self.margin, y, width, y)
                y -= (self.margin + 3)

        painter = None
        self.drawText()
Ejemplo n.º 4
0
    def paintEvent(self, e):
        painter = QPainter(self)

        brush = QBrush(painter.brush())
        self.bgcolor.setAlpha(20)
        painter.setBrush(self.bgcolor)
        painter.drawRect(0, 0, self.width(), self.height())
        self.bgcolor.setAlpha(15)
        painter.setBrush(self.bgcolor)
        painter.drawRect(0, 20, self.width(), self.height()-40)
        painter.setBrush(brush)

        frame = self.clock.last_beat_frame
        x = self.x_for_frametime(frame)
        while x < self.width():
            x = self.x_for_frametime(frame)
            painter.drawLine(x, 0, x, 15)
            painter.drawLine(x, self.height(), x, self.height() - 15)
            #painter.drawText(QPoint(x+5, 13), str(frame))
            frame += self.clock.frames_per_beat()

        self.items = [i for i in self.items if i.endtime > self.frametime]
        for item in self.items:
            x = self.x_for_frametime(item.starttime)
            w = self.x_for_frametime(item.endtime) - x
            color = QColor(item.color)
            color.setAlpha(150)
            painter.setPen(color)
            pen = painter.pen()
            pen.setWidth(3)
            painter.setPen(pen)
            color.setAlpha(100)
            painter.setBrush(color)
            painter.drawRect(x, 0, w, self.height())
Ejemplo n.º 5
0
 def updateTerritoryOwner(self, name, owner):
     t = self.game.board.getTerritory(name)
     p = self.game.getPlayer(owner)
     color = QColor(*p.color)
     color.setAlpha(200)
     territoryImage = QImage(t.image.size(), QImage.Format_ARGB32_Premultiplied)
     p = QPainter()
     p.begin(territoryImage)
     p.drawImage(0, 0, self.game.board.image)
     p.setCompositionMode(QPainter.CompositionMode_DestinationIn)
     p.drawImage(0, 0, t.image)
     p.end()
     coloredTerritoryImage = QImage(territoryImage.size(), QImage.Format_ARGB32_Premultiplied)
     coloredTerritoryImage.fill(0)
     p.begin(coloredTerritoryImage)
     p.fillRect(territoryImage.rect(), color)
     p.setCompositionMode(QPainter.CompositionMode_DestinationIn)
     p.drawImage(0, 0, t.image)
     p.end()
     p.begin(self.ownershipMap)
     p.drawImage(0, 0, territoryImage)
     p.drawImage(0, 0, coloredTerritoryImage)
     p.end()
     self.scaledOwnershipMap = self.ownershipMap.scaled(self.imageSize())
     self.update()
Ejemplo n.º 6
0
    def paintEvent(self, e):
        Part.paintEvent(self, e)
        painter = QPainter(self)
        color = QColor(self._base)
        color.setAlpha(200)
        painter.setPen(color.dark(150))
        painter.setBrush(color.dark(115))
        painter.setRenderHint(QPainter.Antialiasing)

        painter.drawEllipse(11, 22, 10, 10)
        
        rect = QRectF(25, 17, 7, 20)
        painter.drawChord(rect, 270 * 16, 180 * 16)
        
        rect = QRectF(40, 11, 10, 30)
        painter.drawChord(rect, 270 * 16, 180 * 16)

        painter.drawEllipse(63, 14, 5, 5)
        painter.drawEllipse(63, 35, 5, 5)
        painter.drawEllipse(81, 14, 5, 5)
        painter.drawEllipse(81, 35, 5, 5)
        
        painter = None
        if self.data is None:
            text = None
        else:
            text = self.data.name        
        self.drawText(text)
Ejemplo n.º 7
0
 def canvasMoveEvent(self, e):
     super(ArkMapToolInteractive, self).canvasMoveEvent(e)
     if not self._active:
         return
     e.ignore()
     if (self._panningEnabled and e.buttons() & Qt.LeftButton):
         # Pan map mode
         if not self._dragging:
             self._dragging = True
             self.setCursor(QCursor(Qt.ClosedHandCursor))
         self.canvas().panAction(e)
         e.accept()
     elif (self._zoomingEnabled and e.buttons() & Qt.RightButton):
         # Zoom map mode
         if not self._dragging:
             self._dragging = True
             self.setCursor(QCursor(Qt.ClosedHandCursor))
             self._zoomRubberBand = QgsRubberBand(self.canvas(), QGis.Polygon)
             color = QColor(Qt.blue)
             color.setAlpha(63)
             self._zoomRubberBand.setColor(color)
             self._zoomRect = QRect(0, 0, 0, 0)
             self._zoomRect.setTopLeft(e.pos())
         self._zoomRect.setBottomRight(e.pos())
         if self._zoomRubberBand is not None:
             self._zoomRubberBand.setToCanvasRectangle(self._zoomRect)
             self._zoomRubberBand.show()
         e.accept()
     elif self._snappingEnabled:
         mapPoint, snapped = self._snapCursorPoint(e.pos())
         if (snapped):
             self._createSnappingMarker(mapPoint)
         else:
             self._deleteSnappingMarker()
Ejemplo n.º 8
0
 def createRubberBand(self):
     self.myRubberBand = QgsRubberBand(self.iface.mapCanvas())
     color = QColor(78, 97, 114)
     color.setAlpha(190)
     self.myRubberBand.setColor(color)
     self.myRubberBand.setFillColor(QColor(255, 0, 0, 40))
     self.myRubberBand.setBorderColor(QColor(255, 0, 0, 200))
Ejemplo n.º 9
0
    def data(self, index, role):
        if not index.isValid():
            return QVariant()

        status = self.model_data[index.row()][self.get_column_index("status")]
        col = self.get_column_name(index.column())

        if role == Qt.BackgroundColorRole:
            color = QColor(*self.state_colors[status])
            color.setAlpha(color.alpha() / 2)
            if col == 'stdout' or col == 'stderr':
                color = QColor(100, 100, 100, 100)  # make items stand out
            return QVariant(color)

        if role != Qt.DisplayRole:
            return QVariant()

        if self.get_column_name(index.column()).find("time") >= 0:
            if status == "Pending" or status == "Waiting":
                return QVariant()

            timestamp = eval(self.model_data[index.row()][index.column()])
            return QVariant(time.ctime(timestamp))

        if col == 'stdout' or col == 'stderr':
            return QVariant("OPEN")

        return QVariant(self.model_data[index.row()][index.column()])
Ejemplo n.º 10
0
    def _highlightLandmark(self):
        self._clearHighlight()

        self.highlight = QgsHighlight(self.canvas, self.info[1].geometry(),
                                      self.info[0])

        settings = QSettings()
        color = QColor(
            settings.value('/Map/highlight/color',
                           QGis.DEFAULT_HIGHLIGHT_COLOR.name()))
        alpha = settings.value('/Map/highlight/colorAlpha',
                               QGis.DEFAULT_HIGHLIGHT_COLOR.alpha(),
                               type=int)
        buffer = settings.value('/Map/highlight/buffer',
                                QGis.DEFAULT_HIGHLIGHT_BUFFER_MM,
                                type=float)
        minWidth = settings.value('/Map/highlight/minWidth',
                                  QGis.DEFAULT_HIGHLIGHT_MIN_WIDTH_MM,
                                  type=float)

        self.highlight.setColor(color)
        color.setAlpha(alpha)
        self.highlight.setFillColor(color)
        self.highlight.setBuffer(buffer)
        self.highlight.setMinWidth(minWidth)
        self.highlight.show()
Ejemplo n.º 11
0
 def __qcolor(color):
     """Returns qcolor for a given ARGB color
     """
     c = QColor(color)
     if color > 0xFFFFFF:
         c.setAlpha((color >> 24) & 0xFF)
     return c
Ejemplo n.º 12
0
 def highlight_selected_word(self):
     #Highlight selected variable
     if not self.isReadOnly() and not self.textCursor().hasSelection():
         word = self._text_under_cursor()
         if self._patIsWord.match(word):
             lineColor = QColor(
                 resources.CUSTOM_SCHEME.get('selected-word',
                     resources.COLOR_SCHEME['selected-word']))
             lineColor.setAlpha(100)
             block = self.document().findBlock(0)
             cursor = self.document().find(word, block.position(),
                 QTextDocument.FindCaseSensitively or \
                 QTextDocument.FindWholeWords)
             while block.isValid() and \
               block.blockNumber() <= self._sidebarWidget.highest_line \
               and cursor.position() != -1:
                 selection = QTextEdit.ExtraSelection()
                 selection.format.setBackground(lineColor)
                 selection.cursor = cursor
                 self.extraSelections.append(selection)
                 cursor = self.document().find(word, cursor.position(),
                     QTextDocument.FindCaseSensitively or \
                     QTextDocument.FindWholeWords)
                 block = block.next()
     self.setExtraSelections(self.extraSelections)
Ejemplo n.º 13
0
    def highlightReferencingFeature(self):
        self.deleteHighlight()
        if not self.relation.isValid() or not self.referencingFeature.isValid(
        ):
            return

        self.featureHighlight = QgsHighlight(
            self.iface.mapCanvas(), self.referencingFeature.geometry(),
            self.relation.referencingLayer())
        settings = QSettings()
        color = QColor(
            settings.value("/Map/highlight/color",
                           QGis.DEFAULT_HIGHLIGHT_COLOR.name()))
        alpha = int(
            settings.value("/Map/highlight/colorAlpha",
                           QGis.DEFAULT_HIGHLIGHT_COLOR.alpha()))
        bbuffer = float(
            settings.value("/Map/highlight/buffer",
                           QGis.DEFAULT_HIGHLIGHT_BUFFER_MM))
        minWidth = float(
            settings.value("/Map/highlight/minWidth",
                           QGis.DEFAULT_HIGHLIGHT_MIN_WIDTH_MM))

        self.featureHighlight.setColor(color)
        color.setAlpha(alpha)
        self.featureHighlight.setFillColor(color)
        self.featureHighlight.setBuffer(bbuffer)
        self.featureHighlight.setMinWidth(minWidth)
        self.featureHighlight.show()

        timer = QTimer(self)
        timer.setSingleShot(True)
        timer.timeout.connect(self.deleteHighlight)
        timer.start(3000)
Ejemplo n.º 14
0
 def highlight_selected_word(self):
     #Highlight selected variable
     if not self.isReadOnly() and not self.textCursor().hasSelection():
         word = self._text_under_cursor()
         if self._patIsWord.match(word):
             lineColor = QColor(
                 resources.CUSTOM_SCHEME.get(
                     'selected-word',
                     resources.COLOR_SCHEME['selected-word']))
             lineColor.setAlpha(100)
             block = self.document().findBlock(0)
             cursor = self.document().find(word, block.position(),
                 QTextDocument.FindCaseSensitively or \
                 QTextDocument.FindWholeWords)
             while block.isValid() and \
               block.blockNumber() <= self._sidebarWidget.highest_line \
               and cursor.position() != -1:
                 selection = QTextEdit.ExtraSelection()
                 selection.format.setBackground(lineColor)
                 selection.cursor = cursor
                 self.extraSelections.append(selection)
                 cursor = self.document().find(word, cursor.position(),
                     QTextDocument.FindCaseSensitively or \
                     QTextDocument.FindWholeWords)
                 block = block.next()
     self.setExtraSelections(self.extraSelections)
Ejemplo n.º 15
0
 def update_visible_area(self):
     block = self._parent.firstVisibleBlock()
     first_line = block.blockNumber()
     max_count = self.blockCount()
     parent_cursor = self._parent.textCursor()
     parent_cursor.setPosition(block.position())
     self.setTextCursor(parent_cursor)
     lines_count = self.max_line
     if (first_line + self.max_line) > max_count:
         lines_count = max_count - first_line
     extraSelections = []
     for i in xrange(lines_count):
         selection = QTextEdit.ExtraSelection()
         lineColor = QColor(resources.CUSTOM_SCHEME.get('current-line',
                     resources.COLOR_SCHEME['current-line']))
         lineColor.setAlpha(100)
         selection.format.setBackground(lineColor)
         selection.format.setProperty(QTextFormat.FullWidthSelection, True)
         cursor = self.textCursor()
         cursor.setPosition(block.position())
         selection.cursor = cursor
         selection.cursor.clearSelection()
         extraSelections.append(selection)
         block = block.next()
     self.setExtraSelections(extraSelections)
Ejemplo n.º 16
0
 def _drawDarkness(self, painter):
     """if appropriate, make tiles darker. Mainly used for hidden tiles"""
     if self.tile.dark:
         board = self.tile.board
         rect = board.tileFaceRect().adjusted(-1, -1, -1, -1)
         color = QColor('black')
         color.setAlpha(self.tileset.darkenerAlpha)
         painter.fillRect(rect, color)
Ejemplo n.º 17
0
    def __init__(self, p_navplot):
        QwtPlotCurve.__init__(self)

        self.__p_nav_plot = p_navplot
        _color = QColor(0, 0, 0)
        _color.setAlpha(50)
        self._penColor = _color
        self._brushColor = _color
Ejemplo n.º 18
0
 def _drawDarkness(self, painter):
     """if appropriate, make tiles darker. Mainly used for hidden tiles"""
     if self.tile.dark:
         board = self.tile.board
         rect = board.tileFaceRect().adjusted(-1, -1, -1, -1)
         color = QColor('black')
         color.setAlpha(self.tileset.darkenerAlpha)
         painter.fillRect(rect, color)
Ejemplo n.º 19
0
 def __init__(self, ganttWidget):
     super(GanttHeaderView, self).__init__ (Qt.Horizontal, ganttWidget)
     self.ganttWidget = ganttWidget
     color = QColor(Qt.lightGray)
     color.setAlpha(128)
     self.pen4line = QPen(color)
     self.pen4text = QPen(Qt.darkGray)
     self.sectionResized.connect(self._adjustSectionSize)
     self.cdi = CalendarDrawingInfo()
Ejemplo n.º 20
0
 def paintEvent(self, e):
     if self.active:
         painter = QPainter(self)
         pen = painter.pen()
         pen.setWidth(self.margin)
         pen.setColor(self.frame_color)
         color = QColor(self.frame_color)
         color.setAlpha(30)
         painter.setBrush(color)
         painter.drawRect(0, 0, self.width(), self.height())
Ejemplo n.º 21
0
 def paintEvent(self, e):
     Part.paintEvent(self, e)
     painter = QPainter(self)
     color = QColor(self._base.dark(150))
     color.setAlpha(150)
     painter.setPen(color)
     painter.pen().setWidth(2)
     painter.drawPolyline(*tuple(self._SYNTH_POINTS))
     painter = None
     self.drawText()
Ejemplo n.º 22
0
 def clear_markers(self):
     cursor = self.ui.plainTextEditCode.textCursor()
     cursor.setPosition(0, QTextCursor.MoveAnchor)
     cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor)
     format = QTextCharFormat()
     color = QColor()
     color.setAlpha(0) #nice trick to get the original background color back
     brush = QBrush(color)
     format.setBackground(brush)
     cursor.mergeCharFormat(format)
Ejemplo n.º 23
0
 def paintEvent(self, e):
     TimeLine.paintEvent(self, e)
     if self._draw_box:
         painter = QPainter(self)
         color = QColor(self.box_color)
         color.setAlpha(100)
         painter.setPen(color)
         color.setAlpha(50)
         painter.setBrush(color)
         painter.drawRect(self._draw_box)
Ejemplo n.º 24
0
    def draw_distributions(self):
        """Draw distributions with discrete attributes"""
        if not (self.show_distributions and self.have_data and self.data_has_discrete_class):
            return
        class_count = len(self.data_domain.class_var.values)
        class_ = self.data_domain.class_var

        # we create a hash table of possible class values (happens only if we have a discrete class)
        if self.domain_contingencies is None:
            self.domain_contingencies = dict(
                zip(
                    [attr for attr in self.data_domain if isinstance(attr, DiscreteVariable)],
                    get_contingencies(self.raw_data, skipContinuous=True),
                )
            )
            self.domain_contingencies[class_] = get_contingency(self.raw_data, class_, class_)

        max_count = max([contingency.max() for contingency in self.domain_contingencies.values()] or [1])
        sorted_class_values = get_variable_values_sorted(self.data_domain.class_var)

        for axis_idx, attr_idx in enumerate(self.attribute_indices):
            attr = self.data_domain[attr_idx]
            if isinstance(attr, DiscreteVariable):
                continue

            contingency = self.domain_contingencies[attr]
            attr_len = len(attr.values)

            # we create a hash table of variable values and their indices
            sorted_variable_values = get_variable_values_sorted(attr)

            # create bar curve
            for j in range(attr_len):
                attribute_value = sorted_variable_values[j]
                value_count = contingency[:, attribute_value]

                for i in range(class_count):
                    class_value = sorted_class_values[i]

                    color = QColor(self.discrete_palette[i])
                    color.setAlpha(self.alpha_value)

                    width = float(value_count[class_value] * 0.5) / float(max_count)
                    y_off = float(1.0 + 2.0 * j) / float(2 * attr_len)
                    height = 0.7 / float(class_count * attr_len)

                    y_low_bottom = y_off + float(class_count * height) / 2.0 - i * height
                    curve = PolygonCurve(
                        QPen(color),
                        QBrush(color),
                        xData=[axis_idx, axis_idx + width, axis_idx + width, axis_idx],
                        yData=[y_low_bottom, y_low_bottom, y_low_bottom - height, y_low_bottom - height],
                        tooltip=attr.name,
                    )
                    curve.attach(self)
Ejemplo n.º 25
0
    def __init__(self, name, contextType):
        super(ContextTypeItem, self).__init__([name])

        # define custom properties
        self.setFlags(Qt.ItemIsEnabled)
        clr = QColor('white')
        clr.setAlpha(150)
        self.setBackground(0, clr)
        self.setSizeHint(0, QSize(0, 18))

        self._contextType = contextType
Ejemplo n.º 26
0
 def __init__( self, name, contextType ):
     super(ContextTypeItem,self).__init__( [name] )
     
     # define custom properties
     self.setFlags( Qt.ItemIsEnabled )
     clr = QColor('white')
     clr.setAlpha(150)
     self.setBackground( 0, clr )
     self.setSizeHint( 0, QSize( 0, 18 ) )
     
     self._contextType = contextType
Ejemplo n.º 27
0
class Margin:
    """ Margin line class """
    def __init__(self):
        # Default values
        self.color = QColor('gray')
        self.alpha = self.color.setAlpha(60)

    def setColor(self, color, alpha):
        """ Set color and alpha """

        self.color = QColor(color)
        self.alpha = self.color.setAlpha(alpha)
 def _addHighlight(self, canvas, geometry, layer):
     hl = QgsHighlight(canvas, geometry, layer)
     color = QColor(QSettings().value('/Map/highlight/color', QGis.DEFAULT_HIGHLIGHT_COLOR.name(), str))
     alpha = QSettings().value('/Map/highlight/colorAlpha', QGis.DEFAULT_HIGHLIGHT_COLOR.alpha(), int)
     buff = QSettings().value('/Map/highlight/buffer', QGis.DEFAULT_HIGHLIGHT_BUFFER_MM, float)
     minWidth = QSettings().value('/Map/highlight/minWidth', QGis.DEFAULT_HIGHLIGHT_MIN_WIDTH_MM, float)
     hl.setColor(color)
     color.setAlpha(alpha)
     hl.setFillColor(color)
     hl.setBuffer(buff)
     hl.setMinWidth(minWidth)
     self._highlights.append(hl)
Ejemplo n.º 29
0
    class AniObject(QObject):
        def __init__(self, band):
            super(CurrentSelection.AniObject, self).__init__()
            self.color = QColor()

        @pyqtProperty(int)
        def alpha(self):
            return self.color.alpha()

        @alpha.setter
        def alpha(self, value):
            self.color.setAlpha(value)
Ejemplo n.º 30
0
    class AniObject(QObject):
        def __init__(self, band):
            super(CurrentSelection.AniObject, self).__init__()
            self.color = QColor()

        @pyqtProperty(int)
        def alpha(self):
            return self.color.alpha()

        @alpha.setter
        def alpha(self, value):
            self.color.setAlpha(value)
Ejemplo n.º 31
0
    def draw_distributions(self):
        """Draw distributions with discrete attributes"""
        if not (self.show_distributions and self.have_data and self.data_has_discrete_class):
            return
        class_count = len(self.data_domain.class_var.values)
        class_ = self.data_domain.class_var

        # we create a hash table of possible class values (happens only if we have a discrete class)
        if self.domain_contingencies is None:
            self.domain_contingencies = dict(
                zip([attr for attr in self.data_domain if isinstance(attr, DiscreteVariable)],
                    get_contingencies(self.raw_data, skipContinuous=True)))
            self.domain_contingencies[class_] = get_contingency(self.raw_data, class_, class_)

        max_count = max([contingency.max() for contingency in self.domain_contingencies.values()] or [1])
        sorted_class_values = get_variable_values_sorted(self.data_domain.class_var)

        for axis_idx, attr_idx in enumerate(self.attribute_indices):
            attr = self.data_domain[attr_idx]
            if isinstance(attr, DiscreteVariable):
                continue

            contingency = self.domain_contingencies[attr]
            attr_len = len(attr.values)

            # we create a hash table of variable values and their indices
            sorted_variable_values = get_variable_values_sorted(attr)

            # create bar curve
            for j in range(attr_len):
                attribute_value = sorted_variable_values[j]
                value_count = contingency[:, attribute_value]

                for i in range(class_count):
                    class_value = sorted_class_values[i]

                    color = QColor(self.discrete_palette[i])
                    color.setAlpha(self.alpha_value)

                    width = float(value_count[class_value] * 0.5) / float(max_count)
                    y_off = float(1.0 + 2.0 * j) / float(2 * attr_len)
                    height = 0.7 / float(class_count * attr_len)

                    y_low_bottom = y_off + float(class_count * height) / 2.0 - i * height
                    curve = PolygonCurve(QPen(color),
                                         QBrush(color),
                                         xData=[axis_idx, axis_idx + width,
                                                axis_idx + width, axis_idx],
                                         yData=[y_low_bottom, y_low_bottom, y_low_bottom - height,
                                                y_low_bottom - height],
                                         tooltip=attr.name)
                    curve.attach(self)
Ejemplo n.º 32
0
    def highlight_current_line(self):
        extraSelections = []

        if not self.isReadOnly():
            selection = QTextEdit.ExtraSelection()
            lineColor = QColor(Qt.darkCyan)
            lineColor.setAlpha(20)
            selection.format.setBackground(lineColor)
            selection.format.setProperty(QTextFormat.FullWidthSelection, True)
            selection.cursor = self.textCursor()
            selection.cursor.clearSelection()
            extraSelections.append(selection)
        self.setExtraSelections(extraSelections)
Ejemplo n.º 33
0
 def paintEvent(self, e):
     painter = QPainter(self)
     if self._diff is None:
         color = QColor(self.diff_brush)
         color.setAlpha(25)
     else:
         color = self.diff_brush
         a = abs(self._diff) * 1.7
         if a > 75: a == 75
         color.setAlpha(25 + a)
     painter.setPen(color)
     painter.setBrush(color)
     painter.drawRect(e.rect())
Ejemplo n.º 34
0
    def trackerTextF(self, pos):
        text = QwtText()
        points = self.selection()
        if (not points.isEmpty()):
            #QString num
            #num.setNum( QLineF( pos, invTransform( points[0] ) ).length() )
            num = "123"
            bg = QColor(Qt.white)
            bg.setAlpha(200)

            text.setBackgroundBrush(QBrush(bg))
            text.setText(num)
        return text
Ejemplo n.º 35
0
class Margin:
    """ Margin line class """

    def __init__(self):
        # Default values
        self.color = QColor('gray')
        self.alpha = self.color.setAlpha(60)

    def setColor(self, color, alpha):
        """ Set color and alpha """

        self.color = QColor(color)
        self.alpha = self.color.setAlpha(alpha)
Ejemplo n.º 36
0
    def highlight_current_line(self):
        extraSelections = []
        if not self.isReadOnly():
            selection = QTextEdit.ExtraSelection()
            lineColor = QColor(Qt.darkCyan)
            lineColor.setAlpha(20)

            selection.format.setBackground(lineColor)
            selection.format.setProperty(QTextFormat.FullWidthSelection, True)
            selection.cursor = self.textCursor()
            selection.cursor.clearSelection()
            extraSelections.append(selection)
        self.setExtraSelections(extraSelections)
Ejemplo n.º 37
0
    def paintEvent(self, event):
        """
        Handles the drawing for this widget and its selection region.
        
        :param      event | <QPaintEvent>
        """
        pen = QPen(Qt.DashLine)
        pen.setColor(QColor('red'))
        painter = QPainter(self)
        painter.setPen(pen)
        clr = QColor('black')
        clr.setAlpha(100)
        painter.setBrush(clr)

        painter.drawRect(self._region)
Ejemplo n.º 38
0
 def paintEvent(self, event):
     painter = QPainter(self)
     painter.fillRect(event.rect(), self.__background_color)
     # Draw markers
     self.__draw_markers(painter)
     # Draw slider
     if settings.DOCMAP_SLIDER and self.__scrollbar.isVisible():
         painter.setPen(Qt.NoPen)
         color = QColor(Qt.lightGray)
         color.setAlpha(50)
         painter.setBrush(QBrush(color))
         position1 = self.__get_position(self.__scrollbar.value())
         position2 = self.__get_position(self.__scrollbar.value() +
                                         self.__scrollbar.pageStep())
         painter.drawRect(0, position1, self.__width, position2 - position1)
Ejemplo n.º 39
0
 def paintEvent(self, event):
     """
     Handles the drawing for this widget and its selection region.
     
     :param      event | <QPaintEvent>
     """
     pen = QPen(Qt.DashLine)
     pen.setColor(QColor('red'))
     painter = QPainter(self)
     painter.setPen(pen)
     clr = QColor('black')
     clr.setAlpha(100)
     painter.setBrush(clr)
     
     painter.drawRect(self._region)
Ejemplo n.º 40
0
 def paintEvent(self, event):
     painter = QPainter(self)
     painter.fillRect(event.rect(), self.__background_color)
     # Draw markers
     self.__draw_markers(painter)
     # Draw slider
     if settings.DOCMAP_SLIDER and self.__scrollbar.isVisible():
         painter.setPen(Qt.NoPen)
         color = QColor(Qt.lightGray)
         color.setAlpha(50)
         painter.setBrush(QBrush(color))
         position1 = self.__get_position(self.__scrollbar.value())
         position2 = self.__get_position(
             self.__scrollbar.value() + self.__scrollbar.pageStep())
         painter.drawRect(0, position1, self.__width, position2 - position1)
Ejemplo n.º 41
0
    def RubberBand(self, bolean):
        if bolean:
            self.myRubberBand = QgsRubberBand(self.iface.mapCanvas(),
                                              QGis.Polygon)
            color = QColor(78, 97, 114)
            color.setAlpha(190)
            self.myRubberBand.setColor(color)
            self.myRubberBand.setFillColor(QColor(255, 0, 0, 40))
            self.myRubberBand.setBorderColor(QColor(255, 0, 0, 200))

            # Set MapTool
            self.iface.mapCanvas().setMapTool(self.myMapTool)
            self.iface.mapCanvas().xyCoordinates.connect(self.mouseMove)
        else:
            self.disconnect()
Ejemplo n.º 42
0
    def _setup_plot(self):
        self.plot.clear()

        points = self.ca
        variables = self.selected_vars()
        colors = colorpalette.ColorPaletteGenerator(len(variables))

        p_axes = self._p_axes()

        if len(variables) == 2:
            row_points = self.ca.row_factors[:, p_axes]
            col_points = self.ca.col_factors[:, p_axes]
            points = [row_points, col_points]
        else:
            points = self.ca.row_factors[:, p_axes]
            counts = [len(var.values) for var in variables]
            range_indices = numpy.cumsum([0] + counts)
            ranges = zip(range_indices, range_indices[1:])
            points = [points[s:e] for s, e in ranges]

        for i, (v, points) in enumerate(zip(variables, points)):
            color_outline = colors[i]
            color_outline.setAlpha(200)
            color = QColor(color_outline)
            color.setAlpha(120)
            item = ScatterPlotItem(
                x=points[:, 0],
                y=points[:, 1],
                brush=QBrush(color),
                pen=pg.mkPen(color_outline.darker(120), width=1.5),
                size=numpy.full((points.shape[0], ), 10.1),
            )
            self.plot.addItem(item)

            for name, point in zip(v.values, points):
                item = pg.TextItem(name, anchor=(0.5, 0))
                self.plot.addItem(item)
                item.setPos(point[0], point[1])

        inertia = self.ca.inertia_of_axis()
        inertia = 100 * inertia / numpy.sum(inertia)

        ax = self.plot.getAxis("bottom")
        ax.setLabel("Component {} ({:.1f}%)".format(p_axes[0] + 1,
                                                    inertia[p_axes[0]]))
        ax = self.plot.getAxis("left")
        ax.setLabel("Component {} ({:.1f}%)".format(p_axes[1] + 1,
                                                    inertia[p_axes[1]]))
Ejemplo n.º 43
0
    def highlightFeature(self, canvasExtent = CanvasExtent.Fixed):
        if self.canvas is None or not self.feature.isValid():
            return

        geom = self.feature.geometry()

        if geom is None:
            return
  
        if canvasExtent == CanvasExtent.Scale:
            featBBox = geom.boundingBox()
            featBBox = self.canvas.mapSettings().layerToMapCoordinates(self.layer, featBBox)
            extent = self.canvas.extent()
            if not extent.contains(featBBox):
                extent.combineExtentWith(featBBox)
                extent.scale(1.1)
                self.canvas.setExtent(extent)
                self.canvas.refresh()
            
        elif canvasExtent == CanvasExtent.Pan:
            centroid = geom.centroid()
            center = centroid.asPoint()

            center = self.canvas.mapSettings().layerToMapCoordinates(self.layer, center)
            self.canvas.zoomByFactor(1.0, center)  # refresh is done in this method

        # highlight
        self.delete_highlight()
        self.highlight = QgsHighlight(self.canvas, geom, self.layer)

        settings = QSettings()
        color = QColor(settings.value("/Map/highlight/color", QGis.DEFAULT_HIGHLIGHT_COLOR.name()))
        alpha = int(settings.value("/Map/highlight/colorAlpha", QGis.DEFAULT_HIGHLIGHT_COLOR.alpha()))
        buffer = 2*float(settings.value("/Map/highlight/buffer", QGis.DEFAULT_HIGHLIGHT_BUFFER_MM))
        min_width = 2*float(settings.value("/Map/highlight/min_width", QGis.DEFAULT_HIGHLIGHT_MIN_WIDTH_MM))

        self.highlight.setColor(color)  # sets also fill with default alpha
        color.setAlpha(alpha)
        self.highlight.setFillColor(color)  # sets fill with alpha
        self.highlight.setBuffer(buffer)
        self.highlight.setMinWidth(min_width)
        self.highlight.setWidth(4.0)
        self.highlight.show()
        
        self.timer = QTimer(self)
        self.timer.setSingleShot(True)
        self.timer.timeout.connect(self.delete_highlight)
        self.timer.start(3000)
Ejemplo n.º 44
0
    def __init__(self, canvas):
        self._yaw = 0
        self._angle = 0
        self.size = 8
        self.halfsize = self.size / 2.0
        super(PostionMarker, self).__init__(canvas)

        self.canvas = canvas
        colorvalue = "#019633"
        colour = QColor(colorvalue)
        colour.setAlpha(50)
        self.conebrush = QBrush(colour)
        pencolour = QColor(colorvalue)
        self.pointpen = QPen(pencolour, 1)
        self.solidbrush = QBrush(pencolour)
        self.map_pos = QgsPoint()
        self.tracking = False
Ejemplo n.º 45
0
    def hoverEnterEvent(self, event):
        """ Stuff related to hover enter events.

        For now we just show a rectangular outline.

        """

        if not self._outline:
            self._outline = QGraphicsRectItem(self.boundingRect(), self)
            highlightColor = QColor(Qt.blue)
            highlightColor.setAlpha(30)
            self._outline.setBrush(highlightColor)
            highlightPen = QPen(Qt.blue)
            highlightPen.setWidth(2)
            self._outline.setPen(highlightPen)
        else:
            self._outline.show()
Ejemplo n.º 46
0
    def _setup_plot(self):
        self.plot.clear()

        points = self.ca
        variables = self.selected_vars()
        colors = colorpalette.ColorPaletteGenerator(len(variables))

        p_axes = self._p_axes()

        if len(variables) == 2:
            row_points = self.ca.row_factors[:, p_axes]
            col_points = self.ca.col_factors[:, p_axes]
            points = [row_points, col_points]
        else:
            points = self.ca.row_factors[:, p_axes]
            counts = [len(var.values) for var in variables]
            range_indices = numpy.cumsum([0] + counts)
            ranges = zip(range_indices, range_indices[1:])
            points = [points[s:e] for s, e in ranges]

        for i, (v, points) in enumerate(zip(variables, points)):
            color_outline = colors[i]
            color_outline.setAlpha(200)
            color = QColor(color_outline)
            color.setAlpha(120)
            item = ScatterPlotItem(
                x=points[:, 0], y=points[:, 1], brush=QBrush(color),
                pen=pg.mkPen(color_outline.darker(120), width=1.5),
                size=numpy.full((points.shape[0],), 10.1),
            )
            self.plot.addItem(item)

            for name, point in zip(v.values, points):
                item = pg.TextItem(name, anchor=(0.5, 0))
                self.plot.addItem(item)
                item.setPos(point[0], point[1])

        inertia = self.ca.inertia_of_axis()
        inertia = 100 * inertia / numpy.sum(inertia)

        ax = self.plot.getAxis("bottom")
        ax.setLabel("Component {} ({:.1f}%)"
                    .format(p_axes[0] + 1, inertia[p_axes[0]]))
        ax = self.plot.getAxis("left")
        ax.setLabel("Component {} ({:.1f}%)"
                    .format(p_axes[1] + 1, inertia[p_axes[1]]))
Ejemplo n.º 47
0
    def hoverEnterEvent(self, event):
        """ Stuff related to hover enter events.

        For now we just show a rectangular outline.

        """

        if not self._outline:
            self._outline = QGraphicsRectItem(self.boundingRect(), self)
            highlightColor = QColor(Qt.blue)
            highlightColor.setAlpha(30)
            self._outline.setBrush(highlightColor)
            highlightPen = QPen(Qt.blue)
            highlightPen.setWidth(2)
            self._outline.setPen(highlightPen)
        else:
            self._outline.show()
Ejemplo n.º 48
0
    def __init__(self, canvas):
        self._yaw = 0
        self._angle = 0
        self.size = 8
        self.halfsize = self.size / 2.0
        super(PostionMarker, self).__init__(canvas)

        self.canvas = canvas
        colorvalue = "#019633"
        colour = QColor(colorvalue)
        colour.setAlpha(50)
        self.conebrush = QBrush(colour)
        pencolour = QColor(colorvalue)
        self.pointpen = QPen(pencolour, 1)
        self.solidbrush = QBrush(pencolour)
        self.map_pos = QgsPoint()
        self.tracking = False
Ejemplo n.º 49
0
	def paint( self, painter, option, index ):
		self.initStyleOption(option,index)

		style = option.widget.style() or QApplication.style()

		#draw icon
		option.text = ""
		style.drawControl( QStyle.CE_ItemViewItem, option, painter,option.widget)

		painter.save()
		item = self.tree.itemFromIndex( index )
		colorData = item.userdata
		color = QColorF( *colorData.get( 'color', (1,1,1,1) ) )
		rect = option.rect
		margin = 2
		rect.adjust( margin,0,-margin,-margin*2 )
		w = rect.width()
		h = rect.height()
		
		gridSize = 5
		gridPart = gridSize * 1
		painter.translate( rect.x(), rect.y() )
		painter.translate( margin, margin )
		painter.setPen( Qt.black )
		painter.setBrush( Qt.white )
		painter.drawRect( 0,0,w,h )
		painter.setPen( Qt.NoPen )
		painter.setBrush( QColor.fromRgbF( 0.5, 0.5, 0.5 ) )
		painter.setClipRect( 0,0,w,h )
		for y in range( int(h/gridSize+1) ):
				for x in range( int(w/gridSize+1) ):
					if (x % 2) == (y % 2):
						painter.drawRect( x * gridSize, y * gridSize, gridSize, gridSize )
		painter.setBrush( color )
		painter.drawRect( 0,0,w,h )
		colorFull = QColor( color )
		colorFull.setAlpha( 255 )
		painter.setBrush( colorFull )
		painter.drawRect( 0,0, w/2, h )
		# painter.fillRect( rect, color )
		# if option.state & QStyle.State_Selected:
		# 	painter.setPen  ( Qt.white )
		# 	painter.setBrush( Qt.NoBrush )
		# 	painter.drawRect( rect )
		painter.restore()
Ejemplo n.º 50
0
    def paintEvent(self, e):
        Part.paintEvent(self, e)
        if not self.data is None:
            painter = QPainter(self)
            color = QColor(self._base.dark(150))
            color.setAlpha(150)
            painter.setPen(color)
            painter.setBrush(color)

            x_px = self.width() / (self.data.beats * 64.0)
            for note in self.data:
                x = note.start * x_px
                y = self.height() - (note.pitch / 127.0) * self.height()
                w = (note.stop - note.start) * x_px
                painter.drawRect(x, y, w, 1)
            painter = None
        if self.data:
            self.drawText(self.data.name)
Ejemplo n.º 51
0
 def _addHighlight(self, canvas, geometry, layer):
     hl = QgsHighlight(canvas, geometry, layer)
     color = QColor(QSettings().value('/Map/highlight/color',
                                      QGis.DEFAULT_HIGHLIGHT_COLOR.name(),
                                      str))
     alpha = QSettings().value('/Map/highlight/colorAlpha',
                               QGis.DEFAULT_HIGHLIGHT_COLOR.alpha(), int)
     buff = QSettings().value('/Map/highlight/buffer',
                              QGis.DEFAULT_HIGHLIGHT_BUFFER_MM, float)
     minWidth = QSettings().value('/Map/highlight/minWidth',
                                  QGis.DEFAULT_HIGHLIGHT_MIN_WIDTH_MM,
                                  float)
     hl.setColor(color)
     color.setAlpha(alpha)
     hl.setFillColor(color)
     hl.setBuffer(buff)
     hl.setMinWidth(minWidth)
     self._highlights.append(hl)
def font_bmp_to_alpha(filename):
  
  image = QImage(filename)
  image = image.convertToFormat(QImage.Format_ARGB32_Premultiplied)
  
  # Because the game uses 8bit grayscale bitmaps for its fonts with white as
  # fully visible and black as fully transparent, I'm using a naive technique
  # that averages the RGB value of a pixel and sets that as its alpha value.
  # I'm sure this will do fun stuff to other images, but it does the job
  # for the game's fonts, and that's all that really matters. ヽ(´ー`)ノ
  for i in range(image.width()):
    for j in range(image.height()):
      color = QColor(image.pixel(i, j))
      alpha = (color.red() + color.green() + color.blue()) / 3
      color.setAlpha(alpha)
      image.setPixel(i, j, color.rgba())
  
  return image
def font_bmp_to_alpha(filename):
  
  image = QImage(filename)
  image = image.convertToFormat(QImage.Format_ARGB32_Premultiplied)
  
  # Because the game uses 8bit grayscale bitmaps for its fonts with white as
  # fully visible and black as fully transparent, I'm using a naive technique
  # that averages the RGB value of a pixel and sets that as its alpha value.
  # I'm sure this will do fun stuff to other images, but it does the job
  # for the game's fonts, and that's all that really matters. ヽ(´ー`)ノ
  for i in range(image.width()):
    for j in range(image.height()):
      color = QColor(image.pixel(i, j))
      alpha = (color.red() + color.green() + color.blue()) / 3
      color.setAlpha(alpha)
      image.setPixel(i, j, color.rgba())
  
  return image
Ejemplo n.º 54
0
    def notify(self, text, textHighlight=None):
        # highlightRange is range in passed text.
        length = len(self.notifyBox.toPlainText())
        self.notifyBox.append(text)
        self.notifyBox.verticalScrollBar().setValue(
            self.notifyBox.verticalScrollBar().maximum())

        if textHighlight != None:
            begin = length + text.find(textHighlight) + 1
            end = begin + len(textHighlight)
            fmt = QTextCharFormat()
            col = QColor(Qt.red)
            col.setAlpha(130)
            fmt.setBackground(col)
            cursor = QTextCursor(self.notifyBox.document())
            cursor.setPosition(begin)
            cursor.setPosition(end, QTextCursor.KeepAnchor)
            cursor.setCharFormat(fmt)
Ejemplo n.º 55
0
 def drawOverlay( self, painter, option, index ):
     """
             Paints the overlay color for this item if the current frame
             is out of range
             
             :param      painter:
             :type       <QPainter>:
             
             :param      option:
             :param      <QStyleOptionItem>:
             
             :param      index:
             :type       <QModelIndex>:
     """
     # extract the option's frame range information
     currFrame   = index.data( Qt.EditRole ).toInt()[0]
     frameRange  = index.data( Qt.UserRole ).toPyObject()
     
     # determine if the current frame is within the valid range
     if ( frameRange and currFrame < frameRange[0] ):
         toolTip = '%s is below the minimum frame (%s)' % (currFrame,frameRange[0])
     elif ( frameRange and frameRange[1] < currFrame ):
         toolTip = '%s is above the maximum frame (%s)' % (currFrame,frameRange[1])
     else:
         toolTip = ''
     
     # update the tool tip for the index
     model   = index.model()
     blocked = model.signalsBlocked()
     model.blockSignals(True)
     model.setData( index, QVariant(toolTip), Qt.ToolTipRole )
     model.blockSignals(blocked)
     
     if ( not toolTip ):
         return
     
     # create the out of range color
     color = QColor(self.outOfRangeColor())
     color.setAlpha(100)
     
     # draw the overlay
     painter.setPen( Qt.NoPen )
     painter.setBrush(color)
     painter.drawRect( option.rect )
Ejemplo n.º 56
0
    def __init__(self, parent):
        # initialize the super class
        super(LoaderWidget, self).__init__(parent)

        # create the movie
        if (LoaderWidget.MOVIE == None):
            LoaderWidget.MOVIE = QMovie(
                resources.find('img/main/ajax-loader.gif'))
            LoaderWidget.MOVIE.start()

        # create the movie label
        self._movieLabel = QLabel(self)
        self._movieLabel.setMovie(LoaderWidget.MOVIE)
        self._movieLabel.setAlignment(Qt.AlignCenter)

        self._messageLabel = QLabel(self)
        self._messageLabel.setAlignment(Qt.AlignCenter)

        palette = self._messageLabel.palette()
        palette.setColor(palette.WindowText, QColor('gray'))
        self._messageLabel.setPalette(palette)

        # create the interface
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addStretch()
        layout.addWidget(self._movieLabel)
        layout.addWidget(self._messageLabel)
        layout.addStretch()

        self.setLayout(layout)
        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.resize(0, 0)
        self.setMessage('')

        # set the default properties
        self.setAutoFillBackground(True)
        self.setBackgroundRole(QPalette.Window)

        # create custom properties
        clr = QColor('black')
        clr.setAlpha(150)
        self._backgroundColor = clr
Ejemplo n.º 57
0
    def setColor(self, color):
        """
        Convenience method to set the border, fill and highlight colors based
        on the inputed color.
        
        :param      color | <QColor>
        """
        # sets the border color as the full value
        self.setBorderColor(color)

        # set the highlight color as the color with a 140 % alpha
        clr = QColor(color)
        clr.setAlpha(150)
        self.setHighlightColor(clr)

        # set the fill color as the color with a 50 % alpha
        clr = QColor(color)
        clr.setAlpha(80)
        self.setFillColor(clr)
Ejemplo n.º 58
0
 def __init__(self, canvas, parent=None):
     super(ScaleBarItem, self).__init__(parent)
     self.canvas = canvas
     self.realsize = 100
     black = QColor(Qt.black)
     black.setAlpha(150)
     white = QColor(Qt.white)
     white.setAlpha(150)
     blackpen = QPen(black, 4)
     whitepen = QPen(white, 8)
     self.pens = [whitepen, blackpen]
     self.whitepen = QPen(white, 1)
     self.blackbrush = QBrush(black)
     self.ticksize = 10
     self.fontsize = 15
     self.font = QFont()
     self.font.setPointSize(self.fontsize)
     self.font.setStyleHint(QFont.Times, QFont.PreferAntialias)
     self.font.setBold(True)
     self.metrics = QFontMetrics(self.font)
Ejemplo n.º 59
0
    def getColorFromCmnd(self, colorinfo):
        '''
        Returns a QColor based on the information in the dictionary
        colorinfo.  Raises a KeyError if the "color" key is not given.

        Recognized keys are:
            "color": color name or 24-bit RGB integer value
                         (eg, 0xFF0088)
            "alpha": alpha value from 0 (transparent) to 255 (opaque)
                     if viewer.ignoreAlpha True, this value is ignored
        '''
        colordata = colorinfo["color"]
        mycolor = QColor(colordata)
        if not mycolor.isValid():
            raise ValueError("Invalid color '%s'" % str(colordata))
        if not self.__viewer.ignoreAlpha():
            try:
                mycolor.setAlpha(int(colorinfo["alpha"]))
            except KeyError:
                pass
        return mycolor
Ejemplo n.º 60
0
 def highlight_background(self, marker_meta_data, color=None):
     '''
     highlights the background of the marker. Use metadata.color_name if color is None
     '''
     cursor = self.ui.plainTextEditCode.textCursor()
     cursor.setPosition(0, QTextCursor.MoveAnchor); #Moves the cursor to the beginning of the document
     #Now moves the cursor to the start_line
     cursor.movePosition(QTextCursor.Down, QTextCursor.MoveAnchor, marker_meta_data.start_block)
     #select everything till the end line
     assert(marker_meta_data.end_block >= marker_meta_data.start_block)
     move_dist = marker_meta_data.end_block - marker_meta_data.start_block
     cursor.movePosition(QTextCursor.Down, QTextCursor.KeepAnchor, move_dist)
     cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor)
     format = QTextCharFormat()
     background_color = color
     if background_color is None:
         background_color = QColor(marker_meta_data.color_name)
     background_color.setAlpha(70)
     brush = QBrush(background_color)
     format.setBackground(brush)
     cursor.mergeCharFormat(format)