/*
* This file is part of project OpenEmbroidery. It's copyrighted by
* the contributors recorded in the version control history of the file.
* Original project location https://code.electrolab.fr/openEmbroidery/openEmbroidery_software
*
* SPDX-License-Identifier: CECILL-2.1
* License-Filename: Licence_CeCILL_V2.1-en.txt
*/

#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];
};

