#ifndef PLOT_WINDOW_H
#define PLOT_WINDOW_H

#if QT_VERSION < 0x040000
#include <qmainwindow.h>
#include <qmenubar.h>
#include <qslider.h>
#include <qfiledialog.h>
#include <qdialog.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qprintdialog.h>
#include <qprinter.h>
#else
#include <QMainWindow>
#include <QAction>
#include <QMenuBar>
#include <QSlider>
#include <QFileDialog>
#include <QDialog>
#include <QLayout>
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QPrintDialog>
#include <QPrinter>
#endif

#include "IntervalDialog.h"
#include "QtPLWidget.h"
#include "qprofile.h"


class PlotWindow : public QMainWindow
{
    Q_OBJECT
            
	public:
		PlotWindow(int id, int width=500, int height=500, double saveWidth=600, double saveHeight=600, int resolution=72, QPrinter::PageSize pageSize=QPrinter::A4, QPrinter::Orientation orientation=QPrinter::Portrait, QWidget* parent=NULL);
		
                        QtPLWidget * plot;
                        
                        void save();
                        
                        void unsave();
                        
                        void print_iden();
                        
                        void setSmooth(bool b);
                        
                        void setId(int id);
                        
                        int getId();
                        
                        void setPLFocus();
                        
                        void setSize(double width, double height); //for save only
			
			void setTitle(const QString& title);
			
			QPrinter::PageSize pageSize;
			QPrinter::Orientation orientation;
                        int resolution; //dpi
			
			IntervalDialog * intervalDialog;
			
	signals:
		
		void clicked(double x,double y, int pos_x, int pos_y); // interface between widget and window
		
		void rescale(double start, double end); // interface between intervalDialog and window
				
    public slots:
        
	void savePlotPNG(); // Functions for Mac
	void savePlotJPG();
	void savePlotPS();
	void savePlotPDF();
	void savePlotSVG();

//         void savePlot();

	void printPlot();
	
	void changeDisplayedRatio(double r);
        
	protected:
            
            int id;
            
            PLINT strm;
            
            double saveWidth, saveHeight;
	    
	    QString title;


};

// extern PlotWindow *QPlot_window;
#if QT_VERSION < 0x040000
extern std::list<PlotWindow*> GlobalPlotWindows;
#else
extern QList<PlotWindow*> GlobalPlotWindows;
#endif

// void QPlotmakeWindow(QWidget*,char*);

PlotWindow* focusPlotWindow(int id, double width=-1., double height=-1., int resolution=72, QPrinter::PageSize pageSize=QPrinter::A4, QPrinter::Orientation orientation=QPrinter::Portrait);
PlotWindow* newPlotWindow(double width, double height, int* id, int resolution=72, QPrinter::PageSize pageSize=QPrinter::A4, QPrinter::Orientation orientation=QPrinter::Portrait);

void clearPlotWindows();


#endif

