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  return 0.0;
69 }
70 
72  return started_;
73 }
74 
75 /*****************************************************************************/
76 /* Methods */
77 /*****************************************************************************/
78 
79 void ProgressWidget::start(const QString& toolTip) {
80  if (!started_) {
81  ui_->widgetStatus->setCurrentRole(StatusWidget::Busy, toolTip);
82 
83  ui_->progressBar->reset();
84  ui_->progressBar->setTextVisible(true);
85 
86  started_ = true;
87  }
88 }
89 
90 void ProgressWidget::finish(const QString& toolTip) {
91  if (started_) {
92  ui_->widgetStatus->setCurrentRole(StatusWidget::Okay, toolTip);
93 
94  ui_->progressBar->reset();
95  ui_->progressBar->setTextVisible(false);
96 
97  started_ = false;
98  }
99 }
100 
101 void ProgressWidget::fail(const QString& toolTip) {
102  if (started_) {
103  ui_->widgetStatus->setCurrentRole(StatusWidget::Error, toolTip);
104 
105  ui_->progressBar->reset();
106  ui_->progressBar->setTextVisible(false);
107 
108  started_ = false;
109  }
110 }
111 
112 }
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_plugin
Author(s): Ralf Kaestner
autogenerated on Fri Jan 15 2021 03:47:53