From 83b9e8ac4a76ce02eff29c0bb5ff699dd965802d Mon Sep 17 00:00:00 2001 From: Paul Beuchat <beuchatp@control.ee.ethz.ch> Date: Fri, 22 Nov 2019 20:11:23 +0100 Subject: [PATCH] Added example of how to inclue a chart to the CS1 gui --- .../GUI_Qt/flyingAgentGUI/flyingAgentGUI.pro | 2 + .../flyingAgentGUI/forms/controllertabs.ui | 30 +- .../forms/csonecontrollertab.ui | 283 ++++++++---------- .../forms/defaultcontrollertab.ui | 12 + .../forms/studentcontrollertab.ui | 12 + .../include/remotecontrollertab.h | 5 - .../flyingAgentGUI/src/csonecontrollertab.cpp | 35 +++ .../src/remotecontrollertab.cpp | 22 -- 8 files changed, 217 insertions(+), 184 deletions(-) diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/flyingAgentGUI.pro b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/flyingAgentGUI.pro index a479b1b1..c7e2f5ac 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/flyingAgentGUI.pro +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/flyingAgentGUI.pro @@ -10,6 +10,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets #greaterThan(QT_MAJOR_VERSION, 4): QT += svg +greaterThan(QT_MAJOR_VERSION, 4): QT += charts + TARGET = flyingAgentGUI TEMPLATE = app diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/controllertabs.ui b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/controllertabs.ui index fc801c9c..90485cc3 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/controllertabs.ui +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/controllertabs.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>1150</width> + <width>1779</width> <height>718</height> </rect> </property> @@ -58,8 +58,34 @@ <string>CS1</string> </attribute> <layout class="QGridLayout" name="gridLayout_8"> + <property name="leftMargin"> + <number>3</number> + </property> + <property name="topMargin"> + <number>3</number> + </property> + <property name="rightMargin"> + <number>3</number> + </property> + <property name="bottomMargin"> + <number>3</number> + </property> <item row="0" column="0"> - <widget class="CsoneControllerTab" name="csone_controller_tab_widget" native="true"/> + <widget class="QScrollArea" name="scrollArea"> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <widget class="CsoneControllerTab" name="csone_controller_tab_widget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>1723</width> + <height>576</height> + </rect> + </property> + </widget> + </widget> </item> </layout> </widget> diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/csonecontrollertab.ui b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/csonecontrollertab.ui index 3d188247..de8163e4 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/csonecontrollertab.ui +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/csonecontrollertab.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>1335</width> - <height>937</height> + <width>1492</width> + <height>1434</height> </rect> </property> <property name="font"> @@ -19,175 +19,44 @@ <string>Form</string> </property> <layout class="QGridLayout" name="gridLayout_2"> - <item row="2" column="0"> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <item row="4" column="0"> + <widget class="QChartView" name="chartView_for_x"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> </property> - <property name="sizeHint" stdset="0"> + <property name="maximumSize"> <size> - <width>20</width> - <height>20</height> + <width>16777215</width> + <height>16777215</height> </size> </property> - </spacer> + </widget> </item> - <item row="4" column="0"> - <spacer name="verticalSpacer"> + <item row="2" column="0"> + <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>40</height> + <height>20</height> </size> </property> </spacer> </item> - <item row="3" column="0"> - <layout class="QGridLayout" name="gridLayout_3"> - <property name="topMargin"> - <number>6</number> - </property> - <property name="bottomMargin"> - <number>6</number> - </property> - <item row="0" column="3"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="1"> - <widget class="QPushButton" name="custom_button_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Button 2</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QPushButton" name="custom_button_3"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Button 3</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QPushButton" name="custom_button_1"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Button 1</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <item> - <widget class="QLineEdit" name="lineEdit_custom_3"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <item> - <widget class="QLineEdit" name="lineEdit_custom_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <item> - <widget class="QLineEdit" name="lineEdit_custom_1"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> <item row="1" column="0"> <widget class="Line" name="line"> <property name="orientation"> @@ -863,10 +732,114 @@ </item> </layout> </item> + <item row="1" column="4"> + <widget class="QPushButton" name="custom_button_1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Button 1</string> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="QLineEdit" name="lineEdit_custom_1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="3" column="4"> + <widget class="QPushButton" name="custom_button_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Button 2</string> + </property> + </widget> + </item> + <item row="4" column="4"> + <widget class="QLineEdit" name="lineEdit_custom_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="5" column="4"> + <widget class="QPushButton" name="custom_button_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Button 3</string> + </property> + </widget> + </item> + <item row="6" column="4"> + <widget class="QLineEdit" name="lineEdit_custom_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> </layout> </item> + <item row="3" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Time series of: x [m]</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>QChartView</class> + <extends>QGraphicsView</extends> + <header>QtCharts</header> + </customwidget> + </customwidgets> <resources/> <connections/> </ui> diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/defaultcontrollertab.ui b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/defaultcontrollertab.ui index c8225eaf..496157df 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/defaultcontrollertab.ui +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/defaultcontrollertab.ui @@ -320,6 +320,9 @@ <family>Courier</family> </font> </property> + <property name="text"> + <string>0.1</string> + </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> @@ -386,6 +389,9 @@ <family>Courier</family> </font> </property> + <property name="text"> + <string>0.1</string> + </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> @@ -512,6 +518,9 @@ <family>Courier</family> </font> </property> + <property name="text"> + <string>15</string> + </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> @@ -826,6 +835,9 @@ <family>Courier</family> </font> </property> + <property name="text"> + <string>0.1</string> + </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/studentcontrollertab.ui b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/studentcontrollertab.ui index e3e70de4..c100ec79 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/studentcontrollertab.ui +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/studentcontrollertab.ui @@ -456,6 +456,9 @@ <family>Courier</family> </font> </property> + <property name="text"> + <string>0.1</string> + </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> @@ -1028,6 +1031,9 @@ <family>Courier</family> </font> </property> + <property name="text"> + <string>0.1</string> + </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> @@ -1094,6 +1100,9 @@ <family>Courier</family> </font> </property> + <property name="text"> + <string>15</string> + </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> @@ -1160,6 +1169,9 @@ <family>Courier</family> </font> </property> + <property name="text"> + <string>0.1</string> + </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/remotecontrollertab.h b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/remotecontrollertab.h index 686b250b..60d50bc2 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/remotecontrollertab.h +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/remotecontrollertab.h @@ -109,11 +109,6 @@ private slots: void on_default_setpoint_button_clicked(); - void on_custom_button_1_clicked(); - void on_custom_button_2_clicked(); - void on_custom_button_3_clicked(); - - // COPIED FROM PREVIOUS REMOTE CONTROLLER GUI void on_subscribe_button_clicked(); void on_unsubscribe_button_clicked(); 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 28ab5cda..f147fe61 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 @@ -47,6 +47,41 @@ CsoneControllerTab::CsoneControllerTab(QWidget *parent) : ui->red_frame_position_left->setVisible(false); ui->red_frame_position_right->setVisible(false); + // Set the sizing policy for the chart + // > This needs to be set here because the sizing policy needs to be + // set for the chart, but only the sizing policy for the + // ui->chartView_for_x object is accessible through the graphical + // designer for the .ui file + // > Syntax hint: + // void QWidget::setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) + ui->chartView_for_x->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Expanding); + ui->chartView_for_x->chart()->setMinimumHeight(600); + + // Hide the legend of the chart + ui->chartView_for_x->chart()->legend()->hide(); + + // Set the chart to have no title + ui->chartView_for_x->chart()->setTitle(""); + + // Set the theme of the chart + ui->chartView_for_x->chart()->setTheme(QChart::ChartThemeLight); + + // 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); + + // Add the + ui->chartView_for_x->chart()->addSeries(series); + ui->chartView_for_x->chart()->createDefaultAxes(); + + + + #ifdef CATKIN_MAKE diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/remotecontrollertab.cpp b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/remotecontrollertab.cpp index b4dc5ecf..c897cd93 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/remotecontrollertab.cpp +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/remotecontrollertab.cpp @@ -296,28 +296,6 @@ void RemoteControllerTab::publish_custom_button_command(int button_index , QLine #endif -void RemoteControllerTab::on_custom_button_1_clicked() -{ -#ifdef CATKIN_MAKE - //publish_custom_button_command(1,ui->lineEdit_custom_1); -#endif -} - -void RemoteControllerTab::on_custom_button_2_clicked() -{ -#ifdef CATKIN_MAKE - //publish_custom_button_command(2,ui->lineEdit_custom_2); -#endif -} - -void RemoteControllerTab::on_custom_button_3_clicked() -{ -#ifdef CATKIN_MAKE - //publish_custom_button_command(3,ui->lineEdit_custom_3); -#endif -} - - -- GitLab