/*
* 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_base.h"
#include "Archive.h"

OE_base::OE_base() : needRefresh(true)
{
}

OE_base::~OE_base()
{
	for (OE_base* dep : dependency)
	{
		dep->delDependency(this);
	}
}

void OE_base::persist(Pakal::Archive* archive)
{
	archive->refer("dependency", "object", dependency);
}

bool OE_base::getNeedRefresh()
{
	return needRefresh;
}

void OE_base::setNeedRefresh()
{
	needRefresh = true;
	for (OE_base* dep : dependency)
	{
		dep->setNeedRefresh();
	}
}

bool OE_base::ptInBounds(vector_2d pt, float* bounds)
{
	return pt.x >= bounds[0] && pt.x <= bounds[2] && pt.y >= bounds[1] && pt.y <= bounds[3];
}

void OE_base::addDependency(OE_base* object)
{
	dependency.insert(object);
}
void OE_base::removeDependency(OE_base* object)
{
	dependency.erase(object);
}

void OE_base::refreshDependency()
{
}

