ProgressWidget.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2015 by Ralf Kaestner                                        *
00003  * ralf.kaestner@gmail.com                                                    *
00004  *                                                                            *
00005  * This program is free software; you can redistribute it and/or modify       *
00006  * it under the terms of the Lesser GNU General Public License as published by*
00007  * the Free Software Foundation; either version 3 of the License, or          *
00008  * (at your option) any later version.                                        *
00009  *                                                                            *
00010  * This program is distributed in the hope that it will be useful,            *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               *
00013  * Lesser GNU General Public License for more details.                        *
00014  *                                                                            *
00015  * You should have received a copy of the Lesser GNU General Public License   *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.       *
00017  ******************************************************************************/
00018 
00019 #include <ros/package.h>
00020 
00021 #include <ui_ProgressWidget.h>
00022 
00023 #include "rqt_multiplot/ProgressWidget.h"
00024 
00025 namespace rqt_multiplot {
00026 
00027 /*****************************************************************************/
00028 /* Constructors and Destructor                                               */
00029 /*****************************************************************************/
00030 
00031 ProgressWidget::ProgressWidget(QWidget* parent) :
00032   QWidget(parent),
00033   ui_(new Ui::ProgressWidget()),
00034   started_(false) {
00035   ui_->setupUi(this);
00036   
00037   ui_->progressBar->setMinimum(0);
00038   ui_->progressBar->setMaximum(100);
00039   ui_->progressBar->setValue(0);
00040   
00041   ui_->widgetStatus->setIcon(StatusWidget::Okay,
00042     QPixmap(QString::fromStdString(ros::package::getPath("rqt_multiplot").
00043     append("/resource/16x16/okay.png"))));
00044   ui_->widgetStatus->setIcon(StatusWidget::Error,
00045     QPixmap(QString::fromStdString(ros::package::getPath("rqt_multiplot").
00046     append("/resource/16x16/error.png"))));
00047   ui_->widgetStatus->setFrames(StatusWidget::Busy,
00048     QPixmap(QString::fromStdString(ros::package::getPath("rqt_multiplot").
00049     append("/resource/16x16/busy.png"))), 8);
00050 }
00051 
00052 ProgressWidget::~ProgressWidget() {
00053   delete ui_;
00054 }
00055 
00056 /*****************************************************************************/
00057 /* Accessors                                                                 */
00058 /*****************************************************************************/
00059 
00060 void ProgressWidget::setCurrentProgress(double progress) {
00061   if (started_)
00062     ui_->progressBar->setValue(progress*1e2);
00063 }
00064 
00065 double ProgressWidget::getCurrentProgress() const {
00066   if (started_)
00067     return ui_->progressBar->value()*1e-2;
00068 }
00069 
00070 bool ProgressWidget::isStarted() const {
00071   return started_;
00072 }
00073 
00074 /*****************************************************************************/
00075 /* Methods                                                                   */
00076 /*****************************************************************************/
00077 
00078 void ProgressWidget::start(const QString& toolTip) {
00079   if (!started_) {
00080     ui_->widgetStatus->setCurrentRole(StatusWidget::Busy, toolTip);
00081     
00082     ui_->progressBar->reset();
00083     ui_->progressBar->setTextVisible(true);
00084     
00085     started_ = true;
00086   }
00087 }
00088 
00089 void ProgressWidget::finish(const QString& toolTip) {
00090   if (started_) {
00091     ui_->widgetStatus->setCurrentRole(StatusWidget::Okay, toolTip);
00092     
00093     ui_->progressBar->reset();
00094     ui_->progressBar->setTextVisible(false);
00095     
00096     started_ = false;
00097   }
00098 }
00099 
00100 void ProgressWidget::fail(const QString& toolTip) {
00101   if (started_) {
00102     ui_->widgetStatus->setCurrentRole(StatusWidget::Error, toolTip);  
00103     
00104     ui_->progressBar->reset();
00105     ui_->progressBar->setTextVisible(false);
00106     
00107     started_ = false;
00108   }
00109 }
00110 
00111 }


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Tue May 9 2017 02:16:02