ProgressWidget.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2015 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
19 #include <ros/package.h>
20 
21 #include <ui_ProgressWidget.h>
22 
24 
25 namespace rqt_multiplot {
26 
27 /*****************************************************************************/
28 /* Constructors and Destructor */
29 /*****************************************************************************/
30 
32  QWidget(parent),
33  ui_(new Ui::ProgressWidget()),
34  started_(false) {
35  ui_->setupUi(this);
36 
37  ui_->progressBar->setMinimum(0);
38  ui_->progressBar->setMaximum(100);
39  ui_->progressBar->setValue(0);
40 
41  ui_->widgetStatus->setIcon(StatusWidget::Okay,
42  QPixmap(QString::fromStdString(ros::package::getPath("rqt_multiplot").
43  append("/resource/16x16/okay.png"))));
44  ui_->widgetStatus->setIcon(StatusWidget::Error,
45  QPixmap(QString::fromStdString(ros::package::getPath("rqt_multiplot").
46  append("/resource/16x16/error.png"))));
47  ui_->widgetStatus->setFrames(StatusWidget::Busy,
48  QPixmap(QString::fromStdString(ros::package::getPath("rqt_multiplot").
49  append("/resource/16x16/busy.png"))), 8);
50 }
51 
53  delete ui_;
54 }
55 
56 /*****************************************************************************/
57 /* Accessors */
58 /*****************************************************************************/
59 
60 void ProgressWidget::setCurrentProgress(double progress) {
61  if (started_)
62  ui_->progressBar->setValue(progress*1e2);
63 }
64 
66  if (started_)
67  return ui_->progressBar->value()*1e-2;
68 }
69 
71  return started_;
72 }
73 
74 /*****************************************************************************/
75 /* Methods */
76 /*****************************************************************************/
77 
78 void ProgressWidget::start(const QString& toolTip) {
79  if (!started_) {
80  ui_->widgetStatus->setCurrentRole(StatusWidget::Busy, toolTip);
81 
82  ui_->progressBar->reset();
83  ui_->progressBar->setTextVisible(true);
84 
85  started_ = true;
86  }
87 }
88 
89 void ProgressWidget::finish(const QString& toolTip) {
90  if (started_) {
91  ui_->widgetStatus->setCurrentRole(StatusWidget::Okay, toolTip);
92 
93  ui_->progressBar->reset();
94  ui_->progressBar->setTextVisible(false);
95 
96  started_ = false;
97  }
98 }
99 
100 void ProgressWidget::fail(const QString& toolTip) {
101  if (started_) {
102  ui_->widgetStatus->setCurrentRole(StatusWidget::Error, toolTip);
103 
104  ui_->progressBar->reset();
105  ui_->progressBar->setTextVisible(false);
106 
107  started_ = false;
108  }
109 }
110 
111 }
ProgressWidget(QWidget *parent=0)
void setCurrentProgress(double progress)
Ui::ProgressWidget * ui_
void fail(const QString &toolTip=QString())
ROSLIB_DECL std::string getPath(const std::string &package_name)
void start(const QString &toolTip=QString())
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
void finish(const QString &toolTip=QString())


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Wed Jul 10 2019 03:49:44