Пример #1
0
/*!
    Returns the time relative to the reference time for
    given pixel position (x-coordinate) \a xcoord
*/
double UiTimeAxis::pixelToTimeRelativeRef(double xcoord)
{
    // make xcoord relative to the plot area only
    xcoord -= infoWidth();

    return (xcoord*mMajorStepTime) / (MajorStepPixelWidth) + mRangeLower;
}
Пример #2
0
/*!
    Paint event handler responsible for painting this widget.
*/
void UiTimeAxis::paintEvent(QPaintEvent *event)
{
    (void)event;
    QPainter painter(this);

    int plotWidth = width()-infoWidth();

    int numMinorSteps = plotWidth
            / (MajorStepPixelWidth/NumberOfMinorSteps) + 1;

    painter.save();
    painter.translate(infoWidth(), 0);

    for (int i = 0; i < numMinorSteps; i++) {
        int stepHeight = 3;

        if (/*i > 0 &&*/ (i % NumberOfMinorSteps) == 0) {
            stepHeight += 9;

            QString stepText = getTimeLabelForStep(i/NumberOfMinorSteps);

            // draw text centered over a major step
            int textWidth = painter.fontMetrics().width(stepText);
            painter.drawText((MajorStepPixelWidth/NumberOfMinorSteps)*i
                             - textWidth/2, 10, stepText);

        }

        // draw minor/major step on the time axis
        painter.drawLine((MajorStepPixelWidth/NumberOfMinorSteps)*i,
                         height()-stepHeight,
                         (MajorStepPixelWidth/NumberOfMinorSteps)*i,
                         height());
    }

    painter.restore();
}
Пример #3
0
/*!
    Returns the pixel position relative to the reference position for
    given time \a value
*/
double UiTimeAxis::timeToPixelRelativeRef(double value)
{
    return timeToPixel(value-mRangeLower) + infoWidth();
}
Пример #4
0
int Element::skipBlockWidth() const {
	return st::msgDateSpace + infoWidth() - st::msgDateDelta.x();
}