Example #1
0
    def drawContents(self, painter):
        x0 = 10
        x1 = 218
        y0 = 109
        y1 = 109 + painter.fontMetrics().height()
        pxsize = 14
        painter.font().setPixelSize(pxsize)

        painter.setPen(qt.QPen(qt.Qt.white))

        painter.drawText(
            qt.QRect(qt.QPoint(x0, y0), qt.QPoint(x1, y1)),
            qt.Qt.AlignLeft | qt.Qt.AlignTop,
            "Loading",
        )
        painter.font().setPixelSize(pxsize * 2.5)
        y0 = y1
        y1 += 3 + painter.fontMetrics().height()
        painter.drawText(
            qt.QRect(qt.QPoint(x0, y0), qt.QPoint(x1, y1)),
            qt.Qt.AlignCenter,
            self.guiName,
        )
        painter.font().setPixelSize(pxsize)
        y0 = y1
        y1 += 3 + painter.fontMetrics().height()
        painter.drawText(
            qt.QRect(qt.QPoint(x0, y0), qt.QPoint(x1, y1)),
            qt.Qt.AlignLeft | qt.Qt.AlignBottom,
            "Please wait...",
        )
class ScreenShotMixin(object):

    SV_RECT = qt.QRect(260, 0, 240, 105)
    BASE_RECT = qt.QRect(270, 105, 230, 165)
    MID_RECT = qt.QRect(290, 280, 210, 165)
    APEX_RECT = qt.QRect(310, 465, 190, 130)
    UR_RECT = qt.QRect(355, 610, 145, 65)

    REGIONS = {
        "Vesicle": SV_RECT,
        "Base": BASE_RECT,
        "Mid": MID_RECT,
        "Apex": APEX_RECT,
        "Urethra": UR_RECT
    }

    def getScreenShots(self):
        pixmaps = []
        for rect in self.getRegionRectangles():
            pixmap = qt.QPixmap(rect.size())
            self.ui.render(pixmap, qt.QPoint(), qt.QRegion(rect))
            pixmaps.append(pixmap)
        return pixmaps

    def getRegionRectangles(self):
        selectedRegions = set(
            [sector.split("_")[1] for sector in self.getSelectedSectors()])
        return [self.REGIONS[selRegion] for selRegion in selectedRegions]
Example #3
0
    def scalePixmap(self, pixmap):
        # extract the center of the pixmap and then zoom
        halfWidth = self.width // 2
        halfHeight = self.height // 2
        quarterWidth = self.width // 4
        quarterHeight = self.height // 4
        centerPixmap = qt.QPixmap(halfWidth, halfHeight)
        centerPixmap.fill(self.gray)
        self.painter.begin(centerPixmap)
        fullRect = qt.QRect(0, 0, halfWidth, halfHeight)
        centerRect = qt.QRect(quarterWidth, quarterHeight, halfWidth,
                              halfHeight)
        self.painter.drawPixmap(fullRect, pixmap, centerRect)
        self.painter.end()
        scaledPixmap = centerPixmap.scaled(self.width, self.height)

        return scaledPixmap
Example #4
0
  def __init__(self):

    self.popupGeometry = qt.QRect()
    settings = qt.QSettings()
    if settings.contains('DICOM/headerPopup.geometry'):
      self.popupGeometry = settings.value('DICOM/headerPopup.geometry')
    self.popupPositioned = False
    self.window = ctk.ctkDICOMObjectListWidget()
    self.window.setWindowTitle('DICOM File Metadata')
Example #5
0
    def timeimage(self, request=''):
        """
        For timing and debugging - return an image with the current time
        rendered as text down to the hundredth of a second
        :param color: hex encoded RGB of dashed border (default 333 for dark gray)
        :return: png image
        """

        # check arguments
        p = urllib.parse.urlparse(request.decode())
        q = urllib.parse.parse_qs(p.query)
        try:
            color = "#" + q['color'][0].strip().lower()
        except KeyError:
            color = "#330"

        #
        # make a generally transparent image,
        #
        imageWidth = 128
        imageHeight = 32
        timeImage = qt.QImage(imageWidth, imageHeight,
                              qt.QImage().Format_ARGB32)
        timeImage.fill(0)

        # a painter to use for various jobs
        painter = qt.QPainter()

        # draw a border around the pixmap
        painter.begin(timeImage)
        pen = qt.QPen()
        color = qt.QColor(color)
        color.setAlphaF(0.8)
        pen.setColor(color)
        pen.setWidth(5)
        pen.setStyle(3)  # dotted line (Qt::DotLine)
        painter.setPen(pen)
        rect = qt.QRect(1, 1, imageWidth - 2, imageHeight - 2)
        painter.drawRect(rect)
        color = qt.QColor("#333")
        pen.setColor(color)
        painter.setPen(pen)
        position = qt.QPoint(10, 20)
        text = str(time.time())  # text to draw
        painter.drawText(position, text)
        painter.end()

        # convert the image to vtk, then to png from there
        vtkTimeImage = vtk.vtkImageData()
        slicer.qMRMLUtils().qImageToVtkImageData(timeImage, vtkTimeImage)
        pngData = self.vtkImageDataToPNG(vtkTimeImage)
        return pngData, b'image/png'
Example #6
0
  def __init__(self,dicomBrowser=None):
    VTKObservationMixin.__init__(self)
    self.dicomBrowser = dicomBrowser
    
    # initialize the dicomDatabase
    #   - pick a default and let the user know
    if not slicer.dicomDatabase:
      self.promptForDatabaseDirectory()
    
    if self.dicomBrowser == None:
      # This creates a DICOM database in the current working directory if nothing else
      # is specified in the settings, therefore promptForDatabaseDirectory must be called before this.
      self.dicomBrowser = ctk.ctkDICOMBrowser()

    self.browserPersistent = settingsValue('DICOM/BrowserPersistent', False, converter=toBool)
    self.tableDensity = settingsValue('DICOM/tableDensity', 'Compact')
    self.popupGeometry = settingsValue('DICOM/detailsPopup.geometry', qt.QRect())
    self.advancedView = settingsValue('DICOM/advancedView', 0, converter=int)
    self.horizontalTables = settingsValue('DICOM/horizontalTables', 0, converter=int)

    self.create()
    self.popupPositioned = False
    self.pluginInstances = {}
    self.fileLists = []

    setDatabasePrecacheTags(self.dicomBrowser)

    self.dicomBrowser.connect('databaseDirectoryChanged(QString)', self.onDatabaseDirectoryChanged)

    # Update visibility
    for name in [
        'ActionImport', 'ActionExport', 'ActionQuery', 'ActionSend', 'ActionRemove', 'ActionRepair',
        'ActionViewMetadata',
        'AdvancedViewCheckBox', 'HorizontalViewCheckBox', 'BrowserPersistentCheckBox'
        ]:
      visible = settingsValue('DICOM/%s.visible' % name, True, converter=toBool)
      control = self._findChildren(name)
      control.visible = visible

    # Define set of widgets that should be hidden/shown together
    self.settingsWidgetNames = {
      'DatabaseButton' : ('DatabaseNameLabel', 'DirectoryButton'),
      'TableDensityComboBox' : ('tablesDensityLabel', 'tableDensityComboBox')
      }

    # Hide the settings button if all associated widgets should be hidden
    settingsButtonHidden = True
    for groupName in self.settingsWidgetNames.keys():
      settingsButtonHidden = settingsButtonHidden and not settingsValue('DICOM/%s.visible' % groupName, True, converter=toBool)
    self.settingsButton.visible = not settingsButtonHidden
    def openCreateNewImageClassWindow(self):
        self.createNewImageClassWidget = qt.QDialog()
        self.createNewImageClassWidget.setModal(True)
        self.createNewImageClassFrame = qt.QFrame(
            self.createNewImageClassWidget)
        self.createNewImageClassFrame.setFrameStyle(0x0006)
        self.createNewImageClassWidget.setWindowTitle('Create New Model')
        self.createNewImageClassPopupGeometry = qt.QRect()
        mainWindow = slicer.util.mainWindow()
        if mainWindow:
            mainWindowGeometry = mainWindow.geometry
            self.windowWidth = mainWindow.width * 0.35
            self.windowHeight = mainWindow.height * 0.35
            self.createNewImageClassPopupGeometry.setWidth(self.windowWidth)
            self.createNewImageClassPopupGeometry.setHeight(self.windowHeight)
            self.popupPositioned = False
            self.createNewImageClassWidget.setGeometry(
                self.createNewImageClassPopupGeometry)
            self.createNewImageClassFrame.setGeometry(
                self.createNewImageClassPopupGeometry)
            self.createNewImageClassWidget.move(
                mainWindow.width / 2.0 - self.windowWidth,
                mainWindow.height / 2 - self.windowHeight)
        self.createNewImageClassLayout = qt.QVBoxLayout()
        self.createNewImageClassLayout.setContentsMargins(12, 4, 4, 4)
        self.createNewImageClassLayout.setSpacing(4)

        self.createNewImageClassButtonLayout = qt.QFormLayout()
        self.createNewImageClassButtonLayout.setContentsMargins(12, 4, 4, 4)
        self.createNewImageClassButtonLayout.setSpacing(4)

        self.imageClassNameLineEdit = qt.QLineEdit("Image Class Name")
        self.createNewImageClassButtonLayout.addRow(
            self.imageClassNameLineEdit)

        self.createNewImageClassButton = qt.QPushButton("Add Image Class")
        self.createNewImageClassButtonLayout.addRow(
            self.createNewImageClassButton)

        self.imageErrorLabel = qt.QLabel("")
        self.createNewImageClassButtonLayout.addRow(self.imageErrorLabel)

        self.createNewImageClassButton.connect('clicked(bool)',
                                               self.onNewImageClassAdded)

        self.createNewImageClassLayout.addLayout(
            self.createNewImageClassButtonLayout)
        self.createNewImageClassFrame.setLayout(self.createNewImageClassLayout)
Example #8
0
    def drawShape(self, painter):
        self.__painter = painter
        rect = self.rect()

        self.__num_cells = 0
        num_rows = (rect.bottom() - rect.top()) / self.__cell_height
        num_colls = (rect.right() - rect.left()) / self.__cell_width

        for i in range(0, num_rows + 1):
            offset = i * self.__cell_height
            self.__height = offset
            painter.drawLine(rect.left(),
                             rect.top() + offset, rect.right(),
                             rect.top() + offset)

        for i in range(0, num_colls + 1):
            offset = i * self.__cell_width
            self.__width = offset
            painter.drawLine(rect.left() + offset, rect.top(),
                             rect.left() + offset, rect.bottom())

        for i in range(0, num_rows):
            row_offset = i * self.__cell_height
            for k in range(0, num_colls):
                coll_offset = k * self.__cell_width
                self.__num_cells += 1
                if not self.__has_data:
                    self.__grid_data[self.__num_cells] = (self.__num_cells,
                                                          (0, 0, 255))

                color = self.__grid_data[self.__num_cells][1]

                painter.setBrush(
                    qt.QBrush(qt.QColor(*color), qt.Qt.Dense4Pattern))
                painter.drawEllipse(rect.left() + coll_offset,
                                    rect.top() + row_offset, self.__beam_width,
                                    self.__beam_height)

                tr = qt.QRect(rect.left() + coll_offset,
                              rect.top() + row_offset, self.__cell_width,
                              self.__cell_height)
                painter.drawText(tr, qt.Qt.AlignCenter, str(self.__num_cells))
Example #9
0
  def __init__(self, layoutManager=None):
    VTKObservationMixin.__init__(self)
    self.hasVTKPVScalarBarActor = hasattr(slicer, 'vtkPVScalarBarActor')
    if not self.hasVTKPVScalarBarActor:
      slicer.logging.warning("SliceAnnotations: Disable features relying on vtkPVScalarBarActor")

    self.layoutManager = layoutManager
    if self.layoutManager is None:
      self.layoutManager = slicer.app.layoutManager()
    self.layoutManager.connect("destroyed()", self.onLayoutManagerDestroyed)

    self.dataProbeUtil = DataProbeUtil.DataProbeUtil()

    self.dicomVolumeNode = 0
    self.sliceViewNames = []
    self.popupGeometry = qt.QRect()
    self.cornerTexts =[]
    # Bottom Left Corner Text
    self.cornerTexts.append({
      '1-Label':{'text':'','category':'A'},
      '2-Foreground':{'text':'','category':'A'},
      '3-Background':{'text':'','category':'A'}
      })
    # Bottom Right Corner Text
    # Not used - orientation figure may be drawn there
    self.cornerTexts.append({
      '1-TR':{'text':'','category':'A'},
      '2-TE':{'text':'','category':'A'}
      })
    # Top Left Corner Text
    self.cornerTexts.append({
      '1-PatientName':{'text':'','category':'B'},
      '2-PatientID':{'text':'','category':'A'},
      '3-PatientInfo':{'text':'','category':'B'},
      '4-Bg-SeriesDate':{'text':'','category':'B'},
      '5-Fg-SeriesDate':{'text':'','category':'B'},
      '6-Bg-SeriesTime':{'text':'','category':'C'},
      '7-Bg-SeriesTime':{'text':'','category':'C'},
      '8-Bg-SeriesDescription':{'text':'','category':'C'},
      '9-Fg-SeriesDescription':{'text':'','category':'C'}
      })
    # Top Right Corner Text
    self.cornerTexts.append({
      '1-Institution-Name':{'text':'','category':'B'},
      '2-Referring-Phisycian':{'text':'','category':'B'},
      '3-Manufacturer':{'text':'','category':'C'},
      '4-Model':{'text':'','category':'C'},
      '5-Patient-Position':{'text':'','category':'A'},
      '6-TR':{'text':'','category':'A'},
      '7-TE':{'text':'','category':'A'}
      })

    self.annotationsDisplayAmount = 0

    #
    self.scene = slicer.mrmlScene
    self.sliceViews = {}

    # If there are no user settings load defaults
    self.sliceViewAnnotationsEnabled = settingsValue('DataProbe/sliceViewAnnotations.enabled', 1, converter=int)

    self.bottomLeft = settingsValue('DataProbe/sliceViewAnnotations.bottomLeft', 1, converter=int)
    self.topLeft = settingsValue('DataProbe/sliceViewAnnotations.topLeft', 0, converter=int)
    self.topRight = settingsValue('DataProbe/sliceViewAnnotations.topRight', 0, converter=int)
    self.fontFamily = settingsValue('DataProbe/sliceViewAnnotations.fontFamily', 'Times')
    self.fontSize = settingsValue('DataProbe/sliceViewAnnotations.fontSize', 14, converter=int)
    self.backgroundDICOMAnnotationsPersistence = settingsValue(
        'DataProbe/sliceViewAnnotations.bgDICOMAnnotationsPersistence', 0, converter=int)

    self.scalarBarEnabled = settingsValue('DataProbe/sliceViewAnnotations.scalarBarEnabled', 0, converter=int)
    self.scalarBarEnabledLastStatus = self.scalarBarEnabled
    self.scalarBarSelectedLayer = 'background'
    self.rangeLabelFormat = settingsValue('DataProbe/sliceViewAnnotations.rangeLabelFormat', '%G')

    self.parameter = 'sliceViewAnnotationsEnabled'
    self.parameterNode = self.dataProbeUtil.getParameterNode()
    self.addObserver(self.parameterNode, vtk.vtkCommand.ModifiedEvent, self.updateGUIFromMRML)

    self.maximumTextLength= 35

    self.create()

    if self.sliceViewAnnotationsEnabled:
      self.updateSliceViewFromGUI()
Example #10
0
    def revealPixmap(self, xy):
        """fill a pixmap with an image that has a reveal pattern
    at xy with the fg drawn over the bg"""

        # Get QImages for the two layers
        bgVTKImage = self.layerLogics['B'].GetImageData()
        fgVTKImage = self.layerLogics['F'].GetImageData()
        bgQImage = qt.QImage()
        fgQImage = qt.QImage()
        slicer.qMRMLUtils().vtkImageDataToQImage(bgVTKImage, bgQImage)
        slicer.qMRMLUtils().vtkImageDataToQImage(fgVTKImage, fgQImage)

        # get the geometry of the focal point (xy) and images
        # noting that vtk has the origin at the bottom left and qt has
        # it at the top left.  yy is the flipped version of y
        imageWidth = bgQImage.width()
        imageHeight = bgQImage.height()
        x, y = xy
        yy = imageHeight - y

        #
        # make a generally transparent image,
        # then fill quadrants with the fg image
        #
        overlayImage = qt.QImage(imageWidth, imageHeight,
                                 qt.QImage().Format_ARGB32)
        overlayImage.fill(0)

        halfWidth = imageWidth // 2
        halfHeight = imageHeight // 2
        topLeft = qt.QRect(0, 0, x, yy)
        bottomRight = qt.QRect(x, yy, imageWidth - x - 1, imageHeight - yy - 1)

        self.painter.begin(overlayImage)
        self.painter.drawImage(topLeft, fgQImage, topLeft)
        self.painter.drawImage(bottomRight, fgQImage, bottomRight)
        self.painter.end()

        # draw the bg and fg on top of gray background
        compositePixmap = qt.QPixmap(self.width, self.height)
        compositePixmap.fill(self.gray)
        self.painter.begin(compositePixmap)
        self.painter.drawImage(-1 * (x - self.width // 2),
                               -1 * (yy - self.height // 2), bgQImage)
        self.painter.drawImage(-1 * (x - self.width // 2),
                               -1 * (yy - self.height // 2), overlayImage)
        self.painter.end()

        if self.scale:
            compositePixmap = self.scalePixmap(compositePixmap)

        # draw a border around the pixmap
        self.painter.begin(compositePixmap)
        self.pen = qt.QPen()
        self.color = qt.QColor("#FF0")
        self.color.setAlphaF(0.3)
        self.pen.setColor(self.color)
        self.pen.setWidth(5)
        self.pen.setStyle(3)  # dotted line (Qt::DotLine)
        self.painter.setPen(self.pen)
        rect = qt.QRect(1, 1, self.width - 2, self.height - 2)
        self.painter.drawRect(rect)
        self.painter.end()

        return compositePixmap
Example #11
0
    def __init__(self, layoutManager=None):
        VTKObservationMixin.__init__(self)

        self.layoutManager = layoutManager
        if self.layoutManager is None:
            self.layoutManager = slicer.app.layoutManager()
        self.layoutManager.connect("destroyed()",
                                   self.onLayoutManagerDestroyed)

        self.dataProbeUtil = DataProbeUtil.DataProbeUtil()

        self.dicomVolumeNode = 0

        # Cache recently used extracted DICOM values.
        # Getting all necessary DICOM values from the database (tag cache)
        # would slow down slice browsing significantly.
        # We may have several different volumes shown in different slice views,
        # so we keep in the cache a number of items, not just 2.
        self.extractedDICOMValuesCacheSize = 12
        import collections
        self.extractedDICOMValuesCache = collections.OrderedDict()

        self.sliceViewNames = []
        self.popupGeometry = qt.QRect()
        self.cornerTexts = []
        # Bottom Left Corner Text
        self.cornerTexts.append({
            '1-Label': {
                'text': '',
                'category': 'A'
            },
            '2-Foreground': {
                'text': '',
                'category': 'A'
            },
            '3-Background': {
                'text': '',
                'category': 'A'
            }
        })
        # Bottom Right Corner Text
        # Not used - orientation figure may be drawn there
        self.cornerTexts.append({
            '1-TR': {
                'text': '',
                'category': 'A'
            },
            '2-TE': {
                'text': '',
                'category': 'A'
            }
        })
        # Top Left Corner Text
        self.cornerTexts.append({
            '1-PatientName': {
                'text': '',
                'category': 'B'
            },
            '2-PatientID': {
                'text': '',
                'category': 'A'
            },
            '3-PatientInfo': {
                'text': '',
                'category': 'B'
            },
            '4-Bg-SeriesDate': {
                'text': '',
                'category': 'B'
            },
            '5-Fg-SeriesDate': {
                'text': '',
                'category': 'B'
            },
            '6-Bg-SeriesTime': {
                'text': '',
                'category': 'C'
            },
            '7-Bg-SeriesTime': {
                'text': '',
                'category': 'C'
            },
            '8-Bg-SeriesDescription': {
                'text': '',
                'category': 'C'
            },
            '9-Fg-SeriesDescription': {
                'text': '',
                'category': 'C'
            }
        })
        # Top Right Corner Text
        self.cornerTexts.append({
            '1-Institution-Name': {
                'text': '',
                'category': 'B'
            },
            '2-Referring-Phisycian': {
                'text': '',
                'category': 'B'
            },
            '3-Manufacturer': {
                'text': '',
                'category': 'C'
            },
            '4-Model': {
                'text': '',
                'category': 'C'
            },
            '5-Patient-Position': {
                'text': '',
                'category': 'A'
            },
            '6-TR': {
                'text': '',
                'category': 'A'
            },
            '7-TE': {
                'text': '',
                'category': 'A'
            }
        })

        self.annotationsDisplayAmount = 0

        #
        self.scene = slicer.mrmlScene
        self.sliceViews = {}

        # If there are no user settings load defaults
        self.sliceViewAnnotationsEnabled = settingsValue(
            'DataProbe/sliceViewAnnotations.enabled', 1, converter=int)

        self.bottomLeft = settingsValue(
            'DataProbe/sliceViewAnnotations.bottomLeft', 1, converter=int)
        self.topLeft = settingsValue('DataProbe/sliceViewAnnotations.topLeft',
                                     0,
                                     converter=int)
        self.topRight = settingsValue(
            'DataProbe/sliceViewAnnotations.topRight', 0, converter=int)
        self.fontFamily = settingsValue(
            'DataProbe/sliceViewAnnotations.fontFamily', 'Times')
        self.fontSize = settingsValue(
            'DataProbe/sliceViewAnnotations.fontSize', 14, converter=int)
        self.backgroundDICOMAnnotationsPersistence = settingsValue(
            'DataProbe/sliceViewAnnotations.bgDICOMAnnotationsPersistence',
            0,
            converter=int)
        self.sliceViewAnnotationsEnabledparameter = 'sliceViewAnnotationsEnabled'
        self.parameterNode = self.dataProbeUtil.getParameterNode()
        self.addObserver(self.parameterNode, vtk.vtkCommand.ModifiedEvent,
                         self.updateGUIFromMRML)

        self.maximumTextLength = 35

        self.create()

        if self.sliceViewAnnotationsEnabled:
            self.updateSliceViewFromGUI()
Example #12
0
    def drawShape(self, painter):
        """
        Overloads the QCanvasRectangle drawShape. Performs the drawing of the
        grid.

        :param painter: The QPainter object to use when drawing.
        :type painter: QPainter
        """
        self.__painter = painter
        rect = self.rect()

        self.__num_cells = 0
        num_rows = (rect.bottom() - rect.top()) / self.__cell_height
        num_colls = (rect.right() - rect.left()) / self.__cell_width

        if self.__highlighted:
            painter.setPen(qt.QPen(qt.Qt.green, 0, qt.Qt.SolidLine))
        else:
            painter.setPen(qt.QPen(qt.Qt.black, 0, qt.Qt.DotLine))

        for i in range(0, num_rows + 1):
            offset = i * self.__cell_height
            self.__height = offset
            painter.drawLine(rect.left(),
                             rect.top() + offset, rect.right(),
                             rect.top() + offset)

        for i in range(0, num_colls + 1):
            offset = i * self.__cell_width
            self.__width = offset
            painter.drawLine(rect.left() + offset, rect.top(),
                             rect.left() + offset, rect.bottom())

        for i in range(0, num_rows):
            row_offset = i * self.__cell_height
            for k in range(0, num_colls):
                coll_offset = k * self.__cell_width
                self.__num_cells += 1
                if not self.__has_data:
                    if self.__num_cells % 2:
                        self.__grid_data[self.__num_cells] = (self.__num_cells,
                                                              (0, 0, 150))
                    else:
                        self.__grid_data[self.__num_cells] = (self.__num_cells,
                                                              (0, 0, 150))

                painter.setPen(qt.QPen(qt.Qt.black, 0, qt.Qt.SolidLine))

                color = self.__grid_data[self.__num_cells][1]

                #if self.__highlighted:
                painter.setBrush(
                    qt.QBrush(qt.QColor(*color), qt.Qt.Dense4Pattern))
                #else:
                #    painter.setBrush(qt.QBrush(qt.QColor(*color), qt.Qt.Dense6Pattern))

                beam_hspacing = (self.__cell_width - self.__beam_width) / 2
                beam_vspacing = (self.__cell_height - self.__beam_height) / 2

                painter.drawEllipse(rect.left() + coll_offset + beam_hspacing,
                                    rect.top() + row_offset + beam_vspacing,
                                    self.__beam_width, self.__beam_height)

                painter.setPen(qt.QPen(qt.Qt.black, 1, qt.Qt.SolidLine))
                tr = qt.QRect(rect.left() + coll_offset,
                              rect.top() + row_offset, self.__cell_width,
                              self.__cell_height)

                score = self.__grid_data[self.__num_cells][0]

                if score:
                    painter.drawText(tr, qt.Qt.AlignCenter, str(score))

            if self.__label and self.__highlighted:
                #painter.setPen(qt.QPen(qt.Qt.green, 0, qt.Qt.SolidLine))
                painter.drawText(rect.right() + 2,
                                 rect.top() - 5, self.__label)

        self.__num_rows = num_rows
        self.__num_colls = num_colls