Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef DEFORMATIONSELECTOR_H
Toshihiro Shimizu 890ddd
#define DEFORMATIONSELECTOR_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ext/StrokeDeformationImpl.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace ToonzExt
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
/**
Toshihiro Shimizu 890ddd
   * @brief This class is a Singleton that selects the correct 
Toshihiro Shimizu 890ddd
   *  StrokeDeformationImpl that will use StrokeDeformation.
Toshihiro Shimizu 890ddd
   * 
Toshihiro Shimizu 890ddd
   * The selection use aspect of stroke (type of corner, smoothness,
Toshihiro Shimizu 890ddd
   * ...) and priority of StrokeDeformationImpl itself. 
Toshihiro Shimizu 890ddd
   * Priority can manage simply some strange case (corner that 
Toshihiro Shimizu 890ddd
   * seems to be straight corner and smooth corner).
Toshihiro Shimizu 890ddd
   *
Toshihiro Shimizu 890ddd
   * @note Selection can be overriden by user.
Toshihiro Shimizu 890ddd
   * @note Private use only.
Toshihiro Shimizu 890ddd
   */
Toshihiro Shimizu 890ddd
class DeformationSelector
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	typedef std::pair<strokedeformationimpl *,="" int=""> Deformation;</strokedeformationimpl>
Toshihiro Shimizu 890ddd
	vector<deformation> ref_;</deformation>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	DeformationSelector();
Toshihiro Shimizu 890ddd
	DeformationSelector(const DeformationSelector &);
Toshihiro Shimizu 890ddd
	DeformationSelector operator=(const DeformationSelector &);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	~DeformationSelector();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static DeformationSelector *
Toshihiro Shimizu 890ddd
	instance();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void
Toshihiro Shimizu 890ddd
	add(StrokeDeformationImpl *deformation,
Toshihiro Shimizu 890ddd
		int priority);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	StrokeDeformationImpl *
Toshihiro Shimizu 890ddd
	getDeformation(const ContextStatus *status);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/**
Toshihiro Shimizu 890ddd
 * @brief This macro manage the registration in internal catalog
Toshihiro Shimizu 890ddd
 * of deformations.
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
#define REGISTER(myClass, priority)                                          \
Toshihiro Shimizu 890ddd
	static bool add_in_array()                                               \
Toshihiro Shimizu 890ddd
	{                                                                        \
Toshihiro Shimizu 890ddd
		DeformationSelector::instance()->add(myClass::instance(), priority); \
Toshihiro Shimizu 890ddd
		return true;                                                         \
Toshihiro Shimizu 890ddd
	}                                                                        \
Toshihiro Shimizu 890ddd
	static bool done = add_in_array();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif /* DEFORMATIONSELECTOR_H */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//  End Of File
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------