/* ImLib3D
 * Copyright (c) 2001, ULP-IPB Strasbourg.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
/*! \file   GnuPlotInterface.hpp */

#ifndef _GnuPlotInterface_hpp
#define _GnuPlotInterface_hpp

#include <GnuPlotInterface/gnuplot_i.h>
#include <vector>
#include <string>
#ifndef __HP_aCC
using namespace std;
#endif // __HP_aCC

//using namespace NEWMAT;

//!Wrapper Class for gnuplot_i (formerly gnuplot_pipes) by N. Devillard
class GnuPlotInterface
{
private:
	gnuplot_ctrl* plot;
public:
	GnuPlotInterface(){plot = gnuplot_init();}
	~GnuPlotInterface(){gnuplot_close(plot);}
	void Cmd(const char * cmd, ...);
	//! Set one of the following styles: {lines, points, linespoints, impulses, dots, steps, errobars, boxes, boxeserrorbars}
	void SetStyle(const string& plotStyle){gnuplot_setstyle(plot,(char *)plotStyle.c_str());}
	void Reset(){gnuplot_resetplot(plot);}
	void Clear(){gnuplot_resetplot(plot);}

	void PlotData(const vector<float>& data, float nStart=-10000, float nStop=-10000, const string& title="");
	void PlotData(const vector<float >& dataX, vector<float >& dataY, const string& title="");
	void PlotData(const vector<double>& dataX, vector<double>& dataY, const string& title="");
	void PlotData(const vector<pair<float, float> >& dataPoints, const string& title="");


/*	void PlotData(const  DiagonalMatrix& values, float nStart=-10000, float nStop=-10000, const string& title="")
	{
		vector<float> vec; 	MakeVector(values, vec);
		PlotData(vec, nStart, nStop, title);
		}*/
	void PlotSlope(float a, float b, const string& title="");
	void PlotFunction(const string& fncName, const string& title="");

	void SetXLabel(const string& label){gnuplot_set_xlabel(plot, (char *)label.c_str());}
	void SetYLabel(const string& label){gnuplot_set_ylabel(plot, (char *)label.c_str());}
	
	static void Test();
};


#endif // _GnuPlotInterface_hpp
