#ifndef WIDGETS_GRAPHPLOTTER_SRAMPINTERPOLATOR_H
#define WIDGETS_GRAPHPLOTTER_SRAMPINTERPOLATOR_H

#include "Interpolator.h"


// -- TDE NAMESPACE ----------------------------------------------------

namespace TDE {

// -- Widgets NAMESPACE ------------------------------------------------

namespace Widgets {

namespace Plot {


class SRamp
{
public:
	// http://www.plcforum.it/f/files/file/161-rampe-ad-spdf/
	// http://www.websiti.com/plcforum/upload/index.php?action=downloadfile&filename=Rampe%20ad%20S.pdf&directory=Matematica-Fisica&PHPSESSID=14c52111d26ee8405900ae59166ed0f8
	SRamp(const Point& p0, const Point& p1, const InterpolatorParameters& params);

	double compute(double x) const;

	double operator()(double x) const 	{ return compute(x); }

	Point p0, p1;
	double T, t, a, m, c, f, g, h;
	double x1, x2;

private:
	void _setup();
	InterpolatorParameters m_parameters;
};

class SRampInterpolator : public Interpolator
{
public:
	SRampInterpolator(const std::vector<Point>& points);
	SRampInterpolator(const std::vector<Point>& points, const InterpolatorParameters& params);
	virtual ~SRampInterpolator();

	virtual double compute(double x) const;
	boost::optional<const SRamp&> findSRamp(double x) const;

	std::vector<SRamp> m_ramps;

private:
	void _setup(const std::vector<Point>& points);
};


} /* end of namespace Plot */

} /* end of namespace Widgets */

} /* end of namespace TDE */

#endif /* WIDGETS_GRAPHPLOTTER_SRAMPINTERPOLATOR_H */
