Пример #1
0
ImuItem ImuBuffer::interpolateAtTime(double time) const {
    if (time > getMaxTime()) {
        throw GeneralException("Lookup would require extrapolation into the future.");
    }
    if (time < getMinTime()) {
        throw GeneralException("Interpolating too far in to past.");
    }
    for (int i = 0; i < size_ - 1; ++i) {
        const ImuItem& later = items_[(cur_pos_ - i - 1) % size_];
        const ImuItem& earlier = items_[(cur_pos_ - i - 2) % size_];
        if (std::abs(time - later.getTime()) < 1e-3) {
            return later;
        }
        if (std::abs(time - earlier.getTime()) < 1e-3) {
            return earlier;
        }
        if (earlier.getTime() >= later.getTime()) {
            throw ImpossibleException("Bad time ordering.");
        }
        if (earlier.getTime() < time && time < later.getTime()) {
            ImuItem interpolated;
            double time_delta = later.getTime() - earlier.getTime();
            double t = (time - earlier.getTime()) / time_delta;
            interpolated.time_ = time;
            interpolated.device_ = later.getDevice();
            interpolated.data_ = t * earlier.data_ + (1-t) * later.data_;
            return interpolated;
        }
    }
    throw ImpossibleException("Interpolation failure. Time " + std::to_string(time) + " min " + std::to_string(getMinTime()) + " max " + std::to_string(getMaxTime()));
}
Пример #2
0
/************************************************
  Issue #18: Panel clock plugin changes your size
 ************************************************/
void RazorClock::updateMinWidth()
{
    QFontMetrics metrics(gui->font());
    QDate maxDate = getMaxDate(metrics, dateFormat);
    QTime maxTime = getMaxTime(metrics, timeFormat);
    QDateTime dt(maxDate, maxTime);

    //qDebug() << "T:" << metrics.boundingRect(dt.toString(timeFormat)).width();
    //qDebug() << "C:" << metrics.boundingRect(QTime::currentTime().toString(timeFormat)).width() << QTime::currentTime().toString(timeFormat);
    //qDebug() << "D:" << metrics.boundingRect(dt.toString(dateFormat)).width();

    int width;
    if (dateOnNewLine && showDate)
        width = qMax(metrics.boundingRect(dt.toString(timeFormat)).width(),
                     metrics.boundingRect(dt.toString(dateFormat)).width()
                     );
    else
        width = metrics.boundingRect(dt.toString(clockFormat)).width();

    qDebug() << "RazorClock Recalc width " << width << dt.toString(clockFormat);
//    gui->setMinimumWidth(width + 5);
    this->setMinimumWidth(width + 5);

//    gui->setMaximumWidth(width + 5);
//    this->setMaximumWidth(width + 5);
}
Пример #3
0
/************************************************
  Issue #18: Panel clock plugin changes your size
 ************************************************/
void LxQtClock::updateMinWidth()
{
    QFontMetrics timeLabelMetrics(mTimeLabel->font());
    QFontMetrics dateLabelMetrics(mDateLabel->font());
    QDate maxDate = getMaxDate(mDateOnNewLine ? dateLabelMetrics : timeLabelMetrics, mDateFormat);
    QTime maxTime = getMaxTime(timeLabelMetrics, mTimeFormat);
    QDateTime dt(maxDate, maxTime);

    //qDebug() << "T:" << metrics.boundingRect(dt.toString(mTimeFormat)).width();
    //qDebug() << "C:" << metrics.boundingRect(QTime::currentTime().toString(mTimeFormat)).width() << QTime::currentTime().toString(mTimeFormat);
    //qDebug() << "D:" << metrics.boundingRect(dt.toString(mDateFormat)).width();

    int width;
    int height;
    if (mDateOnNewLine)
    {
        QRect rect1(timeLabelMetrics.boundingRect(dt.toString(mTimeFormat)));
        mTimeLabel->setMinimumSize(rect1.size());
        QRect rect2(dateLabelMetrics.boundingRect(dt.toString(mDateFormat)));
        mDateLabel->setMinimumSize(rect2.size());
        width = qMax(rect1.width(), rect2.width());
        height = rect1.height() + rect2.height();
//        qDebug() << "LxQtClock Recalc size" << width << height << dt.toString(mTimeFormat) << dt.toString(mDateFormat);
    }
    else
    {
        QRect rect(timeLabelMetrics.boundingRect(dt.toString(mClockFormat)));
        mTimeLabel->setMinimumSize(rect.size());
        mDateLabel->setMinimumSize(0, 0);
        width = rect.width();
        height = rect.height();
//        qDebug() << "LxQtClock Recalc size" << width << height << dt.toString(mClockFormat);
    }


    mContent->setMinimumSize(width, height);
}
Пример #4
0
double RFWTimer::getTimeToExpire () { //may be negative!
	if (getMaxTime() == 0) return INFINITE_TIME;
	else return (getTime() - getMaxTime());
}
Пример #5
0
bool RFWTimer::isTimeExpired () {
	if (getMaxTime() == 0) return false;
	bool time_expired = (getTime() >= getMaxTime());
	return time_expired;
}