Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef STROKE_PARAMETRIC_DEFORMER_H
Toshihiro Shimizu 890ddd
#define STROKE_PARAMETRIC_DEFORMER_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
#include "tstrokedeformations.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
e280ae
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
Toshihiro Shimizu 890ddd
// to avoid annoying warning
Toshihiro Shimizu 890ddd
#pragma warning(push)
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4290)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TStroke;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace ToonzExt {
Toshihiro Shimizu 890ddd
class Potential;
Toshihiro Shimizu 890ddd
/**
Toshihiro Shimizu 890ddd
   * @brief This class implements new deformer.
Shinya Kitaoka 120a6e
   *
Toshihiro Shimizu 890ddd
   * New stroke deformer doesn't change last point of stroke.
Toshihiro Shimizu 890ddd
   */
Shinya Kitaoka d1f6c4
class DVAPI StrokeParametricDeformer final : public TStrokeDeformation {
Toshihiro Shimizu 890ddd
public:
MCCCS a0ce32
  StrokeParametricDeformer(double actionLength, double startParameter,
Shinya Kitaoka 120a6e
                           TStroke *s, Potential *);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ~StrokeParametricDeformer();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Set mouse movement from last valid position.
Shinya Kitaoka 120a6e
*@param vx  horyzontal
Shinya Kitaoka 120a6e
*@param vy  vertical
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void setMouseMove(double vx, double vy);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Return displacement to use with function increaseControlPoints
Shinya Kitaoka 120a6e
*@param stroke to test
Shinya Kitaoka 120a6e
*@param w stroke parameter
Shinya Kitaoka 120a6e
*@return displacement to apply to obtain deformation
Shinya Kitaoka 120a6e
*@sa increaseControlPoints
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 473e70
  TThickPoint getDisplacement(const TStroke &stroke, double w) const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Return displacement to use with function  modifyControlPoints
Shinya Kitaoka 120a6e
*@param stroke to test
Shinya Kitaoka 120a6e
*@param n control point to get
Shinya Kitaoka 120a6e
*@return displacement to apply to obtain deformation
Shinya Kitaoka 120a6e
*@sa modifyControlPoints
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  TThickPoint getDisplacementForControlPoint(const TStroke &stroke,
Shinya Kitaoka 473e70
                                             UINT n) const override;
Shinya Kitaoka 120a6e
  TThickPoint getDisplacementForControlPointLen(const TStroke &stroke,
Shinya Kitaoka 473e70
                                                double cpLen) const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief This method compute the delta (gradient) referred to stroke in
Shinya Kitaoka 120a6e
*       at parameter w.
Shinya Kitaoka 120a6e
*
Shinya Kitaoka 120a6e
* This value is the result of \f$ \frac{getDisplacement(stroke,w)}{dw} \f$.
Shinya Kitaoka 120a6e
*@note Sometimes this value can be approximated.
Shinya Kitaoka 120a6e
*@param stroke Stroke to test
Shinya Kitaoka 120a6e
*@param w Stroke parameter
Shinya Kitaoka 120a6e
*@return the @b gradient in w
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 473e70
  double getDelta(const TStroke &stroke, double w) const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Max diff of delta (This value indicates when it's necessary
Shinya Kitaoka 120a6e
*  to insert control point)
Shinya Kitaoka 120a6e
*@return max displacement permitted
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 473e70
  double getMaxDiff() const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // just for debug
Shinya Kitaoka 120a6e
  const Potential *getPotential() const { return pot_; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Campbell Barton f49389
*@brief Change sensitivity of deformer (just for debug).
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void setDiff(double diff) { diff_ = diff; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*@brief Retrieve the parameters range where is applied deformation.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void getRange(double &from, double &to);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  StrokeParametricDeformer(const StrokeParametricDeformer &);
Shinya Kitaoka 120a6e
  StrokeParametricDeformer &operator=(const StrokeParametricDeformer &);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // mouse incremental movement
Shinya Kitaoka 120a6e
  double vx_, vy_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // parameter where is applicated action
Shinya Kitaoka 120a6e
  double startParameter_;
Toshihiro Shimizu 890ddd
MCCCS a0ce32
  // like startParameter_ but recover length
MCCCS a0ce32
  double startLength_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // how many traits move
MCCCS a0ce32
  double actionLength_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // deformation shape
Shinya Kitaoka 120a6e
  Potential *pot_;
Toshihiro Shimizu 890ddd
Campbell Barton f49389
  // sensitivity of deformer
Shinya Kitaoka 120a6e
  // Indica il valore minimo a partire dal quale
Shinya Kitaoka 120a6e
  //  l'inseritore comincia a mettere punti di controllo
Shinya Kitaoka 120a6e
  double diff_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TStroke *ref_copy_;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
e280ae
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
Toshihiro Shimizu 890ddd
#pragma warning(pop)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif /* STROKE_PARAMETRIC_DEFORMER_H */
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//  End Of File
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------