SocExplorerPlot.h
134 lines
| 4.7 KiB
| text/x-c
|
CLexer
/ src / SocExplorerPlot.h
r0 | /*------------------------------------------------------------------------------ | |||
-- 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 <QWidget> | ||||
#include <QGridLayout> | ||||
#include <qcustomplot.h> | ||||
r7 | #include <qcustomplotvect.h> | |||
r2 | #include <QRubberBand> | |||
#include <QPoint> | ||||
r0 | ||||
r7 | class SocExplorerPlotActions : public QAction | |||
{ | ||||
Q_OBJECT | ||||
public: | ||||
SocExplorerPlotActions(const QString &text,int PID,QObject* parent=0) | ||||
:QAction(text,parent) | ||||
{ | ||||
setPID(PID); | ||||
connect(this,SIGNAL(triggered()),this,SLOT(trigger())); | ||||
} | ||||
SocExplorerPlotActions(const QIcon &icon, const QString &text,int PID, QObject* parent) | ||||
:QAction(icon,text,parent) | ||||
{ | ||||
setPID(PID); | ||||
connect(this,SIGNAL(triggered()),this,SLOT(trigger())); | ||||
} | ||||
~SocExplorerPlotActions(){} | ||||
void setPID(int PID){this->m_PID=PID;} | ||||
int PID(){return m_PID;} | ||||
private slots: | ||||
void trigger(){emit triggered(m_PID);} | ||||
signals: | ||||
void triggered(int PID); | ||||
private: | ||||
int m_PID; | ||||
}; | ||||
r0 | class SocExplorerPlot : public QWidget | |||
{ | ||||
Q_OBJECT | ||||
public: | ||||
explicit SocExplorerPlot(QWidget *parent = 0); | ||||
r2 | ~SocExplorerPlot(); | |||
r0 | void setTitle(QString title); | |||
r10 | const QString& title(); | |||
r0 | void setXaxisLabel(QString label); | |||
r9 | void setXaxisLog(); | |||
r0 | void setXaxisRange(double lower, double upper); | |||
void setYaxisLabel(QString label); | ||||
r9 | void setYaxisLog(); | |||
r0 | void setYaxisRange(double lower, double upper); | |||
void rescaleAxis(); | ||||
void setLegendFont(QFont font); | ||||
void setLegendSelectedFont(QFont font); | ||||
void setAdaptativeSampling(int graphIndex,bool enable); | ||||
r3 | void setUseFastVector(int graphIndex,bool enable); | |||
r0 | int addGraph(); | |||
bool removeGraph(int graphIndex); | ||||
r7 | int graphCount(); | |||
r0 | void removeAllGraphs(); | |||
void setGraphName(int graphIndex,QString name); | ||||
r10 | const QString& graphName(int graphIndex); | |||
r0 | void setGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> y); | |||
void setGraphData(int graphIndex, QCPDataMap* data,bool copy = true,bool replot=true); | ||||
r3 | void setGraphData(int graphIndex, QVector<QCPData> *data, bool replot); | |||
r0 | void addGraphData(int graphIndex, QList<QVariant> x, QList<QVariant> 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(); | ||||
r5 | void exportToSVG(const QString& fileName); | |||
void exportToPDF(const QString& fileName); | ||||
r7 | void addAction(SocExplorerPlotActions* action); | |||
int PID(){return m_PID;} | ||||
void setPID(int PID){m_PID = PID;} | ||||
QVector<QCPData>* getVisibleData(int graphIndex); | ||||
r0 | signals: | |||
r6 | void titleChanged(const QString& newTitle); | |||
r0 | public slots: | |||
protected: | ||||
void keyPressEvent(QKeyEvent *); | ||||
void keyReleaseEvent(QKeyEvent *); | ||||
void wheelEvent(QWheelEvent *); | ||||
void mousePressEvent(QMouseEvent *); | ||||
void mouseMoveEvent(QMouseEvent *); | ||||
void mouseReleaseEvent(QMouseEvent *); | ||||
private: | ||||
r1 | void zoom(double factor, int center, Qt::Orientation orientation); | |||
void move(double factor, Qt::Orientation orientation); | ||||
r7 | QCustomPlotVect* m_plot; | |||
r0 | QGridLayout* m_mainlayout; | |||
bool ctrl_hold; | ||||
bool shift_hold; | ||||
bool mouse_hold; | ||||
QCPRange DragStartHorzRange; | ||||
QCPRange DragStartVertRange; | ||||
QPoint mDragStart; | ||||
r2 | bool mZoomMode; | |||
QRubberBand * mRubberBand; | ||||
QPoint mOrigin; | ||||
r7 | QList<SocExplorerPlotActions*> m_actions; | |||
r10 | QString m_Title; | |||
r7 | int m_PID; | |||
r0 | }; | |||
#endif // SOCEXPLORERPLOT_H | ||||