select_service_dialog.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2015, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL Southwest Research Institute® BE LIABLE
21 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 //
29 // *****************************************************************************
30 
31 #ifndef MAPVIZ_SELECT_SERVICE_DIALOG_H
32 #define MAPVIZ_SELECT_SERVICE_DIALOG_H
33 
34 #include <set>
35 #include <vector>
36 
37 #include <boost/shared_ptr.hpp>
38 
39 #include <QDialog>
40 #include <QMetaType>
41 #include <QThread>
42 
43 #include <ros/ros.h>
44 
45 QT_BEGIN_NAMESPACE
46 class QLineEdit;
47 class QListWidget;
48 class QPushButton;
49 QT_END_NAMESPACE
50 
51 // This is ugly, but necessary in order to be able to send a std::vector<std::string>
52 // via a queued signal/slot connection.
53 typedef std::vector<std::string> ServiceStringVector;
55 
56 namespace mapviz
57 {
62  class ServiceUpdaterThread : public QThread
63  {
64  Q_OBJECT
65  public:
66  ServiceUpdaterThread(ros::NodeHandle& nh, const std::string& allowed_datatype, QObject* parent) :
67  QThread(parent),
68  nh_(nh),
69  allowed_datatype_(allowed_datatype)
70  {
71  }
72  void run();
73 
74  Q_SIGNALS:
75  void servicesFetched(ServiceStringVector services);
76  void fetchingFailed(const QString error_msg);
77 
78  private:
80  const std::string& allowed_datatype_;
81  };
82 
87  class SelectServiceDialog : public QDialog
88  {
89  Q_OBJECT
90  public:
100  static std::string selectService(const std::string& datatype, QWidget* parent=0);
101 
109  SelectServiceDialog(const std::string& datatype = "", QWidget* parent=0);
110  virtual ~SelectServiceDialog();
111 
118  void setDatatypeFilter(const std::string& datatype);
119 
125  std::string selectedService() const;
126 
127  private Q_SLOTS:
132  void fetchServices();
137  void updateDisplayedServices();
141  void updateKnownServices(ServiceStringVector services);
146  void displayUpdateError(const QString);
147 
148  private:
149  std::vector<std::string> filterServices();
150  void timerEvent(QTimerEvent *);
151  void closeEvent(QCloseEvent *);
152 
154 
155  std::string allowed_datatype_;
156  std::vector<std::string> displayed_services_;
157  std::vector<std::string> known_services_;
158 
160 
161  QPushButton *cancel_button_;
162  QListWidget *list_widget_;
163  QLineEdit *name_filter_;
164  QPushButton *ok_button_;
166  };
167 }
168 
169 #endif //MAPVIZ_SELECT_SERVICE_DIALOG_H
std::vector< std::string > known_services_
void servicesFetched(ServiceStringVector services)
const std::string & allowed_datatype_
const char * datatype()
std::vector< std::string > displayed_services_
boost::shared_ptr< ServiceUpdaterThread > worker_thread_
QT_END_NAMESPACE typedef std::vector< std::string > ServiceStringVector
Q_DECLARE_METATYPE(ServiceStringVector)
ServiceUpdaterThread(ros::NodeHandle &nh, const std::string &allowed_datatype, QObject *parent)
void fetchingFailed(const QString error_msg)


mapviz
Author(s): Marc Alban
autogenerated on Fri Dec 16 2022 03:59:30