tahoma2d/toonz/sources/tnzext/DeformationSelector.h

56 lines
1.8 KiB
C
Raw Normal View History

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