/*
 * 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 "stitchs/OE_fillstitch.h"
#include "actions/OE_actions.h"

class OE_actionNewFillStitch : public OE_actions
{
	public:
		OE_actionNewFillStitch(OE_document* doc, float len, float width, OE_pattern* pattern);

		virtual ~OE_actionNewFillStitch();

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

	protected:
		OE_actions* action;
		OE_fillstitch* FillStitch;
};

class OE_actionSetFillStitchPattern : public OE_actions
{
	public:
		OE_actionSetFillStitchPattern(OE_document* doc, OE_fillstitch* stitch, OE_pattern* pattern);

		virtual ~OE_actionSetFillStitchPattern();

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

	protected:
		OE_fillstitch* actionStitch;
		OE_pattern* oldPattern;
		OE_pattern* newPattern;
};

class OE_actionSetFillStitchLen : public OE_actions
{
	public:
		OE_actionSetFillStitchLen(OE_document* doc, OE_fillstitch* stitch, float len);

		virtual ~OE_actionSetFillStitchLen();

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

	protected:
		OE_fillstitch* actionStitch;
		float oldLen;
};

class OE_actionSetFillStitchWidth : public OE_actions
{
	public:
		OE_actionSetFillStitchWidth(OE_document* doc, OE_fillstitch* stitch, float width);

		virtual ~OE_actionSetFillStitchWidth();

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

		float getWidth();

		void setWidth(float width);

		void offsetWidth(float offset);

	protected:
		OE_fillstitch* actionStitch;
		float oldWidth;
		float oldOffset;
};

class OE_actionScaleSelectedFillStitchWidth : public OE_actions
{
	public:
		OE_actionScaleSelectedFillStitchWidth(OE_document* doc, float scale);

		virtual ~OE_actionScaleSelectedFillStitchWidth();

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

		void scaleWidth(float scale);

	protected:
		std::list<OE_actionSetFillStitchWidth*> actions;
		float oldScale;
};

class OE_actionScaleSelectedFillStitchLen : public OE_actions
{
	public:
		OE_actionScaleSelectedFillStitchLen(OE_document* doc, float scale);

		virtual ~OE_actionScaleSelectedFillStitchLen();

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

		void scaleLen(float scale);

	protected:
		std::list<OE_actionSetFillStitchLen*> actions;
};


class OE_actionSetSelectedFillStitchPattern : public OE_actions
{
	public:
		OE_actionSetSelectedFillStitchPattern(OE_document* doc, OE_pattern* pattern);

		virtual ~OE_actionSetSelectedFillStitchPattern();

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

	protected:
		std::list<OE_actionSetFillStitchPattern*> actions;
};

class OE_actionMovePointFillStitch : public OE_actions
{
	public:
		OE_actionMovePointFillStitch(OE_document* doc, OE_fillstitch* stitch, int _pos, vector_2d _offet);

		virtual ~OE_actionMovePointFillStitch();

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

		void setOffset(vector_2d offset);

	protected:
		OE_fillstitch* actionStitch;
		vector_2d oldPoint;
		vector_2d offset;
		int pos;
};

