/*
* 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 "OE_pattern.h"

OE_pattern::OE_pattern()
{
}

OE_pattern::OE_pattern(std::vector<vector_2d> _pts, float _defaultOffset, bool _endPoints, std::string _name)
{
	pts = _pts;
	endPoints = _endPoints;
	defaultOffset = _defaultOffset;
	name = _name;
}

void OE_pattern::persist(Pakal::Archive* archive)
{
	archive->value("pts", pts);
	archive->value("endPoints", endPoints);
	archive->value("defaultOffset", defaultOffset);
	archive->value("name", name);
}

std::list<OE_pattern*> OE_pattern::createStandardPatterns()
{
	std::list<OE_pattern*> standardPattern;
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0)},0, false, "straight"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
	                                          vector_2d(1, 0),
											  vector_2d(0, 0)},0, false, "triple straight"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 1),
											  vector_2d(0.5, 0)},0.5, false, "satin"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
											  vector_2d(0, 1)},0.5, false, "stretch"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
											  vector_2d(0.3, 1),
											  vector_2d(0.6, 0)},0.5, false, "overcast"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
											  vector_2d(0, 1),
											  vector_2d(0, 0)},0.5, false, "applique"));
	standardPattern.push_back(new OE_pattern({vector_2d(1, 1),
											  vector_2d(0.5, 0.5),
											  vector_2d(0, 1),
											  vector_2d(1, 0)},0.5, false, "cross"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
											  vector_2d(0.5, 0),
											  vector_2d(0.5, 0.6),
											  vector_2d(0.3, 0.8),
											  vector_2d(0.5, 1),
											  vector_2d(0.7, 0.8),
											  vector_2d(0.5, 0.6),
											  vector_2d(0.5, 0)},0.5, false, "applique circle"));
	standardPattern.push_back(new OE_pattern({vector_2d(0.5, 0.5),
											  vector_2d(0.8, 0.5),
											  vector_2d(0.2, 0.5),
											  vector_2d(0.5, 0.5),
											  vector_2d(0.5, 0.2),
											  vector_2d(0.5, 0.8),
											  vector_2d(0.5, 0.5),
											  vector_2d(0.3, 0.3),
											  vector_2d(0.7, 0.7),
											  vector_2d(0.5, 0.5),
											  vector_2d(0.7, 0.3),
											  vector_2d(0.3, 0.7),
											  vector_2d(0.5, 0.5)},0.5, false, "flower"));

	return standardPattern;
}

