Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmiklos committed Feb 1, 2019
1 parent 2cfea9e commit f1a4ef8
Show file tree
Hide file tree
Showing 29 changed files with 924 additions and 114 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ An another plotting plugin for rqt based on the QtCharts module

## But why?

Yes I know about (rqt_plot)[https://github.com/ros-visualization/rqt_plot] and (rqt_multiplot)[https://github.com/ANYbotics/rqt_multiplot_plugin] plugins.
Yes I know about [rqt_plot](https://github.com/ros-visualization/rqt_plot) and [rqt_multiplot](https://github.com/ANYbotics/rqt_multiplot_plugin) plugins.
I miss the follwing features from them:
* Show/hide individual plots by clicking on the legend
* Add multiple Y axes and allow plots assigned to different axes (when tweaking PID controller it would be very useful)
* Zoom with mouse wheel
* Instantly editable axis scale: https://www.youtube.com/watch?v=Ab1aIiMawGA&feature=youtu.be
* Instantly editable axis scale: https://www.youtube.com/watch?v=Ab1aIiMawGA
8 changes: 5 additions & 3 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 "plotchartwidget.h"
#include "rqt_plot_qtcharts/plotverticalaxesmodel.h"

#include <QDialog>

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

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

private slots:
void on_toolButtonAddAxis_clicked();

void on_toolButtonRemoveAxis_clicked();
void on_tableViewAxesList_doubleClicked(const QModelIndex &index);

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

Expand Down
10 changes: 9 additions & 1 deletion include/rqt_plot_qtcharts/dialogaxisproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#define DIALOGAXISPROPERTIES_H

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

#include <QDialog>
#include <QShowEvent>

namespace Ui {
class DialogAxisProperties;
Expand All @@ -17,12 +19,18 @@ class DialogAxisProperties : public QDialog
explicit DialogAxisProperties(QWidget *parent = 0);
~DialogAxisProperties();

void showEvent(QShowEvent *event);

PlotLineSeries *series() const;
void setSeries(PlotLineSeries *series);

private slots:
PlotVerticalAxis *axis() const;
void setAxis(PlotVerticalAxis *axis);

private slots:
void on_checkBoxAutoScale_toggled(bool checked);
void on_pushButtonAddSeries_clicked();
void on_buttonBox_accepted();

private:
Ui::DialogAxisProperties *ui;
Expand Down
12 changes: 11 additions & 1 deletion include/rqt_plot_qtcharts/dialogplotseriesproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define DIALOGPLOTSERIESPROPERTIES_H

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

#include <QDialog>

Expand All @@ -14,16 +15,25 @@ class DialogPlotSeriesProperties : public QDialog
Q_OBJECT

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

PlotLineSeries *series() const;
void setSeries(PlotLineSeries *series);

void updateAxesComboBox();

private slots:
void on_toolButtonSelectColor_clicked();
void on_DialogPlotSeriesProperties_accepted();

private:
Ui::DialogPlotSeriesProperties *ui;

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

#endif // DIALOGPLOTSERIESPROPERTIES_H
35 changes: 28 additions & 7 deletions include/rqt_plot_qtcharts/plotchartwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

#include "plotlineseries.h"
#include "plotverticalaxis.h"
#include "plotverticalaxesmodel.h"
#include "zoomablechartview.h"

#include <rqt_gui_cpp/plugin.h>

#include <QWidget>

#include <QtCharts/QChart>
Expand All @@ -23,23 +26,41 @@ QT_CHARTS_USE_NAMESPACE

class PlotChartWidget : public QWidget
{
friend class PlotVerticalAxesModel;
Q_OBJECT
public:
explicit PlotChartWidget(QWidget *parent = nullptr);
~PlotChartWidget();

void saveSettings(qt_gui_cpp::Settings& instance_settings) const;
void restoreSettings(const qt_gui_cpp::Settings& instance_settings);
signals:

public slots:
void addSeries(PlotLineSeries *seriesList);
void removeSeries(PlotLineSeries *seriesList);
void addAxis(PlotVerticalAxis *axis);

QList<PlotVerticalAxis *> verticalAxes() const;
void connectLegendMarkerEvents();

QList<PlotLineSeries *> seriesList() const;

private:
QChart *m_chart;
ZoomableChartView *m_chartView;
QValueAxis *m_axisX;
QChart *m_chart;
ZoomableChartView *m_chartView;
QValueAxis *m_axisX;

QList<PlotLineSeries*> m_series;
QList<PlotVerticalAxis*> m_verticalAxes;

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);
void addDefaultAxis();
void setVisibilityOfMarkerAndSeries(QLegendMarker* marker, bool visible);

QList<PlotLineSeries*> m_series;
QList<PlotVerticalAxis*> m_verticalAxes;
private slots:
void handleMarkerClicked();
};

#endif // PLOTCHARTWIDGET_H
17 changes: 15 additions & 2 deletions include/rqt_plot_qtcharts/plotlineseries.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef PLOTLINESERIES_H
#define PLOTLINESERIES_H

#include "rqt_plot_qtcharts/plotverticalaxis.h"

#include <QtCharts/QChart>
#include <QtCharts/QChartGlobal>
#include <QtCharts/QLineSeries>
Expand All @@ -15,11 +17,22 @@ class PlotLineSeries : public QLineSeries
{
public:
PlotLineSeries(QObject *parent = nullptr);
QString dataSource() const;
void setDataSource(const QString &dataSource);

QColor color() const;
void setColor(const QColor &color);

qreal width() const;
void setWidth(const qreal &width);

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

private:
// topic name
QString m_dataSource;


PlotVerticalAxis *m_verticalAxis = nullptr;
};

#endif // PLOTLINESERIES_H
38 changes: 38 additions & 0 deletions include/rqt_plot_qtcharts/plotverticalaxesmodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef PLOTVERTICALAXESMODEL_H
#define PLOTVERTICALAXESMODEL_H

#include "plotchartwidget.h"

#include <QAbstractTableModel>

class PlotChartWidget;

class PlotVerticalAxesModel : public QAbstractTableModel
{
public:

enum Columns {
Col_Name,
Col_Visible,
Col_Invalid
};

PlotVerticalAxesModel(PlotChartWidget *widget, 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;

void refresh();
PlotVerticalAxis *axis(const QModelIndex & index);

private:
PlotChartWidget *m_chartWidget;
};

#endif // PLOTVERTICALAXESMODEL_H
20 changes: 20 additions & 0 deletions include/rqt_plot_qtcharts/plotverticalaxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,28 @@ QT_CHARTS_USE_NAMESPACE

class PlotVerticalAxis : public QValueAxis
{
Q_OBJECT
public:
PlotVerticalAxis(QObject *parent = nullptr);

QString label() const;
void setLabel(const QString &label);

QString name() const;
void setName(const QString &name);

bool autoScale() const;
void setAutoScale(bool value);

Qt::Alignment align() const;
void setAlign(const Qt::Alignment &align);

private:
QString m_name, m_label;
bool m_autoScale = false;
Qt::Alignment m_align;
signals:
void alignChanged(Qt::Alignment align);
};

#endif // PLOTVERTICALAXIS_H
18 changes: 18 additions & 0 deletions include/rqt_plot_qtcharts/randomcolorgenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef RANDOMCOLORGENERATOR_H
#define RANDOMCOLORGENERATOR_H

#include <QColor>
#include <QVector>

class RandomColorGenerator
{
public:
QColor get();
static RandomColorGenerator *getInstance();
private:
QVector<QColor> m_colorList;
int m_index = 0;
static RandomColorGenerator* m_instance;
};

#endif // RANDOMCOLORGENERATOR_H
6 changes: 4 additions & 2 deletions include/rqt_plot_qtcharts/rqt_plot_qtcharts.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ class PlotQtCharts : public rqt_gui_cpp::Plugin
void initPlugin(qt_gui_cpp::PluginContext& context) override;
void shutdownPlugin() override;

void saveSettings(qt_gui_cpp::Settings& plugin_settings, qt_gui_cpp::Settings& instance_settings) const override;
void restoreSettings(const qt_gui_cpp::Settings& plugin_settings, const qt_gui_cpp::Settings& instance_settings) override;
void saveSettings(qt_gui_cpp::Settings& plugin_settings,
qt_gui_cpp::Settings& instance_settings) const override;
void restoreSettings(const qt_gui_cpp::Settings& plugin_settings,
const qt_gui_cpp::Settings& instance_settings) override;

private:
PlotQtChartsWidget *m_widget = nullptr;
Expand Down
22 changes: 18 additions & 4 deletions include/rqt_plot_qtcharts/rqt_plot_qtcharts_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@
#include "rqt_plot_qtcharts/plotverticalaxis.h"
#include "rqt_plot_qtcharts/dialogaxes.h"

#include <ros/master.h>

#include <rqt_gui_cpp/plugin.h>

#include <QAction>
#include <QWidget>

namespace Ui {
class PlotQtChartsWidget;
}

class SeriesRemoveAction : public QAction
{
Q_OBJECT
public:
SeriesRemoveAction(PlotLineSeries *series, QObject *parent = nullptr);

PlotLineSeries *series() const;

private:
PlotLineSeries *m_series;
};

class PlotQtChartsWidget : public QWidget
{
Q_OBJECT
Expand All @@ -21,8 +33,8 @@ class PlotQtChartsWidget : public QWidget
explicit PlotQtChartsWidget(QWidget *parent = nullptr);
~PlotQtChartsWidget();

void saveSettings(qt_gui_cpp::Settings& plugin_settings, qt_gui_cpp::Settings& instance_settings) const override;
void restoreSettings(const qt_gui_cpp::Settings& plugin_settings, const qt_gui_cpp::Settings& instance_settings) override;
void saveSettings(qt_gui_cpp::Settings& instance_settings) const;
void restoreSettings(const qt_gui_cpp::Settings& instance_settings);

private slots:
void on_toolButtonAddTopic_clicked();
Expand All @@ -34,6 +46,8 @@ private slots:
DialogAxes *m_axesDialog;

QList<PlotVerticalAxis*> m_verticalAxes;

QMenu *m_seriesMenu;
};

#endif // RQT_PLOT_QTCHARTS_WIDGET_H
Binary file added res/list-add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/list-remove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions res/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<RCC>
<qresource prefix="/icons">
<file>x-axis_and_y-axis-512.png</file>
<file>list-remove.png</file>
<file>list-add.png</file>
</qresource>
</RCC>
5 changes: 5 additions & 0 deletions rqt_plot_qtcharts.files
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
include/rqt_plot_qtcharts/plotverticalaxesmodel.h
include/rqt_plot_qtcharts/plotverticalaxis.h
include/rqt_plot_qtcharts/plotlineseries.h
include/rqt_plot_qtcharts/dialogaxes.h
include/rqt_plot_qtcharts/dialogaxisproperties.h
include/rqt_plot_qtcharts/dialogplotseriesproperties.h
include/rqt_plot_qtcharts/randomcolorgenerator.h
include/rqt_plot_qtcharts/rqt_plot_qtcharts.h
include/rqt_plot_qtcharts/rqt_plot_qtcharts_widget.h
include/rqt_plot_qtcharts/plotchartwidget.h
include/rqt_plot_qtcharts/zoomablechartview.h
res/resources.qrc
res/resources.qrc
src/rqt_plot_qtcharts/plotlineseries.cpp
src/rqt_plot_qtcharts/dialogaxes.cpp
src/rqt_plot_qtcharts/dialogaxisproperties.cpp
src/rqt_plot_qtcharts/dialogplotseriesproperties.cpp
src/rqt_plot_qtcharts/plotverticalaxesmodel.cpp
src/rqt_plot_qtcharts/plotverticalaxis.cpp
src/rqt_plot_qtcharts/randomcolorgenerator.cpp
src/rqt_plot_qtcharts/rqt_plot_qtcharts.cpp
src/rqt_plot_qtcharts/rqt_plot_qtcharts_widget.cpp
src/rqt_plot_qtcharts/plotchartwidget.cpp
Expand Down
Loading

0 comments on commit f1a4ef8

Please sign in to comment.