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 class DisplayFactory;
50 class Display;
51 
56 {
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 = nullptr,
89  QString* topic_output = nullptr,
90  QString* datatype_output = nullptr,
91  QWidget* parent = nullptr);
92 
93  QSize sizeHint() const override;
94 
95 public Q_SLOTS:
96  void accept() override;
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 {
156  Q_OBJECT
157 public:
158  DisplayTypeTree();
159 
160  void fillTree(Factory* factory);
161 
162 Q_SIGNALS:
163  void itemChanged(SelectionData* selection);
164 
165 private Q_SLOTS:
166  void onCurrentItemChanged(QTreeWidgetItem* curr, QTreeWidgetItem* prev);
167 };
168 
170 class TopicDisplayWidget : public QWidget
171 {
172  Q_OBJECT
173 public:
175  void fill(DisplayFactory* factory);
176 
177 Q_SIGNALS:
178  void itemChanged(SelectionData* selection);
179  void itemActivated(QTreeWidgetItem* item, int column);
180 
181 private Q_SLOTS:
182  void stateChanged(int state);
183  void onCurrentItemChanged(QTreeWidgetItem* curr);
184  void onComboBoxClicked(QTreeWidgetItem* curr);
185 
186 private:
187  void findPlugins(DisplayFactory* factory);
188 
194  QTreeWidgetItem* insertItem(const QString& topic, bool disabled);
195 
196  QTreeWidget* tree_;
197  QCheckBox* enable_hidden_box_;
198 
199  // Map from ROS topic type to all displays that can visualize it.
200  // One key may have multiple values.
201  QMap<QString, QString> datatype_plugins_;
202 };
203 
209 class EmbeddableComboBox : public QComboBox
210 {
211  Q_OBJECT
212 public:
213  EmbeddableComboBox(QTreeWidgetItem* parent, int col) : parent_(parent), column_(col)
214  {
215  connect(this, SIGNAL(activated(int)), this, SLOT(onActivated(int)));
216  }
217 
218 Q_SIGNALS:
219  void itemClicked(QTreeWidgetItem* item, int column);
220 
221 private Q_SLOTS:
222  void onActivated(int /*index*/)
223  {
224  Q_EMIT itemClicked(parent_, column_);
225  }
226 
227 private:
228  QTreeWidgetItem* parent_;
229  int column_;
230 };
231 
232 } // namespace rviz
233 
234 #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:42
Widget for selecting a display by display type.
QDialogButtonBox * button_box_


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:24