8 nh_(
std::make_shared<
ros::NodeHandle>()),
9 start_pause_button_(new QPushButton),
10 topic_button_(new QPushButton(
"Topics")),
11 stop_button_(new QPushButton(
"Stop")),
12 graph_settings_button_(new QPushButton(
"Graph settings")),
13 export_button_(new QPushButton(
"Export")),
14 graph_refresh_timer_(new QTimer(this)),
28 qRegisterMetaType<QMessageBox::Icon>();
35 QPushButton *settings_button =
new QPushButton(
"Settings");
38 QPushButton *reset_button =
new QPushButton(
"Reset");
43 QHBoxLayout *button_layout =
new QHBoxLayout();
46 button_layout->addStretch(1);
49 button_layout->addWidget(settings_button);
51 button_layout->addStretch(1);
52 button_layout->addWidget(reset_button);
54 QVBoxLayout *layout =
new QVBoxLayout();
56 layout->addLayout(button_layout);
57 layout->addWidget(
plot_);
61 QFont legendFont = font();
62 legendFont.setPointSize(9);
75 settings_button->setMinimumWidth(70);
77 reset_button->setMinimumWidth(45);
127 if (!topic_time.empty())
141 const QString message,
142 const QString info_msg,
143 const QMessageBox::Icon icon)
145 const bool old(isEnabled());
146 Q_EMIT setEnabled(
false);
148 msg_box.setWindowTitle(title);
149 msg_box.setText(message);
150 msg_box.setInformativeText(info_msg);
151 msg_box.setIcon(icon);
152 msg_box.setStandardButtons(QMessageBox::Ok);
154 Q_EMIT setEnabled(old);
165 if (config.
mapGetBool(
"window_time_enable", &tmp))
168 if (config.
mapGetBool(
"yaxis_rescale_auto", &tmp))
191 if (config.
mapGetInt(
"refresh_freq", &tmp))
209 if (!config.
mapGetString(
"topic_" + QString::number(i) +
"_name", &topic_name))
212 if (!config.
mapGetString(
"topic_" + QString::number(i) +
"_type", &topic_type))
215 if (!config.
mapGetInt(
"topic_" + QString::number(i) +
"_thickness", &topic_thickness))
218 if (!config.
mapGetInt(
"topic_" + QString::number(i) +
"_color", &color_index))
221 std::shared_ptr<TopicData> topic_data = std::make_shared<TopicData>(topic_name.toStdString(),
222 topic_type.toStdString(),
nh_);
223 topic_data->thickness_ = topic_thickness;
254 config.
mapSetValue(
"topic_" + QString::number(i) +
"_name",
256 config.
mapSetValue(
"topic_" + QString::number(i) +
"_type",
259 config.
mapSetValue(
"topic_" + QString::number(i) +
"_color",
347 QString file_name = QFileDialog::getSaveFileName(
this, tr(
"Save file"),
export_directory_ +
"/graph.png",
348 tr(
"PNG (*.png);; JPG (*.jpg) ;; PDF (*.pdf)"));
350 if (file_name.isEmpty())
353 QFileInfo path = QFile(file_name);
355 if (path.completeSuffix() ==
"png")
357 else if (path.completeSuffix() ==
"jpg")
369 std::vector<std::string> allowed_topics;
370 allowed_topics.emplace_back(
"std_msgs/Bool");
371 allowed_topics.emplace_back(
"std_msgs/Int8");
372 allowed_topics.emplace_back(
"std_msgs/UInt8");
373 allowed_topics.emplace_back(
"std_msgs/Int16");
374 allowed_topics.emplace_back(
"std_msgs/UInt16");
375 allowed_topics.emplace_back(
"std_msgs/Int32");
376 allowed_topics.emplace_back(
"std_msgs/UInt32");
377 allowed_topics.emplace_back(
"std_msgs/Int64");
378 allowed_topics.emplace_back(
"std_msgs/UInt64");
379 allowed_topics.emplace_back(
"std_msgs/Float32");
380 allowed_topics.emplace_back(
"std_msgs/Float64");
386 Q_EMIT
displayMessageBox(
"No supported topic",
"Error with topics, no supported topics found.",
"",
387 QMessageBox::Icon::Warning);
391 if (topic_window->exec())
420 if (configure_topics->exec())
429 if (!configure_graph->exec())
bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
0x001 Axis ranges are draggable (see QCPAxisRect::setRangeDrag, QCPAxisRect::setRangeDragAxes) ...
std::atomic< bool > window_time_enable_
QCPGraph * graph(int index) const
void setName(const QString &name)
LinePanel(QWidget *parent=0)
void rescale(bool onlyVisiblePlottables=false)
void setInteractions(const QCP::Interactions &interactions)
virtual QString getName() const
std::deque< std::shared_ptr< TopicData > > displayed_topics_
void setBrush(const QBrush &brush)
QPushButton * start_pause_button_
int getIndexFromColor(const QColor color) const
Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpRefreshHint)
std::shared_ptr< ros::NodeHandle > nh_
Q_SLOT void setRange(const QCPRange &range)
virtual void save(Config config) const
bool mapGetString(const QString &key, QString *value_out) const
std::atomic< bool > graph_stopped_
void displayMessageBoxHandler(const QString title, const QString text, const QString info="", const QMessageBox::Icon icon=QMessageBox::Icon::Information)
void displayMessageBox(const QString, const QString, const QString, const QMessageBox::Icon)
void mapSetValue(const QString &key, QVariant value)
std::atomic< bool > yaxis_rescale_auto_
virtual void save(rviz::Config config) const
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
QPushButton * graph_settings_button_
bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
virtual void setName(const QString &name)
QTimer * graph_refresh_timer_
std::vector< std::pair< QString, QColor > > colors_list_
void topicsSelectionClicked()
bool savePdf(const QString &fileName, int width=0, int height=0, QCP::ExportPen exportPen=QCP::epAllowCosmetic, const QString &pdfCreator=QString(), const QString &pdfTitle=QString())
void setPen(const QPen &pen)
QCPGraph * addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0)
bool mapGetFloat(const QString &key, float *value_out) const
void setInteraction(const QCP::Interaction &interaction, bool enabled=true)
QPushButton * topic_button_
TopicColor topic_color_class_
void setLineStyle(LineStyle ls)
void setData(QSharedPointer< QCPGraphDataContainer > data)
bool mapGetBool(const QString &key, bool *value_out) const
ros::master::V_TopicInfo supported_topics_
std::atomic< bool > legend_enable_
void setFont(const QFont &font)
0x002 Axis ranges are zoomable with the mouse wheel (see QCPAxisRect::setRangeZoom, QCPAxisRect::setRangeZoomAxes)
bool removeFromLegend(QCPLegend *legend) const
QPushButton * stop_button_
void enableLegend(bool legend_enable)
QPushButton * export_button_
void graphSettingsUpdate()
virtual void load(const Config &config)
void graphSettingsClicked()
QString export_directory_
bool mapGetInt(const QString &key, int *value_out) const
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
virtual void load(const rviz::Config &config)
QColor getColorFromIndex(const int index) const
std::deque< std::shared_ptr< TopicData > > displayed_topics_
bool addToLegend(QCPLegend *legend)