add_display_dialog.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
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 the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * 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 THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef RVIZ_ADD_DISPLAY_DIALOG_H
31 #define RVIZ_ADD_DISPLAY_DIALOG_H
32 
33 #include <QDialog>
34 #include <QTreeWidget>
35 #include <QComboBox>
36 
37 #include <boost/shared_ptr.hpp>
38 
39 #include "rviz/factory.h"
40 
41 class QTextBrowser;
42 class QLineEdit;
43 class QDialogButtonBox;
44 class QLabel;
45 class QCheckBox;
46 
47 namespace rviz
48 {
49 
50 class DisplayFactory;
51 class Display;
52 
56 struct SelectionData {
57  QString whats_this;
58  QString lookup_name;
59  QString display_name;
60  QString topic;
61  QString datatype;
62 };
63 
64 class AddDisplayDialog : public QDialog
65 {
66 Q_OBJECT
67 public:
84  const QString& object_type,
85  const QStringList& disallowed_display_names,
86  const QStringList& disallowed_class_lookup_names,
87  QString* lookup_name_output,
88  QString* display_name_output = 0,
89  QString* topic_output = 0,
90  QString* datatype_output = 0,
91  QWidget* parent = 0 );
92 
93  virtual QSize sizeHint () const;
94 
95 public Q_SLOTS:
96  virtual void accept();
97 
98 private Q_SLOTS:
99  void onDisplaySelected( SelectionData *data);
100  void onTopicSelected( SelectionData *data );
101  void onTabChanged( int index );
102  void onNameChanged();
103 
104 private:
106  void fillTree( QTreeWidget* tree );
107 
110  bool isValid();
111 
114  void setError( const QString& error_text );
115 
117  void updateDisplay();
118 
120  const QStringList& disallowed_display_names_;
121  const QStringList& disallowed_class_lookup_names_;
122 
125  QString* topic_output_;
127 
129  QTabWidget *tab_widget_;
138 
140  QTextBrowser* description_;
141 
142  QLineEdit* name_editor_;
143 
145  QDialogButtonBox* button_box_;
146 
149  QString lookup_name_;
150 };
151 
152 
154 class DisplayTypeTree : public QTreeWidget {
155 Q_OBJECT
156 public:
157  DisplayTypeTree();
158 
159  void fillTree(Factory *factory);
160 
161 Q_SIGNALS:
162  void itemChanged( SelectionData *selection );
163 
164 private Q_SLOTS:
165  void onCurrentItemChanged(QTreeWidgetItem *curr, QTreeWidgetItem *prev);
166 };
167 
169 class TopicDisplayWidget : public QWidget {
170 Q_OBJECT
171 public:
173  void fill(DisplayFactory *factory);
174 
175 Q_SIGNALS:
176  void itemChanged( SelectionData *selection );
177  void itemActivated( QTreeWidgetItem *item, int column );
178 
179 private Q_SLOTS:
180  void stateChanged(int state);
181  void onCurrentItemChanged( QTreeWidgetItem *curr );
182  void onComboBoxClicked( QTreeWidgetItem *curr );
183 
184 private:
185  void findPlugins( DisplayFactory* );
186 
192  QTreeWidgetItem* insertItem ( const QString &topic, bool disabled );
193 
194  QTreeWidget *tree_;
195  QCheckBox *enable_hidden_box_;
196 
197  // Map from ROS topic type to all displays that can visualize it.
198  // One key may have multiple values.
199  QMap<QString, QString > datatype_plugins_;
200 };
201 
207 class EmbeddableComboBox : public QComboBox
208 {
209  Q_OBJECT
210 public:
211  EmbeddableComboBox(QTreeWidgetItem *parent, int col)
212  : parent_( parent ), column_(col)
213  {
214  connect(this, SIGNAL( activated( int )), this, SLOT( onActivated( int )));
215  }
216 
217 Q_SIGNALS:
218  void itemClicked( QTreeWidgetItem *item, int column );
219 
220 private Q_SLOTS:
221  void onActivated( int index )
222  {
223  Q_EMIT itemClicked( parent_, column_ );
224  }
225 
226 private:
227  QTreeWidgetItem *parent_;
228  int column_;
229 };
230 
231 } //namespace rviz
232 
233 #endif // RVIZ_ADD_DISPLAY_DIALOG_H
EmbeddableComboBox(QTreeWidgetItem *parent, int col)
const QStringList & disallowed_class_lookup_names_
const QStringList & disallowed_display_names_
Widget for selecting a display by topic.
tree
QMap< QString, QString > datatype_plugins_
Abstract superclass representing the ability to get a list of class IDs and the ability to get name...
Definition: factory.h:43
Widget for selecting a display by display type.
QDialogButtonBox * button_box_


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Wed Aug 28 2019 04:01:50