#include <string>
#include <vector>
#include <gnuplot_i.hpp>
#include <Component.h>
#include <Profile.h>

using namespace std;

#ifndef _Projection
#define _Projection

class Command;

class Projection
{
private:
	int ID_;
	Gnuplot *gplt;
	string terminal_;
	string argvComp_;		// string sent by the user with -p or -t option

	vector <Command *> cmds_;
	vector <Component *> inputComps_;
	vector <Component *> comps_;
	vector <string> compToProj_;	// individual components separated from argvComp_ (: striped)
	vector <string> compToLabel_;	// individual components separated from argvComp_ (: striped)
	vector <string> colorToProj_;	// individual components separated from argvComp_ (: striped)

	float xmin_, xmax_, ymin_, ymax_;	// min and max values in x and y coords
	float xSmin_, xSmax_, ySmin_, ySmax_;	// custom range selected by the user
	float border_;
	bool sRange_;				// indicate custom range must be used
	bool geometry_;

	void extractArgv(void);
	void calcRange(string);
	void replaceCompName(void);
	void replaceAll(string& str, const string& from, const string& to);
public:
	Projection(int, string, argvOpt, const vector <Component *> &);

	int ID(void);
	Gnuplot * projection(void);
	string terminal(void);

	int nCmd(void);
	Command * cmd(int);
	void addCmd(Command *);
	void addComp(Component *);
	int nComps(void);	// number of components

	string compToProj(int);
	string compToLabel(int);
	string colorToProj(int);

	float xmin(void);
	float xmax(void);
	float ymin(void);
	float ymax(void);
	bool sRange(void);

	void setSrange(float, float, float, float);
	void resetSrange(void);
	void triangularTransform(void);
	void findColors(void);
	void showComps(void);
};

#endif
