31 #include <QHBoxLayout> 32 #include <QVBoxLayout> 33 #include <QPushButton> 34 #include <QInputDialog> 35 #include <QApplication> 37 #include <boost/bind.hpp> 58 QPushButton* add_button =
new QPushButton(
"Add" );
59 add_button->setShortcut( QKeySequence( QString(
"Ctrl+N" )));
60 add_button->setToolTip(
"Add a new display, Ctrl+N" );
74 QHBoxLayout* button_layout =
new QHBoxLayout;
75 button_layout->addWidget( add_button );
79 button_layout->setContentsMargins( 2, 0, 2, 2 );
81 QVBoxLayout* layout =
new QVBoxLayout;
82 layout->setContentsMargins( 0, 0, 0, 2 );
84 layout->addLayout( button_layout );
88 connect( add_button, SIGNAL( clicked(
bool )),
this, SLOT(
onNewDisplay() ));
107 QString display_name;
113 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
121 QApplication::restoreOverrideCursor();
124 if( dialog->exec() == QDialog::Accepted )
127 if ( !topic.isEmpty() && !datatype.isEmpty() )
141 QList<Display*> duplicated_displays;
143 for(
int i = 0; i < displays_to_duplicate.size(); i++ )
146 QString lookup_name = displays_to_duplicate[ i ]->
getClassId();
147 QString display_name = displays_to_duplicate[ i ]->getName();
151 displays_to_duplicate[ i ]->save(config);
153 duplicated_displays.push_back(disp);
156 if (duplicated_displays.size() > 0) {
159 QItemSelection selection(first, last);
160 property_grid_->selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect);
170 QModelIndex new_selected;
172 for(
int i = 0; i < displays_to_delete.size(); i++ )
177 new_selected = first.sibling(first.row() - 1, first.column());
181 displays_to_delete[ i ]->disconnect();
183 displays_to_delete[ i ]->deleteLater();
186 QItemSelection selection(new_selected, new_selected);
187 property_grid_->selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect);
196 int num_displays_selected = displays.size();
206 if( displays.size() == 0 )
210 Display* display_to_rename = displays[ 0 ];
212 if( !display_to_rename )
217 QString old_name = display_to_rename->
getName();
218 QString new_name = QInputDialog::getText(
this,
"Rename Display",
"New Name?", QLineEdit::Normal, old_name );
220 if( new_name.isEmpty() || new_name == old_name )
225 display_to_rename->
setName( new_name );
QPushButton * duplicate_button_
VisualizationManager * vis_manager_
PropertyTreeWidget * getTree()
virtual void save(Config config) const
Write state to the given Config object.
Display * createDisplay(const QString &class_lookup_name, const QString &name, bool enabled)
Create and add a display to this panel, by class lookup name.
void onDeleteDisplay()
Called when the "Remove" button is pressed.
virtual void setTopic(const QString &topic, const QString &datatype)
Set the ROS topic to listen to for this display.
void onNewDisplay()
Called when the "Add" button is pressed.
DisplaysPanel(QWidget *parent=0)
virtual void load(const Config &config)
Read state from the given Config.
Configuration data storage class.
QModelIndex indexOf(Property *property) const
void save(Config config) const
Write state to the given Config.
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
QPushButton * remove_button_
void onRenameDisplay()
Called when the "Rename" button is pressed.
PropertyTreeWithHelp * tree_with_help_
void onSelectionChanged()
virtual DisplayFactory * getDisplayFactory() const
Return a factory for creating Display subclasses based on a class id string.
PropertyTreeModel * getDisplayTreeModel() const
virtual void load(const Config &config)
Load the settings for this display from the given Config node, which must be a map.
QPushButton * rename_button_
void setName(const QString &name)
Overridden from Property to set associated widget title to the new name.
PropertyTreeWidget * property_grid_
void load(const Config &config)
Read state from the given Config.
void notifyConfigChanged()
Notify this VisualizationManager that something about its display configuration has changed...
virtual void save(Config config) const
Override to save configuration data. This version saves the name and class ID of the panel...
virtual void load(const Config &config)
Override to load configuration data. This version loads the name of the panel.
void onDuplicateDisplay()
Called when the "copy" button is pressed.
virtual void onInitialize()
void startUpdate()
Start timers. Creates and starts the update and idle timers, both set to 30Hz (33ms).
virtual QString getName() const
Return the name of this Property as a QString.