/* General purpose X-Y plotting that can print/export to Postscript thanks to Trolltech's QT

Copyright (C) 2001-2002 Andrew Rogers

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 */

#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qprinter.h>
#include <qcolor.h>


class MPlot : public QWidget
{
    Q_OBJECT
private:
    double x_min,x_max,y_min,y_max,x_nd,y_nd;
    int x_margin, y_margin;
    double *x_data;
    double *y_data;
    float x_angle,y_angle;

    QPushButton *buttPrint;
    QPrinter *printer;

    struct data
    {
        double *x_data_ptr;
        double *y_data_ptr;
        QColor color;
        int size;
    } data_array[10];

    int data_array_size;

public:
    MPlot(QWidget * parent=0, const char * name=0, WFlags f=0);
    virtual ~MPlot();
    void drawFromFloat(int num,double *xdata,double *ydata, int line_num=0, QColor color=blue);
    void setRangeFromFloat(double xmin,double ymin,double xmax,double ymax);
    void setAxis(int nxd=10,int nyd=10,float anglex=30,float angley=10);
    void MPlot::drawPlot(QPainter *p);

protected:
    virtual void paintEvent ( QPaintEvent * );

public slots:
    void print();

};

