Skip to content

Commit

Permalink
Merge pull request Kotakku#6 from Kotakku/fix/picker_tool
Browse files Browse the repository at this point in the history
Fix/picker tool
  • Loading branch information
Kotakku authored Jun 28, 2023
2 parents dfb9009 + 774d3bf commit a51b089
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 23 deletions.
12 changes: 6 additions & 6 deletions jsk_rviz_plugins/plugins_description.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@
type="jsk_rviz_plugins::PictogramArrayDisplay"
base_class_type="rviz_common::Display">
<description>
visualize jsk_rviz_plugins/msg/PictogramArray
visualize jsk_rviz_plugin_msgs/msg/PictogramArray
</description>
<message_type>jsk_rviz_plugins/msg/PictogramArray</message_type>
<message_type>jsk_rviz_plugin_msgs/msg/PictogramArray</message_type>
</class>

<class name="jsk_rviz_plugin/Pictogram"
type="jsk_rviz_plugins::PictogramDisplay"
base_class_type="rviz_common::Display">
<description>
visualize jsk_rviz_plugins/msg/Pictogram
visualize jsk_rviz_plugin_msgs/msg/Pictogram
</description>
<message_type>jsk_rviz_plugins/msg/Pictogram</message_type>
<message_type>jsk_rviz_plugin_msgs/msg/Pictogram</message_type>
</class>


Expand Down Expand Up @@ -184,15 +184,15 @@
<description>
Displays text as overlay
</description>
<message_type>jsk_rviz_plugins/msg/OverlayText</message_type>
<message_type>jsk_rviz_plugin_msgs/msg/OverlayText</message_type>
</class>
<class name="jsk_rviz_plugin/OverlayMenu"
type="jsk_rviz_plugins::OverlayMenuDisplay"
base_class_type="rviz_common::Display">
<description>
Displays menu as overlay
</description>
<message_type>jsk_rviz_plugins/msg/OverlayMenu</message_type>
<message_type>jsk_rviz_plugin_msgs/msg/OverlayMenu</message_type>
</class>
<class name="jsk_rviz_plugin/OverlayImage"
type="jsk_rviz_plugins::OverlayImageDisplay"
Expand Down
4 changes: 2 additions & 2 deletions jsk_rviz_plugins/src/linear_gauge_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ bool LinearGaugeDisplay::isInRegion(int x, int y)

void LinearGaugeDisplay::movePosition(int x, int y)
{
top_ = y;
left_ = x;
top_property_->setValue(y);
left_property_->setValue(x);
}

void LinearGaugeDisplay::setPosition(int x, int y)
Expand Down
7 changes: 7 additions & 0 deletions jsk_rviz_plugins/src/overlay_picker_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "pie_chart_display.hpp"
#include "plotter_2d_display.hpp"
#include "rviz_utils.hpp"
#include "string_display.hpp"

namespace jsk_rviz_plugins
{
Expand Down Expand Up @@ -101,6 +102,8 @@ bool OverlayPickerTool::handleDisplayClick(
} else {
if (startMovement<OverlayTextDisplay>(property, event, "overlay_text_display")) {
return true;
} else if (startMovement<StringDisplay>(property, event, "string_display")) {
return true;
} else if (startMovement<Plotter2DDisplay>(property, event, "plotter_2d_display")) {
return true;
} else if (startMovement<PieChartDisplay>(property, event, "pie_chart_display")) {
Expand Down Expand Up @@ -139,6 +142,8 @@ void OverlayPickerTool::onMove(rviz_common::ViewportMouseEvent & event)
if (target_property_) {
if (target_property_type_ == "overlay_text_display") {
movePosition<OverlayTextDisplay>(event);
} else if (target_property_type_ == "string_display") {
movePosition<StringDisplay>(event);
} else if (target_property_type_ == "plotter_2d_display") {
movePosition<Plotter2DDisplay>(event);
} else if (target_property_type_ == "pie_chart_display") {
Expand All @@ -163,6 +168,8 @@ void OverlayPickerTool::onRelease(rviz_common::ViewportMouseEvent & event)
if (target_property_) {
if (target_property_type_ == "overlay_text_display") {
setPosition<OverlayTextDisplay>(event);
} else if (target_property_type_ == "string_display") {
setPosition<StringDisplay>(event);
} else if (target_property_type_ == "plotter_2d_display") {
setPosition<Plotter2DDisplay>(event);
} else if (target_property_type_ == "pie_chart_display") {
Expand Down
73 changes: 60 additions & 13 deletions jsk_rviz_plugins/src/pie_chart_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,23 +260,59 @@ void PieChartDisplay::updateSize()
mutex_.unlock();
}

void PieChartDisplay::updateTop() { top_ = top_property_->getInt(); }
void PieChartDisplay::updateTop()
{
top_ = top_property_->getInt();
update_required_ = true;
}

void PieChartDisplay::updateLeft() { left_ = left_property_->getInt(); }
void PieChartDisplay::updateLeft()
{
left_ = left_property_->getInt();
update_required_ = true;
}

void PieChartDisplay::updateBGColor() { bg_color_ = bg_color_property_->getColor(); }
void PieChartDisplay::updateBGColor()
{
bg_color_ = bg_color_property_->getColor();
update_required_ = true;
}

void PieChartDisplay::updateFGColor() { fg_color_ = fg_color_property_->getColor(); }
void PieChartDisplay::updateFGColor()
{
fg_color_ = fg_color_property_->getColor();
update_required_ = true;
}

void PieChartDisplay::updateFGAlpha() { fg_alpha_ = fg_alpha_property_->getFloat() * 255.0; }
void PieChartDisplay::updateFGAlpha()
{
fg_alpha_ = fg_alpha_property_->getFloat() * 255.0;
update_required_ = true;
}

void PieChartDisplay::updateFGAlpha2() { fg_alpha2_ = fg_alpha2_property_->getFloat() * 255.0; }
void PieChartDisplay::updateFGAlpha2()
{
fg_alpha2_ = fg_alpha2_property_->getFloat() * 255.0;
update_required_ = true;
}

void PieChartDisplay::updateBGAlpha() { bg_alpha_ = bg_alpha_property_->getFloat() * 255.0; }
void PieChartDisplay::updateBGAlpha()
{
bg_alpha_ = bg_alpha_property_->getFloat() * 255.0;
update_required_ = true;
}

void PieChartDisplay::updateMinValue() { min_value_ = min_value_property_->getFloat(); }
void PieChartDisplay::updateMinValue()
{
min_value_ = min_value_property_->getFloat();
update_required_ = true;
}

void PieChartDisplay::updateMaxValue() { max_value_ = max_value_property_->getFloat(); }
void PieChartDisplay::updateMaxValue()
{
max_value_ = max_value_property_->getFloat();
update_required_ = true;
}

void PieChartDisplay::updateTextSize()
{
Expand All @@ -287,9 +323,14 @@ void PieChartDisplay::updateTextSize()
font.setPointSize(text_size_);
caption_offset_ = QFontMetrics(font).height();
mutex_.unlock();
update_required_ = true;
}

void PieChartDisplay::updateShowCaption() { show_caption_ = show_caption_property_->getBool(); }
void PieChartDisplay::updateShowCaption()
{
show_caption_ = show_caption_property_->getBool();
update_required_ = true;
}

void PieChartDisplay::updateTopic()
{
Expand All @@ -305,13 +346,19 @@ void PieChartDisplay::updateAutoColorChange()
} else {
max_color_property_->hide();
}
update_required_ = true;
}

void PieChartDisplay::updateMaxColor() { max_color_ = max_color_property_->getColor(); }
void PieChartDisplay::updateMaxColor()
{
max_color_ = max_color_property_->getColor();
update_required_ = true;
}

void PieChartDisplay::updateClockwiseRotate()
{
clockwise_rotate_ = clockwise_rotate_property_->getBool();
update_required_ = true;
}

bool PieChartDisplay::isInRegion(int x, int y)
Expand All @@ -321,8 +368,8 @@ bool PieChartDisplay::isInRegion(int x, int y)

void PieChartDisplay::movePosition(int x, int y)
{
top_ = y;
left_ = x;
top_property_->setValue(y);
left_property_->setValue(x);
}

void PieChartDisplay::setPosition(int x, int y)
Expand Down
4 changes: 2 additions & 2 deletions jsk_rviz_plugins/src/string_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ bool StringDisplay::isInRegion(int x, int y)

void StringDisplay::movePosition(int x, int y)
{
top_ = y;
left_ = x;
top_property_->setValue(y);
left_property_->setValue(x);
}

void StringDisplay::setPosition(int x, int y)
Expand Down

0 comments on commit a51b089

Please sign in to comment.