#include <PrintEpsCommand.h>
#include <PlotCommand.h>


PrintEpsCommand :: PrintEpsCommand() :
	name("PrintEps")
{
}


string PrintEpsCommand :: execute(Projection *projection, Profile *profile)
{
	string decor, strPlotCmd;

	Gnuplot * gplt = projection->projection();

/*
	if ( profile->decoration() )
		decor = "_decor";
	else
		decor = "";
*/

	system ("mkdir -p img");
	//cout << "Saving image 'img/proj"<< projection->ID() << "_step" << profile->index() << decor << ".eps" << endl;
	cout << "Saving image 'img/proj"<< projection->ID() << "_step" << profile->index() << ".eps" << endl;

	// terminal epslatex produces a .tex file !!
	//gplt->cmd ("set terminal epslatex size 7.0,5.24 color colortext 10");
	//gplt->cmd ("set terminal postscript eps size 7.0,5.24 solid enhanced color font 'Helvetica,15'");
	gplt->cmd ("set terminal postscript eps size %f,%f solid enhanced color font 'Helvetica,%d' linewidth %f",\
		profile->printXdim(), profile->printYdim(), profile->fontSize(), profile->lineWidth() );
	gplt->cmd ("set output 'img/proj%d_step%d%s.eps'", projection->ID(), profile->index(), decor.c_str());

	PlotCommand * plotCmd = new PlotCommand;
	strPlotCmd = plotCmd->execute(projection, profile);
	gplt->cmd (strPlotCmd.c_str());

	gplt->cmd ("set term %s noraise title 'Projection %d'", projection->terminal().c_str(), projection->ID());
	gplt->cmd ("unset output");

	return "";
}


