diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/csonecontrollertab.h b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/csonecontrollertab.h index b85bfbd139590f6c2f53e457ba65d51819ab9a91..ee39cd66cda4763ce88a927ad76a1af0fbc67120 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/csonecontrollertab.h +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/csonecontrollertab.h @@ -42,6 +42,11 @@ #include <QLineEdit> #include <QTextStream> +// For the chart: +#include <QChart> +#include <QLineSeries> +using namespace QtCharts; + #ifdef CATKIN_MAKE #include <ros/ros.h> #include <ros/network.h> @@ -133,6 +138,10 @@ private: bool m_shouldCoordinateAll = true; QMutex m_agentIDs_toCoordinate_mutex; + // For plotting data on the chart + QLineSeries *m_lineSeries_for_setpoint_x; + QLineSeries *m_lineSeries_for_measured_x; + #ifdef CATKIN_MAKE diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/csonecontrollertab.cpp b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/csonecontrollertab.cpp index f147fe615d8b7d088f916613c86b71b9be79a03a..ef8c15cf153cd7742f3d9021a3dcfffe4f9ea52e 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/csonecontrollertab.cpp +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/csonecontrollertab.cpp @@ -66,17 +66,21 @@ CsoneControllerTab::CsoneControllerTab(QWidget *parent) : // Set the theme of the chart ui->chartView_for_x->chart()->setTheme(QChart::ChartThemeLight); + // Initialise the line series to be used for plotting + m_lineSeries_for_setpoint_x = new QLineSeries(); + m_lineSeries_for_measured_x = new QLineSeries(); + // DEBUGGING: SET SOME FAKE DATA FOR TESTING FOR A LINE CHART - QLineSeries *series = new QLineSeries(); - series->append(0, 6); - series->append(2, 4); - series->append(3, 8); - series->append(7, 4); - series->append(10, 5); - *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); + m_lineSeries_for_setpoint_x->append(0, 6); + m_lineSeries_for_setpoint_x->append(2, 4); + m_lineSeries_for_setpoint_x->append(3, 8); + m_lineSeries_for_setpoint_x->append(7, 4); + m_lineSeries_for_setpoint_x->append(10, 5); + *m_lineSeries_for_setpoint_x << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); // Add the - ui->chartView_for_x->chart()->addSeries(series); + ui->chartView_for_x->chart()->addSeries(m_lineSeries_for_setpoint_x); + ui->chartView_for_x->chart()->addSeries(m_lineSeries_for_measured_x); ui->chartView_for_x->chart()->createDefaultAxes(); @@ -194,6 +198,8 @@ void CsoneControllerTab::publish_custom_button_command(int button_index , QLineE void CsoneControllerTab::on_custom_button_1_clicked() { + m_lineSeries_for_setpoint_x->append(10, 6); + //ui->chartView_for_x->chart()->createDefaultAxes(); #ifdef CATKIN_MAKE publish_custom_button_command(1,ui->lineEdit_custom_1); #endif @@ -201,6 +207,8 @@ void CsoneControllerTab::on_custom_button_1_clicked() void CsoneControllerTab::on_custom_button_2_clicked() { + m_lineSeries_for_setpoint_x->append(22, 6); + //ui->chartView_for_x->chart()->createDefaultAxes(); #ifdef CATKIN_MAKE publish_custom_button_command(2,ui->lineEdit_custom_2); #endif @@ -208,6 +216,9 @@ void CsoneControllerTab::on_custom_button_2_clicked() void CsoneControllerTab::on_custom_button_3_clicked() { + m_lineSeries_for_setpoint_x->append(22, 6); + ui->chartView_for_x->chart()->createDefaultAxes(); + ui->chartView_for_x->chart()->axisX()->setMax(24); #ifdef CATKIN_MAKE publish_custom_button_command(3,ui->lineEdit_custom_3); #endif