/*------------------------------------------------------------------------------ -- This file is a part of the QLop Software -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------*/ /*-- Author : Alexis Jeandet -- Mail : alexis.jeandet@member.fsf.org ----------------------------------------------------------------------------*/ #ifndef SOCEXPLORERPLOT_H #define SOCEXPLORERPLOT_H #include #include #include #include #include class SocExplorerPlot : public QWidget { Q_OBJECT public: explicit SocExplorerPlot(QWidget *parent = 0); ~SocExplorerPlot(); void setTitle(QString title); void setXaxisLabel(QString label); void setXaxisRange(double lower, double upper); void setYaxisLabel(QString label); void setYaxisRange(double lower, double upper); void rescaleAxis(); void setLegendFont(QFont font); void setLegendSelectedFont(QFont font); void setAdaptativeSampling(int graphIndex,bool enable); void setUseFastVector(int graphIndex,bool enable); int addGraph(); bool removeGraph(int graphIndex); void removeAllGraphs(); void setGraphName(int graphIndex,QString name); void setGraphData(int graphIndex, QList x, QList y); void setGraphData(int graphIndex, QCPDataMap* data,bool copy = true,bool replot=true); void setGraphData(int graphIndex, QVector *data, bool replot); void addGraphData(int graphIndex, QList x, QList y); void addGraphData(int graphIndex, QVariant x, QVariant y); void setGraphPen(int graphIndex,QPen pen); QPen getGraphPen(int graphIndex); void setGraphLineStyle(int graphIndex,QString lineStyle); void setGraphScatterStyle(int graphIndex,QString scatterStyle); void setXaxisTickLabelType(QCPAxis::LabelType type); void setXaxisDateTimeFormat(const QString &format); void show(); void replot(); void exportToSVG(const QString& fileName); void exportToPDF(const QString& fileName); signals: void titleChanged(const QString& newTitle); public slots: protected: void keyPressEvent(QKeyEvent *); void keyReleaseEvent(QKeyEvent *); void wheelEvent(QWheelEvent *); void mousePressEvent(QMouseEvent *); void mouseMoveEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); private: void zoom(double factor, int center, Qt::Orientation orientation); void move(double factor, Qt::Orientation orientation); QCustomPlot* m_plot; QGridLayout* m_mainlayout; bool ctrl_hold; bool shift_hold; bool mouse_hold; QCPRange DragStartHorzRange; QCPRange DragStartVertRange; QPoint mDragStart; bool mZoomMode; QRubberBand * mRubberBand; QPoint mOrigin; }; #endif // SOCEXPLORERPLOT_H