QGCDataPlot2D.h 1.93 KB
Newer Older
1 2 3 4 5 6 7 8
#ifndef QGCDATAPLOT2D_H
#define QGCDATAPLOT2D_H

#include <QWidget>
#include <QFile>
#include "IncrementalPlot.h"
#include "LogCompressor.h"

9 10 11
namespace Ui
{
class QGCDataPlot2D;
12 13
}

14 15
class QGCDataPlot2D : public QWidget
{
16 17 18 19 20
    Q_OBJECT
public:
    QGCDataPlot2D(QWidget *parent = 0);
    ~QGCDataPlot2D();

21 22 23
    /** @brief Calculate and display regression function*/
    bool calculateRegression(QString xName, QString yName, QString method="linear");

24
    /** @brief Linear regression over data points */
25
    bool linearRegression(double *x, double *y, int n, double *a, double *b, double *r);
26 27

public slots:
28
    /** @brief Load previously selected file */
29
    void loadFile();
30 31
    /** @brief Load file with this name */
    void loadFile(QString file);
32 33 34 35 36 37 38 39
    /** @brief Reload a file, with filtering enabled */
    void reloadFile();
    void selectFile();
    void loadCsvLog(QString file, QString xAxisName="", QString yAxisFilter="");
    void loadRawLog(QString file, QString xAxisName="", QString yAxisFilter="");
    void saveCsvLog();
    /** @brief Save plot to PDF or SVG */
    void savePlot();
40 41
    /** @brief Export PDF file */
    void exportPDF(QString fileName);
42 43 44 45
    /** @brief Export SVG file */
    void exportSVG(QString file);
    /** @brief Print or save PDF file (MacOS/Linux) */
    void print();
46 47
    /** @brief Calculate and display regression function*/
    bool calculateRegression();
48

LM's avatar
LM committed
49 50 51
signals:
    void visibilityChanged(bool visible);

52
protected:
LM's avatar
LM committed
53 54 55 56 57 58 59 60 61 62 63 64
    void showEvent(QShowEvent* event)
    {
        QWidget::showEvent(event);
        emit visibilityChanged(true);
    }

    void hideEvent(QHideEvent* event)
    {
        QWidget::hideEvent(event);
        emit visibilityChanged(false);
    }

65
    void changeEvent(QEvent *e);
66
    QString getSavePlotFilename();
67 68 69 70
    IncrementalPlot* plot;
    LogCompressor* compressor;
    QFile* logFile;
    QString fileName;
71
    QStringList curveNames;
72 73 74 75 76 77

private:
    Ui::QGCDataPlot2D *ui;
};

#endif // QGCDATAPLOT2D_H