Skip to content

Commit

Permalink
Adding a way for plugin config widgets to resize
Browse files Browse the repository at this point in the history
- Adding an event plugins can emit to indicate their geometry has changed
- Modifying the PCL2 plugin to use it as an example

Fixes swri-robotics#393
  • Loading branch information
pjreed committed Jul 6, 2016
1 parent 9101b53 commit 18adc52
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 219 deletions.
1 change: 1 addition & 0 deletions mapviz/include/mapviz/mapviz_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ namespace mapviz

Q_SIGNALS:
void DrawOrderChanged(int draw_order);
void SizeChanged();
void TargetFrameChanged(const std::string& target_frame);
void UseLatestTransformsChanged(bool use_latest_transforms);
void VisibleChanged(bool visible);
Expand Down
13 changes: 11 additions & 2 deletions mapviz/src/mapviz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@
#include <QMessageBox>
#include <QProcessEnvironment>
#include <QFileInfo>
#include <QListWidgetItem>

#include <swri_math_util/constants.h>
#include <swri_transform_util/frames.h>
#include <swri_yaml_util/yaml_util.h>

#include <mapviz/config_item.h>
#include <QtGui/QtGui>

namespace mapviz
{
Expand Down Expand Up @@ -1058,6 +1060,7 @@ MapvizPluginPtr Mapviz::CreateNewDisplay(
connect(config_item, SIGNAL(UpdateSizeHint()), this, SLOT(UpdateSizeHints()));
connect(config_item, SIGNAL(ToggledDraw(QListWidgetItem*, bool)), this, SLOT(ToggleShowPlugin(QListWidgetItem*, bool)));
connect(plugin.get(), SIGNAL(VisibleChanged(bool)), config_item, SLOT(ToggleDraw(bool)));
connect(plugin.get(), SIGNAL(SizeChanged()), this, SLOT(UpdateSizeHints()));

if (draw_order == 0)
{
Expand Down Expand Up @@ -1295,10 +1298,16 @@ void Mapviz::Screenshot()

void Mapviz::UpdateSizeHints()
{
ROS_INFO("Updating size hints");
for (int i = 0; i < ui_.configs->count(); i++)
{
ui_.configs->item(i)->setSizeHint(ui_.configs->itemWidget(ui_.configs->item(i))->sizeHint());
QListWidgetItem* item = ui_.configs->item(i);
ConfigItem* widget = static_cast<ConfigItem*>(ui_.configs->itemWidget(item));
if (widget) {
// Make sure the ConfigItem in the QListWidgetItem we're getting really
// exists; if this method is called before it's been initialized, it would
// cause a crash.
item->setSizeHint(widget->sizeHint());
}
}
}

Expand Down
1 change: 1 addition & 0 deletions mapviz_plugins/include/mapviz_plugins/pointcloud2_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ namespace mapviz_plugins
double PointFeature(const uint8_t*, const Field_info&);
void PointCloud2Callback(const sensor_msgs::PointCloud2ConstPtr& scan);
QColor CalculateColor(const StampedPoint& point);
void UpdateMinMaxWidgets();

Ui::PointCloud2_config ui_;
QWidget* config_widget_;
Expand Down
Loading

0 comments on commit 18adc52

Please sign in to comment.