/*
 * Copyright (c) 2015 Tricoire Sebastien 3dsman@free.fr
 *
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 * claim that you wrote the original software. If you use this software
 * in a product, an acknowledgment in the product documentation would be
 * appreciated but is not required.
 * 2. Altered source versions must be plainly marked as such, and must not be
 * misrepresented as being the original software.
 * 3. This notice may not be removed or altered from any source distribution.
 *
 */

#pragma once

#include "OE_utils.h"
#include "OE_curve.h"
#include <stdint.h>
#include <vector>

class OE_pointcurve : public OE_curve
{
	public:
		/** Default constructor */
		OE_pointcurve();
		OE_pointcurve(std::vector<vector_2d> points, bool closed);
		/** Default destructor */
		virtual ~OE_pointcurve();

		/** \brief to get a point in the curve. */
		bool getPoint(uint16_t nb, float* x, float* y);
		bool getPoint(uint16_t nb, vector_2d& pt);

		/** \brief to set a point in the curve. */
		bool setPoint(uint16_t nb, float x, float y);
		bool setPoint(uint16_t nb, vector_2d coord);
		bool movePoint(uint16_t nb, vector_2d coord);

		/** \brief to add a point at the end of the curve. */
		bool addPoint(float x, float y);
		bool addPoint(vector_2d pt);

		/** \brief to add a linear segment at the end of the curve. */
		void lineTo(float x, float y);
		void lineTo(vector_2d pt);

		virtual void setClosed(bool closed);

		void cubicBezTo(float cpx1, float cpy1, float cpx2, float cpy2, float x, float y);

		/** \brief refresh the pts array. */
		//virtual void refresh(){};
		virtual void refresh(float dpi, bool force=false);

		/** \brief move the curve
		 */
		virtual void move(vector_2d offset);

		/** \brief scale the curve
		 */
		virtual void scale(vector_2d ratio, vector_2d pos);

	private:
		/** \brief color of the handle lines */
		static unsigned char controlLineColor[4];

		/** \brief color of the handle points */
		static unsigned char controlPointColor[4];

		/** \brief color of the curve start and end points */
		static unsigned char controlEndPointColor[4];
};

