/*
* 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 "actions/OE_actions.h"
#include "curves/OE_curve.h"
#include "curves/OE_joincurve.h"
#include "curves/OE_subcurve.h"
#include "curves/OE_pointcurve.h"

class OE_actionNewCurve : public OE_actions
{
	public:
		OE_actionNewCurve(OE_document* doc, OE_pointcurve* curve);

		virtual ~OE_actionNewCurve();

		virtual void undo();
		virtual void redo();

	protected:
		OE_pointcurve* actionCurve;
};

class OE_actionDelCurve : public OE_actions
{
	public:
		OE_actionDelCurve(OE_document* doc, OE_pointcurve* curve);

		virtual ~OE_actionDelCurve();

		virtual void undo();
		virtual void redo();

	protected:
		OE_pointcurve* actionCurve;
};

class OE_actionJoincurveAddSubCurve : public OE_actions
{
	public:
		OE_actionJoincurveAddSubCurve(OE_document* doc, OE_joincurve* joincurve, int index, OE_curve* curve,
		                              float start, float end, bool reverse);

		virtual ~OE_actionJoincurveAddSubCurve();

		virtual void undo();
		virtual void redo();

		bool getDir();

		void setEnd(float end);

		void setStart(float start);

		void setDir(bool dir);
	protected:
		OE_joincurve* actionCurve;
		OE_subcurve* subcurve;
		int id;
};

class OE_actionMovePointCurve : public OE_actions
{
	public:
		OE_actionMovePointCurve(OE_document* doc, OE_pointcurve* curve, uint16_t idPoint, vector_2d offset);

		virtual ~OE_actionMovePointCurve();

		virtual void undo();
		virtual void redo();

		void setMove(vector_2d offset);

	protected:
		OE_pointcurve* actionCurve;
		uint16_t idPoint;
		vector_2d oldCoord;
		vector_2d offset;
};

class OE_actionSetCloseCurve : public OE_actions
{
	public:
		OE_actionSetCloseCurve(OE_document* doc, OE_curve* curve, bool closed);

		virtual ~OE_actionSetCloseCurve();

		virtual void undo();
		virtual void redo();

	protected:
		OE_curve* actionCurve;
		bool oldClosed;
		bool closed;
		int oldPts;
};

class OE_actionSetSubcurvePos : public OE_actions
{
	public:
		OE_actionSetSubcurvePos(OE_document* doc, OE_subcurve* curve, bool start, double pos);

		virtual ~OE_actionSetSubcurvePos();

		virtual void undo();
		virtual void redo();

		bool getInvertDir();

		void setPos(double pos);

		void setInvertDir(bool invert);

	protected:
		OE_subcurve* actionCurve;
		bool start;
		double pos;
		double oldPos;
		bool invert = false;
};

