Beispiel #1
0
    def paint(self, painter, option, widget):
        """
      painter é un QPainter
      """
        pen = QPen(QColor(self.borderColor))
        pen.setWidth(1)
        painter.setPen(pen)
        painter.rotate(self.__rot)

        if self.__iconType == QadGripIconTypeEnum.NONE:
            pass
        elif self.__iconType == QadGripIconTypeEnum.BOX:
            # un quadrato
            painter.fillRect(-self.iconSize, -self.iconSize, self.iconSize * 2,
                             self.iconSize * 2, QBrush(QColor(self.fillColor)))
            painter.drawRect(-self.iconSize, -self.iconSize, self.iconSize * 2,
                             self.iconSize * 2)
        elif self.__iconType == QadGripIconTypeEnum.CIRCLE:
            # cerchio
            painter.setBrush(QBrush(QColor(self.fillColor)))
            painter.drawEllipse(QPointF(0, 0), self.iconSize, self.iconSize)
        elif self.__iconType == QadGripIconTypeEnum.RECTANGLE:
            # un rettangolo
            painter.fillRect(-self.iconSize, -self.iconSize / 2,
                             self.iconSize * 2, self.iconSize,
                             QBrush(QColor(self.fillColor)))
            painter.drawRect(-self.iconSize, -self.iconSize / 2,
                             self.iconSize * 2, self.iconSize)
    def paint(self, painter, xxx, xxx2):
        if not self.position:
            return

        s = (self.size - 1) / 2
        pen = QPen(self.color)
        pen.setWidth(self.penWidth)
        painter.setPen(pen)
        painter.setRenderHint(QPainter.Antialiasing, True)
        if self.type == 'CROSS':
            painter.drawLine(QLineF(-s, 0, s, 0))
            painter.drawLine(QLineF(0, -s, 0, s))
        elif self.type == 'X':
            painter.drawLine(QLineF(-s, -s, s, s))
            painter.drawLine(QLineF(-s, s, s, -s))
        elif self.type == 'BOX':
            brush = QBrush(self.fillColor)
            painter.setBrush(brush)
            painter.drawConvexPolygon(self.paintShape)
        elif self.type == 'SHAPE':
            if self.paintCircle:
                pen.setWidth(self.penWidth * 2)
                if self.defaultIconFilled:
                    brush = QBrush(self.fillColor)
                    painter.setBrush(brush)
                painter.setPen(pen)
                painter.drawEllipse(QPointF(0, 0), self.CIRLCE_SIZE * 0.4, self.CIRLCE_SIZE * 0.4)
                painter.drawLine(QLineF(0, -self.CIRLCE_SIZE * 0.4, 0, -self.CIRLCE_SIZE))
            else:
                brush = QBrush(self.fillColor)
                painter.setBrush(brush)
                painter.drawConvexPolygon(self.paintShape)
 def paint(self, painter, xxx, xxx2):
     if not self.position:
         return
     pen = QPen(self.color)
     pen.setWidth(1)
     painter.setPen(pen)
     painter.drawLine(QPointF(0, 0), QPointF(self.labelDistance, -self.labelDistance / 2))
     painter.drawText(QPointF(self.labelDistance + 2, -self.labelDistance / 2 + 2), self.label)
    def displayPlot(self):
        QGraphicsScene.clear(self)
        self.marker.clear()
        self.sceneRect()

        # display lines fitting in sceneRect
        poly = QPolygonF()
        for x, y, _ in self.data:
            poly.append(QPointF(self.xToScene(x), self.yToScene(y)))
        # close the polygon
        x2 = self.xToScene(self.xMax)
        y2 = self.sceneRect().height()
        poly.append(QPointF(x2, y2))
        x2 = self.barWidth
        poly.append(QPointF(x2, y2))
        x2 = self.xToScene(self.xMin)
        y2 = self.yToScene(0)
        poly.append(QPointF(x2, y2))
        brush = QBrush(QColor("#DCF1F7"))
        pen = QPen()
        pen.setWidth(0)
        self.addPolygon(poly, pen, brush)

        # horizontal line on ymin and ymax
        self.addLine(
            self.barWidth - 5,
            self.yToScene(self.yMin),
            self.barWidth + 5,
            self.yToScene(self.yMin),
        )
        self.addLine(
            self.barWidth - 5,
            self.yToScene(self.yMax),
            self.barWidth + 5,
            self.yToScene(self.yMax),
        )

        # display scale
        self.addLine(self.barWidth, 0, self.barWidth,
                     self.sceneRect().height())

        font = QFont()
        fm = QFontMetrics(font)
        t1 = self.addText("%.1f" % self.yMin)
        t1.setPos(0, self.yToScene(self.yMin) - fm.ascent())
        t2 = self.addText("%.1f" % self.yMax)
        t2.setPos(0, self.yToScene(self.yMax) - fm.ascent())

        # Z(m)
        t3 = self.addText(self.yTitle)
        t3.setPos(0, 0)
Beispiel #5
0
 def draw_background(self, painter, outline=True):
     old_pen = painter.pen()
     old_brush = painter.brush()
     p = QPen()
     b = QBrush()
     if self.__selected:
         p.setColor(QColor("#ffff99"))
         p.setWidth(2)
         b.setColor(QColor("#ffff66"))
         b.setStyle(Qt.SolidPattern)
     if self.__selected:
         painter.setBrush(b)
         painter.setPen(p)
         painter.drawRect(1, 0, self.boundingRect().width()-1, self.boundingRect().height()-1)
     if outline:
         painter.setBrush(QBrush())
         painter.setPen(QPen())
         painter.drawRect(0, 0, self.boundingRect().width(), self.boundingRect().height()-1)
     painter.setBrush(old_brush)
     painter.setPen(old_pen)
Beispiel #6
0
    def paint(self, painter, xxx, xxx2):
        if not self.position:
            return

        s = (self.size - 1) / 2
        pen = QPen(self.color)
        pen.setWidth(self.penWidth)
        painter.setPen(pen)
        if self.type == 'CROSS':
            painter.drawLine(QLineF(-s, 0, s, 0))
            painter.drawLine(QLineF(0, -s, 0, s))
        elif self.type == 'X':
            painter.drawLine(QLineF(-s, -s, s, s))
            painter.drawLine(QLineF(-s, s, s, -s))
        elif self.type == 'BOX':
            brush = QBrush(self.fillColor)
            painter.setBrush(brush)
            painter.drawConvexPolygon(self.paintShape)
        elif self.type == 'SHAPE':
            painter.setRenderHint(QPainter.Antialiasing, True)
            brush = QBrush(self.fillColor)
            painter.setBrush(brush)
            painter.drawConvexPolygon(self.paintShape)
Beispiel #7
0
class GPSMarker(QgsMapCanvasItem):
    def __init__(self, canvas):
        super(GPSMarker, self).__init__(canvas)
        self.canvas = canvas
        self._quaility = 0
        self._heading = 0
        self.size = roam.config.settings.get('gps', {}).get('marker_size', 24)
        self.red = Qt.darkRed
        self.blue = QColor(129, 173, 210)
        self.green = Qt.darkGreen
        self._gpsinfo = QgsGpsInformation()

        self.pointbrush = QBrush(self.red)
        self.pointpen = QPen(Qt.black)
        self.pointpen.setWidth(1)
        self.map_pos = QgsPoint(0.0, 0.0)
        self.gps = None

    def setgps(self, gps):
        self.gps = gps

    def setSize(self, size):
        self.size = size

    def paint(self, painter, xxx, xxx2):
        self.setPos(self.toCanvasCoordinates(self.map_pos))

        halfSize = self.size / 2.0
        rect = QRectF(0 - halfSize, 0 - halfSize, self.size, self.size)
        painter.setRenderHint(QPainter.Antialiasing)
        if self.quality == 0:
            color = self.red
        elif self.quality == 1:
            color = self.green
        elif self.quality >= 2:
            color = self.blue
        else:
            color = self.red

        self.pointpen.setColor(Qt.gray)
        self.pointpen.setWidth(2)
        self.pointbrush.setColor(color)

        painter.setBrush(self.pointbrush)
        painter.setPen(self.pointpen)
        y = 0 - halfSize
        x = rect.width() / 2 - halfSize
        line = QLine(x, y, x, rect.height() - halfSize)
        y = rect.height() / 2 - halfSize
        x = 0 - halfSize
        line2 = QLine(x, y, rect.width() - halfSize, y)

        # Arrow
        p = QPolygonF()
        p.append(QPoint(0 - halfSize, 0))
        p.append(QPoint(0, -self.size))
        x = rect.width() - halfSize
        p.append(QPoint(x, 0))
        p.append(QPoint(0, 0))

        offsetp = QPolygonF()
        offsetp.append(QPoint(0 - halfSize, 0))
        offsetp.append(QPoint(0, -self.size))
        x = rect.width() - halfSize
        offsetp.append(QPoint(x, 0))
        offsetp.append(QPoint(0, 0))

        waypoint = self.gps.waypoint
        if waypoint:
            az = self.map_pos.azimuth(waypoint)

            painter.save()
            painter.rotate(az)
            self.pointbrush.setColor(Qt.red)
            painter.setBrush(self.pointbrush)
            path = QPainterPath()
            path.addPolygon(offsetp)
            painter.drawPath(path)
            painter.restore()

        painter.save()
        painter.rotate(self._heading)
        path = QPainterPath()
        path.addPolygon(p)
        painter.drawPath(path)

        painter.restore()
        painter.drawEllipse(rect)
        painter.drawLine(line)
        painter.drawLine(line2)

    def boundingRect(self):
        halfSize = self.size / 2.0
        size = self.size * 2
        return QRectF(-size, -size, 2.0 * size, 2.0 * size)

    @property
    def quality(self):
        return self._gpsinfo.quality

    @quality.setter
    def quality(self, value):
        self._quaility = value
        self.update()

    def setCenter(self, map_pos, gpsinfo):
        self._heading = gpsinfo.direction
        self._gpsinfo = gpsinfo
        self.map_pos = QgsPointXY(map_pos)
        self.setPos(self.toCanvasCoordinates(self.map_pos))

    def updatePosition(self):
        self.setCenter(self.map_pos, self._gpsinfo)
Beispiel #8
0
    def setValues(options=None):
        ''' Function to set Drawing Values '''
        s = QSettings()

        ####### Magnifier Glass #######

        shape_type = s.value(DrawToolBar.NameSpace +
                             "/Options/magnifier/shape")
        if shape_type is not None:
            global TYPE_MAGNIFIER
            TYPE_MAGNIFIER = shape_type
            if options is not None:
                if TYPE_MAGNIFIER == 0:
                    # Square
                    options.rB_Square_m.setChecked(True)
                else:
                    # Circle
                    options.rB_Circle_m.setChecked(True)

        mFactor = s.value(DrawToolBar.NameSpace + "/Options/magnifier/factor")
        if mFactor is not None:
            global MAX_FACTOR
            MAX_FACTOR = int(mFactor)
            if options is not None:
                options.sb_factor.setValue(MAX_FACTOR)

        mSize = s.value(DrawToolBar.NameSpace + "/Options/magnifier/size")
        if mSize is not None:
            global MAX_MAGNIFIER
            MAX_MAGNIFIER = int(mSize)
            if options is not None:
                options.sl_Size.setValue(MAX_MAGNIFIER)

        ####### Drawings #######

        poly_w = s.value(DrawToolBar.NameSpace +
                         "/Options/drawings/polygons/width")
        if poly_w is not None:
            global PolyWidth
            PolyWidth = int(poly_w)
            if options is not None:
                options.poly_width.setValue(PolyWidth)

        poly_p = s.value(DrawToolBar.NameSpace +
                         "/Options/drawings/polygons/pen")
        if poly_p is not None:
            global PolyPen
            PolyPen = QPen(QColor(poly_p))
            PolyPen.setCapStyle(Qt.RoundCap)
            PolyPen.setWidth(PolyWidth)
            if options is not None:
                options.poly_pen.setColor(QColor(poly_p))

        poly_b = s.value(DrawToolBar.NameSpace +
                         "/Options/drawings/polygons/brush")
        if poly_b is not None:
            global PolyBrush
            PolyBrush = QBrush(QColor(poly_b))
            if options is not None:
                options.poly_brush.setColor(QColor(poly_b))

        point_w = s.value(DrawToolBar.NameSpace +
                          "/Options/drawings/points/width")
        if point_w is not None:
            global PointWidth
            PointWidth = int(point_w)
            if options is not None:
                options.point_width.setValue(PointWidth)

        point_p = s.value(DrawToolBar.NameSpace +
                          "/Options/drawings/points/pen")
        if point_p is not None:
            global PointPen
            PointPen = QPen(QColor(point_p))
            PointPen.setCapStyle(Qt.RoundCap)
            PointPen.setWidth(PointWidth)
            if options is not None:
                options.point_pen.setColor(QColor(point_p))

        line_w = s.value(DrawToolBar.NameSpace +
                         "/Options/drawings/lines/width")
        if line_w is not None:
            global LineWidth
            LineWidth = int(line_w)
            if options is not None:
                options.lines_width.setValue(LineWidth)

        line_p = s.value(DrawToolBar.NameSpace + "/Options/drawings/lines/pen")
        if line_p is not None:
            global LinePen
            LinePen = QPen(QColor(line_p))
            LinePen.setCapStyle(Qt.RoundCap)
            LinePen.setWidth(LineWidth)
            if options is not None:
                options.lines_pen.setColor(QColor(line_p))

        measure_w = s.value(DrawToolBar.NameSpace +
                            "/Options/drawings/measures/width")
        if measure_w is not None:
            global MeasureWidth
            MeasureWidth = int(measure_w)
            if options is not None:
                options.measures_width.setValue(MeasureWidth)

        measure_p = s.value(DrawToolBar.NameSpace +
                            "/Options/drawings/measures/pen")
        if measure_p is not None:
            global MeasurePen
            MeasurePen = QPen(QColor(measure_p))
            MeasurePen.setCapStyle(Qt.RoundCap)
            MeasurePen.setWidth(MeasureWidth)
            if options is not None:
                options.measures_pen.setColor(QColor(measure_p))

        measure_b = s.value(DrawToolBar.NameSpace +
                            "/Options/drawings/measures/brush")
        if measure_b is not None:
            global MeasureBrush
            MeasureBrush = QBrush(QColor(measure_b))
            if options is not None:
                options.measures_brush.setColor(QColor(measure_b))

        return
Beispiel #9
0
    def paint(self, painter, option, widget):
        if not painter:
            return

        painter.save()
        painter.setRenderHint(QPainter.Antialiasing, True)

        # do a bit of trigonometry to find out how to transform a rotated item such
        # that the center point is at the point feature
        x = 0.0
        y = 0.0

        if self.pixmap.width() > 0 and self.pixmap.height() > 0:
            half_item_diagonal = math.sqrt(
                self.pixmap.width() * self.pixmap.width() +
                self.pixmap.height() * self.pixmap.height()) / 2
            diagonal_angle = math.acos(
                self.pixmap.width() / (half_item_diagonal * 2)) * 180 / math.pi
            x = half_item_diagonal * math.cos(
                (self.rotation - diagonal_angle) * math.pi / 180)
            y = half_item_diagonal * math.sin(
                (self.rotation - diagonal_angle) * math.pi / 180)

        painter.rotate(self.rotation)
        painter.translate(x - self.pixmap.width() / 2.0,
                          -y - self.pixmap.height() / 2.0)
        painter.drawPixmap(0, 0, self.pixmap)

        # draw arrow, using a red line over a thicker white line so that the arrow is visible
        # against a range of backgrounds
        pen = QPen()
        pen.setWidth(GuiUtils.scale_icon_size(4))
        pen.setColor(QColor(Qt.white))
        painter.setPen(pen)
        painter.drawPath(self.arrow_path)
        pen.setWidth(GuiUtils.scale_icon_size(1))
        pen.setColor(QColor(Qt.red))
        painter.setPen(pen)
        painter.drawPath(self.arrow_path)
        painter.restore()

        # draw numeric value beside the symbol
        painter.save()
        painter.setRenderHint(QPainter.Antialiasing, True)

        buffer_pen = QPen()
        buffer_pen.setColor(Qt.white)
        buffer_pen.setWidthF(GuiUtils.scale_icon_size(4))
        fm = QFontMetricsF(self.marker_font)
        label = QPainterPath()
        label.addText(self.pixmap.width(),
                      self.pixmap.height() / 2.0 + fm.height() / 2.0,
                      self.marker_font, str(round(self.rotation, 1)))
        painter.setPen(buffer_pen)
        painter.setBrush(Qt.NoBrush)
        painter.drawPath(label)
        painter.setPen(Qt.NoPen)
        painter.setBrush(QBrush(Qt.black))
        painter.drawPath(label)

        painter.restore()
    def drawLine(self, painter, commit, parent):
        commitRow = self.graph.commitRows[commit.commitid]
        commitCol = self.graph.commitColumns[commit.commitid]
        parentRow = self.graph.commitRows[parent.commitid]
        parentCol = self.graph.commitColumns[parent.commitid]
        commitX = self.RADIUS * 3 + commitCol * self.COLUMN_SEPARATION
        parentX = self.RADIUS * 3 + parentCol * self.COLUMN_SEPARATION
        commitY = commitRow * self.COMMIT_GRAPH_HEIGHT
        parentY = parentRow * self.COMMIT_GRAPH_HEIGHT
        color = self._columnColor(parentCol)

        if parent is not None and self.graph.isFauxLink(parent.commitid, commit.commitid)\
                and len(parent.childrenIds)>1:
            # draw a faux line
            path = QPainterPath()
            path.moveTo(parentX, parentY)
            path.lineTo(commitX , commitY)

            color = QColor(255,160,255)
            pen = QPen()
            pen.setWidth(2)
            pen.setBrush(color)
            pen.setStyle(Qt.DashLine)
            painter.setPen(pen)
            painter.drawPath(path)

            # draw arrow
            # draw arrow
            ARROW_POINT_SIZE = 9
            painter.setPen(color)
            painter.setBrush(color)
            line = QLineF(commitX , commitY, parentX, parentY)

            angle = math.acos(line.dx() / line.length())
            if line.dy() >= 0:
                angle = 2.0 * math.pi - angle

            sourcePoint = QPointF(commitX,commitY)
            sourceArrowP1 = sourcePoint + QPointF(math.sin(angle + math.pi / 3) * ARROW_POINT_SIZE,
                                                       math.cos(angle + math.pi / 3) * ARROW_POINT_SIZE)
            sourceArrowP2 = sourcePoint + QPointF(math.sin(angle + math.pi - math.pi / 3) * ARROW_POINT_SIZE,
                                                       math.cos(angle + math.pi - math.pi / 3) * ARROW_POINT_SIZE)
            arrow = QPolygonF([line.p1(), sourceArrowP1, sourceArrowP2])
            painter.drawPolygon(arrow)
            return

        path = QPainterPath()
        painter.setBrush(color)
        painter.setPen(color)

        if parentCol != commitCol:
            if parent.isFork() and commit.getParents()[0].commitid == parent.commitid:
                path.moveTo(commitX, commitY)
                path.lineTo(commitX, parentY)
                if parentX<commitX:
                    path.lineTo(parentX + self.RADIUS + 1, parentY)
                else:
                    path.lineTo(parentX - self.RADIUS, parentY)
                color = self._columnColor(commitCol)
            else:
                path2 = QPainterPath()
                path2.moveTo(commitX + self.RADIUS + 1, commitY)
                path2.lineTo(commitX + self.RADIUS + self.COLUMN_SEPARATION / 2, commitY + self.COLUMN_SEPARATION / 3)
                path2.lineTo(commitX + self.RADIUS + self.COLUMN_SEPARATION / 2, commitY - self.COLUMN_SEPARATION / 3)
                path2.lineTo(commitX + + self.RADIUS + 1, commitY)
                painter.setBrush(color)
                painter.setPen(color)
                painter.drawPath(path2)
                path.moveTo(commitX + self.RADIUS + self.COLUMN_SEPARATION / 2, commitY)
                path.lineTo(parentX, commitY)
                path.lineTo(parentX, parentY)

            if parent.isFork():
                if commitCol in self.columnColor.keys():
                    del self.columnColor[commitCol]
  
        else:
            path.moveTo(commitX, commitY)
            path.lineTo(parentX, parentY)

        pen = QPen(color, self.PEN_WIDTH, Qt.SolidLine, Qt.FlatCap, Qt.RoundJoin)
        painter.strokePath(path, pen)

        if not commit.commitid in self.linked:
            y = commitRow * self.COLUMN_SEPARATION
            x = self.RADIUS * 3 + commitCol * self.COLUMN_SEPARATION
            painter.setPen(color)
            painter.setBrush(color)
            painter.drawEllipse(QPoint(x, y), self.RADIUS, self.RADIUS)
            self.linked.append(commit.commitid)
Beispiel #11
0
    def drawForeground(self, painter, rect):
        #print "BoreHoleScene.drawForeground"
        if self.__redraw:
            with self.__project.connect() as con:
                cur = con.cursor()
                self.__redraw = False
                self.clear()
                fm = painter.fontMetrics()

                if self.__id is None:
                    QGraphicsScene.drawForeground(self, painter, rect)
                    return

                cur.execute(
                    "SELECT geom FROM albion.hole WHERE id='{}'".format(
                        self.__id))
                res = cur.fetchone()

                if not res:
                    QGraphicsScene.drawForeground(self, painter, rect)
                    return

                hole = wkb.loads(bytes.fromhex(res[0]))
                line = [p[2] for p in hole.coords]
                tick_width = 20
                spacing = 5
                tick_text_offset = -10
                tabs = [50, 75, 150, 250, 350, 400, 500]
                zmin, zmax = min(line), max(line)
                zpmin, zpmax = 0, ((zmin - zmax) - 5) / self.m_per_pixel

                text = self.addText(self.__id)
                text.setPos(tabs[1], -5 * fm.height())

                label = 'Depth [m]'
                text = self.addText(label)
                text.setRotation(-90)
                text.setPos(0, 0)
                text = self.addText('Formation')
                text.setPos(tabs[1], -3 * fm.height())
                text = self.addText('Radiometry')
                text.setPos(tabs[2], -3 * fm.height())
                text = self.addText('Resistivity')
                text.setPos(tabs[3], -3 * fm.height())
                text = self.addText('Mineralization')
                text.setPos(tabs[4], -3 * fm.height())

                top = zpmin - 3 * fm.height()
                pen = QPen()
                pen.setWidth(3)
                for tab in [tabs[1], tabs[2], tabs[3], tabs[4], tabs[6]]:
                    self.addLine(tab, top, tab, zpmax, pen)
                self.addLine(tabs[1], zpmin, tabs[-1], zpmin, pen)
                self.addLine(tabs[1], zpmax, tabs[-1], zpmax, pen)
                self.addLine(tabs[1], top, tabs[-1], top, pen)

                # depth ticks
                for z in range(0, int(-(zmax - zmin) - 5), -10):
                    text = "% 4.0f" % (max(line) + z)
                    z /= self.m_per_pixel
                    width = fm.width(text)
                    text = self.addText(text)
                    text.setPos(tabs[0] - width - spacing,
                                tick_text_offset + int(z))
                    self.addLine(tabs[0], z, tabs[1], z)
                    self.addLine(tabs[2], z, tabs[4], z)

                #res = cur.execute("SELECT AsText(GEOMETRY), code FROM lithologies WHERE forage={}".format(self.__id)).fetchall()

                ## litho image
                #for geom, code in res:
                #    line = [(float(pt.split()[2])-z_tube+h_tube_sol)
                #            for pt in geom.replace('LINESTRING Z(','').replace(')','').split(',')]
                #    z_start = line[0]/self.m_per_pixel
                #    z_end = line[-1]/self.m_per_pixel
                #    brush = QBrush()
                #    brush.setTextureImage(self.texture(code))
                #    self.addRect(tabs[1], z_start, tabs[2]-tabs[1], z_end-z_start, brush=brush)

                ## bar diagram grid
                #for i in range(1, 10):
                #    pen.setWidth(1 if i != 5 else 2)
                #    x = tabs[3]+(tabs[4]-tabs[3])*float(i)/10
                #    self.addLine(x, zmin, x, zmax, pen)

                # formation color
                cur.execute(
                    "SELECT geom, code FROM albion.formation WHERE hole_id='{}'"
                    .format(self.__id))

                for geom, code in cur.fetchall():
                    line = [
                        p[2] for p in wkb.loads(bytes.fromhex(geom)).coords
                    ]
                    z_start = (line[0] - zmax) / self.m_per_pixel
                    z_end = (line[-1] - zmax) / self.m_per_pixel
                    brush = QBrush()
                    brush.setStyle(Qt.SolidPattern)
                    brush.setColor(self.formation_color(code))
                    self.addRect(tabs[1],
                                 z_start,
                                 tabs[2] - tabs[1],
                                 z_end - z_start,
                                 brush=brush)
                    #width = fm.width(code);
                    #text = self.addText(code)
                    #text.setPos(tabs[2]+spacing, tick_text_offset+int(.5*(z_start+z_end)))
                    self.addLine(tabs[2], z_start, tabs[2], z_start)
                    self.addLine(tabs[2], z_end, tabs[2], z_end)

                # radiometry diagram
                cur.execute(
                    "SELECT max(gamma) FROM albion.radiometry WHERE hole_id='{}'"
                    .format(self.__id))
                gamma_max = cur.fetchone()[0]
                cur.execute(
                    "SELECT geom, gamma FROM albion.radiometry WHERE hole_id='{}' AND gamma>=0"
                    .format(self.__id))
                for geom, gamma in cur.fetchall():
                    line = [
                        p[2] for p in wkb.loads(bytes.fromhex(geom)).coords
                    ]
                    z_start = (line[0] - zmax) / self.m_per_pixel
                    z_end = (line[-1] - zmax) / self.m_per_pixel
                    brush = QBrush()
                    brush.setStyle(Qt.SolidPattern)
                    brush.setColor(QColor(55, 51, 149))
                    self.addRect(tabs[2],
                                 z_start,
                                 (tabs[3] - tabs[2]) * gamma / gamma_max,
                                 z_end - z_start,
                                 pen=QPen(Qt.NoPen),
                                 brush=brush)

                # resistivity diagram
                cur.execute(
                    "SELECT max(rho) FROM albion.resistivity WHERE hole_id='{}'"
                    .format(self.__id))
                rho_max = cur.fetchone()[0]
                cur.execute(
                    "SELECT geom, rho FROM albion.resistivity WHERE hole_id='{}' AND rho>=0"
                    .format(self.__id))
                for geom, rho in cur.fetchall():
                    line = [
                        p[2] for p in wkb.loads(bytes.fromhex(geom)).coords
                    ]
                    z_start = (line[0] - zmax) / self.m_per_pixel
                    z_end = (line[-1] - zmax) / self.m_per_pixel
                    brush = QBrush()
                    brush.setStyle(Qt.SolidPattern)
                    brush.setColor(QColor(155, 51, 49))
                    self.addRect(tabs[3],
                                 z_start, (tabs[4] - tabs[3]) * rho / rho_max,
                                 z_end - z_start,
                                 pen=QPen(Qt.NoPen),
                                 brush=brush)

                # mineralization
                cur.execute(
                    "SELECT geom, oc, accu, grade FROM albion.mineralization WHERE hole_id='{}'"
                    .format(self.__id))

                for geom, oc, accu, grade in cur.fetchall():
                    line = [
                        p[2] for p in wkb.loads(bytes.fromhex(geom)).coords
                    ]
                    z_start = (line[0] - zmax) / self.m_per_pixel
                    z_end = (line[-1] - zmax) / self.m_per_pixel
                    brush = QBrush()
                    brush.setStyle(Qt.SolidPattern)
                    brush.setColor(QColor(250, 250, 50))
                    self.addRect(tabs[4],
                                 z_start,
                                 tabs[5] - tabs[4],
                                 z_end - z_start,
                                 brush=brush)
                    txt = "oc=" + str(oc) + "\naccu=" + str(
                        accu) + "\ngrade=" + str(grade)
                    width = fm.width(txt)
                    text = self.addText(txt)
                    text.setPos(
                        tabs[5] + spacing,
                        -int(1.5 * fm.height()) + int(.5 * (z_start + z_end)))
                    self.addLine(tabs[4], z_start, tabs[6], z_start)
                    self.addLine(tabs[4], z_end, tabs[6], z_end)

                self.setSceneRect(self.itemsBoundingRect())

        QGraphicsScene.drawForeground(self, painter, rect)