add_display_dialog.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef RVIZ_ADD_DISPLAY_DIALOG_H
00031 #define RVIZ_ADD_DISPLAY_DIALOG_H
00032 
00033 #include <QDialog>
00034 #include <QTreeWidget>
00035 #include <QComboBox>
00036 
00037 #include <boost/shared_ptr.hpp>
00038 
00039 #include "rviz/factory.h"
00040 
00041 class QTextBrowser;
00042 class QLineEdit;
00043 class QDialogButtonBox;
00044 class QLabel;
00045 class QCheckBox;
00046 
00047 namespace rviz
00048 {
00049 
00050 class DisplayFactory;
00051 class Display;
00052 
00056 struct SelectionData {
00057   QString whats_this;
00058   QString lookup_name;
00059   QString display_name;
00060   QString topic;
00061   QString datatype;
00062 };
00063 
00064 class AddDisplayDialog : public QDialog
00065 {
00066 Q_OBJECT
00067 public:
00083   AddDisplayDialog( DisplayFactory* factory,
00084                     const QString& object_type,
00085                     const QStringList& disallowed_display_names,
00086                     const QStringList& disallowed_class_lookup_names,
00087                     QString* lookup_name_output,
00088                     QString* display_name_output = 0,
00089                     QString* topic_output = 0,
00090                     QString* datatype_output = 0,
00091                     QWidget* parent = 0 );
00092 
00093   virtual QSize sizeHint () const;
00094 
00095 public Q_SLOTS:
00096   virtual void accept();
00097 
00098 private Q_SLOTS:
00099   void onDisplaySelected( SelectionData *data);
00100   void onTopicSelected( SelectionData *data );
00101   void onTabChanged( int index );
00102   void onNameChanged();
00103 
00104 private:
00106   void fillTree( QTreeWidget* tree );
00107 
00110   bool isValid();
00111 
00114   void setError( const QString& error_text );
00115 
00117   void updateDisplay();
00118 
00119   Factory* factory_;
00120   const QStringList& disallowed_display_names_;
00121   const QStringList& disallowed_class_lookup_names_;
00122 
00123   QString* lookup_name_output_;
00124   QString* display_name_output_;
00125   QString* topic_output_;
00126   QString* datatype_output_;
00127 
00129   QTabWidget *tab_widget_;
00131   int topic_tab_;
00133   int display_tab_;
00135   SelectionData display_data_;
00137   SelectionData topic_data_;
00138 
00140   QTextBrowser* description_;
00141 
00142   QLineEdit* name_editor_;
00143 
00145   QDialogButtonBox* button_box_;
00146 
00149   QString lookup_name_;
00150 };
00151 
00152 
00154 class DisplayTypeTree : public QTreeWidget {
00155 Q_OBJECT
00156 public:
00157   DisplayTypeTree();
00158 
00159   void fillTree(Factory *factory);
00160 
00161 Q_SIGNALS:
00162   void itemChanged( SelectionData *selection );
00163 
00164 private Q_SLOTS:
00165   void onCurrentItemChanged(QTreeWidgetItem *curr, QTreeWidgetItem *prev);
00166 };
00167 
00169 class TopicDisplayWidget : public QWidget {
00170 Q_OBJECT
00171 public:
00172   TopicDisplayWidget();
00173   void fill(DisplayFactory *factory);
00174 
00175 Q_SIGNALS:
00176   void itemChanged( SelectionData *selection );
00177   void itemActivated( QTreeWidgetItem *item, int column );
00178 
00179 private Q_SLOTS:
00180   void stateChanged(int state);
00181   void onCurrentItemChanged( QTreeWidgetItem *curr );
00182   void onComboBoxClicked( QTreeWidgetItem *curr );
00183 
00184 private:
00185   void findPlugins( DisplayFactory* );
00186 
00192   QTreeWidgetItem* insertItem ( const QString &topic, bool disabled );
00193 
00194   QTreeWidget *tree_;
00195   QCheckBox *enable_hidden_box_;
00196 
00197   // Map from ROS topic type to all displays that can visualize it.
00198   // One key may have multiple values.
00199   QMap<QString, QString > datatype_plugins_;
00200 };
00201 
00207 class EmbeddableComboBox : public QComboBox
00208 {
00209   Q_OBJECT
00210 public:
00211   EmbeddableComboBox(QTreeWidgetItem *parent, int col)
00212     : parent_( parent ), column_(col)
00213   {
00214     connect(this, SIGNAL( activated( int )), this, SLOT( onActivated( int )));
00215   }
00216 
00217 Q_SIGNALS:
00218   void itemClicked( QTreeWidgetItem *item, int column );
00219 
00220 private Q_SLOTS:
00221   void onActivated( int index )
00222   {
00223     Q_EMIT itemClicked( parent_, column_ );
00224   }
00225 
00226 private:
00227   QTreeWidgetItem *parent_;
00228   int column_;
00229 };
00230 
00231 } //namespace rviz
00232 
00233 #endif // RVIZ_ADD_DISPLAY_DIALOG_H


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Tue Oct 3 2017 03:19:30