Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmiklos committed Feb 4, 2019
1 parent e64c767 commit 14952c2
Show file tree
Hide file tree
Showing 52 changed files with 1,323 additions and 545 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ CMakeLists.txt.user*
*creator.user*

.directory

*.includes
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ project(rqt_plot_qtcharts)
find_package(catkin REQUIRED COMPONENTS
rqt_gui
rqt_gui_cpp
rescube_msgs
)

## System dependencies are found with CMake's conventions
Expand All @@ -35,6 +36,7 @@ qt5_add_resources (RCC_SOURCES ${RESOURCES})

set(rqt_plot_qtcharts_INCLUDE_DIRECTORIES
include
include/rqt_plot_qtcharts
${CMAKE_CURRENT_BINARY_DIR}
)

Expand Down
9 changes: 5 additions & 4 deletions include/rqt_plot_qtcharts/dialogaxes.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DIALOGAXES_H
#define DIALOGAXES_H

#include "rqt_plot_qtcharts/plotverticalaxesmodel.h"
#include "verticalaxesmodel.h"

#include <QDialog>

Expand All @@ -14,7 +14,7 @@ class DialogAxes : public QDialog
Q_OBJECT

public:
explicit DialogAxes(PlotChartWidget *plotWidget, QWidget *parent = 0);
explicit DialogAxes(QWidget *parent = 0);
~DialogAxes();
void refreshAxisList();

Expand All @@ -23,10 +23,11 @@ private slots:
void on_toolButtonRemoveAxis_clicked();
void on_tableViewAxesList_doubleClicked(const QModelIndex &index);

void on_tableViewAxesList_customContextMenuRequested(const QPoint &pos);

private:
Ui::DialogAxes *ui;
PlotVerticalAxesModel *m_model;
PlotChartWidget *m_plotChartWidget;
VerticalAxesModel *m_model;
};

#endif // DIALOGAXES_H
8 changes: 4 additions & 4 deletions include/rqt_plot_qtcharts/dialogaxisproperties.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DIALOGAXISPROPERTIES_H
#define DIALOGAXISPROPERTIES_H

#include "plotverticalaxis.h"
#include "verticalaxis.h"
#include "plotlineseries.h"

#include <QDialog>
Expand All @@ -24,8 +24,8 @@ class DialogAxisProperties : public QDialog
PlotLineSeries *series() const;
void setSeries(PlotLineSeries *series);

PlotVerticalAxis *axis() const;
void setAxis(PlotVerticalAxis *axis);
VerticalAxis *axis() const;
void setAxis(VerticalAxis *axis);

private slots:
void on_checkBoxAutoScale_toggled(bool checked);
Expand All @@ -34,7 +34,7 @@ private slots:

private:
Ui::DialogAxisProperties *ui;
PlotVerticalAxis *m_axis = nullptr;
VerticalAxis *m_axis = nullptr;
};

#endif // DIALOGAXISPROPERTIES_H
5 changes: 1 addition & 4 deletions include/rqt_plot_qtcharts/dialogplotseriesproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define DIALOGPLOTSERIESPROPERTIES_H

#include "plotlineseries.h"
#include "plotchartwidget.h"

#include <QDialog>

Expand All @@ -15,8 +14,7 @@ class DialogPlotSeriesProperties : public QDialog
Q_OBJECT

public:
DialogPlotSeriesProperties(PlotChartWidget *chart, QWidget *parent = 0);
DialogPlotSeriesProperties(PlotChartWidget *chart, const QString & topicName, QWidget *parent = 0);
DialogPlotSeriesProperties(QWidget *parent = 0);
~DialogPlotSeriesProperties();

PlotLineSeries *series() const;
Expand All @@ -33,7 +31,6 @@ private slots:

PlotLineSeries *m_series = nullptr;
QColor m_color = Qt::red;
PlotChartWidget *m_plotChartWidget;
};

#endif // DIALOGPLOTSERIESPROPERTIES_H
32 changes: 32 additions & 0 deletions include/rqt_plot_qtcharts/dialogseries.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef DIALOGSERIES_H
#define DIALOGSERIES_H

#include "dialogplotseriesproperties.h"
#include "serieslistmodel.h"

#include <QDialog>

namespace Ui {
class DialogSeries;
}

class DialogSeries : public QDialog
{
Q_OBJECT

public:
explicit DialogSeries(QWidget *parent = 0);
~DialogSeries();

private slots:
void on_tableViewSeries_doubleClicked(const QModelIndex &index);

void on_tableViewSeries_customContextMenuRequested(const QPoint &pos);

private:
Ui::DialogSeries *ui;
SeriesListModel *m_model;
DialogPlotSeriesProperties *m_seriesPropertiesDialog = nullptr;
};

#endif // DIALOGSERIES_H
66 changes: 0 additions & 66 deletions include/rqt_plot_qtcharts/plotchartwidget.h

This file was deleted.

16 changes: 12 additions & 4 deletions include/rqt_plot_qtcharts/plotlineseries.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PLOTLINESERIES_H
#define PLOTLINESERIES_H

#include "rqt_plot_qtcharts/plotverticalaxis.h"
#include "verticalaxis.h"

#include <QtCharts/QChart>
#include <QtCharts/QChartGlobal>
Expand All @@ -15,6 +15,7 @@ QT_CHARTS_USE_NAMESPACE

class PlotLineSeries : public QLineSeries
{
Q_OBJECT
public:
PlotLineSeries(QObject *parent = nullptr);
QString dataSource() const;
Expand All @@ -26,13 +27,20 @@ class PlotLineSeries : public QLineSeries
qreal width() const;
void setWidth(const qreal &width);

PlotVerticalAxis *verticalAxis() const;
void setVerticalAxis(PlotVerticalAxis *verticalAxis);
VerticalAxis *verticalAxis() const;
void setVerticalAxis(VerticalAxis *verticalAxis);

void dataReceived(qreal y);
void clear();

private:
// topic name
QString m_dataSource;
PlotVerticalAxis *m_verticalAxis = nullptr;
VerticalAxis *m_verticalAxis = nullptr;
qreal m_xIndex = 0;
signals:
void axisChanged();
};

#endif // PLOTLINESERIES_H

2 changes: 1 addition & 1 deletion include/rqt_plot_qtcharts/randomcolorgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RandomColorGenerator
{
public:
QColor get();
static RandomColorGenerator *getInstance();
static RandomColorGenerator *instance();
private:
QVector<QColor> m_colorList;
int m_index = 0;
Expand Down
36 changes: 31 additions & 5 deletions include/rqt_plot_qtcharts/rqt_plot_qtcharts_widget.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#ifndef RQT_PLOT_QTCHARTS_WIDGET_H
#define RQT_PLOT_QTCHARTS_WIDGET_H

#include "rqt_plot_qtcharts/plotverticalaxis.h"
#include "rqt_plot_qtcharts/dialogaxes.h"
#include "verticalaxis.h"
#include "dialogaxes.h"
#include "dialogseries.h"

#include <rescube_msgs/PIDDebug.h>

#include <ros/node_handle.h>
#include <ros/subscriber.h>

#include <rqt_gui_cpp/plugin.h>

Expand Down Expand Up @@ -40,14 +46,34 @@ private slots:
void on_toolButtonAddTopic_clicked();
void on_toolButtonRemoveTopic_clicked();
void on_toolButtonSettings_clicked();
void on_toolButtonSeries_clicked();
void on_toolButtonRecord_toggled(bool checked);
void on_toolButtonClear_clicked();

void seriesAdded(PlotLineSeries *newSeries);
void seriesRemoved(PlotLineSeries *series);

void axisAdded(VerticalAxis *axis);
void axisRemoved(VerticalAxis *axis);

private:
Ui::PlotQtChartsWidget *ui;
DialogAxes *m_axesDialog;
DialogAxes *m_axesDialog = nullptr;
DialogSeries *m_seriesDialog = nullptr;

QValueAxis *m_axisX = nullptr;

ros::Subscriber m_subscriber;
ros::NodeHandle m_nodeHandle;

void saveAxes(qt_gui_cpp::Settings &instance_settings) const;
void saveSeries(qt_gui_cpp::Settings &instance_settings) const;
void restoreAxes(const qt_gui_cpp::Settings &instance_settings);
void restoreSeries(const qt_gui_cpp::Settings &instance_settings);

QList<PlotVerticalAxis*> m_verticalAxes;
void debugCallback(const rescube_msgs::PIDDebug::ConstPtr &dbg);

QMenu *m_seriesMenu;
void addDefaultVerticalAxis();
};

#endif // RQT_PLOT_QTCHARTS_WIDGET_H
35 changes: 35 additions & 0 deletions include/rqt_plot_qtcharts/serieslistmodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef SERIESLISTMODEL_H
#define SERIESLISTMODEL_H

#include "plotlineseries.h"

#include <QAbstractTableModel>

class SeriesListModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum Columns {
Col_Name,
Col_Visible,
Col_Invalid
};

SeriesListModel(QObject *parent = nullptr);

int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;

QVariant data(const QModelIndex &index, int role) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;

Qt::ItemFlags flags(const QModelIndex &index) const;

PlotLineSeries *series(const QModelIndex& index);

public slots:
void refresh();
};

#endif // SERIESLISTMODEL_H
32 changes: 32 additions & 0 deletions include/rqt_plot_qtcharts/seriesmanager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef SERIESMANAGER_H
#define SERIESMANAGER_H

#include "plotlineseries.h"

#include <QObject>

class SeriesManager : public QObject
{
Q_OBJECT
public:
SeriesManager();
~SeriesManager();
static SeriesManager *instance();

void clear();

void addSeries(PlotLineSeries *series);
void removeSeries(PlotLineSeries *series);

QList<PlotLineSeries *> seriesList() const;

signals:
void seriesAdded(PlotLineSeries *series);
void seriesRemoved(PlotLineSeries *series);

private:
static SeriesManager *m_instance;
QList<PlotLineSeries*> m_series;
};

#endif // SERIESMANAGER_H
Loading

0 comments on commit 14952c2

Please sign in to comment.