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  QMultiMap<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, qOverload<int>(&QComboBox::activated), this, [this] { itemClicked(parent_, column_); });
216  }
217 
218 Q_SIGNALS:
219  void itemClicked(QTreeWidgetItem* item, int column);
220 
221 private:
222  QTreeWidgetItem* parent_;
223  int column_;
224 };
225 
226 } // namespace rviz
227 
228 #endif // RVIZ_ADD_DISPLAY_DIALOG_H
rviz::AddDisplayDialog::onNameChanged
void onNameChanged()
Definition: add_display_dialog.cpp:338
rviz::AddDisplayDialog::topic_data_
SelectionData topic_data_
Definition: add_display_dialog.h:137
rviz::TopicDisplayWidget
Widget for selecting a display by topic.
Definition: add_display_dialog.h:170
factory.h
rviz::AddDisplayDialog::onDisplaySelected
void onDisplaySelected(SelectionData *data)
Definition: add_display_dialog.cpp:264
rviz::TopicDisplayWidget::itemChanged
void itemChanged(SelectionData *selection)
rviz::SelectionData
Definition: add_display_dialog.h:55
rviz::AddDisplayDialog::display_data_
SelectionData display_data_
Definition: add_display_dialog.h:135
rviz::AddDisplayDialog::sizeHint
QSize sizeHint() const override
Definition: add_display_dialog.cpp:254
rviz::AddDisplayDialog::topic_output_
QString * topic_output_
Definition: add_display_dialog.h:125
rviz::DisplayTypeTree::fillTree
void fillTree(Factory *factory)
Definition: add_display_dialog.cpp:376
rviz::DisplayTypeTree
Widget for selecting a display by display type.
Definition: add_display_dialog.h:154
rviz::SelectionData::whats_this
QString whats_this
Definition: add_display_dialog.h:57
rviz::AddDisplayDialog::isValid
bool isValid()
Definition: add_display_dialog.cpp:308
rviz::SelectionData::datatype
QString datatype
Definition: add_display_dialog.h:61
rviz::AddDisplayDialog::description_
QTextBrowser * description_
Definition: add_display_dialog.h:140
rviz::EmbeddableComboBox::EmbeddableComboBox
EmbeddableComboBox(QTreeWidgetItem *parent, int col)
Definition: add_display_dialog.h:213
rviz::AddDisplayDialog::topic_tab_
int topic_tab_
Definition: add_display_dialog.h:131
rviz::AddDisplayDialog::fillTree
void fillTree(QTreeWidget *tree)
rviz::AddDisplayDialog::lookup_name_output_
QString * lookup_name_output_
Definition: add_display_dialog.h:123
tree
tree
rviz::AddDisplayDialog::onTopicSelected
void onTopicSelected(SelectionData *data)
Definition: add_display_dialog.cpp:270
rviz::AddDisplayDialog::tab_widget_
QTabWidget * tab_widget_
Definition: add_display_dialog.h:129
rviz::TopicDisplayWidget::enable_hidden_box_
QCheckBox * enable_hidden_box_
Definition: add_display_dialog.h:197
rviz::SelectionData::lookup_name
QString lookup_name
Definition: add_display_dialog.h:58
rviz::SelectionData::display_name
QString display_name
Definition: add_display_dialog.h:59
rviz::TopicDisplayWidget::TopicDisplayWidget
TopicDisplayWidget()
Definition: add_display_dialog.cpp:421
rviz::AddDisplayDialog::name_editor_
QLineEdit * name_editor_
Definition: add_display_dialog.h:142
rviz
Definition: add_display_dialog.cpp:54
rviz::AddDisplayDialog::updateDisplay
void updateDisplay()
Definition: add_display_dialog.cpp:276
rviz::AddDisplayDialog::onTabChanged
void onTabChanged(int index)
Definition: add_display_dialog.cpp:259
rviz::TopicDisplayWidget::onComboBoxClicked
void onComboBoxClicked(QTreeWidgetItem *curr)
Definition: add_display_dialog.cpp:480
rviz::SelectionData::topic
QString topic
Definition: add_display_dialog.h:60
rviz::TopicDisplayWidget::onCurrentItemChanged
void onCurrentItemChanged(QTreeWidgetItem *curr)
Definition: add_display_dialog.cpp:449
rviz::AddDisplayDialog::button_box_
QDialogButtonBox * button_box_
Definition: add_display_dialog.h:145
rviz::AddDisplayDialog
Definition: add_display_dialog.h:64
rviz::TopicDisplayWidget::itemActivated
void itemActivated(QTreeWidgetItem *item, int column)
rviz::EmbeddableComboBox
Definition: add_display_dialog.h:209
rviz::DisplayTypeTree::onCurrentItemChanged
void onCurrentItemChanged(QTreeWidgetItem *curr, QTreeWidgetItem *prev)
Definition: add_display_dialog.cpp:362
rviz::AddDisplayDialog::disallowed_display_names_
const QStringList & disallowed_display_names_
Definition: add_display_dialog.h:120
rviz::AddDisplayDialog::display_tab_
int display_tab_
Definition: add_display_dialog.h:133
rviz::AddDisplayDialog::display_name_output_
QString * display_name_output_
Definition: add_display_dialog.h:124
rviz::DisplayFactory
Definition: display_factory.h:42
rviz::DisplayTypeTree::DisplayTypeTree
DisplayTypeTree()
Definition: add_display_dialog.cpp:356
rviz::EmbeddableComboBox::itemClicked
void itemClicked(QTreeWidgetItem *item, int column)
rviz::AddDisplayDialog::lookup_name_
QString lookup_name_
Definition: add_display_dialog.h:149
rviz::EmbeddableComboBox::column_
int column_
Definition: add_display_dialog.h:223
rviz::AddDisplayDialog::factory_
Factory * factory_
Definition: add_display_dialog.h:119
rviz::TopicDisplayWidget::insertItem
QTreeWidgetItem * insertItem(const QString &topic, bool disabled)
Definition: add_display_dialog.cpp:571
rviz::AddDisplayDialog::accept
void accept() override
Definition: add_display_dialog.cpp:343
rviz::EmbeddableComboBox::parent_
QTreeWidgetItem * parent_
Definition: add_display_dialog.h:222
rviz::TopicDisplayWidget::tree_
QTreeWidget * tree_
Definition: add_display_dialog.h:196
rviz::Factory
Abstract superclass representing the ability to get a list of class IDs and the ability to get name,...
Definition: factory.h:42
rviz::AddDisplayDialog::AddDisplayDialog
AddDisplayDialog(DisplayFactory *factory, const QString &object_type, const QStringList &disallowed_display_names, const QStringList &disallowed_class_lookup_names, QString *lookup_name_output, QString *display_name_output=nullptr, QString *topic_output=nullptr, QString *datatype_output=nullptr, QWidget *parent=nullptr)
Definition: add_display_dialog.cpp:167
rviz::TopicDisplayWidget::stateChanged
void stateChanged(int state)
Definition: add_display_dialog.cpp:485
rviz::AddDisplayDialog::datatype_output_
QString * datatype_output_
Definition: add_display_dialog.h:126
rviz::DisplayTypeTree::itemChanged
void itemChanged(SelectionData *selection)
rviz::TopicDisplayWidget::findPlugins
void findPlugins(DisplayFactory *)
Definition: add_display_dialog.cpp:551
rviz::TopicDisplayWidget::fill
void fill(DisplayFactory *factory)
Definition: add_display_dialog.cpp:496
rviz::AddDisplayDialog::setError
void setError(const QString &error_text)
Definition: add_display_dialog.cpp:333
rviz::TopicDisplayWidget::datatype_plugins_
QMultiMap< QString, QString > datatype_plugins_
Definition: add_display_dialog.h:201
rviz::AddDisplayDialog::disallowed_class_lookup_names_
const QStringList & disallowed_class_lookup_names_
Definition: add_display_dialog.h:121


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:09