Shinya Kitaoka 810553
#pragma once
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
Shinya Kitaoka 120a6e
namespace ToonzExt {
Toshihiro Shimizu 890ddd
/**
Shinya Kitaoka 120a6e
   * @brief This class is a Singleton that selects the correct
Toshihiro Shimizu 890ddd
   *  StrokeDeformationImpl that will use StrokeDeformation.
Shinya Kitaoka 120a6e
   *
Toshihiro Shimizu 890ddd
   * The selection use aspect of stroke (type of corner, smoothness,
Shinya Kitaoka 120a6e
   * ...) and priority of StrokeDeformationImpl itself.
Shinya Kitaoka 120a6e
   * 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
   */
Shinya Kitaoka 120a6e
class DeformationSelector {
Shinya Kitaoka 120a6e
  typedef std::pair<strokedeformationimpl *,="" int=""> Deformation;</strokedeformationimpl>
Shinya Kitaoka 120a6e
  std::vector<deformation> ref_;</deformation>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  DeformationSelector();
Shinya Kitaoka 120a6e
  DeformationSelector(const DeformationSelector &);
Shinya Kitaoka 120a6e
  DeformationSelector operator=(const DeformationSelector &);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ~DeformationSelector();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static DeformationSelector *instance();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void add(StrokeDeformationImpl *deformation, int priority);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  StrokeDeformationImpl *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
 */
Shinya Kitaoka 120a6e
#define REGISTER(myClass, priority)                                            \
Shinya Kitaoka 120a6e
  static bool add_in_array() {                                                 \
Shinya Kitaoka 120a6e
    DeformationSelector::instance()->add(myClass::instance(), priority);       \
Shinya Kitaoka 120a6e
    return true;                                                               \
Shinya Kitaoka 120a6e
  }                                                                            \
Shinya Kitaoka 120a6e
  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
//-----------------------------------------------------------------------------