Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef STROKE_DEFORMATION_H
Toshihiro Shimizu 890ddd
#define STROKE_DEFORMATION_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/**
Toshihiro Shimizu 890ddd
 * @author  Fabrizio Morciano <fabrizio.morciano@gmail.com></fabrizio.morciano@gmail.com>
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TNZEXT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tgeometry.h"
Toshihiro Shimizu 890ddd
//#include "ext/TriParam.h"
Toshihiro Shimizu 890ddd
#include "ext/Types.h"
Toshihiro Shimizu 890ddd
#include "ext/ContextStatus.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <vector></vector>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TStroke;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#if defined(_WIN32) && (_MSC_VER <= 1200)
Toshihiro Shimizu 890ddd
// to avoid annoying warning
Toshihiro Shimizu 890ddd
#pragma warning(push)
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4251)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace ToonzExt {
Toshihiro Shimizu 890ddd
class Designer;
Toshihiro Shimizu 890ddd
class Potential;
Toshihiro Shimizu 890ddd
class StrokeParametricDeformer;
Toshihiro Shimizu 890ddd
class StrokeDeformationImpl;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===========================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/**
Shinya Kitaoka 120a6e
   * @brief This class is the interface for manipulation
Toshihiro Shimizu 890ddd
   *        algorihms.
Toshihiro Shimizu 890ddd
   *
Toshihiro Shimizu 890ddd
   * StrokeDeformation is a wrapper for for StrokeDeformationImpl,
Shinya Kitaoka 120a6e
   * its function is to verify state and parameteres before
Toshihiro Shimizu 890ddd
   * to call the implementation methods of deformation.
Shinya Kitaoka 120a6e
   *
Toshihiro Shimizu 890ddd
   * There is an internal status to verify that actions:
Toshihiro Shimizu 890ddd
   * @arg @c CREATED on constructor
Shinya Kitaoka 120a6e
   * @arg @c ACTIVE on active
Toshihiro Shimizu 890ddd
   * @arg @c UPDATING on updating
Toshihiro Shimizu 890ddd
   * @arg @c DEACTIVE on deactive
Toshihiro Shimizu 890ddd
   *
Toshihiro Shimizu 890ddd
   * If some error of state occurs @c reset method is called.
Toshihiro Shimizu 890ddd
   * ContextStatus contains information about deformation parameter,
Toshihiro Shimizu 890ddd
   * and it occurs to reduce the number of parameters required.
Toshihiro Shimizu 890ddd
   */
Shinya Kitaoka 120a6e
class DVAPI StrokeDeformation {
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  StrokeDeformationImpl *deformationImpl_;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Internal status.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  enum StrokeDeformationState { CREATED, ACTIVE, UPDATING, DEACTIVE, RESETTED };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  StrokeDeformationState state_;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Recover from an invalid state
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void recover();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Retrieve the current deformator.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  StrokeDeformationImpl *retrieveDeformator(const ContextStatus *status);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  StrokeDeformation();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ~StrokeDeformation();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Init deformation and add control points.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void activate(const ContextStatus *);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Modify stroke.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void update(const TPointD &delta);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Return a stroke deformed.
Shinya Kitaoka 120a6e
*@return A stroke deformed.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TStroke *deactivate();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Clear inner status of Deformation.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void reset();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Just select correct Deformation.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void check(const ContextStatus *);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Apply a designer on current deformation.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void draw(Designer *);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Retrieve valid extremes for current manipulator/deformator.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  ToonzExt::Interval getExtremes() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Return the stroke selected from user.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  const TStroke *getStroke() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Return the stroke selected from user.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  const TStroke *getCopiedStroke() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Return a reference to the stroke created to be manipulated.
Shinya Kitaoka 120a6e
*@note This stroke is different from stroke selected by user.
Shinya Kitaoka 120a6e
*@sa getStroke
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  const TStroke *getTransformedStroke() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Return the internal status of current deformation.
Shinya Kitaoka 120a6e
*@sa ContextStatus
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  const ContextStatus *getStatus() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Retrieve cursor associated to current deformator.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  int getCursorId() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Return the potential used in implementation.
Shinya Kitaoka 120a6e
*@note This is useful just for debug, please do not use directly.
Shinya Kitaoka 120a6e
*@sa Potential
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  const Potential *getPotential() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Return the potential used in implementation.
Shinya Kitaoka 120a6e
*@note This is useful just for debug, please do not use directly.
Shinya Kitaoka 120a6e
*@sa Potential
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  const StrokeDeformationImpl *getDeformationImpl() const;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#if defined(_WIN32) && (_MSC_VER <= 1200)
Toshihiro Shimizu 890ddd
#pragma warning(pop)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif /* STROKE_DEFORMATION_H */
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//  End Of File
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------