void ProgressDlg::setCurrentPercent(const float percent) { if (!stopRequested()) { static float lastPercent = 23456.0f; if (percent != lastPercent) { lastPercent = percent; char dsp[20]; sprintf(dsp, "%.3f%%", percent); currentTaskPercent.SetWindowText(dsp); currentTaskProgress.SetPos(static_cast<int>(percent * 10.0f)); } { char disp[90]; memset(disp, 0, sizeof(disp)); currentTaskText.GetWindowText(disp, sizeof(disp)); char disp2[90]; #ifdef _DEBUG sprintf(disp2, "%.2f%% - %s (DEBUG)", percent, disp); #else sprintf(disp2, "%.2f%% - %s", percent, disp); #endif SetWindowText(disp2); } } // Update the timer, if it has changed int thisTime = time(NULL); if (thisTime != lastTime() && !paused()) { lastTime() = thisTime; int seconds = lastTime() - runtimeStart(); int minutes = seconds / 60; seconds -= minutes * 60; int hours = minutes / 60; minutes -= hours * 60; char dsp[90]; sprintf(dsp, "%02d:%02d:%02d", hours, minutes, seconds); runtimeText.SetWindowText(dsp); } allowBackgroundProcessing(); }
void FsRadProgressDlg::setCurrentPercent(const float percent) { if (!stopRequested()) { static float lastPercent = 23456.0f; if (percent != lastPercent) { lastPercent = percent; CString str; str.Format(L"%.3f%%", percent); currentTaskPercent.SetWindowText(str); currentTaskProgress.SetPos(static_cast<int>(percent * 10.0f)); } { CString disp; currentTaskText.GetWindowText(disp); CString disp2; disp2.Format(L"%.2f%% - %s", percent, (LPCWSTR)disp); SetWindowText(disp2); } } // Update the timer, if it has changed auto thisTime = time(NULL); if (thisTime != lastTime() && !paused()) { lastTime() = thisTime; auto seconds = lastTime() - runtimeStart(); auto minutes = seconds / 60; seconds -= minutes * 60; auto hours = minutes / 60; minutes -= hours * 60; CString dsp; dsp.Format(L"%02d:%02d:%02d", hours, minutes, seconds); runtimeText.SetWindowText(dsp); } allowBackgroundProcessing(); }
/*! \internal \brief Records point to list with timestamp. \param point Point to be recorded. \param time Time to be recorded. \return Nothing. */ void HbPointRecorder::record(qreal point, const QTime &time) { // Empty list always accepts first point without tests. if ( !isEmpty() ) { // No point to record a point, if timestamp is less or equal with previous. if ( lastTime().msecsTo(time) == 0 ) { DEBUG() << "Ignoring point, because no difference in time stamps."; return; } // Don't tolerate points, which are too close to previously recorded point. if ( qAbs(lastPoint() - point) < mThreshold ) { DEBUG() << "Ignoring point, because it is withing threshold of previous point"; return; } } // In case the list contains two or more points, direction can be // determined. Each new point added needs to be checked for direction // change. if ( length() > 1 ) { // Clear list, on direction change. Leave the last recorded point // to the list, as it can be considered as first point for new direction. if ( dirChanged( point ) ) { HbPointTime temp = last(); clear(); append(temp); } } // Finally check, if the position has changed. Don't record point, when no position // change. if ( isEmpty() || point != lastPoint() ) { // Add point and time to list. append(HbPointTime(point, time)); } else { DEBUG() << "Ignoring point, because it equals previous."; } }
//set up time void NetCdfConfigureDialog::on_comboBoxDim3_currentIndexChanged(int id) { if (_currentVar->num_dims() > 2) { if (id == -1) id = 0; double firstValue=0, lastValue=0; unsigned size = 0; getDimEdges(id,size,firstValue,lastValue); QTime firstTime(0,0,0), lastTime(0,0,0); int firstDaysToAdd = 0, lastDaysToAdd = 0; getDaysTime(firstValue,firstTime,firstDaysToAdd); getDaysTime(lastValue,lastTime,lastDaysToAdd); QDate initialDate(1960,1,1); QTime initialTime(0,0); QDateTime initialDateTime; initialDateTime.setDate(initialDate); initialDateTime.setTime(initialTime); QDateTime firstDateTime = initialDateTime.addDays(firstDaysToAdd); firstDateTime.setTime(firstTime); QDateTime lastDateTime = initialDateTime.addDays(lastDaysToAdd); lastDateTime.setTime(lastTime); dateTimeEditDim3->setDateTime(firstDateTime); dateTimeEditDim3->setMinimumDateTime(firstDateTime); dateTimeEditDim3->setMaximumDateTime(lastDateTime); _currentInitialDateTime = initialDateTime; lineEditName->setText(setName()); } }
std::string FeltFile::information() const { std::ostringstream cont; cont << "File type\t\t" << block1_[0] << "\n"; cont << "Time a\t\t\t" << lastUpdateTime() << "\n"; cont << "Time b\t\t\t" << referenceTime() << "\n"; cont << "M\t\t\t" << block1_[7] << "\n"; cont << "N\t\t\t" << block1_[8] << "\n"; cont << "K\t\t\t" << block1_[9] << "\n"; cont << "L\t\t\t" << block1_[10] << "\n"; cont << "MX\t\t\t" << block1_[11] << "\n"; cont << "Last word last block\t" << block1_[12] << "\n"; cont << "storage type\t\t" << block1_[13] << "\n"; cont << "Update status\t\t" << block1_[14] << "\n"; cont << "Arch time a\t\t" << firstTime() << "\n"; cont << "Arch time b\t\t" << lastTime() << "\n"; cont << "Termins\t\t\t" << block1_[25] << "\n"; cont << "Indexes/term\t\t" << block1_[26] << "\n"; cont << "Producer\t\t" << block1_[27] << "\n"; cont << "Time unit\t\t" << block1_[28] << "\n"; cont << "Time resolution\t\t" << block1_[29] << "\n"; return cont.str(); }
void NotifyWindow::updateNotifyDisplay() { if (!item) return; int32 w = st::notifyWidth, h = st::notifyHeight; QImage img(w * cIntRetinaFactor(), h * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied); if (cRetina()) img.setDevicePixelRatio(cRetinaFactor()); img.fill(st::notifyBG->c); { QPainter p(&img); p.fillRect(0, 0, w - st::notifyBorderWidth, st::notifyBorderWidth, st::notifyBorder->b); p.fillRect(w - st::notifyBorderWidth, 0, st::notifyBorderWidth, h - st::notifyBorderWidth, st::notifyBorder->b); p.fillRect(st::notifyBorderWidth, h - st::notifyBorderWidth, w - st::notifyBorderWidth, st::notifyBorderWidth, st::notifyBorder->b); p.fillRect(0, st::notifyBorderWidth, st::notifyBorderWidth, h - st::notifyBorderWidth, st::notifyBorder->b); if (cNotifyView() <= dbinvShowName) { if (history->peer->photo->loaded()) { p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), history->peer->photo->pix(st::notifyPhotoSize)); } else { MTP::clearLoaderPriorities(); peerPhoto = history->peer->photo; peerPhoto->load(true, true); } } else { static QPixmap icon = QPixmap::fromImage(App::wnd()->iconLarge().scaled(st::notifyPhotoSize, st::notifyPhotoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); p.drawPixmap(st::notifyPhotoPos.x(), st::notifyPhotoPos.y(), icon); } int32 itemWidth = w - st::notifyPhotoPos.x() - st::notifyPhotoSize - st::notifyTextLeft - st::notifyClosePos.x() - st::notifyClose.width; QRect rectForName(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyTextTop, itemWidth, st::msgNameFont->height); if (cNotifyView() <= dbinvShowName) { if (history->peer->chat) { p.drawPixmap(QPoint(rectForName.left() + st::dlgChatImgLeft, rectForName.top() + st::dlgChatImgTop), App::sprite(), st::dlgChatImg); rectForName.setLeft(rectForName.left() + st::dlgChatImgSkip); } } QDateTime now(QDateTime::currentDateTime()), lastTime(item->date); QDate nowDate(now.date()), lastDate(lastTime.date()); QString dt = lastTime.toString(qsl("hh:mm")); int32 dtWidth = st::dlgHistFont->m.width(dt); rectForName.setWidth(rectForName.width() - dtWidth - st::dlgDateSkip); p.setFont(st::dlgDateFont->f); p.setPen(st::dlgDateColor->p); p.drawText(rectForName.left() + rectForName.width() + st::dlgDateSkip, rectForName.top() + st::dlgHistFont->ascent, dt); if (cNotifyView() <= dbinvShowPreview) { const HistoryItem *textCachedFor = 0; Text itemTextCache(itemWidth); bool active = false; item->drawInDialog(p, QRect(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height, itemWidth, 2 * st::dlgFont->height), active, textCachedFor, itemTextCache); } else { static QString notifyText = st::dlgHistFont->m.elidedText(lang(lng_notification_preview), Qt::ElideRight, itemWidth); p.setPen(st::dlgSystemColor->p); p.drawText(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height + st::dlgHistFont->ascent, notifyText); } p.setPen(st::dlgNameColor->p); if (cNotifyView() <= dbinvShowName) { history->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width()); } else { p.setFont(st::msgNameFont->f); static QString notifyTitle = st::msgNameFont->m.elidedText(lang(lng_notification_title), Qt::ElideRight, rectForName.width()); p.drawText(rectForName.left(), rectForName.top() + st::msgNameFont->ascent, notifyTitle); } } pm = QPixmap::fromImage(img); update(); }
int main(int argc, char **argv) { ros::init(argc, argv, "msf_eval"); ros::Time::init(); enum argIndices{ bagfile = 1, EVAL_topic = 2, GT_topic = 3, singleRunOnly = 4 }; //calibration of sensor to vicon Eigen::Matrix4d T_BaBg_mat; //this is the Vicon one - SLAM sensor V0 /////////////////////////////////////////////////////////////////////////////////////////// T_BaBg_mat << 0.999706627053000, -0.022330158354000, 0.005123243528000, -0.060614697387000, 0.022650462142000, 0.997389634278000, -0.068267398302000, 0.035557942651000, -0.003589706237000, 0.068397960288000, 0.997617159323000, -0.042589657349000, 0, 0, 0, 1.000000000000000; //////////////////////////////////////////////////////////////////////////////////////////// ros::Duration dt(0.0039); const double timeSyncThreshold = 0.005; const double timeDiscretization = 10.0; //discretization step for different starting points into the dataset const double trajectoryTimeDiscretization = 0.049; //discretization of evaluation points (vision framerate for fair comparison) const double startTimeOffset = 10.0; if (argc < 4) { MSF_ERROR_STREAM("usage: ./"<<argv[0]<<" bagfile EVAL_topic GT_topic [singleRunOnly]"); return -1; } bool singleRun = false; if (argc == 5) { singleRun = atoi(argv[singleRunOnly]); } if(singleRun){ MSF_WARN_STREAM("Doing only a single run."); }else{ MSF_WARN_STREAM("Will process the dataset from different starting points."); } typedef geometry_msgs::TransformStamped GT_TYPE; typedef geometry_msgs::PoseWithCovarianceStamped EVAL_TYPE; // output file std::stringstream matlab_fname; std::string path = ros::package::getPath("msf_eval"); matlab_fname << path << "/Matlab/matlab_data" << ros::Time::now().sec << ".m"; std::ofstream outfile(matlab_fname.str().c_str()); std::stringstream poses_EVAL; std::stringstream poses_GT; assert(outfile.good()); outfile << "data=[" << std::endl; ros::Duration startOffset(startTimeOffset); sm::kinematics::Transformation T_BaBg(T_BaBg_mat); //body aslam to body Ground Truth // open for reading rosbag::Bag bag(argv[bagfile], rosbag::bagmode::Read); // views on topics rosbag::View view_EVAL(bag, rosbag::TopicQuery(argv[EVAL_topic])); rosbag::View view_GT(bag, rosbag::TopicQuery(argv[GT_topic])); //check topics if (view_EVAL.size() == 0) { MSF_ERROR_STREAM("The bag you provided does not contain messages for topic "<<argv[EVAL_topic]); return -1; } if (view_GT.size() == 0) { MSF_ERROR_STREAM("The bag you provided does not contain messages for topic "<<argv[GT_topic]); return -1; } //litter console with number of messages MSF_INFO_STREAM("Reading from "<<argv[bagfile]); MSF_INFO_STREAM("Topic "<<argv[EVAL_topic]<<", size: "<<view_EVAL.size()); MSF_INFO_STREAM("Topic "<<argv[GT_topic]<<", size: "<<view_GT.size()); //get times of first messages GT_TYPE::ConstPtr GT_begin = view_GT.begin()->instantiate<GT_TYPE>(); assert(GT_begin); EVAL_TYPE::ConstPtr POSE_begin = view_EVAL.begin()->instantiate<EVAL_TYPE>(); assert(POSE_begin); MSF_INFO_STREAM("First GT data at "<<GT_begin->header.stamp); MSF_INFO_STREAM("First EVAL data at "<<POSE_begin->header.stamp); while (true) // start eval from different starting points { rosbag::View::const_iterator it_EVAL = view_EVAL.begin(); rosbag::View::const_iterator it_GT = view_GT.begin(); // read ground truth ros::Time start; // Find start time alignment: set the GT iterater to point to a time larger than the aslam time while (true) { GT_TYPE::ConstPtr trafo = it_GT->instantiate<GT_TYPE>(); assert(trafo); ros::Time time_GT; time_GT = trafo->header.stamp + dt; EVAL_TYPE::ConstPtr pose = it_EVAL->instantiate<EVAL_TYPE>(); assert(pose); ros::Time time_EKF; time_EKF = pose->header.stamp; if (time_EKF >= time_GT) { it_GT++; if (it_GT == view_GT.end()) { MSF_ERROR_STREAM("Time synchronization failed"); return false; } } else { start = time_GT; MSF_INFO_STREAM("Time synced! GT start: "<<start <<" EVAL start: "<<time_EKF); break; } } // world frame alignment sm::kinematics::Transformation T_WaBa; sm::kinematics::Transformation T_WgBg; sm::kinematics::Transformation T_WgBg_last; sm::kinematics::Transformation T_WaWg; // now find the GT/EKF pairings int ctr = 0; //how many meas did we add this run? double ds = 0.0; // distance travelled ros::Time lastTime(0.0); MSF_INFO_STREAM("Processing measurements... Current start point: "<<startOffset<<"s into the bag."); for (; it_GT != view_GT.end(); ++it_GT) { GT_TYPE::ConstPtr trafo = it_GT->instantiate<GT_TYPE>(); assert(trafo); // find closest timestamp ros::Time time_GT = trafo->header.stamp + dt; EVAL_TYPE::ConstPtr pose = it_EVAL->instantiate<EVAL_TYPE>(); assert(pose); ros::Time time_EKF = pose->header.stamp; bool terminate = false; //get the measurement close to this GT value while (time_GT > time_EKF) { it_EVAL++; if (it_EVAL == view_EVAL.end()) { terminate = true; MSF_INFO_STREAM("done. All EKF meas processed!"); break; } pose = it_EVAL->instantiate<EVAL_TYPE>(); assert(pose); time_EKF = pose->header.stamp; } if (terminate){ break; } // add comparison value if (time_GT - start >= startOffset) { T_WaBa = sm::kinematics::Transformation( Eigen::Vector4d(-pose->pose.pose.orientation.x, -pose->pose.pose.orientation.y, -pose->pose.pose.orientation.z, pose->pose.pose.orientation.w), Eigen::Vector3d(pose->pose.pose.position.x, pose->pose.pose.position.y, pose->pose.pose.position.z)); T_WgBg = sm::kinematics::Transformation( Eigen::Vector4d(-trafo->transform.rotation.x, -trafo->transform.rotation.y, -trafo->transform.rotation.z, trafo->transform.rotation.w), Eigen::Vector3d(trafo->transform.translation.x, trafo->transform.translation.y, trafo->transform.translation.z)); // initial alignment if (ctr == 0) { T_WaWg = (T_WaBa) * T_BaBg * T_WgBg.inverse(); T_WgBg_last = T_WgBg; } sm::kinematics::Transformation dT = T_WaBa * (T_WaWg * T_WgBg * T_BaBg.inverse()).inverse(); sm::kinematics::Transformation T_WaBa_gt = (T_WaWg * T_WgBg * T_BaBg.inverse()); T_WaBa_gt = sm::kinematics::Transformation(T_WaBa_gt.q().normalized(), T_WaBa_gt.t()); dT = sm::kinematics::Transformation(dT.q().normalized(), dT.t()); // update integral if (trafo) { ds += (T_WgBg.t() - T_WgBg_last.t()).norm(); // store last GT transformation T_WgBg_last = T_WgBg; } else { // too noisy if ((T_WgBg * T_WgBg_last.inverse()).t().norm() > .1) { ds += (T_WgBg.t() - T_WgBg_last.t()).norm(); //MSF_INFO_STREAM((T_WgBg*T_WgBg_last.inverse()).t().norm()); // store last GT transformation T_WgBg_last = T_WgBg; } } Eigen::Vector3d dalpha; if (dT.q().head<3>().norm() > 1e-12) { dalpha = (asin(dT.q().head<3>().norm()) * 2 * dT.q().head<3>().normalized()); } else { dalpha = 2 * dT.q().head<3>(); } // g-vector alignment Eigen::Vector3d e_z_Wg(0, 0, 1); Eigen::Vector3d e_z_Wa = dT.C() * e_z_Wg; double dalpha_e_z = acos(std::min(1.0, e_z_Wg.dot(e_z_Wa))); if (fabs((time_GT - time_EKF).toSec()) < timeSyncThreshold && (time_EKF - lastTime).toSec() > trajectoryTimeDiscretization) { if (startOffset.toSec() == startTimeOffset) { poses_EVAL << T_WaBa.t().transpose() << ";" << std::endl; poses_GT << T_WgBg.t().transpose() << ";" << std::endl; } Eigen::Matrix<double, 6, 6> cov = getCovariance(pose); outfile << (time_GT - start).toSec() << " " << ds << " " << (T_WaBa.t() - T_WaBa_gt.t()).norm() << " " //translation << 2 * acos(std::min(1.0, fabs(dT.q()[3]))) << " " << dalpha_e_z << " " //orientation <<cov(0, 0)<<" "<<cov(1, 1)<<" "<<cov(2, 2)<<" " //position covariances <<cov(3, 3)<<" "<<cov(4, 4)<<" "<<cov(5, 5)<<";" //orientation covariances << std::endl; lastTime = time_EKF; // remember } // count comparisons ctr++; } } MSF_INFO_STREAM("Added "<<ctr<<" measurement edges."); //where in the bag should the next eval start startOffset += ros::Duration(timeDiscretization); if (ctr == 0 || singleRun) //any new measurements this run? { break; } } // cleanup bag.close(); outfile << "];"; outfile << "poses = [" << poses_EVAL.str() << "];" << std::endl; outfile << "poses_GT = [" << poses_GT.str() << "];" << std::endl; outfile.close(); return 0; }
void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) { _shortPollRequest = 0; setLoading(false); auto availCurrent = st::boxWideWidth - st::sessionPadding.left() - st::sessionTerminateSkip; auto availOther = availCurrent - st::sessionTerminate.iconPosition.x();// -st::sessionTerminate.width - st::sessionTerminateSkip; _list.clear(); if (result.type() != mtpc_account_authorizations) { return; } auto &v = result.c_account_authorizations().vauthorizations.c_vector().v; _list.reserve(v.size()); const CountriesByISO2 &countries(countriesByISO2()); for_const (auto &auth, v) { if (auth.type() != mtpc_authorization) { continue; } auto &d = auth.c_authorization(); Data data; data.hash = d.vhash.v; QString appName, appVer = qs(d.vapp_version), systemVer = qs(d.vsystem_version), deviceModel = qs(d.vdevice_model); if (d.vapi_id.v == 2040 || d.vapi_id.v == 17349) { appName = (d.vapi_id.v == 2040) ? qstr("Telegram Desktop") : qstr("Telegram Desktop (GitHub)"); // if (systemVer == qstr("windows")) { // deviceModel = qsl("Windows"); // } else if (systemVer == qstr("os x")) { // deviceModel = qsl("OS X"); // } else if (systemVer == qstr("linux")) { // deviceModel = qsl("Linux"); // } if (appVer == QString::number(appVer.toInt())) { int32 ver = appVer.toInt(); appVer = QString("%1.%2").arg(ver / 1000000).arg((ver % 1000000) / 1000) + ((ver % 1000) ? ('.' + QString::number(ver % 1000)) : QString()); } else { appVer = QString(); } } else { appName = qs(d.vapp_name);// +qsl(" for ") + qs(d.vplatform); if (appVer.indexOf('(') >= 0) appVer = appVer.mid(appVer.indexOf('(')); } data.name = appName; if (!appVer.isEmpty()) data.name += ' ' + appVer; data.nameWidth = st::sessionNameFont->width(data.name); QString country = qs(d.vcountry), platform = qs(d.vplatform); //CountriesByISO2::const_iterator j = countries.constFind(country); //if (j != countries.cend()) country = QString::fromUtf8(j.value()->name); MTPint active = d.vdate_active.v ? d.vdate_active : d.vdate_created; data.activeTime = active.v; data.info = qs(d.vdevice_model) + qstr(", ") + (platform.isEmpty() ? QString() : platform + ' ') + qs(d.vsystem_version); data.ip = qs(d.vip) + (country.isEmpty() ? QString() : QString::fromUtf8(" \xe2\x80\x93 ") + country); if (!data.hash || (d.vflags.v & 1)) { data.active = lang(lng_sessions_header); data.activeWidth = st::sessionWhenFont->width(lang(lng_sessions_header)); int32 availForName = availCurrent - st::sessionPadding.right() - data.activeWidth; if (data.nameWidth > availForName) { data.name = st::sessionNameFont->elided(data.name, availForName); data.nameWidth = st::sessionNameFont->width(data.name); } data.infoWidth = st::sessionInfoFont->width(data.info); if (data.infoWidth > availCurrent) { data.info = st::sessionInfoFont->elided(data.info, availCurrent); data.infoWidth = st::sessionInfoFont->width(data.info); } data.ipWidth = st::sessionInfoFont->width(data.ip); if (data.ipWidth > availCurrent) { data.ip = st::sessionInfoFont->elided(data.ip, availCurrent); data.ipWidth = st::sessionInfoFont->width(data.ip); } _current = data; } else { QDateTime now(QDateTime::currentDateTime()), lastTime(date(active)); QDate nowDate(now.date()), lastDate(lastTime.date()); QString dt; if (lastDate == nowDate) { data.active = lastTime.toString(cTimeFormat()); } else if (lastDate.year() == nowDate.year() && lastDate.weekNumber() == nowDate.weekNumber()) { data.active = langDayOfWeek(lastDate); } else { data.active = lastDate.toString(qsl("d.MM.yy")); } data.activeWidth = st::sessionWhenFont->width(data.active); int32 availForName = availOther - st::sessionPadding.right() - data.activeWidth; if (data.nameWidth > availForName) { data.name = st::sessionNameFont->elided(data.name, availForName); data.nameWidth = st::sessionNameFont->width(data.name); } data.infoWidth = st::sessionInfoFont->width(data.info); if (data.infoWidth > availOther) { data.info = st::sessionInfoFont->elided(data.info, availOther); data.infoWidth = st::sessionInfoFont->width(data.info); } data.ipWidth = st::sessionInfoFont->width(data.ip); if (data.ipWidth > availOther) { data.ip = st::sessionInfoFont->elided(data.ip, availOther); data.ipWidth = st::sessionInfoFont->width(data.ip); } _list.push_back(data); for (int32 i = _list.size(); i > 1;) { --i; if (_list.at(i).activeTime > _list.at(i - 1).activeTime) { qSwap(_list[i], _list[i - 1]); } } } } _inner->listUpdated(); update(); _shortPollTimer->start(SessionsShortPollTimeout); }