Skip to content
OE_actions.cpp 2.23 KiB
Newer Older
3dsman's avatar
3dsman committed
* 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
*/

#include "actions/OE_actions.h"
#include "OE_document.h"
#include "curves/OE_curve.h"
#include "stitchs/OE_stitchs.h"
OE_actions::OE_actions(OE_document* doc) : active(true), document(doc)
float OE_actions::switchVal(float Original, float* storage)
{
raoul's avatar
raoul committed
	float tmp = *storage;
	*storage = Original;
	return tmp;
OE_curve* OE_actions::switchVal(OE_pointcurve* Original, OE_pointcurve** storage)
raoul's avatar
raoul committed
	OE_pointcurve* tmp = *storage;
	*storage = Original;
	return tmp;
std::list<OE_pointcurve*> OE_actions::switchVal(std::list<OE_pointcurve*> Original, std::list<OE_pointcurve*>* storage)
raoul's avatar
raoul committed
	std::list<OE_pointcurve*> tmp = *storage;
	*storage = Original;
	return tmp;
}

OE_stitchs* OE_actions::switchVal(OE_stitchs* Original, OE_stitchs** storage)
{
raoul's avatar
raoul committed
	OE_stitchs* tmp = *storage;
	*storage = Original;
	return tmp;
}

std::list<OE_stitchs*> OE_actions::switchVal(std::list<OE_stitchs*> Original, std::list<OE_stitchs*>* storage)
{
raoul's avatar
raoul committed
	std::list<OE_stitchs*> tmp = *storage;
	*storage = Original;
	return tmp;
unsigned OE_actions::switchVal(unsigned Original, unsigned* storage)
{
raoul's avatar
raoul committed
	unsigned tmp = *storage;
	*storage = Original;
	return tmp;
}

bool OE_actions::switchVal(bool Original, bool* storage)
{
raoul's avatar
raoul committed
	bool tmp = *storage;
	*storage = Original;
	return tmp;
OE_actionsMeta::OE_actionsMeta(OE_document* doc) : OE_actions(doc)
{
}

OE_actionsMeta::~OE_actionsMeta()
{
raoul's avatar
raoul committed
	if (document)
	{
		std::list<OE_actions*>::iterator action = actions.begin();
		while (action != actions.end())
		{
			delete *action;
		}
		actions.clear();
	}
}

void OE_actionsMeta::undo()
{
raoul's avatar
raoul committed
	if (document)
	{
		std::list<OE_actions*>::iterator action = actions.begin();

		while (action != actions.end())
		{
			(*action)->undo();
			action++;
		}
	}
}

void OE_actionsMeta::redo()
{
raoul's avatar
raoul committed
	if (document)
	{
		std::list<OE_actions*>::iterator action = actions.begin();

		while (action != actions.end())
		{
			(*action)->redo();
			action++;
		}
	}
raoul's avatar
raoul committed