Skip to content

Commit

Permalink
Merge pull request #878 from mqcmd196/PR/Plotter2D/plot_text_size
Browse files Browse the repository at this point in the history
[jsk_rviz_plugins][Plotter2D] add option to control text size in plot
  • Loading branch information
k-okada authored Jan 16, 2024
2 parents 3694e5b + eacb0e6 commit 3e36a62
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
29 changes: 28 additions & 1 deletion jsk_rviz_plugins/src/plotter_2d_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ namespace jsk_rviz_plugins
text_size_property_ = new rviz::IntProperty("text size", 12,
"text size of the caption",
this, SLOT(updateTextSize()));
auto_text_size_in_plot_property_ = new rviz::BoolProperty("auto text size in plot", true,
"automatiacally adjust text size of the value in plot",
this, SLOT(updateAutoTextSizeInPlot()));
text_size_in_plot_property_ = new rviz::IntProperty("text size in plot", 12,
"text size of the value in plot",
this, SLOT(updateTextSizeInPlot()));
text_size_property_->setMin(1);
text_size_property_->setMax(1000);
show_caption_property_ = new rviz::BoolProperty(
Expand Down Expand Up @@ -208,6 +214,8 @@ namespace jsk_rviz_plugins
updateAutoScale();
updateMinValue();
updateMaxValue();
updateTextSizeInPlot();
updateAutoTextSizeInPlot();
overlay_->updateTextureSize(width_property_->getInt(),
height_property_->getInt() + caption_offset_);
}
Expand Down Expand Up @@ -293,7 +301,11 @@ namespace jsk_rviz_plugins
}
if (show_value_) {
QFont font = painter.font();
font.setPointSize(w / 4);
if (auto_text_size_in_plot_) {
font.setPointSize(w / 4);
} else {
font.setPointSize(text_size_in_plot_);
}
font.setBold(true);
painter.setFont(font);
std::ostringstream ss;
Expand Down Expand Up @@ -534,6 +546,21 @@ namespace jsk_rviz_plugins
updateMaxValue();
}

void Plotter2DDisplay::updateAutoTextSizeInPlot(){
auto_text_size_in_plot_ = auto_text_size_in_plot_property_->getBool();
if (auto_text_size_in_plot_) {
text_size_in_plot_property_->hide();
}
else {
text_size_in_plot_property_->show();
}
updateTextSizeInPlot();
}

void Plotter2DDisplay::updateTextSizeInPlot(){
text_size_in_plot_ = text_size_in_plot_property_->getInt();
}

bool Plotter2DDisplay::isInRegion(int x, int y)
{
return (top_ < y && top_ + texture_height_ > y &&
Expand Down
9 changes: 8 additions & 1 deletion jsk_rviz_plugins/src/plotter_2d_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ namespace jsk_rviz_plugins
rviz::BoolProperty* auto_scale_property_;
rviz::FloatProperty* max_value_property_;
rviz::FloatProperty* min_value_property_;

rviz::BoolProperty* auto_text_size_in_plot_property_;
rviz::IntProperty* text_size_in_plot_property_;

OverlayObject::Ptr overlay_;
QColor fg_color_;
QColor max_color_;
Expand All @@ -118,6 +120,8 @@ namespace jsk_rviz_plugins
bool draw_required_;
float last_time_;
float update_interval_;
bool auto_text_size_in_plot_;
int text_size_in_plot_;

int buffer_length_;
std::vector<double> buffer_;
Expand Down Expand Up @@ -159,6 +163,9 @@ namespace jsk_rviz_plugins
void updateAutoScale();
void updateMinValue();
void updateMaxValue();
void updateTextSizeInPlot();
void updateAutoTextSizeInPlot();

private:
};
}
Expand Down

0 comments on commit 3e36a62

Please sign in to comment.