/*
 * 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 "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;
};

