44 :
rviz::Display(), data_(0.0), first_time_(true),
45 width_padding_(5), height_padding_(5)
49 ros::message_traits::datatype<std_msgs::Float32>(),
50 "std_msgs::Float32 topic to subscribe to.",
51 this, SLOT(updateTopic()));
54 "Show value on plotter",
55 this, SLOT(updateShowValue()));
58 "Vertical Gauge",
false,
60 this, SLOT(updateVerticalGauge()));
63 "width of the plotter window",
64 this, SLOT(updateWidth()));
65 width_property_->setMin(1);
66 width_property_->setMax(2000);
68 "height of the plotter window",
69 this, SLOT(updateHeight()));
70 height_property_->setMin(1);
71 height_property_->setMax(2000);
73 "left of the plotter window",
74 this, SLOT(updateLeft()));
75 left_property_->setMin(0);
77 "top of the plotter window",
78 this, SLOT(updateTop()));
79 top_property_->setMin(0);
83 "max value, used only if auto scale is disabled",
84 this, SLOT(updateMaxValue()));
87 "min value, used only if auto scale is disabled",
88 this, SLOT(updateMinValue()));
90 "foreground color", QColor(25, 255, 240),
92 this, SLOT(updateFGColor()));
94 "foreground alpha", 0.7,
95 "alpha belnding value for foreground",
96 this, SLOT(updateFGAlpha()));
97 fg_alpha_property_->setMin(0);
98 fg_alpha_property_->setMax(1.0);
100 "background color", QColor(0, 0, 0),
102 this, SLOT(updateBGColor()));
104 "backround alpha", 0.0,
105 "alpha belnding value for background",
106 this, SLOT(updateBGAlpha()));
107 bg_alpha_property_->setMin(0);
108 bg_alpha_property_->setMax(1.0);
110 "linewidth of the plot",
111 this, SLOT(updateLineWidth()));
112 line_width_property_->setMin(1);
113 line_width_property_->setMax(1000);
116 "show border or not",
117 this, SLOT(updateShowBorder()));
119 "text size of the caption",
120 this, SLOT(updateTextSize()));
121 text_size_property_->setMin(1);
122 text_size_property_->setMax(1000);
124 "show caption",
true,
125 "show caption or not",
126 this, SLOT(updateShowCaption()));
128 "update interval", 0.04,
129 "update interval of the plotter",
130 this, SLOT(updateUpdateInterval()));
131 update_interval_property_->setMin(0.0);
132 update_interval_property_->setMax(100);
133 auto_color_change_property_
136 "change the color automatically",
137 this, SLOT(updateAutoColorChange()));
142 "only used if auto color change is set to True.",
143 this, SLOT(updateMaxColor()));
173 static int count = 0;
175 ss <<
"LinearGaugeDisplayObject" <<
count++;
176 overlay_.reset(
new OverlayObject(ss.str()));
205 double max_gauge_length = 0.0;
215 double r2 = (
r - 0.3) / 0.7;
226 ScopedPixelBuffer buffer =
overlay_->getBuffer();
227 QImage Hud = buffer.getQImage(*
overlay_);
229 for (
int i = 0; i <
overlay_->getTextureWidth(); i++) {
230 for (
int j = 0; j <
overlay_->getTextureHeight(); j++) {
231 Hud.setPixel(i, j,
bg_color.rgba());
236 QPainter painter( &Hud );
237 painter.setRenderHint(QPainter::Antialiasing,
true);
240 uint16_t
w =
overlay_->getTextureWidth();
257 painter.drawLine(0, 0, 0, h);
258 painter.drawLine(0, h,
w, h);
259 painter.drawLine(
w, h,
w, 0);
260 painter.drawLine(
w, 0, 0, 0);
264 QFont
font = painter.font();
267 painter.setFont(
font);
269 Qt::AlignCenter | Qt::AlignVCenter,
275 QFont
font = painter.font();
278 painter.setFont(
font);
279 std::ostringstream ss;
280 ss << std::fixed << std::setprecision(2) <<
data_;
284 painter.translate(0, h);
286 painter.drawText(0, 0, h,
w,
287 Qt::AlignCenter | Qt::AlignVCenter,
290 painter.translate(0, -h);
294 painter.drawText(0, 0,
w, h,
295 Qt::AlignCenter | Qt::AlignVCenter,
341 if (topic_name.length() > 0 && topic_name !=
"/") {
504 return (top_ < y && top_ + texture_height_ >
y &&
505 left_ < x && left_ + texture_width_ >
x);