예제 #1
0
void CursorPair::draw_markers(QPainter &p,
	const QRect &rect, unsigned int prefix)
{
	compute_text_size(p, prefix);
	QRectF delta_rect(get_label_rect(rect));

	const int radius = delta_rect.height() / 2;
	const QRectF text_rect(delta_rect.intersected(
		rect).adjusted(radius, 0, -radius, 0));
	if(text_rect.width() >= _text_size.width())
	{
		const int highlight_radius = delta_rect.height() / 2 - 2;

		p.setBrush(Cursor::FillColour);
		p.setPen(Cursor::LineColour);
		p.drawRoundedRect(delta_rect, radius, radius);

		delta_rect.adjust(1, 1, -1, -1);
		p.setPen(Cursor::HighlightColour);
		p.drawRoundedRect(delta_rect, highlight_radius, highlight_radius);

		p.setPen(Cursor::TextColour);
		p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter,
			Ruler::format_time(_second.time() - _first.time(), prefix, 2));
	}

	// Paint the cursor markers
	_first.paint_label(p, rect, prefix);
	_second.paint_label(p, rect, prefix);
}
예제 #2
0
void Trace::paint_label(QPainter &p, int right, const QPoint pt)
{
    compute_text_size(p);
    const int y = get_y();

    const QRectF color_rect = get_rect("color", y, right);
    const QRectF name_rect  = get_rect("name",  y, right);
    const QRectF label_rect = get_rect("label", get_zeroPos(), right);

    p.setRenderHint(QPainter::Antialiasing);
    // Paint the ColorButton
    p.setPen(Qt::transparent);
    p.setBrush(enabled() ? _colour : dsDisable);
    p.drawRect(color_rect);

    // Paint the signal name
    p.setPen(enabled() ? Qt::black : dsDisable);
    p.drawText(name_rect, Qt::AlignLeft | Qt::AlignVCenter, _name);

    // Paint the trigButton
    paint_type_options(p, right, pt);

    // Paint the label
    if (enabled()) {
        const QPointF points[] = {
            label_rect.topLeft(),
            label_rect.topRight(),
            QPointF(right, get_zeroPos()),
            label_rect.bottomRight(),
            label_rect.bottomLeft()
        };

        p.setPen(Qt::transparent);
        if (_type == SR_CHANNEL_DSO)
            p.setBrush((label_rect.contains(pt) || selected()) ? _colour.darker() : _colour);
        else
            p.setBrush((label_rect.contains(pt) || selected()) ? dsYellow : dsBlue);
        p.drawPolygon(points, countof(points));

        p.setPen(QPen(Qt::blue, 1, Qt::DotLine));
        p.setBrush(Qt::transparent);
        p.drawLine(label_rect.right(), label_rect.top() + 3,
                    label_rect.right(), label_rect.bottom() - 3);

        // Paint the text
        p.setPen(Qt::white);
        if (_type == SR_CHANNEL_GROUP)
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "G");
        else if (_type == SR_CHANNEL_ANALOG)
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "A");
        else if (_type == SR_CHANNEL_DECODER)
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "D");
        else
            p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, QString::number(_index_list.front()));
    }
}
예제 #3
0
파일: cursor.cpp 프로젝트: JenSte/pulseview
void Cursor::paint_label(QPainter &p, const QRect &rect,
	unsigned int prefix)
{
	compute_text_size(p, prefix);
	const QRectF r(get_label_rect(rect));

	if (_time > _other.time())
	{
		const QPointF points[] = {
			r.topLeft(),
			r.topRight(),
			r.bottomRight(),
			QPointF(r.left() + ArrowSize, r.bottom()),
			QPointF(r.left(), rect.bottom()),
		};

		const QPointF highlight_points[] = {
			QPointF(r.left() + 1, r.top() + 1),
			QPointF(r.right() - 1, r.top() + 1),
			QPointF(r.right() - 1, r.bottom() - 1),
			QPointF(r.left() + ArrowSize - 1, r.bottom() - 1),
			QPointF(r.left() + 1, rect.bottom() - 1),
		};

		p.setPen(Qt::transparent);
		p.setBrush(FillColour);
		p.drawPolygon(points, countof(points));

		p.setPen(HighlightColour);
		p.setBrush(Qt::transparent);
		p.drawPolygon(highlight_points, countof(highlight_points));

		p.setPen(LineColour);
		p.setBrush(Qt::transparent);
		p.drawPolygon(points, countof(points));
	}
	else
	{
		const QPointF points[] = {
			r.topRight(),
			r.topLeft(),
			r.bottomLeft(),
			QPointF(r.right() - ArrowSize, r.bottom()),
			QPointF(r.right(), rect.bottom()),
		};

		const QPointF highlight_points[] = {
			QPointF(r.right() - 1, r.top() + 1),
			QPointF(r.left() + 1, r.top() + 1),
			QPointF(r.left() + 1, r.bottom() - 1),
			QPointF(r.right() - ArrowSize + 1, r.bottom() - 1),
			QPointF(r.right() - 1, rect.bottom() - 1),
		};

		p.setPen(Qt::transparent);
		p.setBrush(FillColour);
		p.drawPolygon(points, countof(points));

		p.setPen(HighlightColour);
		p.setBrush(Qt::transparent);
		p.drawPolygon(highlight_points, countof(highlight_points));

		p.setPen(LineColour);
		p.setBrush(Qt::transparent);
		p.drawPolygon(points, countof(points));
	}

	p.setPen(TextColour);
	p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter,
		Ruler::format_time(_time, prefix, 2));
}