31 #include <QHBoxLayout> 32 #include <QVBoxLayout> 33 #include <QPushButton> 34 #include <QInputDialog> 35 #include <QApplication> 36 #include <QProgressDialog> 38 #include <boost/bind.hpp> 57 QPushButton* add_button =
new QPushButton(
"Add");
58 add_button->setShortcut(QKeySequence(QString(
"Ctrl+N")));
59 add_button->setToolTip(
"Add a new display, Ctrl+N");
73 QHBoxLayout* button_layout =
new QHBoxLayout;
74 button_layout->addWidget(add_button);
78 button_layout->setContentsMargins(2, 0, 2, 2);
80 QVBoxLayout* layout =
new QVBoxLayout;
81 layout->setContentsMargins(0, 0, 0, 2);
83 layout->addLayout(button_layout);
87 connect(add_button, SIGNAL(clicked(
bool)),
this, SLOT(
onNewDisplay()));
106 QString display_name;
112 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
114 &display_name, &topic, &datatype);
115 QApplication::restoreOverrideCursor();
118 if (dialog.exec() == QDialog::Accepted)
121 if (!topic.isEmpty() && !datatype.isEmpty())
133 QList<Display*> duplicated_displays;
134 QProgressDialog progress_dlg(
"Duplicating displays...",
"Cancel", 0, displays_to_duplicate.size(),
137 progress_dlg.setWindowModality(Qt::WindowModal);
139 QApplication::processEvents();
142 for (
int i = 0; i < displays_to_duplicate.size(); i++)
145 QString lookup_name = displays_to_duplicate[i]->getClassId();
146 QString display_name = displays_to_duplicate[i]->getName();
150 displays_to_duplicate[i]->save(config);
152 duplicated_displays.push_back(disp);
153 progress_dlg.setValue(i + 1);
154 QApplication::processEvents();
156 if (progress_dlg.wasCanceled())
160 if (!duplicated_displays.empty())
164 QItemSelection selection(first, last);
165 property_grid_->selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect);
175 for (
int i = 0; i < displays_to_delete.size(); i++)
179 displays_to_delete[i]->disconnect();
183 displays_to_delete[i]->deleteLater();
187 QItemSelection selection(cur.sibling(cur.row(), 0),
188 cur.sibling(cur.row(), cur.model()->columnCount() - 1));
189 property_grid_->selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect);
198 int num_displays_selected = displays.size();
208 if (displays.empty())
212 Display* display_to_rename = displays[0];
214 if (!display_to_rename)
219 QString old_name = display_to_rename->
getName();
221 QInputDialog::getText(
this,
"Rename Display",
"New Name?", QLineEdit::Normal, old_name);
223 if (new_name.isEmpty() || new_name == old_name)
228 display_to_rename->
setName(new_name);
QPushButton * duplicate_button_
VisualizationManager * vis_manager_
PropertyTreeWidget * getTree()
~DisplaysPanel() override
Property * getParent() const
Return the parent Property.
void load(const Config &config) override
Read state from the given Config.
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.
void load(const Config &config) override
Load the settings for this display from the given Config node, which must be a map.
virtual void save(Config config) const
Override to save configuration data. This version saves the name and class ID of the panel...
Property * takeChild(Property *child)
Remove a given child object and return a pointer to it.
void save(Config config) const
Write state to the given Config.
Configuration data storage class.
PropertyTreeModel * getDisplayTreeModel() const
void onInitialize() override
QPushButton * remove_button_
void onRenameDisplay()
Called when the "Rename" button is pressed.
virtual QString getName() const
Return the name of this Property as a QString.
PropertyTreeWithHelp * tree_with_help_
void onSelectionChanged()
QModelIndex indexOf(Property *property) const
DisplaysPanel(QWidget *parent=nullptr)
QPushButton * rename_button_
void save(Config config) const override
Write state to the given Config object.
PropertyTreeWidget * property_grid_
void load(const Config &config)
Read state from the given Config.
void setName(const QString &name) override
Overridden from Property to set associated widget title to the new name.
void notifyConfigChanged()
Notify this VisualizationManager that something about its display configuration has changed...
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.
void startUpdate()
Start timers. Creates and starts the update and idle timers, both set to 30Hz (33ms).
DisplayFactory * getDisplayFactory() const override
Return a factory for creating Display subclasses based on a class id string.